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 n,m,s,i;
int taro[1000];
int hana[1000];
int T,H,X;
int anst,ansh;
 
int main(){
  while(1){
    scanf("%d %d",&n,&m);
    if(n==0&&m==0){
      break;
    }
 
    T=0;
    H=0;
    for(i=0;i<1000;i++){
      taro[i]=0;
      hana[i]=0;
    }
    for(i=0;i<n;i++){
      scanf("%d",&s);
      taro[s]=1;
      T+=s;
    }
    for(i=0;i<m;i++){
      scanf("%d",&s);
      hana[s]=1;
      H+=s;
    }
 
    X=(H-T)/2;
    anst=-1;
    ansh=-1;
 
    for(i=0;i<=100;i++){
      if(0<=i+X&&taro[i]==1&&hana[i+X]==1){
        anst=i;
        ansh=i+X;
        break;
      }
    }
     
    if( (H-T)%2!=0 || anst==-1 ){
      printf("-1\n");
    }else{
      printf("%d %d\n",anst,ansh);
    }
 
  }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	taro
	.align 32
	.type	taro, @object
	.size	taro, 4000
taro:
	.zero	4000
	.globl	hana
	.align 32
	.type	hana, @object
	.size	hana, 4000
hana:
	.zero	4000
	.globl	T
	.align 4
	.type	T, @object
	.size	T, 4
T:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	X
	.align 4
	.type	X, @object
	.size	X, 4
X:
	.zero	4
	.globl	anst
	.align 4
	.type	anst, @object
	.size	anst, 4
anst:
	.zero	4
	.globl	ansh
	.align 4
	.type	ansh, @object
	.size	ansh, 4
ansh:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"-1"
.LC3:
	.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
.L17:
	leaq	m(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L2
	movl	m(%rip), %eax
	testl	%eax, %eax
	je	.L20
.L2:
	movl	$0, T(%rip)
	movl	$0, H(%rip)
	movl	$0, i(%rip)
	jmp	.L4
.L5:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	taro(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	hana(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L4:
	movl	i(%rip), %eax
	cmpl	$999, %eax
	jle	.L5
	movl	$0, i(%rip)
	jmp	.L6
.L7:
	leaq	s(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	s(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	taro(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	T(%rip), %edx
	movl	s(%rip), %eax
	addl	%edx, %eax
	movl	%eax, T(%rip)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L6:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L7
	movl	$0, i(%rip)
	jmp	.L8
.L9:
	leaq	s(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	s(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	hana(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	H(%rip), %edx
	movl	s(%rip), %eax
	addl	%edx, %eax
	movl	%eax, H(%rip)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L8:
	movl	i(%rip), %edx
	movl	m(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	movl	H(%rip), %eax
	movl	T(%rip), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, X(%rip)
	movl	$-1, anst(%rip)
	movl	$-1, ansh(%rip)
	movl	$0, i(%rip)
	jmp	.L10
.L13:
	movl	i(%rip), %edx
	movl	X(%rip), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	js	.L11
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	taro(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jne	.L11
	movl	i(%rip), %edx
	movl	X(%rip), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	hana(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jne	.L11
	movl	i(%rip), %eax
	movl	%eax, anst(%rip)
	movl	i(%rip), %edx
	movl	X(%rip), %eax
	addl	%edx, %eax
	movl	%eax, ansh(%rip)
	jmp	.L12
.L11:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L10:
	movl	i(%rip), %eax
	cmpl	$100, %eax
	jle	.L13
.L12:
	movl	H(%rip), %eax
	movl	T(%rip), %edx
	subl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L14
	movl	anst(%rip), %eax
	cmpl	$-1, %eax
	jne	.L15
.L14:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L16
.L15:
	movl	ansh(%rip), %edx
	movl	anst(%rip), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L16:
	jmp	.L17
.L20:
	nop
	movl	$0, %eax
	popq	%rbp
	.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"
.LC2:
	.string	"-1"
.LC3:
	.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
	leaq	m(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	hana(%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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	taro(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r15, %rdx
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	n(%rip), %esi
	movl	m(%rip), %edx
	movl	%esi, %eax
	orl	%edx, %eax
	je	.L18
	xorl	%eax, %eax
	movl	$500, %ecx
	movq	%rbx, %rdi
	movl	$0, T(%rip)
	rep stosq
	movl	$500, %ecx
	movq	%r14, %rdi
	movl	$0, H(%rip)
	rep stosq
	movl	$0, i(%rip)
	testl	%esi, %esi
	jle	.L16
	leaq	s(%rip), %r12
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%rbp, %rdi
	xorl	%eax, %eax
	movq	%r12, %rsi
	call	__isoc99_scanf@PLT
	movslq	s(%rip), %rdx
	movl	i(%rip), %edi
	movq	%rdx, %rax
	movl	$1, (%rbx,%rdx,4)
	addl	T(%rip), %eax
	leal	1(%rdi), %edx
	cmpl	n(%rip), %edx
	movl	%eax, T(%rip)
	movl	%edx, i(%rip)
	jl	.L5
	movl	m(%rip), %edx
.L4:
	movl	$0, i(%rip)
	testl	%edx, %edx
	jle	.L6
	leaq	s(%rip), %r12
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L7:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movslq	s(%rip), %rdx
	movq	%rdx, %rax
	addl	H(%rip), %eax
	movl	$1, (%r14,%rdx,4)
	movl	%eax, H(%rip)
	movl	%eax, %edx
	movl	i(%rip), %eax
	addl	$1, %eax
	cmpl	m(%rip), %eax
	movl	%eax, i(%rip)
	jl	.L7
	movl	T(%rip), %eax
.L8:
	movl	$-1, anst(%rip)
	subl	%eax, %edx
	xorl	%edi, %edi
	movl	$-1, ansh(%rip)
	movl	%edx, %ecx
	movl	$0, i(%rip)
	shrl	$31, %ecx
	addl	%edx, %ecx
	sarl	%ecx
	movslq	%ecx, %rax
	movl	%ecx, X(%rip)
	leaq	(%r14,%rax,4), %r9
	xorl	%eax, %eax
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L9:
	addq	$1, %rax
	leal	1(%rsi), %r13d
	addl	$1, %ecx
	movl	$1, %edi
	cmpq	$101, %rax
	je	.L28
.L11:
	movl	%eax, %esi
	movl	%eax, %r8d
	testl	%ecx, %ecx
	js	.L9
	cmpl	$1, (%rbx,%rax,4)
	jne	.L9
	cmpl	$1, (%r9,%rax,4)
	jne	.L9
	testb	%dil, %dil
	je	.L10
	movl	%r13d, i(%rip)
.L10:
	andl	$1, %edx
	movl	%r8d, anst(%rip)
	movl	%ecx, ansh(%rip)
	jne	.L14
	movl	%r8d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L28:
	movl	%r13d, i(%rip)
.L14:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L2
.L6:
	movl	H(%rip), %edx
	jmp	.L8
.L16:
	xorl	%eax, %eax
	jmp	.L4
.L18:
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	ansh
	.bss
	.align 4
	.type	ansh, @object
	.size	ansh, 4
ansh:
	.zero	4
	.globl	anst
	.align 4
	.type	anst, @object
	.size	anst, 4
anst:
	.zero	4
	.globl	X
	.align 4
	.type	X, @object
	.size	X, 4
X:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	T
	.align 4
	.type	T, @object
	.size	T, 4
T:
	.zero	4
	.globl	hana
	.align 32
	.type	hana, @object
	.size	hana, 4000
hana:
	.zero	4000
	.globl	taro
	.align 32
	.type	taro, @object
	.size	taro, 4000
taro:
	.zero	4000
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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"
.LC2:
	.string	"-1"
.LC3:
	.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
	leaq	m(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	hana(%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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	taro(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r15, %rdx
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	n(%rip), %esi
	movl	m(%rip), %edx
	movl	%esi, %eax
	orl	%edx, %eax
	je	.L18
	xorl	%eax, %eax
	movl	$500, %ecx
	movq	%rbx, %rdi
	movl	$0, T(%rip)
	rep stosq
	movl	$500, %ecx
	movq	%r14, %rdi
	movl	$0, H(%rip)
	rep stosq
	movl	$0, i(%rip)
	testl	%esi, %esi
	jle	.L16
	leaq	s(%rip), %r12
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%rbp, %rdi
	xorl	%eax, %eax
	movq	%r12, %rsi
	call	__isoc99_scanf@PLT
	movslq	s(%rip), %rdx
	movl	i(%rip), %edi
	movq	%rdx, %rax
	movl	$1, (%rbx,%rdx,4)
	addl	T(%rip), %eax
	leal	1(%rdi), %edx
	cmpl	n(%rip), %edx
	movl	%eax, T(%rip)
	movl	%edx, i(%rip)
	jl	.L5
	movl	m(%rip), %edx
.L4:
	movl	$0, i(%rip)
	testl	%edx, %edx
	jle	.L6
	leaq	s(%rip), %r12
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L7:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movslq	s(%rip), %rdx
	movq	%rdx, %rax
	addl	H(%rip), %eax
	movl	$1, (%r14,%rdx,4)
	movl	%eax, H(%rip)
	movl	%eax, %edx
	movl	i(%rip), %eax
	addl	$1, %eax
	cmpl	m(%rip), %eax
	movl	%eax, i(%rip)
	jl	.L7
	movl	T(%rip), %eax
.L8:
	movl	$-1, anst(%rip)
	subl	%eax, %edx
	xorl	%edi, %edi
	movl	$-1, ansh(%rip)
	movl	%edx, %ecx
	movl	$0, i(%rip)
	shrl	$31, %ecx
	addl	%edx, %ecx
	sarl	%ecx
	movslq	%ecx, %rax
	movl	%ecx, X(%rip)
	leaq	(%r14,%rax,4), %r9
	xorl	%eax, %eax
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L9:
	addq	$1, %rax
	leal	1(%rsi), %r13d
	addl	$1, %ecx
	movl	$1, %edi
	cmpq	$101, %rax
	je	.L28
.L11:
	movl	%eax, %esi
	movl	%eax, %r8d
	testl	%ecx, %ecx
	js	.L9
	cmpl	$1, (%rbx,%rax,4)
	jne	.L9
	cmpl	$1, (%r9,%rax,4)
	jne	.L9
	testb	%dil, %dil
	je	.L10
	movl	%r13d, i(%rip)
.L10:
	andl	$1, %edx
	movl	%r8d, anst(%rip)
	movl	%ecx, ansh(%rip)
	jne	.L14
	movl	%r8d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L28:
	movl	%r13d, i(%rip)
.L14:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L2
.L6:
	movl	H(%rip), %edx
	jmp	.L8
.L16:
	xorl	%eax, %eax
	jmp	.L4
.L18:
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	ansh
	.bss
	.align 4
	.type	ansh, @object
	.size	ansh, 4
ansh:
	.zero	4
	.globl	anst
	.align 4
	.type	anst, @object
	.size	anst, 4
anst:
	.zero	4
	.globl	X
	.align 4
	.type	X, @object
	.size	X, 4
X:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	T
	.align 4
	.type	T, @object
	.size	T, 4
T:
	.zero	4
	.globl	hana
	.align 32
	.type	hana, @object
	.size	hana, 4000
hana:
	.zero	4000
	.globl	taro
	.align 32
	.type	taro, @object
	.size	taro, 4000
taro:
	.zero	4000
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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 n,m,s,i;
int taro[1000];
int hana[1000];
int T,H,X;
int anst,ansh;
 
int main(){
  while(1){
    scanf("%d %d",&n,&m);
    if(n==0&&m==0){
      break;
    }
 
    T=0;
    H=0;
    for(i=0;i<1000;i++){
      taro[i]=0;
      hana[i]=0;
    }
    for(i=0;i<n;i++){
      scanf("%d",&s);
      taro[s]=1;
      T+=s;
    }
    for(i=0;i<m;i++){
      scanf("%d",&s);
      hana[s]=1;
      H+=s;
    }
 
    X=(H-T)/2;
    anst=-1;
    ansh=-1;
 
    for(i=0;i<=100;i++){
      if(0<=i+X&&taro[i]==1&&hana[i+X]==1){
        anst=i;
        ansh=i+X;
        break;
      }
    }
     
    if( (H-T)%2!=0 || anst==-1 ){
      printf("-1\n");
    }else{
      printf("%d %d\n",anst,ansh);
    }
 
  }
  return 0;
}
2 2
1
5
4
7
6 5
3
9
5
2
3
3
12
2
7
3
5
4 5
10
0
3
8
1
9
6
0
6
7 4
1
1
2
1
2
1
4
2
3
4
3
2 3
1
1
2
2
2
0 0
 2 2
1
5
4
7
6 5
3
9
5
2
3
3
12
2
7
3
5
4 5
10
0
3
8
1
9
6
0
6
7 4
1
1
2
1
2
1
4
2
3
4
6
2 3
1
1
2
2
2
0 0
 2 2
1
5
4
7
6 5
3
9
7
2
3
3
12
2
7
3
5
4 5
10
0
3
8
1
9
6
0
6
7 4
1
1
2
1
2
1
4
2
3
4
6
2 3
1
1
2
2
2
0 0
 2 2
1
5
4
7
6 5
3
9
7
2
3
3
12
2
7
3
5
4 5
10
0
2
8
1
9
6
0
6
7 4
1
1
2
1
2
1
4
2
3
4
6
2 3
1
1
2
2
2
0 0
 2 2
1
5
7
7
6 5
2
9
7
2
3
3
12
2
7
3
5
4 5
10
0
2
8
1
9
6
0
6
7 4
1
1
2
1
2
1
4
2
3
4
6
2 3
1
1
2
2
2
0 0
 2 2
1
5
4
7
6 5
3
9
5
2
3
3
11
2
7
3
5
4 5
10
0
3
8
1
9
6
0
6
7 4
1
1
2
1
2
1
4
2
3
4
6
2 3
1
1
2
2
2
0 0
 2 2
1
5
3
7
6 5
2
9
7
2
3
3
24
2
7
3
5
4 5
10
0
2
8
1
9
6
0
6
7 4
1
1
2
1
2
1
4
2
3
4
6
2 3
1
1
2
2
2
0 0
 2 2
1
5
3
7
6 5
2
9
7
2
3
3
24
2
7
3
5
4 5
10
0
2
8
1
9
6
0
6
7 4
1
1
2
1
2
1
4
2
2
4
6
2 3
1
1
2
2
2
0 0
 2 2
1
5
11
7
6 5
2
9
7
2
3
3
24
2
7
3
1
4 5
10
0
2
8
1
9
6
0
6
7 4
1
1
2
1
0
1
6
2
3
4
6
2 3
1
1
2
2
2
0 0
 2 2
1
5
3
7
6 5
2
9
7
2
3
3
24
2
7
3
5
4 5
10
0
2
8
1
9
6
0
6
7 4
1
1
2
1
2
1
4
2
2
4
6
2 3
1
1
4
2
2
0 0

-1
3 5
-1
2 2
-1
 -1
3 5
-1
-1
-1
 -1
2 3
-1
-1
-1
 -1
2 3
0 1
-1
-1
 -1
-1
0 1
-1
-1
 -1
-1
-1
-1
-1
 1 3
-1
0 1
-1
-1
 1 3
-1
0 1
1 2
-1
 1 7
-1
0 1
-1
-1
 1 3
-1
0 1
1 2
1 4

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 n,m,s,i;
int taro[1000];
int hana[1000];
int T,H,X;
int anst,ansh;
 
int main(){
  while(1){
    scanf("%d %d",&n,&m);
    if(n==0&&m==0){
      break;
    }
 
    T=0;
    H=0;
    for(i=0;i<1000;i++){
      taro[i]=0;
      hana[i]=0;
    }
    for(i=0;i<n;i++){
      scanf("%d",&s);
      taro[s]=1;
      T+=s;
    }
    for(i=0;i<m;i++){
      scanf("%d",&s);
      hana[s]=1;
      H+=s;
    }
 
    X=(H-T)/2;
    anst=-1;
    ansh=-1;
 
    for(i=0;i<=100;i++){
      if(0<=i+X&&taro[i]==1&&hana[i+X]==1){
        anst=i;
        ansh=i+X;
        break;
      }
    }
     
    if( (H-T)%2!=0 || anst==-1 ){
      printf("-1\n");
    }else{
      printf("%d %d\n",anst,ansh);
    }
 
  }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	taro
	.align 32
	.type	taro, @object
	.size	taro, 4000
taro:
	.zero	4000
	.globl	hana
	.align 32
	.type	hana, @object
	.size	hana, 4000
hana:
	.zero	4000
	.globl	T
	.align 4
	.type	T, @object
	.size	T, 4
T:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	X
	.align 4
	.type	X, @object
	.size	X, 4
X:
	.zero	4
	.globl	anst
	.align 4
	.type	anst, @object
	.size	anst, 4
anst:
	.zero	4
	.globl	ansh
	.align 4
	.type	ansh, @object
	.size	ansh, 4
ansh:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"-1"
.LC3:
	.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
.L17:
	leaq	m(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L2
	movl	m(%rip), %eax
	testl	%eax, %eax
	je	.L20
.L2:
	movl	$0, T(%rip)
	movl	$0, H(%rip)
	movl	$0, i(%rip)
	jmp	.L4
.L5:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	taro(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	hana(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L4:
	movl	i(%rip), %eax
	cmpl	$999, %eax
	jle	.L5
	movl	$0, i(%rip)
	jmp	.L6
.L7:
	leaq	s(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	s(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	taro(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	T(%rip), %edx
	movl	s(%rip), %eax
	addl	%edx, %eax
	movl	%eax, T(%rip)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L6:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L7
	movl	$0, i(%rip)
	jmp	.L8
.L9:
	leaq	s(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	s(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	hana(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	H(%rip), %edx
	movl	s(%rip), %eax
	addl	%edx, %eax
	movl	%eax, H(%rip)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L8:
	movl	i(%rip), %edx
	movl	m(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	movl	H(%rip), %eax
	movl	T(%rip), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, X(%rip)
	movl	$-1, anst(%rip)
	movl	$-1, ansh(%rip)
	movl	$0, i(%rip)
	jmp	.L10
.L13:
	movl	i(%rip), %edx
	movl	X(%rip), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	js	.L11
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	taro(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jne	.L11
	movl	i(%rip), %edx
	movl	X(%rip), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	hana(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jne	.L11
	movl	i(%rip), %eax
	movl	%eax, anst(%rip)
	movl	i(%rip), %edx
	movl	X(%rip), %eax
	addl	%edx, %eax
	movl	%eax, ansh(%rip)
	jmp	.L12
.L11:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L10:
	movl	i(%rip), %eax
	cmpl	$100, %eax
	jle	.L13
.L12:
	movl	H(%rip), %eax
	movl	T(%rip), %edx
	subl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L14
	movl	anst(%rip), %eax
	cmpl	$-1, %eax
	jne	.L15
.L14:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L16
.L15:
	movl	ansh(%rip), %edx
	movl	anst(%rip), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L16:
	jmp	.L17
.L20:
	nop
	movl	$0, %eax
	popq	%rbp
	.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
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	taro
	.align 32
	.type	taro, @object
	.size	taro, 4000
taro:
	.zero	4000
	.globl	hana
	.align 32
	.type	hana, @object
	.size	hana, 4000
hana:
	.zero	4000
	.globl	T
	.align 4
	.type	T, @object
	.size	T, 4
T:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	X
	.align 4
	.type	X, @object
	.size	X, 4
X:
	.zero	4
	.globl	anst
	.align 4
	.type	anst, @object
	.size	anst, 4
anst:
	.zero	4
	.globl	ansh
	.align 4
	.type	ansh, @object
	.size	ansh, 4
ansh:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"-1"
.LC3:
	.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
.L17:
	leaq	m(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L2
	movl	m(%rip), %eax
	testl	%eax, %eax
	je	.L20
.L2:
	movl	$0, T(%rip)
	movl	$0, H(%rip)
	movl	$0, i(%rip)
	jmp	.L4
.L5:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	taro(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	hana(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L4:
	movl	i(%rip), %eax
	cmpl	$999, %eax
	jle	.L5
	movl	$0, i(%rip)
	jmp	.L6
.L7:
	leaq	s(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	s(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	taro(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	T(%rip), %edx
	movl	s(%rip), %eax
	addl	%edx, %eax
	movl	%eax, T(%rip)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L6:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L7
	movl	$0, i(%rip)
	jmp	.L8
.L9:
	leaq	s(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	s(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	hana(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	H(%rip), %edx
	movl	s(%rip), %eax
	addl	%edx, %eax
	movl	%eax, H(%rip)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L8:
	movl	i(%rip), %edx
	movl	m(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	movl	H(%rip), %eax
	movl	T(%rip), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, X(%rip)
	movl	$-1, anst(%rip)
	movl	$-1, ansh(%rip)
	movl	$0, i(%rip)
	jmp	.L10
.L13:
	movl	i(%rip), %edx
	movl	X(%rip), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	js	.L11
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	taro(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jne	.L11
	movl	i(%rip), %edx
	movl	X(%rip), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	hana(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jne	.L11
	movl	i(%rip), %eax
	movl	%eax, anst(%rip)
	movl	i(%rip), %edx
	movl	X(%rip), %eax
	addl	%edx, %eax
	movl	%eax, ansh(%rip)
	jmp	.L12
.L11:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L10:
	movl	i(%rip), %eax
	cmpl	$100, %eax
	jle	.L13
.L12:
	movl	H(%rip), %eax
	movl	T(%rip), %edx
	subl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L14
	movl	anst(%rip), %eax
	cmpl	$-1, %eax
	jne	.L15
.L14:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L16
.L15:
	movl	ansh(%rip), %edx
	movl	anst(%rip), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L16:
	jmp	.L17
.L20:
	nop
	movl	$0, %eax
	popq	%rbp
	.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:
