Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int i, j, k,ip;
	int h_array[300], w_array[300];

	for (i = 0; i < 300; i++) {
		scanf("%d %d", &h_array[i], &w_array[i]);
		
		if (h_array[i] == 0 && w_array[i] == 0) {
			ip = i;
			break;
		}

	}
	for ( k = 0; k < ip; k++) {
		for (i = 0; i < h_array[k]; i++) {
			for (j = 0; j < w_array[k]; j++) {
				printf("#");
			}
			printf("\n");
			if (h_array[k] == 0 && w_array[k] == 0) {
				break;
			}
		}
		printf("\n");
	}
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$2432, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -2432(%rbp)
	jmp	.L2
.L5:
	leaq	-1216(%rbp), %rdx
	movl	-2432(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-2416(%rbp), %rcx
	movl	-2432(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-2432(%rbp), %eax
	cltq
	movl	-2416(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L3
	movl	-2432(%rbp), %eax
	cltq
	movl	-1216(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L3
	movl	-2432(%rbp), %eax
	movl	%eax, -2420(%rbp)
	jmp	.L4
.L3:
	addl	$1, -2432(%rbp)
.L2:
	cmpl	$299, -2432(%rbp)
	jle	.L5
.L4:
	movl	$0, -2424(%rbp)
	jmp	.L6
.L13:
	movl	$0, -2432(%rbp)
	jmp	.L7
.L12:
	movl	$0, -2428(%rbp)
	jmp	.L8
.L9:
	movl	$35, %edi
	call	putchar@PLT
	addl	$1, -2428(%rbp)
.L8:
	movl	-2424(%rbp), %eax
	cltq
	movl	-1216(%rbp,%rax,4), %eax
	cmpl	%eax, -2428(%rbp)
	jl	.L9
	movl	$10, %edi
	call	putchar@PLT
	movl	-2424(%rbp), %eax
	cltq
	movl	-2416(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L10
	movl	-2424(%rbp), %eax
	cltq
	movl	-1216(%rbp,%rax,4), %eax
	testl	%eax, %eax
	je	.L16
.L10:
	addl	$1, -2432(%rbp)
.L7:
	movl	-2424(%rbp), %eax
	cltq
	movl	-2416(%rbp,%rax,4), %eax
	cmpl	%eax, -2432(%rbp)
	jl	.L12
	jmp	.L11
.L16:
	nop
.L11:
	movl	$10, %edi
	call	putchar@PLT
	addl	$1, -2424(%rbp)
.L6:
	movl	-2424(%rbp), %eax
	cmpl	-2420(%rbp), %eax
	jl	.L13
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	xorl	%r14d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$2424, %rsp
	.cfi_def_cfa_offset 2480
	movq	%fs:40, %rax
	movq	%rax, 2408(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %r13
	leaq	1200(%rsp), %rbp
	movq	%rbp, %r12
	movq	%r13, %rbx
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L2:
	addl	$1, %r14d
	addq	$4, %rbx
	addq	$4, %r12
	cmpl	$300, %r14d
	je	.L27
.L4:
	movq	%rbx, %rsi
	movq	%r12, %rdx
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rbx), %esi
	testl	%esi, %esi
	jne	.L2
	movl	(%r12), %ecx
	testl	%ecx, %ecx
	jne	.L2
.L3:
	testl	%r14d, %r14d
	je	.L5
	leal	-1(%r14), %eax
	leaq	4(%rbp), %r14
	leaq	(%r14,%rax,4), %r15
.L6:
	movl	0(%r13), %eax
	xorl	%r12d, %r12d
	testl	%eax, %eax
	jle	.L8
	.p2align 4,,10
	.p2align 3
.L11:
	movl	0(%rbp), %edx
	xorl	%ebx, %ebx
	testl	%edx, %edx
	jle	.L10
	.p2align 4,,10
	.p2align 3
.L7:
	movl	$35, %edi
	addl	$1, %ebx
	call	putchar@PLT
	cmpl	%ebx, 0(%rbp)
	jg	.L7
.L10:
	movl	$10, %edi
	call	putchar@PLT
	movl	0(%r13), %eax
	testl	%eax, %eax
	jne	.L28
.L8:
	movl	$10, %edi
	addq	$4, %r13
	movq	%r14, %rbp
	call	putchar@PLT
	cmpq	%r15, %r14
	je	.L5
	addq	$4, %r14
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L28:
	addl	$1, %r12d
	cmpl	%r12d, %eax
	jg	.L11
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L5:
	movq	2408(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$2424, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L27:
	.cfi_restore_state
	xorl	%r14d, %r14d
	jmp	.L3
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	xorl	%r14d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$2424, %rsp
	.cfi_def_cfa_offset 2480
	movq	%fs:40, %rax
	movq	%rax, 2408(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %r13
	leaq	1200(%rsp), %rbp
	movq	%rbp, %r12
	movq	%r13, %rbx
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L2:
	addl	$1, %r14d
	addq	$4, %rbx
	addq	$4, %r12
	cmpl	$300, %r14d
	je	.L27
.L4:
	movq	%rbx, %rsi
	movq	%r12, %rdx
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rbx), %esi
	testl	%esi, %esi
	jne	.L2
	movl	(%r12), %ecx
	testl	%ecx, %ecx
	jne	.L2
.L3:
	testl	%r14d, %r14d
	je	.L5
	leal	-1(%r14), %eax
	leaq	4(%rbp), %r14
	leaq	(%r14,%rax,4), %r15
.L6:
	movl	0(%r13), %eax
	xorl	%r12d, %r12d
	testl	%eax, %eax
	jle	.L8
	.p2align 4,,10
	.p2align 3
.L11:
	movl	0(%rbp), %edx
	xorl	%ebx, %ebx
	testl	%edx, %edx
	jle	.L10
	.p2align 4,,10
	.p2align 3
.L7:
	movl	$35, %edi
	addl	$1, %ebx
	call	putchar@PLT
	cmpl	%ebx, 0(%rbp)
	jg	.L7
.L10:
	movl	$10, %edi
	call	putchar@PLT
	movl	0(%r13), %eax
	testl	%eax, %eax
	jne	.L28
.L8:
	movl	$10, %edi
	addq	$4, %r13
	movq	%r14, %rbp
	call	putchar@PLT
	cmpq	%r15, %r14
	je	.L5
	addq	$4, %r14
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L28:
	addl	$1, %r12d
	cmpl	%r12d, %eax
	jg	.L11
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L5:
	movq	2408(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$2424, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L27:
	.cfi_restore_state
	xorl	%r14d, %r14d
	jmp	.L3
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int i, j, k,ip;
	int h_array[300], w_array[300];

	for (i = 0; i < 300; i++) {
		scanf("%d %d", &h_array[i], &w_array[i]);
		
		if (h_array[i] == 0 && w_array[i] == 0) {
			ip = i;
			break;
		}

	}
	for ( k = 0; k < ip; k++) {
		for (i = 0; i < h_array[k]; i++) {
			for (j = 0; j < w_array[k]; j++) {
				printf("#");
			}
			printf("\n");
			if (h_array[k] == 0 && w_array[k] == 0) {
				break;
			}
		}
		printf("\n");
	}
	return 0;
}

3 4
5 6
2 3
0 0
 3 4
5 6
2 0
0 0
 3 4
5 6
2 4
0 0
 4 4
5 6
2 0
0 0
 4 4
5 6
4 0
0 0
 4 3
5 6
4 -1
0 0
 3 5
5 6
2 2
0 0
 3 4
5 0
2 2
0 0
 3 4
5 6
2 1
0 0
 6 4
5 6
2 4
0 0

####
####
####

######
######
######
######
######

###
###

 ####
####
####

######
######
######
######
######




 ####
####
####

######
######
######
######
######

####
####

 ####
####
####
####

######
######
######
######
######




 ####
####
####
####

######
######
######
######
######






 ###
###
###
###

######
######
######
######
######






 #####
#####
#####

######
######
######
######
######

##
##

 ####
####
####







##
##

 ####
####
####

######
######
######
######
######

#
#

 ####
####
####
####
####
####

######
######
######
######
######

####
####


Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int i, j, k,ip;
	int h_array[300], w_array[300];

	for (i = 0; i < 300; i++) {
		scanf("%d %d", &h_array[i], &w_array[i]);
		
		if (h_array[i] == 0 && w_array[i] == 0) {
			ip = i;
			break;
		}

	}
	for ( k = 0; k < ip; k++) {
		for (i = 0; i < h_array[k]; i++) {
			for (j = 0; j < w_array[k]; j++) {
				printf("#");
			}
			printf("\n");
			if (h_array[k] == 0 && w_array[k] == 0) {
				break;
			}
		}
		printf("\n");
	}
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$2432, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -2432(%rbp)
	jmp	.L2
.L5:
	leaq	-1216(%rbp), %rdx
	movl	-2432(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-2416(%rbp), %rcx
	movl	-2432(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-2432(%rbp), %eax
	cltq
	movl	-2416(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L3
	movl	-2432(%rbp), %eax
	cltq
	movl	-1216(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L3
	movl	-2432(%rbp), %eax
	movl	%eax, -2420(%rbp)
	jmp	.L4
.L3:
	addl	$1, -2432(%rbp)
.L2:
	cmpl	$299, -2432(%rbp)
	jle	.L5
.L4:
	movl	$0, -2424(%rbp)
	jmp	.L6
.L13:
	movl	$0, -2432(%rbp)
	jmp	.L7
.L12:
	movl	$0, -2428(%rbp)
	jmp	.L8
.L9:
	movl	$35, %edi
	call	putchar@PLT
	addl	$1, -2428(%rbp)
.L8:
	movl	-2424(%rbp), %eax
	cltq
	movl	-1216(%rbp,%rax,4), %eax
	cmpl	%eax, -2428(%rbp)
	jl	.L9
	movl	$10, %edi
	call	putchar@PLT
	movl	-2424(%rbp), %eax
	cltq
	movl	-2416(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L10
	movl	-2424(%rbp), %eax
	cltq
	movl	-1216(%rbp,%rax,4), %eax
	testl	%eax, %eax
	je	.L16
.L10:
	addl	$1, -2432(%rbp)
.L7:
	movl	-2424(%rbp), %eax
	cltq
	movl	-2416(%rbp,%rax,4), %eax
	cmpl	%eax, -2432(%rbp)
	jl	.L12
	jmp	.L11
.L16:
	nop
.L11:
	movl	$10, %edi
	call	putchar@PLT
	addl	$1, -2424(%rbp)
.L6:
	movl	-2424(%rbp), %eax
	cmpl	-2420(%rbp), %eax
	jl	.L13
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$2432, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -2432(%rbp)
	jmp	.L2
.L5:
	leaq	-1216(%rbp), %rdx
	movl	-2432(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-2416(%rbp), %rcx
	movl	-2432(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-2432(%rbp), %eax
	cltq
	movl	-2416(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L3
	movl	-2432(%rbp), %eax
	cltq
	movl	-1216(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L3
	movl	-2432(%rbp), %eax
	movl	%eax, -2420(%rbp)
	jmp	.L4
.L3:
	addl	$1, -2432(%rbp)
.L2:
	cmpl	$299, -2432(%rbp)
	jle	.L5
.L4:
	movl	$0, -2424(%rbp)
	jmp	.L6
.L13:
	movl	$0, -2432(%rbp)
	jmp	.L7
.L12:
	movl	$0, -2428(%rbp)
	jmp	.L8
.L9:
	movl	$35, %edi
	call	putchar@PLT
	addl	$1, -2428(%rbp)
.L8:
	movl	-2424(%rbp), %eax
	cltq
	movl	-1216(%rbp,%rax,4), %eax
	cmpl	%eax, -2428(%rbp)
	jl	.L9
	movl	$10, %edi
	call	putchar@PLT
	movl	-2424(%rbp), %eax
	cltq
	movl	-2416(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L10
	movl	-2424(%rbp), %eax
	cltq
	movl	-1216(%rbp,%rax,4), %eax
	testl	%eax, %eax
	je	.L16
.L10:
	addl	$1, -2432(%rbp)
.L7:
	movl	-2424(%rbp), %eax
	cltq
	movl	-2416(%rbp,%rax,4), %eax
	cmpl	%eax, -2432(%rbp)
	jl	.L12
	jmp	.L11
.L16:
	nop
.L11:
	movl	$10, %edi
	call	putchar@PLT
	addl	$1, -2424(%rbp)
.L6:
	movl	-2424(%rbp), %eax
	cmpl	-2420(%rbp), %eax
	jl	.L13
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
