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>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char str[1000];
    char *tok;
    
    int n;
    int a[100][2];
    int i1,i3,i4;
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    n=strtol(tok,NULL,10);
    //printf("%d\n",n);
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    a[0][0]=strtol(tok,NULL,10);
    for(i1=1;i1<n;i1++){
        tok=strtok(NULL," ");
        a[i1][0]=strtol(tok,NULL,10);
    }
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    a[0][1]=strtol(tok,NULL,10);
    for(i1=1;i1<n;i1++){
        tok=strtok(NULL," ");
        a[i1][1]=strtol(tok,NULL,10);;
    }
    
    i4=a[n-1][1];
    for(i1=0;i1<n;i1++){
        i4+=a[i1][0];
    }
    //printf("%d\n",i4);
    
    i3=i4;
    for(i1=1;i1<n;i1++){
        i4=i4-a[n-i1][0]+a[n-1-i1][1];
        if(i4>i3){
            i3=i4;
        }
    }
    
    
    printf("%d",i3);
    
    return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	" "
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$1840, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rdx
	leaq	-1008(%rbp), %rax
	movl	$1000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-1008(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -1820(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-1008(%rbp), %rax
	movl	$1000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-1008(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -1808(%rbp)
	movl	$1, -1832(%rbp)
	jmp	.L2
.L3:
	leaq	.LC0(%rip), %rax
	movq	%rax, %rsi
	movl	$0, %edi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, %edx
	movl	-1832(%rbp), %eax
	cltq
	movl	%edx, -1808(%rbp,%rax,8)
	addl	$1, -1832(%rbp)
.L2:
	movl	-1832(%rbp), %eax
	cmpl	-1820(%rbp), %eax
	jl	.L3
	movq	stdin(%rip), %rdx
	leaq	-1008(%rbp), %rax
	movl	$1000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-1008(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -1804(%rbp)
	movl	$1, -1832(%rbp)
	jmp	.L4
.L5:
	leaq	.LC0(%rip), %rax
	movq	%rax, %rsi
	movl	$0, %edi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, %edx
	movl	-1832(%rbp), %eax
	cltq
	movl	%edx, -1804(%rbp,%rax,8)
	addl	$1, -1832(%rbp)
.L4:
	movl	-1832(%rbp), %eax
	cmpl	-1820(%rbp), %eax
	jl	.L5
	movl	-1820(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-1804(%rbp,%rax,8), %eax
	movl	%eax, -1824(%rbp)
	movl	$0, -1832(%rbp)
	jmp	.L6
.L7:
	movl	-1832(%rbp), %eax
	cltq
	movl	-1808(%rbp,%rax,8), %eax
	addl	%eax, -1824(%rbp)
	addl	$1, -1832(%rbp)
.L6:
	movl	-1832(%rbp), %eax
	cmpl	-1820(%rbp), %eax
	jl	.L7
	movl	-1824(%rbp), %eax
	movl	%eax, -1828(%rbp)
	movl	$1, -1832(%rbp)
	jmp	.L8
.L10:
	movl	-1820(%rbp), %eax
	subl	-1832(%rbp), %eax
	cltq
	movl	-1808(%rbp,%rax,8), %edx
	movl	-1824(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-1820(%rbp), %eax
	subl	$1, %eax
	subl	-1832(%rbp), %eax
	cltq
	movl	-1804(%rbp,%rax,8), %eax
	addl	%ecx, %eax
	movl	%eax, -1824(%rbp)
	movl	-1824(%rbp), %eax
	cmpl	-1828(%rbp), %eax
	jle	.L9
	movl	-1824(%rbp), %eax
	movl	%eax, -1828(%rbp)
.L9:
	addl	$1, -1832(%rbp)
.L8:
	movl	-1832(%rbp), %eax
	cmpl	-1820(%rbp), %eax
	jl	.L10
	movl	-1828(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	" "
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$1000, %esi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	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	$1832, %rsp
	.cfi_def_cfa_offset 1888
	movq	stdin(%rip), %rdx
	movq	%fs:40, %rax
	movq	%rax, 1816(%rsp)
	xorl	%eax, %eax
	leaq	816(%rsp), %r15
	movq	%r15, %rdi
	call	fgets@PLT
	movq	%rbp, %rsi
	movq	%r15, %rdi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movq	stdin(%rip), %rdx
	movl	$1000, %esi
	movq	%r15, %rdi
	movq	%rax, %r12
	call	fgets@PLT
	movq	%rbp, %rsi
	movq	%r15, %rdi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, 16(%rsp)
	cmpl	$1, %r12d
	jle	.L2
	leaq	16(%rsp), %rax
	leal	-2(%r12), %r13d
	movq	%rax, 8(%rsp)
	salq	$3, %r13
	leaq	24(%rsp), %r14
	leaq	32(%rsp,%r13), %rbx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	xorl	%edi, %edi
	addq	$8, %r14
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -8(%r14)
	cmpq	%rbx, %r14
	jne	.L3
	movq	stdin(%rip), %rdx
	movl	$1000, %esi
	movq	%r15, %rdi
	leaq	28(%rsp), %rbx
	call	fgets@PLT
	movq	%rbp, %rsi
	movq	%r15, %rdi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, 20(%rsp)
	movq	8(%rsp), %rax
	leaq	20(%rax,%r13), %r13
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%rbp, %rsi
	xorl	%edi, %edi
	addq	$8, %rbx
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -8(%rbx)
	cmpq	%r13, %rbx
	jne	.L5
	leal	-1(%r12), %edx
	movslq	%edx, %rcx
	movl	%edx, %edi
	movl	20(%rsp,%rcx,8), %eax
.L13:
	testl	%r12d, %r12d
	movl	$1, %esi
	cmovg	%r12d, %esi
	cmpl	$2, %edx
	jbe	.L16
	testl	%r12d, %r12d
	jle	.L16
	movl	%esi, %ecx
	leaq	16(%rsp), %rdx
	pxor	%xmm1, %xmm1
	shrl	$2, %ecx
	subl	$1, %ecx
	salq	$5, %rcx
	leaq	48(%rsp,%rcx), %rcx
	.p2align 4,,10
	.p2align 3
.L8:
	movdqa	(%rdx), %xmm0
	addq	$32, %rdx
	shufps	$136, -16(%rdx), %xmm0
	paddd	%xmm0, %xmm1
	cmpq	%rcx, %rdx
	jne	.L8
	movdqa	%xmm1, %xmm0
	psrldq	$8, %xmm0
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %edx
	addl	%edx, %eax
	movl	%esi, %edx
	andl	$-4, %edx
	andl	$3, %esi
	je	.L9
.L7:
	movslq	%edx, %rcx
	addl	16(%rsp,%rcx,8), %eax
	leal	1(%rdx), %ecx
	cmpl	%ecx, %r12d
	jle	.L9
	movslq	%ecx, %rcx
	addl	$2, %edx
	addl	16(%rsp,%rcx,8), %eax
	cmpl	%edx, %r12d
	jle	.L14
	movslq	%edx, %rdx
	addl	16(%rsp,%rdx,8), %eax
.L14:
	movslq	%r12d, %r9
	movl	%eax, %r8d
	leaq	0(,%r9,8), %rcx
	leaq	8(%rsp,%rcx), %rsi
	leaq	16(%rsp,%rcx), %rdx
	leal	-2(%r12), %ecx
	salq	$3, %rcx
	subq	%rcx, %rsi
	movslq	%edi, %rcx
	subq	%r9, %rcx
	.p2align 4,,10
	.p2align 3
.L12:
	subl	-8(%rdx), %eax
	addl	-4(%rdx,%rcx,8), %eax
	cmpl	%eax, %r8d
	cmovl	%eax, %r8d
	subq	$8, %rdx
	cmpq	%rsi, %rdx
	jne	.L12
.L11:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	1816(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L28
	addq	$1832, %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
.L9:
	.cfi_restore_state
	cmpl	$1, %r12d
	jg	.L14
.L17:
	movl	%eax, %r8d
	jmp	.L11
.L2:
	movq	stdin(%rip), %rdx
	movl	$1000, %esi
	movq	%r15, %rdi
	call	fgets@PLT
	movq	%rbp, %rsi
	movq	%r15, %rdi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	leal	-1(%r12), %edx
	movl	%eax, 20(%rsp)
	movslq	%edx, %rax
	movl	20(%rsp,%rax,8), %eax
	cmpl	$1, %r12d
	jne	.L17
	xorl	%edi, %edi
	jmp	.L13
.L16:
	xorl	%edx, %edx
	jmp	.L7
.L28:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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	" "
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$1000, %esi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	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	$1832, %rsp
	.cfi_def_cfa_offset 1888
	movq	stdin(%rip), %rdx
	movq	%fs:40, %rax
	movq	%rax, 1816(%rsp)
	xorl	%eax, %eax
	leaq	816(%rsp), %r15
	movq	%r15, %rdi
	call	fgets@PLT
	movq	%rbp, %rsi
	movq	%r15, %rdi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movq	stdin(%rip), %rdx
	movl	$1000, %esi
	movq	%r15, %rdi
	movq	%rax, %r12
	call	fgets@PLT
	movq	%rbp, %rsi
	movq	%r15, %rdi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, 16(%rsp)
	cmpl	$1, %r12d
	jle	.L2
	leaq	16(%rsp), %rax
	leal	-2(%r12), %r13d
	movq	%rax, 8(%rsp)
	salq	$3, %r13
	leaq	24(%rsp), %r14
	leaq	32(%rsp,%r13), %rbx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	xorl	%edi, %edi
	addq	$8, %r14
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -8(%r14)
	cmpq	%rbx, %r14
	jne	.L3
	movq	stdin(%rip), %rdx
	movl	$1000, %esi
	movq	%r15, %rdi
	leaq	28(%rsp), %rbx
	call	fgets@PLT
	movq	%rbp, %rsi
	movq	%r15, %rdi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, 20(%rsp)
	movq	8(%rsp), %rax
	leaq	20(%rax,%r13), %r13
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%rbp, %rsi
	xorl	%edi, %edi
	addq	$8, %rbx
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -8(%rbx)
	cmpq	%r13, %rbx
	jne	.L5
	leal	-1(%r12), %edx
	movslq	%edx, %rcx
	movl	%edx, %edi
	movl	20(%rsp,%rcx,8), %eax
.L13:
	testl	%r12d, %r12d
	movl	$1, %esi
	cmovg	%r12d, %esi
	cmpl	$2, %edx
	jbe	.L16
	testl	%r12d, %r12d
	jle	.L16
	movl	%esi, %ecx
	leaq	16(%rsp), %rdx
	pxor	%xmm1, %xmm1
	shrl	$2, %ecx
	subl	$1, %ecx
	salq	$5, %rcx
	leaq	48(%rsp,%rcx), %rcx
	.p2align 4,,10
	.p2align 3
.L8:
	movdqa	(%rdx), %xmm0
	addq	$32, %rdx
	shufps	$136, -16(%rdx), %xmm0
	paddd	%xmm0, %xmm1
	cmpq	%rcx, %rdx
	jne	.L8
	movdqa	%xmm1, %xmm0
	psrldq	$8, %xmm0
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %edx
	addl	%edx, %eax
	movl	%esi, %edx
	andl	$-4, %edx
	andl	$3, %esi
	je	.L9
.L7:
	movslq	%edx, %rcx
	addl	16(%rsp,%rcx,8), %eax
	leal	1(%rdx), %ecx
	cmpl	%ecx, %r12d
	jle	.L9
	movslq	%ecx, %rcx
	addl	$2, %edx
	addl	16(%rsp,%rcx,8), %eax
	cmpl	%edx, %r12d
	jle	.L14
	movslq	%edx, %rdx
	addl	16(%rsp,%rdx,8), %eax
.L14:
	movslq	%r12d, %r9
	movl	%eax, %r8d
	leaq	0(,%r9,8), %rcx
	leaq	8(%rsp,%rcx), %rsi
	leaq	16(%rsp,%rcx), %rdx
	leal	-2(%r12), %ecx
	salq	$3, %rcx
	subq	%rcx, %rsi
	movslq	%edi, %rcx
	subq	%r9, %rcx
	.p2align 4,,10
	.p2align 3
.L12:
	subl	-8(%rdx), %eax
	addl	-4(%rdx,%rcx,8), %eax
	cmpl	%eax, %r8d
	cmovl	%eax, %r8d
	subq	$8, %rdx
	cmpq	%rsi, %rdx
	jne	.L12
.L11:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	1816(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L28
	addq	$1832, %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
.L9:
	.cfi_restore_state
	cmpl	$1, %r12d
	jg	.L14
.L17:
	movl	%eax, %r8d
	jmp	.L11
.L2:
	movq	stdin(%rip), %rdx
	movl	$1000, %esi
	movq	%r15, %rdi
	call	fgets@PLT
	movq	%rbp, %rsi
	movq	%r15, %rdi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	leal	-1(%r12), %edx
	movl	%eax, 20(%rsp)
	movslq	%edx, %rax
	movl	20(%rsp,%rax,8), %eax
	cmpl	$1, %r12d
	jne	.L17
	xorl	%edi, %edi
	jmp	.L13
.L16:
	xorl	%edx, %edx
	jmp	.L7
.L28:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char str[1000];
    char *tok;
    
    int n;
    int a[100][2];
    int i1,i3,i4;
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    n=strtol(tok,NULL,10);
    //printf("%d\n",n);
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    a[0][0]=strtol(tok,NULL,10);
    for(i1=1;i1<n;i1++){
        tok=strtok(NULL," ");
        a[i1][0]=strtol(tok,NULL,10);
    }
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    a[0][1]=strtol(tok,NULL,10);
    for(i1=1;i1<n;i1++){
        tok=strtok(NULL," ");
        a[i1][1]=strtol(tok,NULL,10);;
    }
    
    i4=a[n-1][1];
    for(i1=0;i1<n;i1++){
        i4+=a[i1][0];
    }
    //printf("%d\n",i4);
    
    i3=i4;
    for(i1=1;i1<n;i1++){
        i4=i4-a[n-i1][0]+a[n-1-i1][1];
        if(i4>i3){
            i3=i4;
        }
    }
    
    
    printf("%d",i3);
    
    return 0;
}


5
3 2 2 4 1
1 2 2 2 1

14
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>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char str[1000];
    char *tok;
    
    int n;
    int a[100][2];
    int i1,i3,i4;
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    n=strtol(tok,NULL,10);
    //printf("%d\n",n);
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    a[0][0]=strtol(tok,NULL,10);
    for(i1=1;i1<n;i1++){
        tok=strtok(NULL," ");
        a[i1][0]=strtol(tok,NULL,10);
    }
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    a[0][1]=strtol(tok,NULL,10);
    for(i1=1;i1<n;i1++){
        tok=strtok(NULL," ");
        a[i1][1]=strtol(tok,NULL,10);;
    }
    
    i4=a[n-1][1];
    for(i1=0;i1<n;i1++){
        i4+=a[i1][0];
    }
    //printf("%d\n",i4);
    
    i3=i4;
    for(i1=1;i1<n;i1++){
        i4=i4-a[n-i1][0]+a[n-1-i1][1];
        if(i4>i3){
            i3=i4;
        }
    }
    
    
    printf("%d",i3);
    
    return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	" "
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$1840, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rdx
	leaq	-1008(%rbp), %rax
	movl	$1000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-1008(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -1820(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-1008(%rbp), %rax
	movl	$1000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-1008(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -1808(%rbp)
	movl	$1, -1832(%rbp)
	jmp	.L2
.L3:
	leaq	.LC0(%rip), %rax
	movq	%rax, %rsi
	movl	$0, %edi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, %edx
	movl	-1832(%rbp), %eax
	cltq
	movl	%edx, -1808(%rbp,%rax,8)
	addl	$1, -1832(%rbp)
.L2:
	movl	-1832(%rbp), %eax
	cmpl	-1820(%rbp), %eax
	jl	.L3
	movq	stdin(%rip), %rdx
	leaq	-1008(%rbp), %rax
	movl	$1000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-1008(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -1804(%rbp)
	movl	$1, -1832(%rbp)
	jmp	.L4
.L5:
	leaq	.LC0(%rip), %rax
	movq	%rax, %rsi
	movl	$0, %edi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, %edx
	movl	-1832(%rbp), %eax
	cltq
	movl	%edx, -1804(%rbp,%rax,8)
	addl	$1, -1832(%rbp)
.L4:
	movl	-1832(%rbp), %eax
	cmpl	-1820(%rbp), %eax
	jl	.L5
	movl	-1820(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-1804(%rbp,%rax,8), %eax
	movl	%eax, -1824(%rbp)
	movl	$0, -1832(%rbp)
	jmp	.L6
.L7:
	movl	-1832(%rbp), %eax
	cltq
	movl	-1808(%rbp,%rax,8), %eax
	addl	%eax, -1824(%rbp)
	addl	$1, -1832(%rbp)
.L6:
	movl	-1832(%rbp), %eax
	cmpl	-1820(%rbp), %eax
	jl	.L7
	movl	-1824(%rbp), %eax
	movl	%eax, -1828(%rbp)
	movl	$1, -1832(%rbp)
	jmp	.L8
.L10:
	movl	-1820(%rbp), %eax
	subl	-1832(%rbp), %eax
	cltq
	movl	-1808(%rbp,%rax,8), %edx
	movl	-1824(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-1820(%rbp), %eax
	subl	$1, %eax
	subl	-1832(%rbp), %eax
	cltq
	movl	-1804(%rbp,%rax,8), %eax
	addl	%ecx, %eax
	movl	%eax, -1824(%rbp)
	movl	-1824(%rbp), %eax
	cmpl	-1828(%rbp), %eax
	jle	.L9
	movl	-1824(%rbp), %eax
	movl	%eax, -1828(%rbp)
.L9:
	addl	$1, -1832(%rbp)
.L8:
	movl	-1832(%rbp), %eax
	cmpl	-1820(%rbp), %eax
	jl	.L10
	movl	-1828(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	" "
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$1840, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rdx
	leaq	-1008(%rbp), %rax
	movl	$1000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-1008(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -1820(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-1008(%rbp), %rax
	movl	$1000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-1008(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -1808(%rbp)
	movl	$1, -1832(%rbp)
	jmp	.L2
.L3:
	leaq	.LC0(%rip), %rax
	movq	%rax, %rsi
	movl	$0, %edi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, %edx
	movl	-1832(%rbp), %eax
	cltq
	movl	%edx, -1808(%rbp,%rax,8)
	addl	$1, -1832(%rbp)
.L2:
	movl	-1832(%rbp), %eax
	cmpl	-1820(%rbp), %eax
	jl	.L3
	movq	stdin(%rip), %rdx
	leaq	-1008(%rbp), %rax
	movl	$1000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-1008(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -1804(%rbp)
	movl	$1, -1832(%rbp)
	jmp	.L4
.L5:
	leaq	.LC0(%rip), %rax
	movq	%rax, %rsi
	movl	$0, %edi
	call	strtok@PLT
	movq	%rax, -1816(%rbp)
	movq	-1816(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, %edx
	movl	-1832(%rbp), %eax
	cltq
	movl	%edx, -1804(%rbp,%rax,8)
	addl	$1, -1832(%rbp)
.L4:
	movl	-1832(%rbp), %eax
	cmpl	-1820(%rbp), %eax
	jl	.L5
	movl	-1820(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-1804(%rbp,%rax,8), %eax
	movl	%eax, -1824(%rbp)
	movl	$0, -1832(%rbp)
	jmp	.L6
.L7:
	movl	-1832(%rbp), %eax
	cltq
	movl	-1808(%rbp,%rax,8), %eax
	addl	%eax, -1824(%rbp)
	addl	$1, -1832(%rbp)
.L6:
	movl	-1832(%rbp), %eax
	cmpl	-1820(%rbp), %eax
	jl	.L7
	movl	-1824(%rbp), %eax
	movl	%eax, -1828(%rbp)
	movl	$1, -1832(%rbp)
	jmp	.L8
.L10:
	movl	-1820(%rbp), %eax
	subl	-1832(%rbp), %eax
	cltq
	movl	-1808(%rbp,%rax,8), %edx
	movl	-1824(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-1820(%rbp), %eax
	subl	$1, %eax
	subl	-1832(%rbp), %eax
	cltq
	movl	-1804(%rbp,%rax,8), %eax
	addl	%ecx, %eax
	movl	%eax, -1824(%rbp)
	movl	-1824(%rbp), %eax
	cmpl	-1828(%rbp), %eax
	jle	.L9
	movl	-1824(%rbp), %eax
	movl	%eax, -1828(%rbp)
.L9:
	addl	$1, -1832(%rbp)
.L8:
	movl	-1832(%rbp), %eax
	cmpl	-1820(%rbp), %eax
	jl	.L10
	movl	-1828(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
