Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
// AOJ 2069: Greedy, Greedy.
// 2017.11.5 bal4u@uu

#include <stdio.h>
#include <string.h>

int c[52], n;
int greedy[10001];
int dp[10001];

int calcGreedy(int lim)
{
	int v, p, i, k;
	memset(greedy, 0, sizeof(greedy));
	for (v = lim; v >= 1; v--) {
		p = v;
		for (i = n - 1; i >= 0; i--) if (c[i] <= p) {
			k = p/c[i];
			greedy[v] += k;
			p -= c[i]*k;
		}
		if (greedy[v] != dp[v]) return 0;
	}
	return 1;
}

void calcDP(int lim)
{
	int i, j, k;
	memset(dp, 0, sizeof(dp));
	for (i = 0; i < n; i++) for (j = 0; (k = j + c[i]) <= lim; j++) {
		if (!dp[k] || dp[k] > dp[j] + 1) dp[k] = dp[j] + 1;
	}
}

int main()
{
	int cno = 0, i, lim;

	while (scanf("%d", &n) && n > 0) {
		printf("Case #%d: ", ++cno);
		for (i = 0; i < n; i++) scanf("%d", c+i);
		if (c[0] != 1) { puts("Cannot pay some amount"); continue; }
		if (n == 1) lim = c[0];
		else lim = c[n-1] + c[n-2];
		calcDP(lim);
		if (calcGreedy(lim)) puts("OK");
		else puts("Cannot use greedy algorithm");
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	c
	.bss
	.align 32
	.type	c, @object
	.size	c, 208
c:
	.zero	208
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	greedy
	.align 32
	.type	greedy, @object
	.size	greedy, 40004
greedy:
	.zero	40004
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 40004
dp:
	.zero	40004
	.text
	.globl	calcGreedy
	.type	calcGreedy, @function
calcGreedy:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	$40004, %edx
	movl	$0, %esi
	leaq	greedy(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	-20(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L2
.L8:
	movl	-16(%rbp), %eax
	movl	%eax, -12(%rbp)
	movl	n(%rip), %eax
	subl	$1, %eax
	movl	%eax, -8(%rbp)
	jmp	.L3
.L5:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L4
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-12(%rbp), %eax
	cltd
	idivl	%esi
	movl	%eax, -4(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	greedy(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	greedy(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	imull	-4(%rbp), %eax
	subl	%eax, -12(%rbp)
.L4:
	subl	$1, -8(%rbp)
.L3:
	cmpl	$0, -8(%rbp)
	jns	.L5
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	greedy(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	je	.L6
	movl	$0, %eax
	jmp	.L7
.L6:
	subl	$1, -16(%rbp)
.L2:
	cmpl	$0, -16(%rbp)
	jg	.L8
	movl	$1, %eax
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	calcGreedy, .-calcGreedy
	.globl	calcDP
	.type	calcDP, @function
calcDP:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	$40004, %edx
	movl	$0, %esi
	leaq	dp(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -12(%rbp)
	jmp	.L10
.L15:
	movl	$0, -8(%rbp)
	jmp	.L11
.L14:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L12
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	addl	$1, %edx
	cmpl	%edx, %eax
	jle	.L13
.L12:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L13:
	addl	$1, -8(%rbp)
.L11:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L14
	addl	$1, -12(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L15
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	calcDP, .-calcDP
	.section	.rodata
.LC0:
	.string	"Case #%d: "
.LC1:
	.string	"%d"
.LC2:
	.string	"Cannot pay some amount"
.LC3:
	.string	"OK"
.LC4:
	.string	"Cannot use greedy algorithm"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	$0, -12(%rbp)
	jmp	.L17
.L25:
	addl	$1, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -8(%rbp)
	jmp	.L18
.L19:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L19
	movl	c(%rip), %eax
	cmpl	$1, %eax
	je	.L20
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L17
.L20:
	movl	n(%rip), %eax
	cmpl	$1, %eax
	jne	.L21
	movl	c(%rip), %eax
	movl	%eax, -4(%rbp)
	jmp	.L22
.L21:
	movl	n(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	n(%rip), %eax
	subl	$2, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, -4(%rbp)
.L22:
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	calcDP
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	calcGreedy
	testl	%eax, %eax
	je	.L23
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L17
.L23:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L17:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L24
	movl	n(%rip), %eax
	testl	%eax, %eax
	jg	.L25
.L24:
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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
	.p2align 4
	.globl	calcGreedy
	.type	calcGreedy, @function
calcGreedy:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	greedy(%rip), %rcx
	xorl	%esi, %esi
	movl	$40004, %edx
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	movq	%rcx, %rdi
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	call	memset@PLT
	testl	%ebx, %ebx
	jle	.L8
	movq	%rax, %rcx
	movslq	n(%rip), %rax
	leaq	c(%rip), %rdx
	movslq	%ebx, %r10
	leaq	(%rcx,%r10,4), %r9
	leaq	dp(%rip), %r11
	leaq	(%rdx,%rax,4), %rbx
	leal	-1(%rax), %edx
	movq	%rax, %rbp
	subq	%rdx, %rax
	leaq	-4+c(%rip), %rdx
	leaq	(%rdx,%rax,4), %r8
	.p2align 4,,10
	.p2align 3
.L7:
	movl	(%r9), %edi
	movl	%r10d, %eax
	testl	%ebp, %ebp
	jle	.L4
	movq	%rbx, %rcx
	.p2align 4,,10
	.p2align 3
.L6:
	movl	-4(%rcx), %esi
	cmpl	%eax, %esi
	jg	.L5
	cltd
	idivl	%esi
	addl	%eax, %edi
	movl	%edx, %eax
	movl	%edi, (%r9)
.L5:
	subq	$4, %rcx
	cmpq	%r8, %rcx
	jne	.L6
.L4:
	cmpl	%edi, (%r11,%r10,4)
	jne	.L9
	subq	$1, %r10
	subq	$4, %r9
	testl	%r10d, %r10d
	jg	.L7
.L8:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movl	$1, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore_state
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE35:
	.size	calcGreedy, .-calcGreedy
	.p2align 4
	.globl	calcDP
	.type	calcDP, @function
calcDP:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	dp(%rip), %r9
	movl	%edi, %ebx
	movl	$40004, %edx
	movq	%r9, %rdi
	xorl	%esi, %esi
	call	memset@PLT
	movq	%rax, %r9
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L14
	leaq	c(%rip), %r8
	leal	-1(%rax), %edx
	leaq	4(%r8), %rax
	leaq	4+dp(%rip), %r11
	leaq	(%rax,%rdx,4), %r10
	.p2align 4,,10
	.p2align 3
.L16:
	movl	(%r8), %edx
	cmpl	%edx, %ebx
	jl	.L21
	movl	%ebx, %ecx
	movslq	%edx, %rdi
	subl	%edx, %ecx
	leaq	0(,%rdi,4), %rsi
	leaq	(%rcx,%rdi), %rdx
	leaq	(%r9,%rsi), %rax
	negq	%rsi
	leaq	(%r11,%rdx,4), %rdi
	.p2align 4,,10
	.p2align 3
.L19:
	movl	(%rax,%rsi), %edx
	movl	(%rax), %ecx
	addl	$1, %edx
	testl	%ecx, %ecx
	je	.L17
	cmpl	%edx, %ecx
	jle	.L18
.L17:
	movl	%edx, (%rax)
.L18:
	addq	$4, %rax
	cmpq	%rdi, %rax
	jne	.L19
.L21:
	addq	$4, %r8
	cmpq	%r10, %r8
	jne	.L16
.L14:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE36:
	.size	calcDP, .-calcDP
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Case #%d: "
.LC1:
	.string	"%d"
.LC2:
	.string	"Cannot pay some amount"
.LC3:
	.string	"OK"
.LC4:
	.string	"Cannot use greedy algorithm"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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
	leaq	4+dp(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	c(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC1(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	$0, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L28:
	xorl	%eax, %eax
	leaq	n(%rip), %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L52
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L52
	addl	$1, 8(%rsp)
	movl	8(%rsp), %edx
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	movl	$1, %edi
	call	__printf_chk@PLT
	movl	n(%rip), %r14d
	testl	%r14d, %r14d
	jle	.L29
	leaq	c(%rip), %r13
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L30:
	movq	%r13, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r14d
	addq	$4, %r13
	cmpl	%r15d, %r14d
	jg	.L30
.L29:
	cmpl	$1, 0(%rbp)
	jne	.L64
	cmpl	$1, %r14d
	je	.L33
	leal	-1(%r14), %eax
	leal	-2(%r14), %edx
	xorl	%esi, %esi
	cltq
	movslq	%edx, %rdx
	leaq	dp(%rip), %r15
	movl	0(%rbp,%rdx,4), %r8d
	movq	%r15, %rdi
	addl	0(%rbp,%rax,4), %r8d
	movl	$40004, %edx
	movl	%r8d, 12(%rsp)
	call	memset@PLT
	testl	%r14d, %r14d
	movl	12(%rsp), %r8d
	jle	.L35
.L34:
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L39:
	movl	0(%rbp,%r9,4), %edx
	cmpl	%edx, %r8d
	jl	.L41
	movl	%r8d, %ecx
	movslq	%edx, %rdi
	subl	%edx, %ecx
	leaq	0(,%rdi,4), %rsi
	leaq	(%rcx,%rdi), %rdx
	leaq	(%r15,%rsi), %rax
	negq	%rsi
	leaq	(%r12,%rdx,4), %rdi
	.p2align 4,,10
	.p2align 3
.L38:
	movl	(%rax,%rsi), %edx
	movl	(%rax), %ecx
	addl	$1, %edx
	testl	%ecx, %ecx
	je	.L36
	cmpl	%edx, %ecx
	jle	.L37
.L36:
	movl	%edx, (%rax)
.L37:
	addq	$4, %rax
	cmpq	%rdi, %rax
	jne	.L38
.L41:
	addq	$1, %r9
	cmpl	%r9d, %r14d
	jg	.L39
.L35:
	leaq	greedy(%rip), %rcx
	movl	$40004, %edx
	xorl	%esi, %esi
	movl	%r8d, 12(%rsp)
	movq	%rcx, %rdi
	call	memset@PLT
	movslq	12(%rsp), %r8
	testl	%r8d, %r8d
	jle	.L42
	leal	-1(%r14), %edx
	leaq	(%rax,%r8,4), %r9
	movslq	%r14d, %rax
	leaq	0(%rbp,%rax,4), %r10
	subq	%rdx, %rax
	leaq	-4+c(%rip), %rdx
	leaq	(%rdx,%rax,4), %rdi
	.p2align 4,,10
	.p2align 3
.L47:
	movl	(%r9), %esi
	movl	%r8d, %eax
	testl	%r14d, %r14d
	jle	.L43
	movq	%r10, %rcx
	.p2align 4,,10
	.p2align 3
.L45:
	movl	-4(%rcx), %r11d
	cmpl	%eax, %r11d
	jg	.L44
	cltd
	idivl	%r11d
	addl	%eax, %esi
	movl	%edx, %eax
	movl	%esi, (%r9)
.L44:
	subq	$4, %rcx
	cmpq	%rcx, %rdi
	jne	.L45
.L43:
	cmpl	%esi, (%r15,%r8,4)
	jne	.L46
	subq	$1, %r8
	subq	$4, %r9
	testl	%r8d, %r8d
	jg	.L47
.L42:
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	jmp	.L28
.L46:
	leaq	.LC4(%rip), %rdi
	call	puts@PLT
	jmp	.L28
.L64:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L28
.L33:
	leaq	dp(%rip), %r15
	movl	$40004, %edx
	xorl	%esi, %esi
	movq	%r15, %rdi
	call	memset@PLT
	movl	$1, %r8d
	jmp	.L34
.L52:
	addq	$24, %rsp
	.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
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.globl	dp
	.bss
	.align 32
	.type	dp, @object
	.size	dp, 40004
dp:
	.zero	40004
	.globl	greedy
	.align 32
	.type	greedy, @object
	.size	greedy, 40004
greedy:
	.zero	40004
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 208
c:
	.zero	208
	.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
	.p2align 4
	.globl	calcGreedy
	.type	calcGreedy, @function
calcGreedy:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	greedy(%rip), %rcx
	xorl	%esi, %esi
	movl	$40004, %edx
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	movq	%rcx, %rdi
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	call	memset@PLT
	testl	%ebx, %ebx
	jle	.L8
	movq	%rax, %rcx
	movslq	n(%rip), %rax
	leaq	c(%rip), %rdx
	movslq	%ebx, %r10
	leaq	(%rcx,%r10,4), %r9
	leaq	dp(%rip), %r11
	leaq	(%rdx,%rax,4), %rbx
	leal	-1(%rax), %edx
	movq	%rax, %rbp
	subq	%rdx, %rax
	leaq	-4+c(%rip), %rdx
	leaq	(%rdx,%rax,4), %r8
	.p2align 4,,10
	.p2align 3
.L7:
	movl	(%r9), %edi
	movl	%r10d, %eax
	testl	%ebp, %ebp
	jle	.L4
	movq	%rbx, %rcx
	.p2align 4,,10
	.p2align 3
.L6:
	movl	-4(%rcx), %esi
	cmpl	%eax, %esi
	jg	.L5
	cltd
	idivl	%esi
	addl	%eax, %edi
	movl	%edx, %eax
	movl	%edi, (%r9)
.L5:
	subq	$4, %rcx
	cmpq	%r8, %rcx
	jne	.L6
.L4:
	cmpl	%edi, (%r11,%r10,4)
	jne	.L9
	subq	$1, %r10
	subq	$4, %r9
	testl	%r10d, %r10d
	jg	.L7
.L8:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movl	$1, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore_state
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE35:
	.size	calcGreedy, .-calcGreedy
	.p2align 4
	.globl	calcDP
	.type	calcDP, @function
calcDP:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	dp(%rip), %r9
	movl	%edi, %ebx
	movl	$40004, %edx
	movq	%r9, %rdi
	xorl	%esi, %esi
	call	memset@PLT
	movq	%rax, %r9
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L14
	leaq	c(%rip), %r8
	leal	-1(%rax), %edx
	leaq	4(%r8), %rax
	leaq	4+dp(%rip), %r11
	leaq	(%rax,%rdx,4), %r10
	.p2align 4,,10
	.p2align 3
.L16:
	movl	(%r8), %edx
	cmpl	%edx, %ebx
	jl	.L21
	movl	%ebx, %ecx
	movslq	%edx, %rdi
	subl	%edx, %ecx
	leaq	0(,%rdi,4), %rsi
	leaq	(%rcx,%rdi), %rdx
	leaq	(%r9,%rsi), %rax
	negq	%rsi
	leaq	(%r11,%rdx,4), %rdi
	.p2align 4,,10
	.p2align 3
.L19:
	movl	(%rax,%rsi), %edx
	movl	(%rax), %ecx
	addl	$1, %edx
	testl	%ecx, %ecx
	je	.L17
	cmpl	%edx, %ecx
	jle	.L18
.L17:
	movl	%edx, (%rax)
.L18:
	addq	$4, %rax
	cmpq	%rdi, %rax
	jne	.L19
.L21:
	addq	$4, %r8
	cmpq	%r10, %r8
	jne	.L16
.L14:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE36:
	.size	calcDP, .-calcDP
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Case #%d: "
.LC1:
	.string	"%d"
.LC2:
	.string	"Cannot pay some amount"
.LC3:
	.string	"OK"
.LC4:
	.string	"Cannot use greedy algorithm"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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
	leaq	4+dp(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	c(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC1(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	$0, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L28:
	xorl	%eax, %eax
	leaq	n(%rip), %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L52
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L52
	addl	$1, 8(%rsp)
	movl	8(%rsp), %edx
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	movl	$1, %edi
	call	__printf_chk@PLT
	movl	n(%rip), %r14d
	testl	%r14d, %r14d
	jle	.L29
	leaq	c(%rip), %r13
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L30:
	movq	%r13, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r14d
	addq	$4, %r13
	cmpl	%r15d, %r14d
	jg	.L30
.L29:
	cmpl	$1, 0(%rbp)
	jne	.L64
	cmpl	$1, %r14d
	je	.L33
	leal	-1(%r14), %eax
	leal	-2(%r14), %edx
	xorl	%esi, %esi
	cltq
	movslq	%edx, %rdx
	leaq	dp(%rip), %r15
	movl	0(%rbp,%rdx,4), %r8d
	movq	%r15, %rdi
	addl	0(%rbp,%rax,4), %r8d
	movl	$40004, %edx
	movl	%r8d, 12(%rsp)
	call	memset@PLT
	testl	%r14d, %r14d
	movl	12(%rsp), %r8d
	jle	.L35
.L34:
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L39:
	movl	0(%rbp,%r9,4), %edx
	cmpl	%edx, %r8d
	jl	.L41
	movl	%r8d, %ecx
	movslq	%edx, %rdi
	subl	%edx, %ecx
	leaq	0(,%rdi,4), %rsi
	leaq	(%rcx,%rdi), %rdx
	leaq	(%r15,%rsi), %rax
	negq	%rsi
	leaq	(%r12,%rdx,4), %rdi
	.p2align 4,,10
	.p2align 3
.L38:
	movl	(%rax,%rsi), %edx
	movl	(%rax), %ecx
	addl	$1, %edx
	testl	%ecx, %ecx
	je	.L36
	cmpl	%edx, %ecx
	jle	.L37
.L36:
	movl	%edx, (%rax)
.L37:
	addq	$4, %rax
	cmpq	%rdi, %rax
	jne	.L38
.L41:
	addq	$1, %r9
	cmpl	%r9d, %r14d
	jg	.L39
.L35:
	leaq	greedy(%rip), %rcx
	movl	$40004, %edx
	xorl	%esi, %esi
	movl	%r8d, 12(%rsp)
	movq	%rcx, %rdi
	call	memset@PLT
	movslq	12(%rsp), %r8
	testl	%r8d, %r8d
	jle	.L42
	leal	-1(%r14), %edx
	leaq	(%rax,%r8,4), %r9
	movslq	%r14d, %rax
	leaq	0(%rbp,%rax,4), %r10
	subq	%rdx, %rax
	leaq	-4+c(%rip), %rdx
	leaq	(%rdx,%rax,4), %rdi
	.p2align 4,,10
	.p2align 3
.L47:
	movl	(%r9), %esi
	movl	%r8d, %eax
	testl	%r14d, %r14d
	jle	.L43
	movq	%r10, %rcx
	.p2align 4,,10
	.p2align 3
.L45:
	movl	-4(%rcx), %r11d
	cmpl	%eax, %r11d
	jg	.L44
	cltd
	idivl	%r11d
	addl	%eax, %esi
	movl	%edx, %eax
	movl	%esi, (%r9)
.L44:
	subq	$4, %rcx
	cmpq	%rcx, %rdi
	jne	.L45
.L43:
	cmpl	%esi, (%r15,%r8,4)
	jne	.L46
	subq	$1, %r8
	subq	$4, %r9
	testl	%r8d, %r8d
	jg	.L47
.L42:
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	jmp	.L28
.L46:
	leaq	.LC4(%rip), %rdi
	call	puts@PLT
	jmp	.L28
.L64:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L28
.L33:
	leaq	dp(%rip), %r15
	movl	$40004, %edx
	xorl	%esi, %esi
	movq	%r15, %rdi
	call	memset@PLT
	movl	$1, %r8d
	jmp	.L34
.L52:
	addq	$24, %rsp
	.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
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.globl	dp
	.bss
	.align 32
	.type	dp, @object
	.size	dp, 40004
dp:
	.zero	40004
	.globl	greedy
	.align 32
	.type	greedy, @object
	.size	greedy, 40004
greedy:
	.zero	40004
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 208
c:
	.zero	208
	.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:

// AOJ 2069: Greedy, Greedy.
// 2017.11.5 bal4u@uu

#include <stdio.h>
#include <string.h>

int c[52], n;
int greedy[10001];
int dp[10001];

int calcGreedy(int lim)
{
	int v, p, i, k;
	memset(greedy, 0, sizeof(greedy));
	for (v = lim; v >= 1; v--) {
		p = v;
		for (i = n - 1; i >= 0; i--) if (c[i] <= p) {
			k = p/c[i];
			greedy[v] += k;
			p -= c[i]*k;
		}
		if (greedy[v] != dp[v]) return 0;
	}
	return 1;
}

void calcDP(int lim)
{
	int i, j, k;
	memset(dp, 0, sizeof(dp));
	for (i = 0; i < n; i++) for (j = 0; (k = j + c[i]) <= lim; j++) {
		if (!dp[k] || dp[k] > dp[j] + 1) dp[k] = dp[j] + 1;
	}
}

int main()
{
	int cno = 0, i, lim;

	while (scanf("%d", &n) && n > 0) {
		printf("Case #%d: ", ++cno);
		for (i = 0; i < n; i++) scanf("%d", c+i);
		if (c[0] != 1) { puts("Cannot pay some amount"); continue; }
		if (n == 1) lim = c[0];
		else lim = c[n-1] + c[n-2];
		calcDP(lim);
		if (calcGreedy(lim)) puts("OK");
		else puts("Cannot use greedy algorithm");
	}
	return 0;
}
3 1 5 25
3 7 77 777
4 1 8 44 64
0
 3 1 7 49
3 7 106 109
4 0 11 78 14
0
 3 2 7 25
3 7 77 777
4 1 11 27 64
0
 3 1 5 25
3 8 77 777
4 1 11 11 64
0
 3 1 7 49
3 2 106 109
0 0 11 78 14
0
 1 1 1 25
3 8 77 777
4 1 11 11 64
0
 3 1 12 25
3 7 106 729
4 1 11 44 14
0
 3 2 7 49
3 2 106 86
0 0 11 78 14
0
 3 1 9 40
3 2 105 777
4 0 8 5 74
0
 3 2 9 43
3 2 105 2170
4 1 1 4 74
0

Case #1: OK
Case #2: Cannot pay some amount
Case #3: Cannot use greedy algorithm
 Case #1: OK
Case #2: Cannot pay some amount
Case #3: Cannot pay some amount
 Case #1: Cannot pay some amount
Case #2: Cannot pay some amount
Case #3: Cannot use greedy algorithm
 Case #1: OK
Case #2: Cannot pay some amount
Case #3: OK
 Case #1: OK
Case #2: Cannot pay some amount
 Case #1: OK
Case #2: Cannot pay some amount
Case #3: Cannot pay some amount
Case #4: OK
 Case #1: Cannot use greedy algorithm
Case #2: Cannot pay some amount
Case #3: Cannot use greedy algorithm
 Case #1: Cannot pay some amount
Case #2: Cannot pay some amount
 Case #1: Cannot use greedy algorithm
Case #2: Cannot pay some amount
Case #3: Cannot pay some amount
 Case #1: Cannot pay some amount
Case #2: Cannot pay some amount
Case #3: OK

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
// AOJ 2069: Greedy, Greedy.
// 2017.11.5 bal4u@uu

#include <stdio.h>
#include <string.h>

int c[52], n;
int greedy[10001];
int dp[10001];

int calcGreedy(int lim)
{
	int v, p, i, k;
	memset(greedy, 0, sizeof(greedy));
	for (v = lim; v >= 1; v--) {
		p = v;
		for (i = n - 1; i >= 0; i--) if (c[i] <= p) {
			k = p/c[i];
			greedy[v] += k;
			p -= c[i]*k;
		}
		if (greedy[v] != dp[v]) return 0;
	}
	return 1;
}

void calcDP(int lim)
{
	int i, j, k;
	memset(dp, 0, sizeof(dp));
	for (i = 0; i < n; i++) for (j = 0; (k = j + c[i]) <= lim; j++) {
		if (!dp[k] || dp[k] > dp[j] + 1) dp[k] = dp[j] + 1;
	}
}

int main()
{
	int cno = 0, i, lim;

	while (scanf("%d", &n) && n > 0) {
		printf("Case #%d: ", ++cno);
		for (i = 0; i < n; i++) scanf("%d", c+i);
		if (c[0] != 1) { puts("Cannot pay some amount"); continue; }
		if (n == 1) lim = c[0];
		else lim = c[n-1] + c[n-2];
		calcDP(lim);
		if (calcGreedy(lim)) puts("OK");
		else puts("Cannot use greedy algorithm");
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	c
	.bss
	.align 32
	.type	c, @object
	.size	c, 208
c:
	.zero	208
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	greedy
	.align 32
	.type	greedy, @object
	.size	greedy, 40004
greedy:
	.zero	40004
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 40004
dp:
	.zero	40004
	.text
	.globl	calcGreedy
	.type	calcGreedy, @function
calcGreedy:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	$40004, %edx
	movl	$0, %esi
	leaq	greedy(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	-20(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L2
.L8:
	movl	-16(%rbp), %eax
	movl	%eax, -12(%rbp)
	movl	n(%rip), %eax
	subl	$1, %eax
	movl	%eax, -8(%rbp)
	jmp	.L3
.L5:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L4
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-12(%rbp), %eax
	cltd
	idivl	%esi
	movl	%eax, -4(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	greedy(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	greedy(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	imull	-4(%rbp), %eax
	subl	%eax, -12(%rbp)
.L4:
	subl	$1, -8(%rbp)
.L3:
	cmpl	$0, -8(%rbp)
	jns	.L5
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	greedy(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	je	.L6
	movl	$0, %eax
	jmp	.L7
.L6:
	subl	$1, -16(%rbp)
.L2:
	cmpl	$0, -16(%rbp)
	jg	.L8
	movl	$1, %eax
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	calcGreedy, .-calcGreedy
	.globl	calcDP
	.type	calcDP, @function
calcDP:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	$40004, %edx
	movl	$0, %esi
	leaq	dp(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -12(%rbp)
	jmp	.L10
.L15:
	movl	$0, -8(%rbp)
	jmp	.L11
.L14:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L12
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	addl	$1, %edx
	cmpl	%edx, %eax
	jle	.L13
.L12:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L13:
	addl	$1, -8(%rbp)
.L11:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L14
	addl	$1, -12(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L15
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	calcDP, .-calcDP
	.section	.rodata
.LC0:
	.string	"Case #%d: "
.LC1:
	.string	"%d"
.LC2:
	.string	"Cannot pay some amount"
.LC3:
	.string	"OK"
.LC4:
	.string	"Cannot use greedy algorithm"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	$0, -12(%rbp)
	jmp	.L17
.L25:
	addl	$1, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -8(%rbp)
	jmp	.L18
.L19:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L19
	movl	c(%rip), %eax
	cmpl	$1, %eax
	je	.L20
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L17
.L20:
	movl	n(%rip), %eax
	cmpl	$1, %eax
	jne	.L21
	movl	c(%rip), %eax
	movl	%eax, -4(%rbp)
	jmp	.L22
.L21:
	movl	n(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	n(%rip), %eax
	subl	$2, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, -4(%rbp)
.L22:
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	calcDP
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	calcGreedy
	testl	%eax, %eax
	je	.L23
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L17
.L23:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L17:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L24
	movl	n(%rip), %eax
	testl	%eax, %eax
	jg	.L25
.L24:
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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
	.globl	c
	.bss
	.align 32
	.type	c, @object
	.size	c, 208
c:
	.zero	208
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	greedy
	.align 32
	.type	greedy, @object
	.size	greedy, 40004
greedy:
	.zero	40004
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 40004
dp:
	.zero	40004
	.text
	.globl	calcGreedy
	.type	calcGreedy, @function
calcGreedy:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	$40004, %edx
	movl	$0, %esi
	leaq	greedy(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	-20(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L2
.L8:
	movl	-16(%rbp), %eax
	movl	%eax, -12(%rbp)
	movl	n(%rip), %eax
	subl	$1, %eax
	movl	%eax, -8(%rbp)
	jmp	.L3
.L5:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L4
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-12(%rbp), %eax
	cltd
	idivl	%esi
	movl	%eax, -4(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	greedy(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	greedy(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	imull	-4(%rbp), %eax
	subl	%eax, -12(%rbp)
.L4:
	subl	$1, -8(%rbp)
.L3:
	cmpl	$0, -8(%rbp)
	jns	.L5
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	greedy(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	je	.L6
	movl	$0, %eax
	jmp	.L7
.L6:
	subl	$1, -16(%rbp)
.L2:
	cmpl	$0, -16(%rbp)
	jg	.L8
	movl	$1, %eax
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	calcGreedy, .-calcGreedy
	.globl	calcDP
	.type	calcDP, @function
calcDP:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	$40004, %edx
	movl	$0, %esi
	leaq	dp(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -12(%rbp)
	jmp	.L10
.L15:
	movl	$0, -8(%rbp)
	jmp	.L11
.L14:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L12
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	addl	$1, %edx
	cmpl	%edx, %eax
	jle	.L13
.L12:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L13:
	addl	$1, -8(%rbp)
.L11:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L14
	addl	$1, -12(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L15
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	calcDP, .-calcDP
	.section	.rodata
.LC0:
	.string	"Case #%d: "
.LC1:
	.string	"%d"
.LC2:
	.string	"Cannot pay some amount"
.LC3:
	.string	"OK"
.LC4:
	.string	"Cannot use greedy algorithm"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	$0, -12(%rbp)
	jmp	.L17
.L25:
	addl	$1, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -8(%rbp)
	jmp	.L18
.L19:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L19
	movl	c(%rip), %eax
	cmpl	$1, %eax
	je	.L20
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L17
.L20:
	movl	n(%rip), %eax
	cmpl	$1, %eax
	jne	.L21
	movl	c(%rip), %eax
	movl	%eax, -4(%rbp)
	jmp	.L22
.L21:
	movl	n(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	n(%rip), %eax
	subl	$2, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, -4(%rbp)
.L22:
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	calcDP
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	calcGreedy
	testl	%eax, %eax
	je	.L23
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L17
.L23:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L17:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L24
	movl	n(%rip), %eax
	testl	%eax, %eax
	jg	.L25
.L24:
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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:
