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 <limits.h>

int main(void)
{
	int array[5000], n, i, j, sum, max;
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		max = INT_MIN;
		
		for (i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		for (i = 0; i < n; i++){
			sum = 0;
			for (j = i; j < n; j++){
				sum += array[j];
				
				if (max < sum){
					max = sum;
				}
			}
		}
		
		printf("%d\n", max);
	}
	
	return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%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
	leaq	-16384(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3664, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L11:
	leaq	-20036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20036(%rbp), %eax
	testl	%eax, %eax
	je	.L15
	movl	$-2147483648, -20020(%rbp)
	movl	$0, -20032(%rbp)
	jmp	.L4
.L5:
	leaq	-20016(%rbp), %rdx
	movl	-20032(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20032(%rbp)
.L4:
	movl	-20036(%rbp), %eax
	cmpl	%eax, -20032(%rbp)
	jl	.L5
	movl	$0, -20032(%rbp)
	jmp	.L6
.L10:
	movl	$0, -20024(%rbp)
	movl	-20032(%rbp), %eax
	movl	%eax, -20028(%rbp)
	jmp	.L7
.L9:
	movl	-20028(%rbp), %eax
	cltq
	movl	-20016(%rbp,%rax,4), %eax
	addl	%eax, -20024(%rbp)
	movl	-20020(%rbp), %eax
	cmpl	-20024(%rbp), %eax
	jge	.L8
	movl	-20024(%rbp), %eax
	movl	%eax, -20020(%rbp)
.L8:
	addl	$1, -20028(%rbp)
.L7:
	movl	-20036(%rbp), %eax
	cmpl	%eax, -20028(%rbp)
	jl	.L9
	addl	$1, -20032(%rbp)
.L6:
	movl	-20036(%rbp), %eax
	cmpl	%eax, -20032(%rbp)
	jl	.L10
	movl	-20020(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L15:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	leave
	.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"
.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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-16384(%rsp), %r11
	.cfi_def_cfa 11, 16440
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3656, %rsp
	.cfi_def_cfa_offset 20096
	leaq	.LC0(%rip), %rbx
	leaq	.LC1(%rip), %r12
	movq	%fs:40, %rax
	movq	%rax, 20024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rbp
	leaq	16(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	je	.L2
	jle	.L3
	movq	%r13, %r15
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %ecx
	addq	$4, %r15
	cmpl	%r14d, %ecx
	jg	.L4
	testl	%ecx, %ecx
	jle	.L3
	movslq	%ecx, %rdi
	xorl	%esi, %esi
	movl	$-2147483648, %r8d
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%rsi, %rdx
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L5:
	addl	0(%r13,%rdx,4), %eax
	cmpl	%eax, %r8d
	cmovl	%eax, %r8d
	addq	$1, %rdx
	cmpl	%edx, %ecx
	jg	.L5
	addq	$1, %rsi
	cmpq	%rsi, %rdi
	jne	.L6
.L7:
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L8
.L2:
	movq	20024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$20040, %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
.L3:
	.cfi_restore_state
	movl	$-2147483648, %r8d
	jmp	.L7
.L15:
	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
	.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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-16384(%rsp), %r11
	.cfi_def_cfa 11, 16440
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3656, %rsp
	.cfi_def_cfa_offset 20096
	leaq	.LC0(%rip), %rbx
	leaq	.LC1(%rip), %r12
	movq	%fs:40, %rax
	movq	%rax, 20024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rbp
	leaq	16(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	je	.L2
	jle	.L3
	movq	%r13, %r15
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %ecx
	addq	$4, %r15
	cmpl	%r14d, %ecx
	jg	.L4
	testl	%ecx, %ecx
	jle	.L3
	movslq	%ecx, %rdi
	xorl	%esi, %esi
	movl	$-2147483648, %r8d
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%rsi, %rdx
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L5:
	addl	0(%r13,%rdx,4), %eax
	cmpl	%eax, %r8d
	cmovl	%eax, %r8d
	addq	$1, %rdx
	cmpl	%edx, %ecx
	jg	.L5
	addq	$1, %rsi
	cmpq	%rsi, %rdi
	jne	.L6
.L7:
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L8
.L2:
	movq	20024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$20040, %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
.L3:
	.cfi_restore_state
	movl	$-2147483648, %r8d
	jmp	.L7
.L15:
	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:

#include <stdio.h>
#include <limits.h>

int main(void)
{
	int array[5000], n, i, j, sum, max;
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		max = INT_MIN;
		
		for (i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		for (i = 0; i < n; i++){
			sum = 0;
			for (j = i; j < n; j++){
				sum += array[j];
				
				if (max < sum){
					max = sum;
				}
			}
		}
		
		printf("%d\n", max);
	}
	
	return (0);
}
7
-5
-2
6
4
9
-6
-7
13
1
2
3
2
-2
-1
1
2
3
2
1
-2
1
3
1000
-200
201
0
 7
-5
-2
6
4
9
-6
-7
13
1
2
3
2
-2
-1
1
1
3
2
1
-2
1
3
1000
-200
201
0
 7
-5
-2
6
8
9
-6
-7
13
1
2
3
2
-2
-1
1
1
3
2
1
-2
1
3
1000
-200
201
0
 7
-5
-2
6
8
9
-6
-7
13
1
2
3
2
-2
-1
1
1
3
2
1
-2
1
3
1000
-200
145
0
 7
-5
-1
6
4
9
-6
-7
13
1
2
1
2
-2
-1
1
2
3
2
1
-2
1
3
1000
-200
201
0
 7
-5
-2
6
4
9
-6
-7
13
1
2
3
2
-2
-1
1
2
3
2
1
-2
1
3
1000
-358
201
0
 7
-5
-2
6
3
9
-6
-7
13
1
2
3
2
-2
-1
1
1
3
2
1
-2
1
3
1000
-200
201
0
 7
-5
-2
6
4
9
-6
-7
13
1
2
3
2
-2
-1
1
0
3
2
1
-2
1
3
1000
-358
201
0
 7
-5
-2
6
8
9
-6
-7
13
1
2
3
2
-2
-1
1
1
3
2
0
-2
2
3
1000
-200
145
0
 7
-5
-1
6
4
9
-6
-7
13
1
2
1
2
-2
-1
1
2
6
2
1
-3
1
3
1000
-200
201
0

19
14
1001
 19
13
1001
 23
13
1001
 23
13
1000
 19
12
1001
 19
14
1000
 18
13
1001
 19
12
1000
 23
12
1000
 19
15
1001

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 <limits.h>

int main(void)
{
	int array[5000], n, i, j, sum, max;
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		max = INT_MIN;
		
		for (i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		for (i = 0; i < n; i++){
			sum = 0;
			for (j = i; j < n; j++){
				sum += array[j];
				
				if (max < sum){
					max = sum;
				}
			}
		}
		
		printf("%d\n", max);
	}
	
	return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%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
	leaq	-16384(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3664, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L11:
	leaq	-20036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20036(%rbp), %eax
	testl	%eax, %eax
	je	.L15
	movl	$-2147483648, -20020(%rbp)
	movl	$0, -20032(%rbp)
	jmp	.L4
.L5:
	leaq	-20016(%rbp), %rdx
	movl	-20032(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20032(%rbp)
.L4:
	movl	-20036(%rbp), %eax
	cmpl	%eax, -20032(%rbp)
	jl	.L5
	movl	$0, -20032(%rbp)
	jmp	.L6
.L10:
	movl	$0, -20024(%rbp)
	movl	-20032(%rbp), %eax
	movl	%eax, -20028(%rbp)
	jmp	.L7
.L9:
	movl	-20028(%rbp), %eax
	cltq
	movl	-20016(%rbp,%rax,4), %eax
	addl	%eax, -20024(%rbp)
	movl	-20020(%rbp), %eax
	cmpl	-20024(%rbp), %eax
	jge	.L8
	movl	-20024(%rbp), %eax
	movl	%eax, -20020(%rbp)
.L8:
	addl	$1, -20028(%rbp)
.L7:
	movl	-20036(%rbp), %eax
	cmpl	%eax, -20028(%rbp)
	jl	.L9
	addl	$1, -20032(%rbp)
.L6:
	movl	-20036(%rbp), %eax
	cmpl	%eax, -20032(%rbp)
	jl	.L10
	movl	-20020(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L15:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	leave
	.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
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%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
	leaq	-16384(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3664, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L11:
	leaq	-20036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20036(%rbp), %eax
	testl	%eax, %eax
	je	.L15
	movl	$-2147483648, -20020(%rbp)
	movl	$0, -20032(%rbp)
	jmp	.L4
.L5:
	leaq	-20016(%rbp), %rdx
	movl	-20032(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -20032(%rbp)
.L4:
	movl	-20036(%rbp), %eax
	cmpl	%eax, -20032(%rbp)
	jl	.L5
	movl	$0, -20032(%rbp)
	jmp	.L6
.L10:
	movl	$0, -20024(%rbp)
	movl	-20032(%rbp), %eax
	movl	%eax, -20028(%rbp)
	jmp	.L7
.L9:
	movl	-20028(%rbp), %eax
	cltq
	movl	-20016(%rbp,%rax,4), %eax
	addl	%eax, -20024(%rbp)
	movl	-20020(%rbp), %eax
	cmpl	-20024(%rbp), %eax
	jge	.L8
	movl	-20024(%rbp), %eax
	movl	%eax, -20020(%rbp)
.L8:
	addl	$1, -20028(%rbp)
.L7:
	movl	-20036(%rbp), %eax
	cmpl	%eax, -20028(%rbp)
	jl	.L9
	addl	$1, -20032(%rbp)
.L6:
	movl	-20036(%rbp), %eax
	cmpl	%eax, -20032(%rbp)
	jl	.L10
	movl	-20020(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L15:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	leave
	.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:
