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

int main(void) {
	int n;
	int h[101] = { 0 };
	int min;
	int ans = 0, left = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &h[i]);

	while (left != INT_MAX) {
		left = INT_MAX, min = INT_MAX;
		for (int i = 0; i <= n; i++) {
			if (h[i] != 0) {
				if (min == INT_MAX) left = i;
				if (min > h[i])min = h[i];
			}
			else if (i >= left) {
				for (int j = left; j < i; j++) h[j] -= min;
				ans += min;
				break;
			}
		}
		//printf("ans=%d\n", ans);
		//for (int k = 0; k < n; k++) printf("h[%d]=%d  ", k, h[k]);
	}
	printf("%d", ans);
	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:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$50, %ecx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$440, %rsp
	.cfi_def_cfa_offset 480
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rbx
	leaq	12(%rsp), %rsi
	movq	%rbx, %rdi
	rep stosq
	movl	$0, (%rdi)
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	testl	%edi, %edi
	jle	.L2
	movq	%rbx, %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	addq	$4, %r13
	cmpl	%r12d, %edi
	jg	.L3
.L2:
	xorl	%r11d, %r11d
	.p2align 4,,10
	.p2align 3
.L4:
	testl	%edi, %edi
	js	.L13
.L16:
	xorl	%eax, %eax
	movl	$2147483647, %esi
	movl	$2147483647, %ecx
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L28:
	cmpl	$2147483647, %ecx
	cmove	%eax, %esi
	cmpl	%edx, %ecx
	cmovg	%edx, %ecx
.L7:
	addq	$1, %rax
	cmpl	%eax, %edi
	jl	.L27
.L12:
	movl	(%rbx,%rax,4), %edx
	movl	%eax, %r8d
	testl	%edx, %edx
	jne	.L28
	cmpl	%eax, %esi
	jg	.L7
	cmpl	%esi, %eax
	jle	.L8
	movl	%eax, %r10d
	subl	%esi, %r10d
	leal	-1(%r10), %eax
	cmpl	$2, %eax
	jbe	.L9
	movslq	%esi, %rax
	movd	%ecx, %xmm2
	leaq	(%rbx,%rax,4), %rdx
	movl	%r10d, %eax
	pshufd	$0, %xmm2, %xmm1
	shrl	$2, %eax
	leal	-1(%rax), %r9d
	leaq	16(%rdx), %rax
	salq	$4, %r9
	addq	%rax, %r9
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L29:
	addq	$16, %rax
.L10:
	movdqu	(%rdx), %xmm0
	psubd	%xmm1, %xmm0
	movups	%xmm0, (%rdx)
	movq	%rax, %rdx
	cmpq	%r9, %rax
	jne	.L29
	movl	%r10d, %eax
	andl	$-4, %eax
	addl	%eax, %esi
	cmpl	%eax, %r10d
	je	.L8
.L9:
	movslq	%esi, %rax
	subl	%ecx, 16(%rsp,%rax,4)
	leal	1(%rsi), %eax
	cmpl	%r8d, %eax
	jge	.L8
	cltq
	addl	$2, %esi
	subl	%ecx, 16(%rsp,%rax,4)
	cmpl	%esi, %r8d
	jle	.L8
	movslq	%esi, %rsi
	subl	%ecx, 16(%rsp,%rsi,4)
.L8:
	addl	%ecx, %r11d
	testl	%edi, %edi
	jns	.L16
.L13:
	xorl	%eax, %eax
	movl	%r11d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$440, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	cmpl	$2147483647, %esi
	jne	.L4
	jmp	.L13
.L30:
	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:
