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>
int main(){
	int N;
	scanf("%d",&N);//トッピングの種類
	int a,b;
	scanf("%d %d",&a,&b);//a:生地の値段,b:トッピング１つの値段
	int c;//生地のカロリー
	scanf("%d",&c);
	int d[N];//トッピングのカロリー
	int i,j;
	for(i=0;i<N;i++){
		scanf("%d",&d[i]);
	}
	int goukei=c;
	int count=0;
	int max;
	for(i=0;i<N;i++){//生地よりもカロリーコストの高いものを追加
		max=0;
		for(j=0;j<N;j++){
			if(max<d[j]){
				max=d[j];
			}
		}
		for(j=0;j<N;j++){
			if(max==d[j]){
				if( (double)(goukei+d[j])/(a+(count+1)*b)>(double)goukei/(a+count*b) ){
					goukei+=d[j];
					count++;
					d[j]=-1;
				}
			}
		}
	}
	printf( "%d\n",goukei/( a+(b*count) ) );
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-108(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100(%rbp), %rdx
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-108(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L5
.L6:
	movl	-92(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -92(%rbp)
.L5:
	movl	-108(%rbp), %eax
	cmpl	%eax, -92(%rbp)
	jl	.L6
	movl	-96(%rbp), %eax
	movl	%eax, -84(%rbp)
	movl	$0, -80(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L7
.L15:
	movl	$0, -76(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L8
.L10:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, -76(%rbp)
	jge	.L9
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	movl	%eax, -76(%rbp)
.L9:
	addl	$1, -88(%rbp)
.L8:
	movl	-108(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L10
	movl	$0, -88(%rbp)
	jmp	.L11
.L14:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, -76(%rbp)
	jne	.L12
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	-84(%rbp), %eax
	addl	%edx, %eax
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm0
	movl	-80(%rbp), %eax
	leal	1(%rax), %edx
	movl	-100(%rbp), %eax
	imull	%eax, %edx
	movl	-104(%rbp), %eax
	addl	%edx, %eax
	pxor	%xmm1, %xmm1
	cvtsi2sdl	%eax, %xmm1
	divsd	%xmm1, %xmm0
	pxor	%xmm1, %xmm1
	cvtsi2sdl	-84(%rbp), %xmm1
	movl	-100(%rbp), %eax
	imull	-80(%rbp), %eax
	movl	%eax, %edx
	movl	-104(%rbp), %eax
	addl	%edx, %eax
	pxor	%xmm2, %xmm2
	cvtsi2sdl	%eax, %xmm2
	divsd	%xmm2, %xmm1
	comisd	%xmm1, %xmm0
	jbe	.L12
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, -84(%rbp)
	addl	$1, -80(%rbp)
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	$-1, (%rax,%rdx,4)
.L12:
	addl	$1, -88(%rbp)
.L11:
	movl	-108(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L14
	addl	$1, -92(%rbp)
.L7:
	movl	-108(%rbp), %eax
	cmpl	%eax, -92(%rbp)
	jl	.L15
	movl	-100(%rbp), %eax
	imull	-80(%rbp), %eax
	movl	%eax, %edx
	movl	-104(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-84(%rbp), %eax
	cltd
	idivl	%ecx
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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 %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	.cfi_offset 15, -24
	leaq	.LC0(%rip), %r15
	pushq	%r14
	leaq	-72(%rbp), %rsi
	movq	%r15, %rdi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	-64(%rbp), %rdx
	leaq	-68(%rbp), %rsi
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	leaq	-60(%rbp), %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-72(%rbp), %rax
	movq	%rsp, %rsi
	movq	%rax, %rcx
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rsi
	andq	$-16, %rdx
	cmpq	%rsi, %rsp
	je	.L3
.L29:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L29
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L30
.L4:
	movq	%rsp, %r12
	testl	%ecx, %ecx
	jle	.L5
	movq	%r12, %r13
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r13, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	-72(%rbp), %r14d
	addq	$4, %r13
	cmpl	%ebx, %r14d
	jg	.L6
	movl	-60(%rbp), %eax
	movl	-64(%rbp), %r11d
	movl	-68(%rbp), %r10d
	testl	%r14d, %r14d
	jle	.L16
	leal	-1(%r14), %edx
	movl	$0, -84(%rbp)
	xorl	%r9d, %r9d
	movl	%edx, -88(%rbp)
	movl	%r14d, %edx
	shrl	$2, %edx
	leal	-1(%rdx), %r13d
	movl	%r14d, %edx
	andl	$-4, %edx
	addq	$1, %r13
	movl	%edx, -92(%rbp)
	salq	$4, %r13
	movl	%r14d, %edx
	addq	%r12, %r13
	leaq	(%r12,%rdx,4), %rdx
	.p2align 4,,10
	.p2align 3
.L14:
	cmpl	$2, -88(%rbp)
	jbe	.L17
	movq	%r12, %rcx
	pxor	%xmm2, %xmm2
	.p2align 4,,10
	.p2align 3
.L9:
	movdqu	(%rcx), %xmm0
	addq	$16, %rcx
	movdqa	%xmm0, %xmm1
	pcmpgtd	%xmm2, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	por	%xmm0, %xmm2
	cmpq	%rcx, %r13
	jne	.L9
	movdqa	%xmm2, %xmm1
	movl	-92(%rbp), %ebx
	psrldq	$8, %xmm1
	movdqa	%xmm1, %xmm0
	movl	%ebx, %ecx
	pcmpgtd	%xmm2, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movd	%xmm1, %edi
	cmpl	%r14d, %ebx
	je	.L10
.L8:
	movslq	%ecx, %rsi
	leaq	(%r12,%rsi,4), %rsi
	movl	(%rsi), %r8d
	cmpl	%r8d, %edi
	cmovl	%r8d, %edi
	leal	1(%rcx), %r8d
	cmpl	%r8d, %r14d
	jle	.L10
	movl	4(%rsi), %r8d
	cmpl	%r8d, %edi
	cmovl	%r8d, %edi
	addl	$2, %ecx
	cmpl	%ecx, %r14d
	jle	.L10
	movl	8(%rsi), %ecx
	cmpl	%ecx, %edi
	cmovl	%ecx, %edi
.L10:
	movq	%r12, %rcx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L11:
	addq	$4, %rcx
	cmpq	%rdx, %rcx
	je	.L31
.L13:
	movl	%r9d, %esi
	imull	%r11d, %esi
	leal	(%rsi,%r10), %r8d
	cmpl	%edi, (%rcx)
	jne	.L11
	leal	(%rdi,%rax), %ebx
	pxor	%xmm1, %xmm1
	pxor	%xmm0, %xmm0
	addl	%r11d, %esi
	cvtsi2sdl	%ebx, %xmm1
	pxor	%xmm2, %xmm2
	leal	1(%r9), %r15d
	addl	%r10d, %esi
	cvtsi2sdl	%esi, %xmm0
	cvtsi2sdl	%r8d, %xmm2
	divsd	%xmm0, %xmm1
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm0
	divsd	%xmm2, %xmm0
	comisd	%xmm0, %xmm1
	jbe	.L11
	movl	$-1, (%rcx)
	addq	$4, %rcx
	movl	%esi, %r8d
	movl	%r15d, %r9d
	movl	%ebx, %eax
	cmpq	%rdx, %rcx
	jne	.L13
	.p2align 4,,10
	.p2align 3
.L31:
	addl	$1, -84(%rbp)
	movl	-84(%rbp), %ebx
	cmpl	%ebx, %r14d
	jne	.L14
.L7:
	cltd
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	idivl	%r8d
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L32
	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
.L17:
	.cfi_restore_state
	xorl	%edi, %edi
	xorl	%ecx, %ecx
	jmp	.L8
.L30:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L5:
	movl	-60(%rbp), %eax
	movl	-68(%rbp), %r8d
	jmp	.L7
.L32:
	call	__stack_chk_fail@PLT
.L16:
	movl	%r10d, %r8d
	jmp	.L7
	.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 %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	.cfi_offset 15, -24
	leaq	.LC0(%rip), %r15
	pushq	%r14
	leaq	-72(%rbp), %rsi
	movq	%r15, %rdi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	-64(%rbp), %rdx
	leaq	-68(%rbp), %rsi
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	leaq	-60(%rbp), %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-72(%rbp), %rax
	movq	%rsp, %rsi
	movq	%rax, %rcx
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rsi
	andq	$-16, %rdx
	cmpq	%rsi, %rsp
	je	.L3
.L29:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L29
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L30
.L4:
	movq	%rsp, %r12
	testl	%ecx, %ecx
	jle	.L5
	movq	%r12, %r13
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r13, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	-72(%rbp), %r14d
	addq	$4, %r13
	cmpl	%ebx, %r14d
	jg	.L6
	movl	-60(%rbp), %eax
	movl	-64(%rbp), %r11d
	movl	-68(%rbp), %r10d
	testl	%r14d, %r14d
	jle	.L16
	leal	-1(%r14), %edx
	movl	$0, -84(%rbp)
	xorl	%r9d, %r9d
	movl	%edx, -88(%rbp)
	movl	%r14d, %edx
	shrl	$2, %edx
	leal	-1(%rdx), %r13d
	movl	%r14d, %edx
	andl	$-4, %edx
	addq	$1, %r13
	movl	%edx, -92(%rbp)
	salq	$4, %r13
	movl	%r14d, %edx
	addq	%r12, %r13
	leaq	(%r12,%rdx,4), %rdx
	.p2align 4,,10
	.p2align 3
.L14:
	cmpl	$2, -88(%rbp)
	jbe	.L17
	movq	%r12, %rcx
	pxor	%xmm2, %xmm2
	.p2align 4,,10
	.p2align 3
.L9:
	movdqu	(%rcx), %xmm0
	addq	$16, %rcx
	movdqa	%xmm0, %xmm1
	pcmpgtd	%xmm2, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	por	%xmm0, %xmm2
	cmpq	%rcx, %r13
	jne	.L9
	movdqa	%xmm2, %xmm1
	movl	-92(%rbp), %ebx
	psrldq	$8, %xmm1
	movdqa	%xmm1, %xmm0
	movl	%ebx, %ecx
	pcmpgtd	%xmm2, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movd	%xmm1, %edi
	cmpl	%r14d, %ebx
	je	.L10
.L8:
	movslq	%ecx, %rsi
	leaq	(%r12,%rsi,4), %rsi
	movl	(%rsi), %r8d
	cmpl	%r8d, %edi
	cmovl	%r8d, %edi
	leal	1(%rcx), %r8d
	cmpl	%r8d, %r14d
	jle	.L10
	movl	4(%rsi), %r8d
	cmpl	%r8d, %edi
	cmovl	%r8d, %edi
	addl	$2, %ecx
	cmpl	%ecx, %r14d
	jle	.L10
	movl	8(%rsi), %ecx
	cmpl	%ecx, %edi
	cmovl	%ecx, %edi
.L10:
	movq	%r12, %rcx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L11:
	addq	$4, %rcx
	cmpq	%rdx, %rcx
	je	.L31
.L13:
	movl	%r9d, %esi
	imull	%r11d, %esi
	leal	(%rsi,%r10), %r8d
	cmpl	%edi, (%rcx)
	jne	.L11
	leal	(%rdi,%rax), %ebx
	pxor	%xmm1, %xmm1
	pxor	%xmm0, %xmm0
	addl	%r11d, %esi
	cvtsi2sdl	%ebx, %xmm1
	pxor	%xmm2, %xmm2
	leal	1(%r9), %r15d
	addl	%r10d, %esi
	cvtsi2sdl	%esi, %xmm0
	cvtsi2sdl	%r8d, %xmm2
	divsd	%xmm0, %xmm1
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm0
	divsd	%xmm2, %xmm0
	comisd	%xmm0, %xmm1
	jbe	.L11
	movl	$-1, (%rcx)
	addq	$4, %rcx
	movl	%esi, %r8d
	movl	%r15d, %r9d
	movl	%ebx, %eax
	cmpq	%rdx, %rcx
	jne	.L13
	.p2align 4,,10
	.p2align 3
.L31:
	addl	$1, -84(%rbp)
	movl	-84(%rbp), %ebx
	cmpl	%ebx, %r14d
	jne	.L14
.L7:
	cltd
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	idivl	%r8d
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L32
	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
.L17:
	.cfi_restore_state
	xorl	%edi, %edi
	xorl	%ecx, %ecx
	jmp	.L8
.L30:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L5:
	movl	-60(%rbp), %eax
	movl	-68(%rbp), %r8d
	jmp	.L7
.L32:
	call	__stack_chk_fail@PLT
.L16:
	movl	%r10d, %r8d
	jmp	.L7
	.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>
int main(){
	int N;
	scanf("%d",&N);//トッピングの種類
	int a,b;
	scanf("%d %d",&a,&b);//a:生地の値段,b:トッピング１つの値段
	int c;//生地のカロリー
	scanf("%d",&c);
	int d[N];//トッピングのカロリー
	int i,j;
	for(i=0;i<N;i++){
		scanf("%d",&d[i]);
	}
	int goukei=c;
	int count=0;
	int max;
	for(i=0;i<N;i++){//生地よりもカロリーコストの高いものを追加
		max=0;
		for(j=0;j<N;j++){
			if(max<d[j]){
				max=d[j];
			}
		}
		for(j=0;j<N;j++){
			if(max==d[j]){
				if( (double)(goukei+d[j])/(a+(count+1)*b)>(double)goukei/(a+count*b) ){
					goukei+=d[j];
					count++;
					d[j]=-1;
				}
			}
		}
	}
	printf( "%d\n",goukei/( a+(b*count) ) );
	return 0;
}
3
12 2
200
50
300
110
 3
17 2
200
73
300
110
 3
12 2
200
50
599
100
 3
12 2
200
73
575
110
 3
17 2
200
50
300
010
 3
17 2
63
50
300
010
 3
12 2
200
54
506
110
 3
17 2
38
50
300
010
 3
12 2
358
87
575
010
 3
12 2
200
54
383
110

38
 29
 57
 55
 26
 19
 51
 18
 66
 43

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>
int main(){
	int N;
	scanf("%d",&N);//トッピングの種類
	int a,b;
	scanf("%d %d",&a,&b);//a:生地の値段,b:トッピング１つの値段
	int c;//生地のカロリー
	scanf("%d",&c);
	int d[N];//トッピングのカロリー
	int i,j;
	for(i=0;i<N;i++){
		scanf("%d",&d[i]);
	}
	int goukei=c;
	int count=0;
	int max;
	for(i=0;i<N;i++){//生地よりもカロリーコストの高いものを追加
		max=0;
		for(j=0;j<N;j++){
			if(max<d[j]){
				max=d[j];
			}
		}
		for(j=0;j<N;j++){
			if(max==d[j]){
				if( (double)(goukei+d[j])/(a+(count+1)*b)>(double)goukei/(a+count*b) ){
					goukei+=d[j];
					count++;
					d[j]=-1;
				}
			}
		}
	}
	printf( "%d\n",goukei/( a+(b*count) ) );
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-108(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100(%rbp), %rdx
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-108(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L5
.L6:
	movl	-92(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -92(%rbp)
.L5:
	movl	-108(%rbp), %eax
	cmpl	%eax, -92(%rbp)
	jl	.L6
	movl	-96(%rbp), %eax
	movl	%eax, -84(%rbp)
	movl	$0, -80(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L7
.L15:
	movl	$0, -76(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L8
.L10:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, -76(%rbp)
	jge	.L9
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	movl	%eax, -76(%rbp)
.L9:
	addl	$1, -88(%rbp)
.L8:
	movl	-108(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L10
	movl	$0, -88(%rbp)
	jmp	.L11
.L14:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, -76(%rbp)
	jne	.L12
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	-84(%rbp), %eax
	addl	%edx, %eax
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm0
	movl	-80(%rbp), %eax
	leal	1(%rax), %edx
	movl	-100(%rbp), %eax
	imull	%eax, %edx
	movl	-104(%rbp), %eax
	addl	%edx, %eax
	pxor	%xmm1, %xmm1
	cvtsi2sdl	%eax, %xmm1
	divsd	%xmm1, %xmm0
	pxor	%xmm1, %xmm1
	cvtsi2sdl	-84(%rbp), %xmm1
	movl	-100(%rbp), %eax
	imull	-80(%rbp), %eax
	movl	%eax, %edx
	movl	-104(%rbp), %eax
	addl	%edx, %eax
	pxor	%xmm2, %xmm2
	cvtsi2sdl	%eax, %xmm2
	divsd	%xmm2, %xmm1
	comisd	%xmm1, %xmm0
	jbe	.L12
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, -84(%rbp)
	addl	$1, -80(%rbp)
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	$-1, (%rax,%rdx,4)
.L12:
	addl	$1, -88(%rbp)
.L11:
	movl	-108(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L14
	addl	$1, -92(%rbp)
.L7:
	movl	-108(%rbp), %eax
	cmpl	%eax, -92(%rbp)
	jl	.L15
	movl	-100(%rbp), %eax
	imull	-80(%rbp), %eax
	movl	%eax, %edx
	movl	-104(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-84(%rbp), %eax
	cltd
	idivl	%ecx
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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 %d"
.LC2:
	.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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-108(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-100(%rbp), %rdx
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-108(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L5
.L6:
	movl	-92(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -92(%rbp)
.L5:
	movl	-108(%rbp), %eax
	cmpl	%eax, -92(%rbp)
	jl	.L6
	movl	-96(%rbp), %eax
	movl	%eax, -84(%rbp)
	movl	$0, -80(%rbp)
	movl	$0, -92(%rbp)
	jmp	.L7
.L15:
	movl	$0, -76(%rbp)
	movl	$0, -88(%rbp)
	jmp	.L8
.L10:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, -76(%rbp)
	jge	.L9
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	movl	%eax, -76(%rbp)
.L9:
	addl	$1, -88(%rbp)
.L8:
	movl	-108(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L10
	movl	$0, -88(%rbp)
	jmp	.L11
.L14:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, -76(%rbp)
	jne	.L12
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	-84(%rbp), %eax
	addl	%edx, %eax
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm0
	movl	-80(%rbp), %eax
	leal	1(%rax), %edx
	movl	-100(%rbp), %eax
	imull	%eax, %edx
	movl	-104(%rbp), %eax
	addl	%edx, %eax
	pxor	%xmm1, %xmm1
	cvtsi2sdl	%eax, %xmm1
	divsd	%xmm1, %xmm0
	pxor	%xmm1, %xmm1
	cvtsi2sdl	-84(%rbp), %xmm1
	movl	-100(%rbp), %eax
	imull	-80(%rbp), %eax
	movl	%eax, %edx
	movl	-104(%rbp), %eax
	addl	%edx, %eax
	pxor	%xmm2, %xmm2
	cvtsi2sdl	%eax, %xmm2
	divsd	%xmm2, %xmm1
	comisd	%xmm1, %xmm0
	jbe	.L12
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%eax, -84(%rbp)
	addl	$1, -80(%rbp)
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	$-1, (%rax,%rdx,4)
.L12:
	addl	$1, -88(%rbp)
.L11:
	movl	-108(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L14
	addl	$1, -92(%rbp)
.L7:
	movl	-108(%rbp), %eax
	cmpl	%eax, -92(%rbp)
	jl	.L15
	movl	-100(%rbp), %eax
	imull	-80(%rbp), %eax
	movl	%eax, %edx
	movl	-104(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-84(%rbp), %eax
	cltd
	idivl	%ecx
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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:
