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

```c
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int n;
  scanf("%d",&n);
  int w[n],total=0;
  for(int i=0;i<n;i++){
	scanf("%d",&w[i]);
    total+=w[i];
           
  }
  int sum=0,min=1000000;
  for(int i=0;i<n-1;i++){
	for(int j=0;j<=i;j++){
      sum+=w[j];
    }
    if(abs(sum-(total-sum))<min)
      min=abs(sum-(total-sum));
                           sum=0;             }
                                     printf("%d",min);
 return 0;
       
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rsi
	pushq	%r13
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	leaq	.LC0(%rip), %r13
	pushq	%r12
	movq	%r13, %rdi
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-60(%rbp), %rax
	movq	%rsp, %rcx
	movq	%rax, %rdi
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L24:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L24
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L25
.L4:
	movq	%rsp, %rbx
	testl	%edi, %edi
	jle	.L13
	movq	%rbx, %r14
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %edi
	addl	(%r14), %r12d
	addq	$4, %r14
	cmpl	%r15d, %edi
	jg	.L6
.L5:
	subl	$1, %edi
	testl	%edi, %edi
	jle	.L14
	movl	$1, %esi
	xorl	%ecx, %ecx
	leaq	16(%rbx), %r9
	movl	$1000000, %r8d
	.p2align 4,,10
	.p2align 3
.L11:
	cmpl	$2, %ecx
	jle	.L15
	movl	%esi, %edx
	movq	%rbx, %rax
	pxor	%xmm0, %xmm0
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r9, %rdx
	.p2align 4,,10
	.p2align 3
.L9:
	movdqu	(%rax), %xmm2
	addq	$16, %rax
	paddd	%xmm2, %xmm0
	cmpq	%rdx, %rax
	jne	.L9
	movdqa	%xmm0, %xmm1
	movl	%esi, %edx
	psrldq	$8, %xmm1
	andl	$-4, %edx
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	testb	$3, %sil
	je	.L10
.L8:
	movslq	%edx, %r10
	leal	1(%rdx), %r11d
	leaq	(%rbx,%r10,4), %r10
	addl	(%r10), %eax
	cmpl	%ecx, %r11d
	jg	.L10
	addl	$2, %edx
	addl	4(%r10), %eax
	cmpl	%edx, %ecx
	jl	.L10
	addl	8(%r10), %eax
.L10:
	movl	%r12d, %edx
	subl	%eax, %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	cmpl	%eax, %r8d
	cmovg	%eax, %r8d
	addl	$1, %ecx
	addl	$1, %esi
	cmpl	%ecx, %edi
	jne	.L11
.L7:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L26
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_restore_state
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L8
.L25:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L14:
	movl	$1000000, %r8d
	jmp	.L7
.L13:
	xorl	%r12d, %r12d
	jmp	.L5
.L26:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rsi
	pushq	%r13
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	leaq	.LC0(%rip), %r13
	pushq	%r12
	movq	%r13, %rdi
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-60(%rbp), %rax
	movq	%rsp, %rcx
	movq	%rax, %rdi
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L24:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L24
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L25
.L4:
	movq	%rsp, %rbx
	testl	%edi, %edi
	jle	.L13
	movq	%rbx, %r14
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %edi
	addl	(%r14), %r12d
	addq	$4, %r14
	cmpl	%r15d, %edi
	jg	.L6
.L5:
	subl	$1, %edi
	testl	%edi, %edi
	jle	.L14
	movl	$1, %esi
	xorl	%ecx, %ecx
	leaq	16(%rbx), %r9
	movl	$1000000, %r8d
	.p2align 4,,10
	.p2align 3
.L11:
	cmpl	$2, %ecx
	jle	.L15
	movl	%esi, %edx
	movq	%rbx, %rax
	pxor	%xmm0, %xmm0
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r9, %rdx
	.p2align 4,,10
	.p2align 3
.L9:
	movdqu	(%rax), %xmm2
	addq	$16, %rax
	paddd	%xmm2, %xmm0
	cmpq	%rdx, %rax
	jne	.L9
	movdqa	%xmm0, %xmm1
	movl	%esi, %edx
	psrldq	$8, %xmm1
	andl	$-4, %edx
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	testb	$3, %sil
	je	.L10
.L8:
	movslq	%edx, %r10
	leal	1(%rdx), %r11d
	leaq	(%rbx,%r10,4), %r10
	addl	(%r10), %eax
	cmpl	%ecx, %r11d
	jg	.L10
	addl	$2, %edx
	addl	4(%r10), %eax
	cmpl	%edx, %ecx
	jl	.L10
	addl	8(%r10), %eax
.L10:
	movl	%r12d, %edx
	subl	%eax, %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	cmpl	%eax, %r8d
	cmovg	%eax, %r8d
	addl	$1, %ecx
	addl	$1, %esi
	cmpl	%ecx, %edi
	jne	.L11
.L7:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L26
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_restore_state
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L8
.L25:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L14:
	movl	$1000000, %r8d
	jmp	.L7
.L13:
	xorl	%r12d, %r12d
	jmp	.L5
.L26:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rsi
	pushq	%r13
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	leaq	.LC0(%rip), %r13
	pushq	%r12
	movq	%r13, %rdi
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-60(%rbp), %rax
	movq	%rsp, %rcx
	movq	%rax, %rdi
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L24:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L24
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L25
.L4:
	movq	%rsp, %rbx
	testl	%edi, %edi
	jle	.L13
	movq	%rbx, %r14
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %edi
	addl	(%r14), %r12d
	addq	$4, %r14
	cmpl	%r15d, %edi
	jg	.L6
.L5:
	subl	$1, %edi
	testl	%edi, %edi
	jle	.L14
	movl	$1, %esi
	xorl	%ecx, %ecx
	leaq	16(%rbx), %r9
	movl	$1000000, %r8d
	.p2align 4,,10
	.p2align 3
.L11:
	cmpl	$2, %ecx
	jle	.L15
	movl	%esi, %edx
	movq	%rbx, %rax
	pxor	%xmm0, %xmm0
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r9, %rdx
	.p2align 4,,10
	.p2align 3
.L9:
	movdqu	(%rax), %xmm2
	addq	$16, %rax
	paddd	%xmm2, %xmm0
	cmpq	%rdx, %rax
	jne	.L9
	movdqa	%xmm0, %xmm1
	movl	%esi, %edx
	psrldq	$8, %xmm1
	andl	$-4, %edx
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	testb	$3, %sil
	je	.L10
.L8:
	movslq	%edx, %r10
	leal	1(%rdx), %r11d
	leaq	(%rbx,%r10,4), %r10
	addl	(%r10), %eax
	cmpl	%ecx, %r11d
	jg	.L10
	addl	$2, %edx
	addl	4(%r10), %eax
	cmpl	%edx, %ecx
	jl	.L10
	addl	8(%r10), %eax
.L10:
	movl	%r12d, %edx
	subl	%eax, %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	cmpl	%eax, %r8d
	cmovg	%eax, %r8d
	addl	$1, %ecx
	addl	$1, %esi
	cmpl	%ecx, %edi
	jne	.L11
.L7:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L26
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_restore_state
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L8
.L25:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L14:
	movl	$1000000, %r8d
	jmp	.L7
.L13:
	xorl	%r12d, %r12d
	jmp	.L5
.L26:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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:
```
```c
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int n;
  scanf("%d",&n);
  int w[n],total=0;
  for(int i=0;i<n;i++){
	scanf("%d",&w[i]);
    total+=w[i];
           
  }
  int sum=0,min=1000000;
  for(int i=0;i<n-1;i++){
	for(int j=0;j<=i;j++){
      sum+=w[j];
    }
    if(abs(sum-(total-sum))<min)
      min=abs(sum-(total-sum));
                           sum=0;             }
                                     printf("%d",min);
 return 0;
       
}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int n;
  scanf("%d",&n);
  int w[n],total=0;
  for(int i=0;i<n;i++){
	scanf("%d",&w[i]);
    total+=w[i];
           
  }
  int sum=0,min=1000000;
  for(int i=0;i<n-1;i++){
	for(int j=0;j<=i;j++){
      sum+=w[j];
    }
    if(abs(sum-(total-sum))<min)
      min=abs(sum-(total-sum));
                           sum=0;             }
                                     printf("%d",min);
 return 0;
       
}```

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.
Optimized Assembly Code:

3
1 2 2
 4
2 3 1 1
 8
27 23 76 2 3 5 62 14
 3
1 1 2
 4
2 3 1 0
 8
27 30 76 2 3 5 62 14
 8
27 30 76 2 3 5 62 5
 8
27 30 76 2 3 2 62 5
 8
27 30 76 2 3 2 102 5
 8
27 30 99 2 3 2 102 5

1 3 40 0 2 47 56 59 19 42
Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int n;
  scanf("%d",&n);
  int w[n],total=0;
  for(int i=0;i<n;i++){
	scanf("%d",&w[i]);
    total+=w[i];
           
  }
  int sum=0,min=1000000;
  for(int i=0;i<n-1;i++){
	for(int j=0;j<=i;j++){
      sum+=w[j];
    }
    if(abs(sum-(total-sum))<min)
      min=abs(sum-(total-sum));
                           sum=0;             }
                                     printf("%d",min);
 return 0;
       
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rsi
	pushq	%r13
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	leaq	.LC0(%rip), %r13
	pushq	%r12
	movq	%r13, %rdi
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-60(%rbp), %rax
	movq	%rsp, %rcx
	movq	%rax, %rdi
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L24:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L24
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L25
.L4:
	movq	%rsp, %rbx
	testl	%edi, %edi
	jle	.L13
	movq	%rbx, %r14
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %edi
	addl	(%r14), %r12d
	addq	$4, %r14
	cmpl	%r15d, %edi
	jg	.L6
.L5:
	subl	$1, %edi
	testl	%edi, %edi
	jle	.L14
	movl	$1, %esi
	xorl	%ecx, %ecx
	leaq	16(%rbx), %r9
	movl	$1000000, %r8d
	.p2align 4,,10
	.p2align 3
.L11:
	cmpl	$2, %ecx
	jle	.L15
	movl	%esi, %edx
	movq	%rbx, %rax
	pxor	%xmm0, %xmm0
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r9, %rdx
	.p2align 4,,10
	.p2align 3
.L9:
	movdqu	(%rax), %xmm2
	addq	$16, %rax
	paddd	%xmm2, %xmm0
	cmpq	%rdx, %rax
	jne	.L9
	movdqa	%xmm0, %xmm1
	movl	%esi, %edx
	psrldq	$8, %xmm1
	andl	$-4, %edx
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	testb	$3, %sil
	je	.L10
.L8:
	movslq	%edx, %r10
	leal	1(%rdx), %r11d
	leaq	(%rbx,%r10,4), %r10
	addl	(%r10), %eax
	cmpl	%ecx, %r11d
	jg	.L10
	addl	$2, %edx
	addl	4(%r10), %eax
	cmpl	%edx, %ecx
	jl	.L10
	addl	8(%r10), %eax
.L10:
	movl	%r12d, %edx
	subl	%eax, %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	cmpl	%eax, %r8d
	cmovg	%eax, %r8d
	addl	$1, %ecx
	addl	$1, %esi
	cmpl	%ecx, %edi
	jne	.L11
.L7:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L26
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_restore_state
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L8
.L25:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L14:
	movl	$1000000, %r8d
	jmp	.L7
.L13:
	xorl	%r12d, %r12d
	jmp	.L5
.L26:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rsi
	pushq	%r13
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	leaq	.LC0(%rip), %r13
	pushq	%r12
	movq	%r13, %rdi
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-60(%rbp), %rax
	movq	%rsp, %rcx
	movq	%rax, %rdi
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L24:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L24
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L25
.L4:
	movq	%rsp, %rbx
	testl	%edi, %edi
	jle	.L13
	movq	%rbx, %r14
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %edi
	addl	(%r14), %r12d
	addq	$4, %r14
	cmpl	%r15d, %edi
	jg	.L6
.L5:
	subl	$1, %edi
	testl	%edi, %edi
	jle	.L14
	movl	$1, %esi
	xorl	%ecx, %ecx
	leaq	16(%rbx), %r9
	movl	$1000000, %r8d
	.p2align 4,,10
	.p2align 3
.L11:
	cmpl	$2, %ecx
	jle	.L15
	movl	%esi, %edx
	movq	%rbx, %rax
	pxor	%xmm0, %xmm0
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r9, %rdx
	.p2align 4,,10
	.p2align 3
.L9:
	movdqu	(%rax), %xmm2
	addq	$16, %rax
	paddd	%xmm2, %xmm0
	cmpq	%rdx, %rax
	jne	.L9
	movdqa	%xmm0, %xmm1
	movl	%esi, %edx
	psrldq	$8, %xmm1
	andl	$-4, %edx
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	testb	$3, %sil
	je	.L10
.L8:
	movslq	%edx, %r10
	leal	1(%rdx), %r11d
	leaq	(%rbx,%r10,4), %r10
	addl	(%r10), %eax
	cmpl	%ecx, %r11d
	jg	.L10
	addl	$2, %edx
	addl	4(%r10), %eax
	cmpl	%edx, %ecx
	jl	.L10
	addl	8(%r10), %eax
.L10:
	movl	%r12d, %edx
	subl	%eax, %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	cmpl	%eax, %r8d
	cmovg	%eax, %r8d
	addl	$1, %ecx
	addl	$1, %esi
	cmpl	%ecx, %edi
	jne	.L11
.L7:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L26
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_restore_state
	xorl	%edx, %edx
	xorl	%eax, %eax
	jmp	.L8
.L25:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L14:
	movl	$1000000, %r8d
	jmp	.L7
.L13:
	xorl	%r12d, %r12d
	jmp	.L5
.L26:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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:
```