```

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:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$50, %ecx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$440, %rsp
	.cfi_def_cfa_offset 480
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rbx
	leaq	12(%rsp), %rsi
	movq	%rbx, %rdi
	rep stosq
	movl	$0, (%rdi)
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	testl	%edi, %edi
	jle	.L2
	movq	%rbx, %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	addq	$4, %r13
	cmpl	%r12d, %edi
	jg	.L3
.L2:
	xorl	%r11d, %r11d
	.p2align 4,,10
	.p2align 3
.L4:
	testl	%edi, %edi
	js	.L13
.L16:
	xorl	%eax, %eax
	movl	$2147483647, %esi
	movl	$2147483647, %ecx
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L28:
	cmpl	$2147483647, %ecx
	cmove	%eax, %esi
	cmpl	%edx, %ecx
	cmovg	%edx, %ecx
.L7:
	addq	$1, %rax
	cmpl	%eax, %edi
	jl	.L27
.L12:
	movl	(%rbx,%rax,4), %edx
	movl	%eax, %r8d
	testl	%edx, %edx
	jne	.L28
	cmpl	%eax, %esi
	jg	.L7
	cmpl	%esi, %eax
	jle	.L8
	movl	%eax, %r10d
	subl	%esi, %r10d
	leal	-1(%r10), %eax
	cmpl	$2, %eax
	jbe	.L9
	movslq	%esi, %rax
	movd	%ecx, %xmm2
	leaq	(%rbx,%rax,4), %rdx
	movl	%r10d, %eax
	pshufd	$0, %xmm2, %xmm1
	shrl	$2, %eax
	leal	-1(%rax), %r9d
	leaq	16(%rdx), %rax
	salq	$4, %r9
	addq	%rax, %r9
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L29:
	addq	$16, %rax
.L10:
	movdqu	(%rdx), %xmm0
	psubd	%xmm1, %xmm0
	movups	%xmm0, (%rdx)
	movq	%rax, %rdx
	cmpq	%r9, %rax
	jne	.L29
	movl	%r10d, %eax
	andl	$-4, %eax
	addl	%eax, %esi
	cmpl	%eax, %r10d
	je	.L8
.L9:
	movslq	%esi, %rax
	subl	%ecx, 16(%rsp,%rax,4)
	leal	1(%rsi), %eax
	cmpl	%r8d, %eax
	jge	.L8
	cltq
	addl	$2, %esi
	subl	%ecx, 16(%rsp,%rax,4)
	cmpl	%esi, %r8d
	jle	.L8
	movslq	%esi, %rsi
	subl	%ecx, 16(%rsp,%rsi,4)
.L8:
	addl	%ecx, %r11d
	testl	%edi, %edi
	jns	.L16
.L13:
	xorl	%eax, %eax
	movl	%r11d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$440, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	cmpl	$2147483647, %esi
	jne	.L4
	jmp	.L13
.L30:
	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
```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:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$50, %ecx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$440, %rsp
	.cfi_def_cfa_offset 480
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rbx
	leaq	12(%rsp), %rsi
	movq	%rbx, %rdi
	rep stosq
	movl	$0, (%rdi)
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	testl	%edi, %edi
	jle	.L2
	movq	%rbx, %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	addq	$4, %r13
	cmpl	%r12d, %edi
	jg	.L3
.L2:
	xorl	%r11d, %r11d
	.p2align 4,,10
	.p2align 3
.L4:
	testl	%edi, %edi
	js	.L13
.L16:
	xorl	%eax, %eax
	movl	$2147483647, %esi
	movl	$2147483647, %ecx
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L28:
	cmpl	$2147483647, %ecx
	cmove	%eax, %esi
	cmpl	%edx, %ecx
	cmovg	%edx, %ecx
.L7:
	addq	$1, %rax
	cmpl	%eax, %edi
	jl	.L27
.L12:
	movl	(%rbx,%rax,4), %edx
	movl	%eax, %r8d
	testl	%edx, %edx
	jne	.L28
	cmpl	%eax, %esi
	jg	.L7
	cmpl	%esi, %eax
	jle	.L8
	movl	%eax, %r10d
	subl	%esi, %r10d
	leal	-1(%r10), %eax
	cmpl	$2, %eax
	jbe	.L9
	movslq	%esi, %rax
	movd	%ecx, %xmm2
	leaq	(%rbx,%rax,4), %rdx
	movl	%r10d, %eax
	pshufd	$0, %xmm2, %xmm1
	shrl	$2, %eax
	leal	-1(%rax), %r9d
	leaq	16(%rdx), %rax
	salq	$4, %r9
	addq	%rax, %r9
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L29:
	addq	$16, %rax
.L10:
	movdqu	(%rdx), %xmm0
	psubd	%xmm1, %xmm0
	movups	%xmm0, (%rdx)
	movq	%rax, %rdx
	cmpq	%r9, %rax
	jne	.L29
	movl	%r10d, %eax
	andl	$-4, %eax
	addl	%eax, %esi
	cmpl	%eax, %r10d
	je	.L8
.L9:
	movslq	%esi, %rax
	subl	%ecx, 16(%rsp,%rax,4)
	leal	1(%rsi), %eax
	cmpl	%r8d, %eax
	jge	.L8
	cltq
	addl	$2, %esi
	subl	%ecx, 16(%rsp,%rax,4)
	cmpl	%esi, %r8d
	jle	.L8
	movslq	%esi, %rsi
	subl	%ecx, 16(%rsp,%rsi,4)
.L8:
	addl	%ecx, %r11d
	testl	%edi, %edi
	jns	.L16
.L13:
	xorl	%eax, %eax
	movl	%r11d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$440, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	cmpl	$2147483647, %esi
	jne	.L4
	jmp	.L13
.L30:
	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:
```
```c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int n;
	int h[101] = { 0 };
	int min;
	int ans = 0, left = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &h[i]);

	while (left != INT_MAX) {
		left = INT_MAX, min = INT_MAX;
		for (int i = 0; i <= n; i++) {
			if (h[i] != 0) {
				if (min == INT_MAX) left = i;
				if (min > h[i])min = h[i];
			}
			else if (i >= left) {
				for (int j = left; j < i; j++) h[j] -= min;
				ans += min;
				break;
			}
		}
		//printf("ans=%d\n", ans);
		//for (int k = 0; k < n; k++) printf("h[%d]=%d  ", k, h[k]);
	}
	printf("%d", ans);
	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>
#include <math.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int n;
	int h[101] = { 0 };
	int min;
	int ans = 0, left = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &h[i]);

	while (left != INT_MAX) {
		left = INT_MAX, min = INT_MAX;
		for (int i = 0; i <= n; i++) {
			if (h[i] != 0) {
				if (min == INT_MAX) left = i;
				if (min > h[i])min = h[i];
			}
			else if (i >= left) {
				for (int j = left; j < i; j++) h[j] -= min;
				ans += min;
				break;
			}
		}
		//printf("ans=%d\n", ans);
		//for (int k = 0; k < n; k++) printf("h[%d]=%d  ", k, h[k]);
	}
	printf("%d", ans);
	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:

4
1 4 2 1
 8
4 23 75 1 23 96 50 100
 5
1 1 2 3 1
 4
1 8 2 1
 8
4 23 75 0 23 97 50 100
 4
1 12 2 1
 8
4 23 136 0 23 97 50 100
 4
1 12 0 2
 8
4 39 136 0 23 97 50 101
 8
4 39 136 0 23 108 50 101

4 220 3 8 222 12 283 14 284 295
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>
#include <math.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int n;
	int h[101] = { 0 };
	int min;
	int ans = 0, left = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &h[i]);

	while (left != INT_MAX) {
		left = INT_MAX, min = INT_MAX;
		for (int i = 0; i <= n; i++) {
			if (h[i] != 0) {
				if (min == INT_MAX) left = i;
				if (min > h[i])min = h[i];
			}
			else if (i >= left) {
				for (int j = left; j < i; j++) h[j] -= min;
				ans += min;
				break;
			}
		}
		//printf("ans=%d\n", ans);
		//for (int k = 0; k < n; k++) printf("h[%d]=%d  ", k, h[k]);
	}
	printf("%d", ans);
	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:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$50, %ecx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$440, %rsp
	.cfi_def_cfa_offset 480
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rbx
	leaq	12(%rsp), %rsi
	movq	%rbx, %rdi
	rep stosq
	movl	$0, (%rdi)
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	testl	%edi, %edi
	jle	.L2
	movq	%rbx, %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	addq	$4, %r13
	cmpl	%r12d, %edi
	jg	.L3
.L2:
	xorl	%r11d, %r11d
	.p2align 4,,10
	.p2align 3
.L4:
	testl	%edi, %edi
	js	.L13
.L16:
	xorl	%eax, %eax
	movl	$2147483647, %esi
	movl	$2147483647, %ecx
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L28:
	cmpl	$2147483647, %ecx
	cmove	%eax, %esi
	cmpl	%edx, %ecx
	cmovg	%edx, %ecx
.L7:
	addq	$1, %rax
	cmpl	%eax, %edi
	jl	.L27
.L12:
	movl	(%rbx,%rax,4), %edx
	movl	%eax, %r8d
	testl	%edx, %edx
	jne	.L28
	cmpl	%eax, %esi
	jg	.L7
	cmpl	%esi, %eax
	jle	.L8
	movl	%eax, %r10d
	subl	%esi, %r10d
	leal	-1(%r10), %eax
	cmpl	$2, %eax
	jbe	.L9
	movslq	%esi, %rax
	movd	%ecx, %xmm2
	leaq	(%rbx,%rax,4), %rdx
	movl	%r10d, %eax
	pshufd	$0, %xmm2, %xmm1
	shrl	$2, %eax
	leal	-1(%rax), %r9d
	leaq	16(%rdx), %rax
	salq	$4, %r9
	addq	%rax, %r9
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L29:
	addq	$16, %rax
