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(void){
    int d,g,i,j,k;
    long int res=1<<30;
    scanf("%d %d",&d,&g);
    int p[d];
    int c[d];
    for(i=0;i<d;i++)
        scanf("%d %d",&p[i],&c[i]);
    for(i=0;i<(1<<d);i++){
        // printf("%d回目-----------------------\n",i+1);
        long int sum=0;
        long int cnt=0;
        for(j=0;j<d;j++){
            // 全完したとき
            if(i&(1<<j)){
                sum+=c[j]+p[j]*100*(j+1);
                cnt+=p[j];
            }
        }
        // printf("sum=%ld,cnt=%ld\n",sum,cnt);
        if(sum>=g){
            if(cnt<res) res=cnt;}
        else{
            // printf("No zenkan\n");
            for(j=d-1;j>=0;j--){
                if(i&(1<<j)) continue;
                //問題数分繰り返す
                for(k=0;k<p[j];k++){
                    // printf("sum=%ld\n",sum)
                    if(sum>=g) break;
                    sum+=100*(j+1);
                    cnt++;
                }
            }
            if(cnt<res) res=cnt;
        }
    }
    printf("%ld\n",res);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%ld\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	$136, %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
	movq	$1073741824, -112(%rbp)
	leaq	-128(%rbp), %rdx
	leaq	-132(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-132(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -88(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -160(%rbp)
	movq	$0, -152(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -176(%rbp)
	movq	$0, -168(%rbp)
	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, -80(%rbp)
	movl	-132(%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, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L5:
	cmpq	%rdx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L6:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L7
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L7:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -124(%rbp)
	jmp	.L8
.L9:
	movl	-124(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-124(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-80(%rbp), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -124(%rbp)
.L8:
	movl	-132(%rbp), %eax
	cmpl	%eax, -124(%rbp)
	jl	.L9
	movl	$0, -124(%rbp)
	jmp	.L10
.L23:
	movq	$0, -104(%rbp)
	movq	$0, -96(%rbp)
	movl	$0, -120(%rbp)
	jmp	.L11
.L13:
	movl	-120(%rbp), %eax
	movl	-124(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L12
	movq	-64(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	movl	-120(%rbp), %edx
	addl	$1, %edx
	imull	%edx, %eax
	imull	$100, %eax, %eax
	addl	%ecx, %eax
	cltq
	addq	%rax, -104(%rbp)
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cltq
	addq	%rax, -96(%rbp)
.L12:
	addl	$1, -120(%rbp)
.L11:
	movl	-132(%rbp), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L13
	movl	-128(%rbp), %eax
	cltq
	cmpq	%rax, -104(%rbp)
	jl	.L14
	movq	-96(%rbp), %rax
	cmpq	-112(%rbp), %rax
	jge	.L15
	movq	-96(%rbp), %rax
	movq	%rax, -112(%rbp)
	jmp	.L15
.L14:
	movl	-132(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -120(%rbp)
	jmp	.L16
.L22:
	movl	-120(%rbp), %eax
	movl	-124(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L26
	movl	$0, -116(%rbp)
	jmp	.L19
.L21:
	movl	-128(%rbp), %eax
	cltq
	cmpq	%rax, -104(%rbp)
	jge	.L27
	movl	-120(%rbp), %eax
	addl	$1, %eax
	imull	$100, %eax, %eax
	cltq
	addq	%rax, -104(%rbp)
	addq	$1, -96(%rbp)
	addl	$1, -116(%rbp)
.L19:
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, -116(%rbp)
	jl	.L21
	jmp	.L18
.L26:
	nop
	jmp	.L18
.L27:
	nop
.L18:
	subl	$1, -120(%rbp)
.L16:
	cmpl	$0, -120(%rbp)
	jns	.L22
	movq	-96(%rbp), %rax
	cmpq	-112(%rbp), %rax
	jge	.L15
	movq	-96(%rbp), %rax
	movq	%rax, -112(%rbp)
.L15:
	addl	$1, -124(%rbp)
.L10:
	movl	-132(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	cmpl	%eax, -124(%rbp)
	jl	.L23
	movq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	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 %d"
.LC1:
	.string	"%ld\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
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %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
	call	__isoc99_scanf@PLT
	movslq	-64(%rbp), %rax
	movq	%rsp, %rcx
	movq	%rax, %r13
	leaq	15(,%rax,4), %rax
	movq	%rax, %rsi
	movq	%rax, %rdx
	andq	$-4096, %rsi
	andq	$-16, %rdx
	subq	%rsi, %rcx
	cmpq	%rcx, %rsp
	je	.L3
.L52:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L52
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L53
.L4:
	movq	%rax, %rdx
	movq	%rsp, %rcx
	andq	$-4096, %rax
	movq	%rsp, %rbx
	andq	$-16, %rdx
	subq	%rax, %rcx
.L5:
	cmpq	%rcx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L53:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L6:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L54
.L7:
	movq	%rsp, %r12
	testl	%r13d, %r13d
	jle	.L8
	movq	%r12, %r15
	xorl	%r14d, %r14d
	movq	%rbx, %r13
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%r15, %rdx
	movq	%r13, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-64(%rbp), %eax
	addl	$1, %r14d
	addq	$4, %r13
	addq	$4, %r15
	cmpl	%r14d, %eax
	jg	.L9
	movl	%eax, %r13d
.L8:
	movl	$1, %eax
	movl	%r13d, %ecx
	sall	%cl, %eax
	movl	%eax, -68(%rbp)
	testl	%eax, %eax
	jle	.L28
	leal	-1(%r13), %r10d
	movslq	-60(%rbp), %r8
	movl	$1073741824, %r14d
	xorl	%edi, %edi
	movl	%r10d, -72(%rbp)
	.p2align 4,,10
	.p2align 3
.L11:
	xorl	%edx, %edx
	xorl	%esi, %esi
	xorl	%eax, %eax
	testl	%r13d, %r13d
	jg	.L13
	jmp	.L55
	.p2align 4,,10
	.p2align 3
.L29:
	movq	%rcx, %rdx
.L13:
	btl	%edx, %edi
	jnc	.L12
	movslq	(%rbx,%rdx,4), %r9
	leal	1(%rdx), %ecx
	imull	%r9d, %ecx
	addq	%r9, %rsi
	imull	$100, %ecx, %ecx
	addl	(%r12,%rdx,4), %ecx
	movslq	%ecx, %rcx
	addq	%rcx, %rax
.L12:
	leaq	1(%rdx), %rcx
	cmpq	%rdx, %r10
	jne	.L29
	cmpq	%rax, %r8
	jg	.L24
.L17:
	cmpq	%rsi, %r14
	cmovg	%rsi, %r14
	addl	$1, %edi
	cmpl	-68(%rbp), %edi
	jne	.L11
.L10:
	xorl	%eax, %eax
	movq	%r14, %rdx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L56
	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
.L55:
	.cfi_restore_state
	xorl	%esi, %esi
	testq	%r8, %r8
	jle	.L17
	cmpl	$0, -72(%rbp)
	js	.L17
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L24:
	movslq	-72(%rbp), %rcx
	leal	1(%rcx), %r11d
	imull	$100, %r11d, %r11d
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L18:
	subq	$1, %rcx
	subl	$100, %r11d
	testl	%ecx, %ecx
	js	.L17
.L21:
	movl	%edi, %edx
	sarl	%cl, %edx
	andl	$1, %edx
	jne	.L18
	movl	(%rbx,%rcx,4), %r9d
	testl	%r9d, %r9d
	jle	.L18
	cmpq	%rax, %r8
	jle	.L18
	movslq	%r11d, %r15
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L57:
	cmpl	%r9d, %edx
	jge	.L18
.L19:
	addq	%r15, %rax
	addq	$1, %rsi
	addl	$1, %edx
	cmpq	%rax, %r8
	jg	.L57
	jmp	.L18
.L28:
	movl	$1073741824, %r14d
	jmp	.L10
.L54:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L7
.L56:
	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 %d"
.LC1:
	.string	"%ld\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
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %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
	call	__isoc99_scanf@PLT
	movslq	-64(%rbp), %rax
	movq	%rsp, %rcx
	movq	%rax, %r13
	leaq	15(,%rax,4), %rax
	movq	%rax, %rsi
	movq	%rax, %rdx
	andq	$-4096, %rsi
	andq	$-16, %rdx
	subq	%rsi, %rcx
	cmpq	%rcx, %rsp
	je	.L3
.L52:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L52
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L53
.L4:
	movq	%rax, %rdx
	movq	%rsp, %rcx
	andq	$-4096, %rax
	movq	%rsp, %rbx
	andq	$-16, %rdx
	subq	%rax, %rcx
.L5:
	cmpq	%rcx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L53:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L6:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L54
.L7:
	movq	%rsp, %r12
	testl	%r13d, %r13d
	jle	.L8
	movq	%r12, %r15
	xorl	%r14d, %r14d
	movq	%rbx, %r13
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%r15, %rdx
	movq	%r13, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-64(%rbp), %eax
	addl	$1, %r14d
	addq	$4, %r13
	addq	$4, %r15
	cmpl	%r14d, %eax
	jg	.L9
	movl	%eax, %r13d
.L8:
	movl	$1, %eax
	movl	%r13d, %ecx
	sall	%cl, %eax
	movl	%eax, -68(%rbp)
	testl	%eax, %eax
	jle	.L28
	leal	-1(%r13), %r10d
	movslq	-60(%rbp), %r8
	movl	$1073741824, %r14d
	xorl	%edi, %edi
	movl	%r10d, -72(%rbp)
	.p2align 4,,10
	.p2align 3
.L11:
	xorl	%edx, %edx
	xorl	%esi, %esi
	xorl	%eax, %eax
	testl	%r13d, %r13d
	jg	.L13
	jmp	.L55
	.p2align 4,,10
	.p2align 3
.L29:
	movq	%rcx, %rdx
.L13:
	btl	%edx, %edi
	jnc	.L12
	movslq	(%rbx,%rdx,4), %r9
	leal	1(%rdx), %ecx
	imull	%r9d, %ecx
	addq	%r9, %rsi
	imull	$100, %ecx, %ecx
	addl	(%r12,%rdx,4), %ecx
	movslq	%ecx, %rcx
	addq	%rcx, %rax
.L12:
	leaq	1(%rdx), %rcx
	cmpq	%rdx, %r10
	jne	.L29
	cmpq	%rax, %r8
	jg	.L24
.L17:
	cmpq	%rsi, %r14
	cmovg	%rsi, %r14
	addl	$1, %edi
	cmpl	-68(%rbp), %edi
	jne	.L11
.L10:
	xorl	%eax, %eax
	movq	%r14, %rdx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L56
	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
.L55:
	.cfi_restore_state
	xorl	%esi, %esi
	testq	%r8, %r8
	jle	.L17
	cmpl	$0, -72(%rbp)
	js	.L17
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L24:
	movslq	-72(%rbp), %rcx
	leal	1(%rcx), %r11d
	imull	$100, %r11d, %r11d
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L18:
	subq	$1, %rcx
	subl	$100, %r11d
	testl	%ecx, %ecx
	js	.L17
.L21:
	movl	%edi, %edx
	sarl	%cl, %edx
	andl	$1, %edx
	jne	.L18
	movl	(%rbx,%rcx,4), %r9d
	testl	%r9d, %r9d
	jle	.L18
	cmpq	%rax, %r8
	jle	.L18
	movslq	%r11d, %r15
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L57:
	cmpl	%r9d, %edx
	jge	.L18
.L19:
	addq	%r15, %rax
	addq	$1, %rsi
	addl	$1, %edx
	cmpq	%rax, %r8
	jg	.L57
	jmp	.L18
.L28:
	movl	$1073741824, %r14d
	jmp	.L10
.L54:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L7
.L56:
	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>
int main(void){
    int d,g,i,j,k;
    long int res=1<<30;
    scanf("%d %d",&d,&g);
    int p[d];
    int c[d];
    for(i=0;i<d;i++)
        scanf("%d %d",&p[i],&c[i]);
    for(i=0;i<(1<<d);i++){
        // printf("%d回目-----------------------\n",i+1);
        long int sum=0;
        long int cnt=0;
        for(j=0;j<d;j++){
            // 全完したとき
            if(i&(1<<j)){
                sum+=c[j]+p[j]*100*(j+1);
                cnt+=p[j];
            }
        }
        // printf("sum=%ld,cnt=%ld\n",sum,cnt);
        if(sum>=g){
            if(cnt<res) res=cnt;}
        else{
            // printf("No zenkan\n");
            for(j=d-1;j>=0;j--){
                if(i&(1<<j)) continue;
                //問題数分繰り返す
                for(k=0;k<p[j];k++){
                    // printf("sum=%ld\n",sum)
                    if(sum>=g) break;
                    sum+=100*(j+1);
                    cnt++;
                }
            }
            if(cnt<res) res=cnt;
        }
    }
    printf("%ld\n",res);
}
5 25000
20 0000
40 1000
50 1000
30 1000
1 1000
 2 431
3 500
5 800
 2 1328
3 500
5 800
 2 2000
3 500
7 800
 5 25000
20 0010
40 1000
50 1000
60 1000
1 1000
 5 10847
20 0010
40 1000
50 1000
60 1000
1 1000
 2 1328
3 890
10 800
 3 10847
26 0010
40 0100
61 1000
60 1000
1 1000
 3 10847
26 0010
40 0100
6 1000
60 1000
1 1000
 3 10847
15 0110
50 0100
7 0000
14 1001
1 1000

66
 3
 5
 7
 60
 25
 4
 37
 46
 51

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(void){
    int d,g,i,j,k;
    long int res=1<<30;
    scanf("%d %d",&d,&g);
    int p[d];
    int c[d];
    for(i=0;i<d;i++)
        scanf("%d %d",&p[i],&c[i]);
    for(i=0;i<(1<<d);i++){
        // printf("%d回目-----------------------\n",i+1);
        long int sum=0;
        long int cnt=0;
        for(j=0;j<d;j++){
            // 全完したとき
            if(i&(1<<j)){
                sum+=c[j]+p[j]*100*(j+1);
                cnt+=p[j];
            }
        }
        // printf("sum=%ld,cnt=%ld\n",sum,cnt);
        if(sum>=g){
            if(cnt<res) res=cnt;}
        else{
            // printf("No zenkan\n");
            for(j=d-1;j>=0;j--){
                if(i&(1<<j)) continue;
                //問題数分繰り返す
                for(k=0;k<p[j];k++){
                    // printf("sum=%ld\n",sum)
                    if(sum>=g) break;
                    sum+=100*(j+1);
                    cnt++;
                }
            }
            if(cnt<res) res=cnt;
        }
    }
    printf("%ld\n",res);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%ld\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	$136, %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
	movq	$1073741824, -112(%rbp)
	leaq	-128(%rbp), %rdx
	leaq	-132(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-132(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -88(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -160(%rbp)
	movq	$0, -152(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -176(%rbp)
	movq	$0, -168(%rbp)
	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, -80(%rbp)
	movl	-132(%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, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L5:
	cmpq	%rdx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L6:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L7
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L7:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -124(%rbp)
	jmp	.L8
.L9:
	movl	-124(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-124(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-80(%rbp), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -124(%rbp)
.L8:
	movl	-132(%rbp), %eax
	cmpl	%eax, -124(%rbp)
	jl	.L9
	movl	$0, -124(%rbp)
	jmp	.L10
.L23:
	movq	$0, -104(%rbp)
	movq	$0, -96(%rbp)
	movl	$0, -120(%rbp)
	jmp	.L11
.L13:
	movl	-120(%rbp), %eax
	movl	-124(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L12
	movq	-64(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	movl	-120(%rbp), %edx
	addl	$1, %edx
	imull	%edx, %eax
	imull	$100, %eax, %eax
	addl	%ecx, %eax
	cltq
	addq	%rax, -104(%rbp)
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cltq
	addq	%rax, -96(%rbp)
.L12:
	addl	$1, -120(%rbp)
.L11:
	movl	-132(%rbp), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L13
	movl	-128(%rbp), %eax
	cltq
	cmpq	%rax, -104(%rbp)
	jl	.L14
	movq	-96(%rbp), %rax
	cmpq	-112(%rbp), %rax
	jge	.L15
	movq	-96(%rbp), %rax
	movq	%rax, -112(%rbp)
	jmp	.L15
.L14:
	movl	-132(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -120(%rbp)
	jmp	.L16
.L22:
	movl	-120(%rbp), %eax
	movl	-124(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L26
	movl	$0, -116(%rbp)
	jmp	.L19
.L21:
	movl	-128(%rbp), %eax
	cltq
	cmpq	%rax, -104(%rbp)
	jge	.L27
	movl	-120(%rbp), %eax
	addl	$1, %eax
	imull	$100, %eax, %eax
	cltq
	addq	%rax, -104(%rbp)
	addq	$1, -96(%rbp)
	addl	$1, -116(%rbp)
.L19:
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, -116(%rbp)
	jl	.L21
	jmp	.L18
.L26:
	nop
	jmp	.L18
.L27:
	nop
.L18:
	subl	$1, -120(%rbp)
.L16:
	cmpl	$0, -120(%rbp)
	jns	.L22
	movq	-96(%rbp), %rax
	cmpq	-112(%rbp), %rax
	jge	.L15
	movq	-96(%rbp), %rax
	movq	%rax, -112(%rbp)
.L15:
	addl	$1, -124(%rbp)
.L10:
	movl	-132(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	cmpl	%eax, -124(%rbp)
	jl	.L23
	movq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	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 %d"
.LC1:
	.string	"%ld\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	$136, %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
	movq	$1073741824, -112(%rbp)
	leaq	-128(%rbp), %rdx
	leaq	-132(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-132(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -88(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -160(%rbp)
	movq	$0, -152(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -176(%rbp)
	movq	$0, -168(%rbp)
	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, -80(%rbp)
	movl	-132(%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, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L5:
	cmpq	%rdx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L6:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L7
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L7:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -124(%rbp)
	jmp	.L8
.L9:
	movl	-124(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-124(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-80(%rbp), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -124(%rbp)
.L8:
	movl	-132(%rbp), %eax
	cmpl	%eax, -124(%rbp)
	jl	.L9
	movl	$0, -124(%rbp)
	jmp	.L10
.L23:
	movq	$0, -104(%rbp)
	movq	$0, -96(%rbp)
	movl	$0, -120(%rbp)
	jmp	.L11
.L13:
	movl	-120(%rbp), %eax
	movl	-124(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L12
	movq	-64(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	movl	-120(%rbp), %edx
	addl	$1, %edx
	imull	%edx, %eax
	imull	$100, %eax, %eax
	addl	%ecx, %eax
	cltq
	addq	%rax, -104(%rbp)
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cltq
	addq	%rax, -96(%rbp)
.L12:
	addl	$1, -120(%rbp)
.L11:
	movl	-132(%rbp), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L13
	movl	-128(%rbp), %eax
	cltq
	cmpq	%rax, -104(%rbp)
	jl	.L14
	movq	-96(%rbp), %rax
	cmpq	-112(%rbp), %rax
	jge	.L15
	movq	-96(%rbp), %rax
	movq	%rax, -112(%rbp)
	jmp	.L15
.L14:
	movl	-132(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -120(%rbp)
	jmp	.L16
.L22:
	movl	-120(%rbp), %eax
	movl	-124(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L26
	movl	$0, -116(%rbp)
	jmp	.L19
.L21:
	movl	-128(%rbp), %eax
	cltq
	cmpq	%rax, -104(%rbp)
	jge	.L27
	movl	-120(%rbp), %eax
	addl	$1, %eax
	imull	$100, %eax, %eax
	cltq
	addq	%rax, -104(%rbp)
	addq	$1, -96(%rbp)
	addl	$1, -116(%rbp)
.L19:
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	cmpl	%eax, -116(%rbp)
	jl	.L21
	jmp	.L18
.L26:
	nop
	jmp	.L18
.L27:
	nop
.L18:
	subl	$1, -120(%rbp)
.L16:
	cmpl	$0, -120(%rbp)
	jns	.L22
	movq	-96(%rbp), %rax
	cmpq	-112(%rbp), %rax
	jge	.L15
	movq	-96(%rbp), %rax
	movq	%rax, -112(%rbp)
.L15:
	addl	$1, -124(%rbp)
.L10:
	movl	-132(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	cmpl	%eax, -124(%rbp)
	jl	.L23
	movq	-112(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	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:
