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

```c
#include<stdio.h>

int main(void){
  int h,w,diag,ans_diag,tmp;
  int i,j,ans_h,ans_w;
  while(1){
    scanf("%d %d",&h,&w);
    if(h==0 && w==0) break;
    diag=h*h+w*w;
    ans_diag=150*150*2;
    for(i=1;i<=150;i++){
      for(j=i+1;j<=150;j++){
        tmp=i*i+j*j;
        if(tmp==diag && i>h){
          ans_h=i;
          ans_w=j;
          goto loop;
        }
        if(tmp>diag && tmp<ans_diag){
          ans_diag=tmp;
          ans_h=i;
          ans_w=j;
        }
      }
    }
    loop:
    printf("%d %d\n",ans_h,ans_w);
  }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d\n"
	.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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L11:
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-40(%rbp), %eax
	testl	%eax, %eax
	je	.L15
.L2:
	movl	-44(%rbp), %edx
	movl	-44(%rbp), %eax
	movl	%edx, %ecx
	imull	%eax, %ecx
	movl	-40(%rbp), %edx
	movl	-40(%rbp), %eax
	imull	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, -16(%rbp)
	movl	$45000, -36(%rbp)
	movl	$1, -32(%rbp)
	jmp	.L4
.L10:
	movl	-32(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -28(%rbp)
	jmp	.L5
.L9:
	movl	-32(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	imull	%eax, %eax
	addl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jne	.L6
	movl	-44(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L6
	movl	-32(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -20(%rbp)
	jmp	.L7
.L6:
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jle	.L8
	movl	-12(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L8
	movl	-12(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -20(%rbp)
.L8:
	addl	$1, -28(%rbp)
.L5:
	cmpl	$150, -28(%rbp)
	jle	.L9
	addl	$1, -32(%rbp)
.L4:
	cmpl	$150, -32(%rbp)
	jle	.L10
	nop
.L7:
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L15:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	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"
.LC1:
	.string	"%d %d\n"
	.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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC1(%rip), %r14
	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
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %r13
	movq	%rsp, %r12
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r12, %rsi
	xorl	%eax, %eax
	movq	%r13, %rdx
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	(%rsp), %r9d
	movl	4(%rsp), %eax
	movl	%r9d, %esi
	orl	%eax, %esi
	je	.L2
	movl	%r9d, %r8d
	imull	%eax, %eax
	movl	%ebx, %edi
	movl	%r15d, %esi
	imull	%r9d, %r8d
	movl	$1, %r15d
	movl	$2, %r10d
	movl	$2, %ebx
	movl	$45000, %ecx
	addl	%eax, %r8d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L4:
	jge	.L6
	cmpl	%ecx, %eax
	setl	%dl
	testb	%dl, %dl
	cmovne	%ebx, %edi
	cmovne	%r15d, %esi
	cmovne	%eax, %ecx
.L6:
	addl	$1, %ebx
	cmpl	$151, %ebx
	je	.L21
.L3:
	movl	%r15d, %eax
	movl	%ebx, %edx
	imull	%r15d, %eax
	imull	%ebx, %edx
	addl	%edx, %eax
	cmpl	%eax, %r8d
	jne	.L4
	cmpl	%r15d, %r9d
	jge	.L6
.L5:
	movl	%ebx, %ecx
	movl	%r15d, %edx
	movq	%r14, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L21:
	leal	1(%r10), %ebx
	cmpl	$150, %r10d
	je	.L22
	movl	%r10d, %r15d
	movl	%ebx, %r10d
	jmp	.L3
.L22:
	movl	%edi, %ebx
	movl	%esi, %r15d
	jmp	.L5
.L2:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	addq	$24, %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
.L23:
	.cfi_restore_state
	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"
.LC1:
	.string	"%d %d\n"
	.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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC1(%rip), %r14
	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
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %r13
	movq	%rsp, %r12
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r12, %rsi
	xorl	%eax, %eax
	movq	%r13, %rdx
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	(%rsp), %r9d
	movl	4(%rsp), %eax
	movl	%r9d, %esi
	orl	%eax, %esi
	je	.L2
	movl	%r9d, %r8d
	imull	%eax, %eax
	movl	%ebx, %edi
	movl	%r15d, %esi
	imull	%r9d, %r8d
	movl	$1, %r15d
	movl	$2, %r10d
	movl	$2, %ebx
	movl	$45000, %ecx
	addl	%eax, %r8d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L4:
	jge	.L6
	cmpl	%ecx, %eax
	setl	%dl
	testb	%dl, %dl
	cmovne	%ebx, %edi
	cmovne	%r15d, %esi
	cmovne	%eax, %ecx
.L6:
	addl	$1, %ebx
	cmpl	$151, %ebx
	je	.L21
.L3:
	movl	%r15d, %eax
	movl	%ebx, %edx
	imull	%r15d, %eax
	imull	%ebx, %edx
	addl	%edx, %eax
	cmpl	%eax, %r8d
	jne	.L4
	cmpl	%r15d, %r9d
	jge	.L6
.L5:
	movl	%ebx, %ecx
	movl	%r15d, %edx
	movq	%r14, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L21:
	leal	1(%r10), %ebx
	cmpl	$150, %r10d
	je	.L22
	movl	%r10d, %r15d
	movl	%ebx, %r10d
	jmp	.L3
.L22:
	movl	%edi, %ebx
	movl	%esi, %r15d
	jmp	.L5
.L2:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	addq	$24, %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
.L23:
	.cfi_restore_state
	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:

#include<stdio.h>

int main(void){
  int h,w,diag,ans_diag,tmp;
  int i,j,ans_h,ans_w;
  while(1){
    scanf("%d %d",&h,&w);
    if(h==0 && w==0) break;
    diag=h*h+w*w;
    ans_diag=150*150*2;
    for(i=1;i<=150;i++){
      for(j=i+1;j<=150;j++){
        tmp=i*i+j*j;
        if(tmp==diag && i>h){
          ans_h=i;
          ans_w=j;
          goto loop;
        }
        if(tmp>diag && tmp<ans_diag){
          ans_diag=tmp;
          ans_h=i;
          ans_w=j;
        }
      }
    }
    loop:
    printf("%d %d\n",ans_h,ans_w);
  }
  return 0;
}
1 2
1 3
2 3
1 4
2 4
5 6
1 8
4 7
98 100
99 100
0 0

1 3
2 3
1 4
2 4
3 4
1 8
4 7
2 8
3 140
89 109

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

```c
#include<stdio.h>