.L10:
	movdqu	(%rdx), %xmm0
	psubd	%xmm1, %xmm0
	movups	%xmm0, (%rdx)
	movq	%rax, %rdx
	cmpq	%r9, %rax
	jne	.L29
	movl	%r10d, %eax
	andl	$-4, %eax
	addl	%eax, %esi
	cmpl	%eax, %r10d
	je	.L8
.L9:
	movslq	%esi, %rax
	subl	%ecx, 16(%rsp,%rax,4)
	leal	1(%rsi), %eax
	cmpl	%r8d, %eax
	jge	.L8
	cltq
	addl	$2, %esi
	subl	%ecx, 16(%rsp,%rax,4)
	cmpl	%esi, %r8d
	jle	.L8
	movslq	%esi, %rsi
	subl	%ecx, 16(%rsp,%rsi,4)
.L8:
	addl	%ecx, %r11d
	testl	%edi, %edi
	jns	.L16
.L13:
	xorl	%eax, %eax
	movl	%r11d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$440, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	cmpl	$2147483647, %esi
	jne	.L4
	jmp	.L13
.L30:
	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:
```

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:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$50, %ecx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$440, %rsp
	.cfi_def_cfa_offset 480
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rbx
	leaq	12(%rsp), %rsi
	movq	%rbx, %rdi
	rep stosq
	movl	$0, (%rdi)
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	testl	%edi, %edi
	jle	.L2
	movq	%rbx, %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	addq	$4, %r13
	cmpl	%r12d, %edi
	jg	.L3
.L2:
	xorl	%r11d, %r11d
	.p2align 4,,10
	.p2align 3
.L4:
	testl	%edi, %edi
	js	.L13
.L16:
	xorl	%eax, %eax
	movl	$2147483647, %esi
	movl	$2147483647, %ecx
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L28:
	cmpl	$2147483647, %ecx
	cmove	%eax, %esi
	cmpl	%edx, %ecx
	cmovg	%edx, %ecx
.L7:
	addq	$1, %rax
	cmpl	%eax, %edi
	jl	.L27
.L12:
	movl	(%rbx,%rax,4), %edx
	movl	%eax, %r8d
	testl	%edx, %edx
	jne	.L28
	cmpl	%eax, %esi
	jg	.L7
	cmpl	%esi, %eax
	jle	.L8
	movl	%eax, %r10d
	subl	%esi, %r10d
	leal	-1(%r10), %eax
	cmpl	$2, %eax
	jbe	.L9
	movslq	%esi, %rax
	movd	%ecx, %xmm2
	leaq	(%rbx,%rax,4), %rdx
	movl	%r10d, %eax
	pshufd	$0, %xmm2, %xmm1
	shrl	$2, %eax
	leal	-1(%rax), %r9d
	leaq	16(%rdx), %rax
	salq	$4, %r9
	addq	%rax, %r9
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L29:
	addq	$16, %rax
.L10:
	movdqu	(%rdx), %xmm0
	psubd	%xmm1, %xmm0
	movups	%xmm0, (%rdx)
	movq	%rax, %rdx
	cmpq	%r9, %rax
	jne	.L29
	movl	%r10d, %eax
	andl	$-4, %eax
	addl	%eax, %esi
	cmpl	%eax, %r10d
	je	.L8
.L9:
	movslq	%esi, %rax
	subl	%ecx, 16(%rsp,%rax,4)
	leal	1(%rsi), %eax
	cmpl	%r8d, %eax
	jge	.L8
	cltq
	addl	$2, %esi
	subl	%ecx, 16(%rsp,%rax,4)
	cmpl	%esi, %r8d
	jle	.L8
	movslq	%esi, %rsi
	subl	%ecx, 16(%rsp,%rsi,4)
.L8:
	addl	%ecx, %r11d
	testl	%edi, %edi
	jns	.L16
.L13:
	xorl	%eax, %eax
	movl	%r11d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$440, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	cmpl	$2147483647, %esi
	jne	.L4
	jmp	.L13
.L30:
	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:
```