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>

#define MAX_N 100

int main(){
  int n,max,min,i,arr[MAX_N],sum;
  int use_max,use_min;
  while(1){
    use_max = use_min = 0;
    max = sum = 0; min = 1000;
    scanf("%d",&n);
    if(n == 0){ break; }
    for(i = 0 ; i < n ; i++){
      scanf("%d",&arr[i]);
      if(max < arr[i]){ max = arr[i]; }
      if(min > arr[i]){ min = arr[i]; }
    }
    for(i = 0 ; i < n ; i++){
      if(max == arr[i]){
        if(use_max == 0){
          use_max = 1;
          continue;
        }
      }
      if(min == arr[i]){
        if(use_min == 0){
          use_min = 1;
          continue;
        }
      }
      sum += arr[i];
    }
    printf("%d\n",sum/(n-2));
  }
  return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%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
	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	$456, %rsp
	.cfi_def_cfa_offset 512
	movq	%fs:40, %rax
	movq	%rax, 440(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L9:
	movq	8(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	je	.L2
	jle	.L12
	leaq	32(%rsp), %r13
	xorl	%r12d, %r12d
	movl	$1000, %r15d
	xorl	%r14d, %r14d
	movq	%r13, %rbx
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbx, %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	(%rbx), %eax
	cmpl	%eax, %r14d
	cmovl	%eax, %r14d
	cmpl	%eax, %r15d
	cmovg	%eax, %r15d
	movl	28(%rsp), %eax
	addl	$1, %r12d
	addq	$4, %rbx
	cmpl	%r12d, %eax
	jg	.L4
	leal	-2(%rax), %r10d
	testl	%eax, %eax
	jle	.L12
	subl	$1, %eax
	leaq	4(%r13), %rcx
	xorl	%r9d, %r9d
	xorl	%edx, %edx
	leaq	(%rcx,%rax,4), %rdi
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L8:
	movl	0(%r13), %esi
	testl	%edx, %edx
	jne	.L15
	cmpl	%esi, %r14d
	je	.L13
.L15:
	testl	%r9d, %r9d
	jne	.L16
	cmpl	%esi, %r15d
	je	.L14
.L16:
	addl	%esi, %eax
.L5:
	movq	%rcx, %r13
	cmpq	%rcx, %rdi
	je	.L25
.L28:
	addq	$4, %rcx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L14:
	movl	$1, %r9d
	movq	%rcx, %r13
	cmpq	%rcx, %rdi
	jne	.L28
	.p2align 4,,10
	.p2align 3
.L25:
	cltd
	idivl	%r10d
.L3:
	movl	%eax, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L13:
	movl	$1, %edx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L2:
	movq	440(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$456, %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
	.p2align 4,,10
	.p2align 3
.L12:
	.cfi_restore_state
	xorl	%eax, %eax
	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:
```

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"
.LC1:
	.string	"%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
	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	$456, %rsp
	.cfi_def_cfa_offset 512
	movq	%fs:40, %rax
	movq	%rax, 440(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L9:
	movq	8(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	je	.L2
	jle	.L12
	leaq	32(%rsp), %r13
	xorl	%r12d, %r12d
	movl	$1000, %r15d
	xorl	%r14d, %r14d
	movq	%r13, %rbx
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbx, %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	(%rbx), %eax
	cmpl	%eax, %r14d
	cmovl	%eax, %r14d
	cmpl	%eax, %r15d
	cmovg	%eax, %r15d
	movl	28(%rsp), %eax
	addl	$1, %r12d
	addq	$4, %rbx
	cmpl	%r12d, %eax
	jg	.L4
	leal	-2(%rax), %r10d
	testl	%eax, %eax
	jle	.L12
	subl	$1, %eax
	leaq	4(%r13), %rcx
	xorl	%r9d, %r9d
	xorl	%edx, %edx
	leaq	(%rcx,%rax,4), %rdi
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L8:
	movl	0(%r13), %esi
	testl	%edx, %edx
	jne	.L15
	cmpl	%esi, %r14d
	je	.L13
.L15:
	testl	%r9d, %r9d
	jne	.L16
	cmpl	%esi, %r15d
	je	.L14
.L16:
	addl	%esi, %eax
.L5:
	movq	%rcx, %r13
	cmpq	%rcx, %rdi
	je	.L25
.L28:
	addq	$4, %rcx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L14:
	movl	$1, %r9d
	movq	%rcx, %r13
	cmpq	%rcx, %rdi
	jne	.L28
	.p2align 4,,10
	.p2align 3
.L25:
	cltd
	idivl	%r10d
.L3:
	movl	%eax, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L13:
	movl	$1, %edx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L2:
	movq	440(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$456, %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
	.p2align 4,,10
	.p2align 3
.L12:
	.cfi_restore_state
	xorl	%eax, %eax
	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
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%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
	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	$456, %rsp
	.cfi_def_cfa_offset 512
	movq	%fs:40, %rax
	movq	%rax, 440(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L9:
	movq	8(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	je	.L2
	jle	.L12
	leaq	32(%rsp), %r13
	xorl	%r12d, %r12d
	movl	$1000, %r15d
	xorl	%r14d, %r14d
	movq	%r13, %rbx
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbx, %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	(%rbx), %eax
	cmpl	%eax, %r14d
	cmovl	%eax, %r14d
	cmpl	%eax, %r15d
	cmovg	%eax, %r15d
	movl	28(%rsp), %eax
	addl	$1, %r12d
	addq	$4, %rbx
	cmpl	%r12d, %eax
	jg	.L4
	leal	-2(%rax), %r10d
	testl	%eax, %eax
	jle	.L12
	subl	$1, %eax
	leaq	4(%r13), %rcx
	xorl	%r9d, %r9d
	xorl	%edx, %edx
	leaq	(%rcx,%rax,4), %rdi
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L8:
	movl	0(%r13), %esi
	testl	%edx, %edx
	jne	.L15
	cmpl	%esi, %r14d
	je	.L13
.L15:
	testl	%r9d, %r9d
	jne	.L16
	cmpl	%esi, %r15d
	je	.L14
.L16:
	addl	%esi, %eax
.L5:
	movq	%rcx, %r13
	cmpq	%rcx, %rdi
	je	.L25
.L28:
	addq	$4, %rcx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L14:
	movl	$1, %r9d
	movq	%rcx, %r13
	cmpq	%rcx, %rdi
	jne	.L28
	.p2align 4,,10
	.p2align 3
.L25:
	cltd
	idivl	%r10d
.L3:
	movl	%eax, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L13:
	movl	$1, %edx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L2:
	movq	440(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$456, %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
	.p2align 4,,10
	.p2align 3
.L12:
	.cfi_restore_state
	xorl	%eax, %eax
	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:
```
```c
#include <stdio.h>

#define MAX_N 100

int main(){
  int n,max,min,i,arr[MAX_N],sum;
  int use_max,use_min;
  while(1){
    use_max = use_min = 0;
    max = sum = 0; min = 1000;
    scanf("%d",&n);
    if(n == 0){ break; }
    for(i = 0 ; i < n ; i++){
      scanf("%d",&arr[i]);
      if(max < arr[i]){ max = arr[i]; }
      if(min > arr[i]){ min = arr[i]; }
    }
    for(i = 0 ; i < n ; i++){
      if(max == arr[i]){
        if(use_max == 0){
          use_max = 1;
          continue;
        }
      }
      if(min == arr[i]){
        if(use_min == 0){
          use_min = 1;
          continue;
        }
      }
      sum += arr[i];
    }
    printf("%d\n",sum/(n-2));
  }
  return 0;
}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>

#define MAX_N 100

int main(){
  int n,max,min,i,arr[MAX_N],sum;
  int use_max,use_min;
  while(1){
    use_max = use_min = 0;
    max = sum = 0; min = 1000;
    scanf("%d",&n);
    if(n == 0){ break; }
    for(i = 0 ; i < n ; i++){
      scanf("%d",&arr[i]);
      if(max < arr[i]){ max = arr[i]; }
      if(min > arr[i]){ min = arr[i]; }
    }
    for(i = 0 ; i < n ; i++){
      if(max == arr[i]){
        if(use_max == 0){
          use_max = 1;
          continue;
        }
      }
      if(min == arr[i]){
        if(use_min == 0){
          use_min = 1;
          continue;
        }
      }
      sum += arr[i];
    }
    printf("%d\n",sum/(n-2));
  }
  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
1000
342
0
5
2
2
9
11
932
5
300
1000
0
200
400
8
353
242
708
274
283
132
402
523
0
 3
1000
342
0
5
0
2
9
11
932
5
300
1000
0
200
400
8
353
242
402
274
283
132
402
523
0
 3
1000
342
0
5
2
2
9
11
932
5
300
1000
0
200
400
8
297
242
924
274
283
132
402
523
0
 3
1000
342
0
5
2
2
9
11
932
5
300
1000
0
200
400
8
297
242
924
274
5
132
402
523
0
 3
1000
342
0
5
0
2
9
11
932
5
300
1000
0
200
685
8
353
242
402
274
283
31
402
523
0
 3
1000
342
0
5
2
2
9
11
932
5
300
1000
0
200
400
8
297
242
924
274
5
132
531
523
0
 3
1000
342
0
5
0
2
9
11
932
5
300
1000
0
200
685
8
353
143
402
274
283
31
402
523
0
 3
1000
342
0
5
2
2
9
11
932
5
300
1000
0
200
400
8
203
242
924
274
5
132
531
523
0
 3
1000
342
0
5
2
2
9
11
932
5
300
1000
0
200
479
8
353
242
402
274
283
132
402
523
0
 3
1000
342
0
5
2
2
9
11
932
5
300
1000
0
200
400
8
353
242
708
274
283
132
13
523
0

342
7
300
346
 342
7
300
326
 342
7
300
336
 342
7
300
311
 342
7
395
326
 342
7
300
333
 342
7
395
309
 342
7
300
317
 342
7
326
326
 342
7
300
301

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>

#define MAX_N 100

int main(){
  int n,max,min,i,arr[MAX_N],sum;
  int use_max,use_min;
  while(1){
    use_max = use_min = 0;
    max = sum = 0; min = 1000;
    scanf("%d",&n);
    if(n == 0){ break; }
    for(i = 0 ; i < n ; i++){
      scanf("%d",&arr[i]);
      if(max < arr[i]){ max = arr[i]; }
      if(min > arr[i]){ min = arr[i]; }
    }
    for(i = 0 ; i < n ; i++){
      if(max == arr[i]){
        if(use_max == 0){
          use_max = 1;
          continue;
        }
      }
      if(min == arr[i]){
        if(use_min == 0){
          use_min = 1;
          continue;
        }
      }
      sum += arr[i];
    }
    printf("%d\n",sum/(n-2));
  }
  return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%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
	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	$456, %rsp
	.cfi_def_cfa_offset 512
	movq	%fs:40, %rax
	movq	%rax, 440(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L9:
	movq	8(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	je	.L2
	jle	.L12
	leaq	32(%rsp), %r13
	xorl	%r12d, %r12d
	movl	$1000, %r15d
	xorl	%r14d, %r14d
	movq	%r13, %rbx
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbx, %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	(%rbx), %eax
	cmpl	%eax, %r14d
	cmovl	%eax, %r14d
	cmpl	%eax, %r15d
	cmovg	%eax, %r15d
	movl	28(%rsp), %eax
	addl	$1, %r12d
	addq	$4, %rbx
	cmpl	%r12d, %eax
	jg	.L4
	leal	-2(%rax), %r10d
	testl	%eax, %eax
	jle	.L12
	subl	$1, %eax
	leaq	4(%r13), %rcx
	xorl	%r9d, %r9d
	xorl	%edx, %edx
	leaq	(%rcx,%rax,4), %rdi
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L8:
	movl	0(%r13), %esi
	testl	%edx, %edx
	jne	.L15
	cmpl	%esi, %r14d
	je	.L13
.L15:
	testl	%r9d, %r9d
	jne	.L16
	cmpl	%esi, %r15d
	je	.L14
.L16:
	addl	%esi, %eax
.L5:
	movq	%rcx, %r13
	cmpq	%rcx, %rdi
	je	.L25
.L28:
	addq	$4, %rcx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L14:
	movl	$1, %r9d
	movq	%rcx, %r13
	cmpq	%rcx, %rdi
	jne	.L28
	.p2align 4,,10
	.p2align 3
.L25:
	cltd
	idivl	%r10d
.L3:
	movl	%eax, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L13:
	movl	$1, %edx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L2:
	movq	440(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$456, %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
	.p2align 4,,10
	.p2align 3
.L12:
	.cfi_restore_state
	xorl	%eax, %eax
	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:
```

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"
.LC1:
	.string	"%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
	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	$456, %rsp
	.cfi_def_cfa_offset 512
	movq	%fs:40, %rax
	movq	%rax, 440(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L9:
	movq	8(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	je	.L2
	jle	.L12
	leaq	32(%rsp), %r13
	xorl	%r12d, %r12d
	movl	$1000, %r15d
	xorl	%r14d, %r14d
	movq	%r13, %rbx
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbx, %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	(%rbx), %eax
	cmpl	%eax, %r14d
	cmovl	%eax, %r14d
	cmpl	%eax, %r15d
	cmovg	%eax, %r15d
	movl	28(%rsp), %eax
	addl	$1, %r12d
	addq	$4, %rbx
	cmpl	%r12d, %eax
	jg	.L4
	leal	-2(%rax), %r10d
	testl	%eax, %eax
	jle	.L12
	subl	$1, %eax
	leaq	4(%r13), %rcx
	xorl	%r9d, %r9d
	xorl	%edx, %edx
	leaq	(%rcx,%rax,4), %rdi
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L8:
	movl	0(%r13), %esi
	testl	%edx, %edx
	jne	.L15
	cmpl	%esi, %r14d
	je	.L13
.L15:
	testl	%r9d, %r9d
	jne	.L16
	cmpl	%esi, %r15d
	je	.L14
.L16:
	addl	%esi, %eax
.L5:
	movq	%rcx, %r13
	cmpq	%rcx, %rdi
	je	.L25
.L28:
	addq	$4, %rcx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L14:
	movl	$1, %r9d
	movq	%rcx, %r13
	cmpq	%rcx, %rdi
	jne	.L28
	.p2align 4,,10
	.p2align 3
.L25:
	cltd
	idivl	%r10d
.L3:
	movl	%eax, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L13:
	movl	$1, %edx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L2:
	movq	440(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$456, %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
	.p2align 4,,10
	.p2align 3
.L12:
	.cfi_restore_state
	xorl	%eax, %eax
	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:
```