int main(void){
  int h,w,diag,ans_diag,tmp;
  int i,j,ans_h,ans_w;
  while(1){
    scanf("%d %d",&h,&w);
    if(h==0 && w==0) break;
    diag=h*h+w*w;
    ans_diag=150*150*2;
    for(i=1;i<=150;i++){
      for(j=i+1;j<=150;j++){
        tmp=i*i+j*j;
        if(tmp==diag && i>h){
          ans_h=i;
          ans_w=j;
          goto loop;
        }
        if(tmp>diag && tmp<ans_diag){
          ans_diag=tmp;
          ans_h=i;
          ans_w=j;
        }
      }
    }
    loop:
    printf("%d %d\n",ans_h,ans_w);
  }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d\n"
	.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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L11:
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-40(%rbp), %eax
	testl	%eax, %eax
	je	.L15
.L2:
	movl	-44(%rbp), %edx
	movl	-44(%rbp), %eax
	movl	%edx, %ecx
	imull	%eax, %ecx
	movl	-40(%rbp), %edx
	movl	-40(%rbp), %eax
	imull	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, -16(%rbp)
	movl	$45000, -36(%rbp)
	movl	$1, -32(%rbp)
	jmp	.L4
.L10:
	movl	-32(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -28(%rbp)
	jmp	.L5
.L9:
	movl	-32(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	imull	%eax, %eax
	addl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jne	.L6
	movl	-44(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L6
	movl	-32(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -20(%rbp)
	jmp	.L7
.L6:
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jle	.L8
	movl	-12(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L8
	movl	-12(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -20(%rbp)
.L8:
	addl	$1, -28(%rbp)
.L5:
	cmpl	$150, -28(%rbp)
	jle	.L9
	addl	$1, -32(%rbp)
.L4:
	cmpl	$150, -32(%rbp)
	jle	.L10
	nop
.L7:
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L15:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	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"
.LC1:
	.string	"%d %d\n"
	.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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L11:
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-40(%rbp), %eax
	testl	%eax, %eax
	je	.L15
.L2:
	movl	-44(%rbp), %edx
	movl	-44(%rbp), %eax
	movl	%edx, %ecx
	imull	%eax, %ecx
	movl	-40(%rbp), %edx
	movl	-40(%rbp), %eax
	imull	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, -16(%rbp)
	movl	$45000, -36(%rbp)
	movl	$1, -32(%rbp)
	jmp	.L4
.L10:
	movl	-32(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -28(%rbp)
	jmp	.L5
.L9:
	movl	-32(%rbp), %eax
	imull	%eax, %eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	imull	%eax, %eax
	addl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jne	.L6
	movl	-44(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L6
	movl	-32(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -20(%rbp)
	jmp	.L7
.L6:
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jle	.L8
	movl	-12(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L8
	movl	-12(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -20(%rbp)
.L8:
	addl	$1, -28(%rbp)
.L5:
	cmpl	$150, -28(%rbp)
	jle	.L9
	addl	$1, -32(%rbp)
.L4:
	cmpl	$150, -32(%rbp)
	jle	.L10
	nop
.L7:
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L15:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	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:
