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>

int main(){
    int i = 0;
    int n;
    int *A = malloc(sizeof(int) *100);
    scanf("%d", &n);
    for (i = 0; i < n;i++){
        scanf("%d", &A[i]);
    }

    long long int kane = 1000;
    long long int kabu = 0;

    int selled = 1;

    long long int num;

    for (i = 0; i < n-1;i++){
        num = 0;
        if(selled==1){
            if(A[i]<A[i+1]){
                num = kane / A[i];
                kabu = num;
                kane -= A[i] * num;
                selled = 0;
            }
        }else{
            if(A[i]>A[i+1]){
                kane += kabu * A[i];
                kabu = 0;
                selled = 1;
            }
        }
    }
    kane += kabu * A[n - 1];
    int kanekane = 1000;
    if(kane>kanekane){
        printf("%lld", kane);
    }else{
        printf("%d", kanekane);
    }
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld"
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -52(%rbp)
	movl	$400, %edi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -52(%rbp)
	jmp	.L2
.L3:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -52(%rbp)
.L2:
	movl	-56(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jl	.L3
	movq	$1000, -40(%rbp)
	movq	$0, -32(%rbp)
	movl	$1, -48(%rbp)
	movl	$0, -52(%rbp)
	jmp	.L4
.L7:
	movq	$0, -16(%rbp)
	cmpl	$1, -48(%rbp)
	jne	.L5
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L6
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movq	-40(%rbp), %rax
	cqto
	idivq	%rcx
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, -32(%rbp)
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	imulq	-16(%rbp), %rax
	subq	%rax, -40(%rbp)
	movl	$0, -48(%rbp)
	jmp	.L6
.L5:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L6
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	imulq	-32(%rbp), %rax
	addq	%rax, -40(%rbp)
	movq	$0, -32(%rbp)
	movl	$1, -48(%rbp)
.L6:
	addl	$1, -52(%rbp)
.L4:
	movl	-56(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -52(%rbp)
	jl	.L7
	movl	-56(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	imulq	-32(%rbp), %rax
	addq	%rax, -40(%rbp)
	movl	$1000, -44(%rbp)
	movl	-44(%rbp), %eax
	cltq
	cmpq	%rax, -40(%rbp)
	jle	.L8
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L8:
	movl	-44(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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	"%d"
.LC1:
	.string	"%lld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$400, %edi
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	leaq	4(%rsp), %rsi
	movq	%r13, %rdi
	movq	%rax, %rbx
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	movq	%rbx, %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %rdi
	addq	$4, %r12
	cmpl	%ebp, %edi
	jg	.L3
	cmpl	$1, %edi
	jle	.L2
	leal	-2(%rdi), %eax
	movq	%rbx, %rcx
	movl	$1, %r8d
	movl	$1000, %r9d
	leaq	4(%rbx,%rax,4), %r10
	xorl	%eax, %eax
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L4:
	cmpl	%esi, 4(%rcx)
	jge	.L5
	imulq	%rax, %rsi
	movl	$1, %r8d
	xorl	%eax, %eax
	addq	%rsi, %r9
.L5:
	addq	$4, %rcx
	cmpq	%r10, %rcx
	je	.L13
.L6:
	movslq	(%rcx), %rsi
	cmpl	$1, %r8d
	jne	.L4
	cmpl	%esi, 4(%rcx)
	jle	.L5
	movq	%r9, %rax
	addq	$4, %rcx
	xorl	%r8d, %r8d
	cqto
	idivq	%rsi
	movq	%rdx, %r9
	cmpq	%r10, %rcx
	jne	.L6
	.p2align 4,,10
	.p2align 3
.L13:
	movslq	-4(%rbx,%rdi,4), %rdx
	imulq	%rax, %rdx
	addq	%r9, %rdx
	cmpq	$1000, %rdx
	jle	.L2
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L7:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L14
	addq	$24, %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
.L2:
	.cfi_restore_state
	movl	$1000, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L7
.L14:
	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
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$400, %edi
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	leaq	4(%rsp), %rsi
	movq	%r13, %rdi
	movq	%rax, %rbx
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	movq	%rbx, %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %rdi
	addq	$4, %r12
	cmpl	%ebp, %edi
	jg	.L3
	cmpl	$1, %edi
	jle	.L2
	leal	-2(%rdi), %eax
	movq	%rbx, %rcx
	movl	$1, %r8d
	movl	$1000, %r9d
	leaq	4(%rbx,%rax,4), %r10
	xorl	%eax, %eax
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L4:
	cmpl	%esi, 4(%rcx)
	jge	.L5
	imulq	%rax, %rsi
	movl	$1, %r8d
	xorl	%eax, %eax
	addq	%rsi, %r9
.L5:
	addq	$4, %rcx
	cmpq	%r10, %rcx
	je	.L13
.L6:
	movslq	(%rcx), %rsi
	cmpl	$1, %r8d
	jne	.L4
	cmpl	%esi, 4(%rcx)
	jle	.L5
	movq	%r9, %rax
	addq	$4, %rcx
	xorl	%r8d, %r8d
	cqto
	idivq	%rsi
	movq	%rdx, %r9
	cmpq	%r10, %rcx
	jne	.L6
	.p2align 4,,10
	.p2align 3
.L13:
	movslq	-4(%rbx,%rdi,4), %rdx
	imulq	%rax, %rdx
	addq	%r9, %rdx
	cmpq	$1000, %rdx
	jle	.L2
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L7:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L14
	addq	$24, %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
.L2:
	.cfi_restore_state
	movl	$1000, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L7
.L14:
	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:

#include <stdio.h>
#include <stdlib.h>

int main(){
    int i = 0;
    int n;
    int *A = malloc(sizeof(int) *100);
    scanf("%d", &n);
    for (i = 0; i < n;i++){
        scanf("%d", &A[i]);
    }

    long long int kane = 1000;
    long long int kabu = 0;

    int selled = 1;

    long long int num;

    for (i = 0; i < n-1;i++){
        num = 0;
        if(selled==1){
            if(A[i]<A[i+1]){
                num = kane / A[i];
                kabu = num;
                kane -= A[i] * num;
                selled = 0;
            }
        }else{
            if(A[i]>A[i+1]){
                kane += kabu * A[i];
                kabu = 0;
                selled = 1;
            }
        }
    }
    kane += kabu * A[n - 1];
    int kanekane = 1000;
    if(kane>kanekane){
        printf("%lld", kane);
    }else{
        printf("%d", kanekane);
    }
    return 0;
}
2
157 145
 7
100 130 243 130 115 115 150
 6
200 237 160 140 120 100
 2
157 218
 7
100 130 243 130 115 115 271
 6
200 237 160 233 120 100
 2
103 218
 7
110 130 243 130 115 115 271
 7
110 130 136 130 115 115 271
 6
200 237 119 233 121 100

1000 3165 1185 1366 5706 1696 2035 5161 2794 2211
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>

int main(){
    int i = 0;
    int n;
    int *A = malloc(sizeof(int) *100);
    scanf("%d", &n);
    for (i = 0; i < n;i++){
        scanf("%d", &A[i]);
    }

    long long int kane = 1000;
    long long int kabu = 0;

    int selled = 1;

    long long int num;

    for (i = 0; i < n-1;i++){
        num = 0;
        if(selled==1){
            if(A[i]<A[i+1]){
                num = kane / A[i];
                kabu = num;
                kane -= A[i] * num;
                selled = 0;
            }
        }else{
            if(A[i]>A[i+1]){
                kane += kabu * A[i];
                kabu = 0;
                selled = 1;
            }
        }
    }
    kane += kabu * A[n - 1];
    int kanekane = 1000;
    if(kane>kanekane){
        printf("%lld", kane);
    }else{
        printf("%d", kanekane);
    }
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld"
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -52(%rbp)
	movl	$400, %edi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -52(%rbp)
	jmp	.L2
.L3:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -52(%rbp)
.L2:
	movl	-56(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jl	.L3
	movq	$1000, -40(%rbp)
	movq	$0, -32(%rbp)
	movl	$1, -48(%rbp)
	movl	$0, -52(%rbp)
	jmp	.L4
.L7:
	movq	$0, -16(%rbp)
	cmpl	$1, -48(%rbp)
	jne	.L5
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L6
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movq	-40(%rbp), %rax
	cqto
	idivq	%rcx
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, -32(%rbp)
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	imulq	-16(%rbp), %rax
	subq	%rax, -40(%rbp)
	movl	$0, -48(%rbp)
	jmp	.L6
.L5:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L6
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	imulq	-32(%rbp), %rax
	addq	%rax, -40(%rbp)
	movq	$0, -32(%rbp)
	movl	$1, -48(%rbp)
.L6:
	addl	$1, -52(%rbp)
.L4:
	movl	-56(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -52(%rbp)
	jl	.L7
	movl	-56(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	imulq	-32(%rbp), %rax
	addq	%rax, -40(%rbp)
	movl	$1000, -44(%rbp)
	movl	-44(%rbp), %eax
	cltq
	cmpq	%rax, -40(%rbp)
	jle	.L8
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L8:
	movl	-44(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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	"%d"
.LC1:
	.string	"%lld"
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -52(%rbp)
	movl	$400, %edi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -52(%rbp)
	jmp	.L2
.L3:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -52(%rbp)
.L2:
	movl	-56(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jl	.L3
	movq	$1000, -40(%rbp)
	movq	$0, -32(%rbp)
	movl	$1, -48(%rbp)
	movl	$0, -52(%rbp)
	jmp	.L4
.L7:
	movq	$0, -16(%rbp)
	cmpl	$1, -48(%rbp)
	jne	.L5
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L6
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movq	-40(%rbp), %rax
	cqto
	idivq	%rcx
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, -32(%rbp)
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	imulq	-16(%rbp), %rax
	subq	%rax, -40(%rbp)
	movl	$0, -48(%rbp)
	jmp	.L6
.L5:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-52(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L6
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	imulq	-32(%rbp), %rax
	addq	%rax, -40(%rbp)
	movq	$0, -32(%rbp)
	movl	$1, -48(%rbp)
.L6:
	addl	$1, -52(%rbp)
.L4:
	movl	-56(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -52(%rbp)
	jl	.L7
	movl	-56(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	imulq	-32(%rbp), %rax
	addq	%rax, -40(%rbp)
	movl	$1000, -44(%rbp)
	movl	-44(%rbp), %eax
	cltq
	cmpq	%rax, -40(%rbp)
	jle	.L8
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L8:
	movl	-44(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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:
