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>

long fac(int x){
	if(x==0) return 1;
	else return x*fac(x-1);
}

long pp(int a, int b){
	int i;
	long ans=1;
	
	for(i=b; i<=a; i++) ans*=i;
	
	return ans;
}

int main(void){
	while(1){
		long count=0;
		int i, j, k, n;		
		
		scanf(" %d", &n);
		if(n==0) break;
		
		for(i=0; i<=30; i++){
			for(j=0; j<=15; j++){
				for(k=0; k<=10; k++){
					if(i + 2*j + 3*k == n) count += pp(i+j+k, i+1)/fac(j)/fac(k);
					else if(i + 2*j + 3*k > n) break;
				}		
			}
		}
		
		printf("%ld\n", count / 3650 + 1);
	}
	
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	fac
	.type	fac, @function
fac:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movl	%edi, -20(%rbp)
	cmpl	$0, -20(%rbp)
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movl	-20(%rbp), %eax
	movslq	%eax, %rbx
	movl	-20(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %edi
	call	fac
	imulq	%rbx, %rax
.L3:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	fac, .-fac
	.globl	pp
	.type	pp, @function
pp:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movq	$1, -8(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L5
.L6:
	movl	-12(%rbp), %eax
	cltq
	movq	-8(%rbp), %rdx
	imulq	%rdx, %rax
	movq	%rax, -8(%rbp)
	addl	$1, -12(%rbp)
.L5:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L6
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	pp, .-pp
	.section	.rodata
.LC0:
	.string	" %d"
.LC1:
	.string	"%ld\n"
	.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
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
.L20:
	movq	$0, -32(%rbp)
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-48(%rbp), %eax
	testl	%eax, %eax
	jne	.L9
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	jmp	.L22
.L9:
	movl	$0, -44(%rbp)
	jmp	.L11
.L19:
	movl	$0, -40(%rbp)
	jmp	.L12
.L18:
	movl	$0, -36(%rbp)
	jmp	.L13
.L17:
	movl	-40(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-44(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-36(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	leal	(%rcx,%rax), %edx
	movl	-48(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L14
	movl	-44(%rbp), %eax
	leal	1(%rax), %edx
	movl	-44(%rbp), %ecx
	movl	-40(%rbp), %eax
	addl	%eax, %ecx
	movl	-36(%rbp), %eax
	addl	%ecx, %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	pp
	movq	%rax, %rbx
	movl	-40(%rbp), %eax
	movl	%eax, %edi
	call	fac
	movq	%rax, %rsi
	movq	%rbx, %rax
	cqto
	idivq	%rsi
	movq	%rax, %rbx
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	fac
	movq	%rax, %rsi
	movq	%rbx, %rax
	cqto
	idivq	%rsi
	addq	%rax, -32(%rbp)
	jmp	.L15
.L14:
	movl	-40(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-44(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-36(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	leal	(%rcx,%rax), %edx
	movl	-48(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L23
.L15:
	addl	$1, -36(%rbp)
.L13:
	cmpl	$10, -36(%rbp)
	jle	.L17
	jmp	.L16
.L23:
	nop
.L16:
	addl	$1, -40(%rbp)
.L12:
	cmpl	$15, -40(%rbp)
	jle	.L18
	addl	$1, -44(%rbp)
.L11:
	cmpl	$30, -44(%rbp)
	jle	.L19
	movq	-32(%rbp), %rcx
	movabsq	$-8096351782488411421, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$11, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	addq	$1, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L20
.L22:
	call	__stack_chk_fail@PLT
.L21:
	movq	-8(%rbp), %rbx
	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	fac
	.type	fac, @function
fac:
.LFB23:
	.cfi_startproc
	endbr64
	movl	$1, %r8d
	testl	%edi, %edi
	je	.L1
	movslq	%edi, %rdx
	leal	-1(%rdi), %esi
	movl	$1, %r8d
	leaq	-1(%rdx), %rax
	movq	%rax, %rcx
	subq	%rsi, %rcx
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L6:
	subq	$1, %rax
.L4:
	imulq	%rdx, %r8
	movq	%rax, %rdx
	cmpq	%rcx, %rax
	jne	.L6
.L1:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE23:
	.size	fac, .-fac
	.p2align 4
	.globl	pp
	.type	pp, @function
pp:
.LFB24:
	.cfi_startproc
	endbr64
	cmpl	%edi, %esi
	jg	.L10
	movslq	%esi, %rdx
	subl	%esi, %edi
	movl	$1, %r8d
	leaq	1(%rdx), %rax
	leaq	(%rax,%rdi), %rcx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L12:
	addq	$1, %rax
.L9:
	imulq	%rdx, %r8
	movq	%rax, %rdx
	cmpq	%rcx, %rax
	jne	.L12
	movq	%r8, %rax
	ret
	.p2align 4,,10
	.p2align 3
.L10:
	movl	$1, %r8d
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE24:
	.size	pp, .-pp
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	" %d"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$200, %rsp
	.cfi_def_cfa_offset 256
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	180(%rsp), %rax
	movq	%rax, 168(%rsp)
.L31:
	movq	168(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	180(%rsp), %r15d
	testl	%r15d, %r15d
	je	.L14
	movq	$1, 16(%rsp)
	movq	$0, 160(%rsp)
	movq	$0, 48(%rsp)
.L15:
	movq	$-2, %r13
	movq	$-1, %r12
	movq	$-14, %r14
	xorl	%ebp, %ebp
	movq	160(%rsp), %rax
	movl	%eax, %r10d
	movl	%eax, %ebx
	addq	$2, %rax
	movq	%rax, 72(%rsp)
	.p2align 4,,10
	.p2align 3
.L30:
	movq	%rbp, %rdi
	leaq	-3(%rbp), %rax
	movl	%ebp, 8(%rsp)
	addl	$1, %r10d
	imulq	%r12, %rdi
	movl	%r12d, 12(%rsp)
	movq	$-9, %r8
	movl	%r13d, 40(%rsp)
	movl	%r14d, 44(%rsp)
	movq	%rdi, 56(%rsp)
	imulq	%r13, %rdi
	imulq	%rdi, %rax
	movq	%rdi, 64(%rsp)
	movq	%rax, %rsi
	movq	%rax, 80(%rsp)
	leaq	-4(%rbp), %rax
	imulq	%rsi, %rax
	movq	%rax, %rsi
	movq	%rax, 88(%rsp)
	leaq	-5(%rbp), %rax
	imulq	%rsi, %rax
	movq	%rax, %rcx
	movq	%rax, 96(%rsp)
	leaq	-6(%rbp), %rax
	imulq	%rcx, %rax
	movq	%rax, %rdi
	movq	%rax, 104(%rsp)
	leaq	-7(%rbp), %rax
	imulq	%rdi, %rax
	movq	%rax, %rsi
	movq	%rax, 112(%rsp)
	leaq	-8(%rbp), %rax
	imulq	%rsi, %rax
	movq	%rax, %rcx
	movq	%rax, 120(%rsp)
	leaq	-9(%rbp), %rax
	imulq	%rcx, %rax
	movq	%rax, %rdi
	movq	%rax, 128(%rsp)
	leaq	-10(%rbp), %rax
	imulq	%rdi, %rax
	movq	%rax, %rsi
	movq	%rax, 136(%rsp)
	leaq	-11(%rbp), %rax
	imulq	%rsi, %rax
	movl	%ebx, %esi
	movq	%rax, %rcx
	movq	%rax, 144(%rsp)
	leaq	-12(%rbp), %rax
	imulq	%rcx, %rax
	movq	$-1, %rcx
	movq	%rax, %rdi
	movq	%rax, 152(%rsp)
	leaq	-13(%rbp), %rax
	imulq	%rdi, %rax
	xorl	%edi, %edi
	movq	%rax, 32(%rsp)
	imulq	%r14, %rax
	movq	%rax, 24(%rsp)
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L16:
	jl	.L26
.L24:
	addq	$1, %rcx
	addq	$1, %rdi
	addl	$3, %esi
	addq	$1, %r8
	cmpq	$10, %rcx
	je	.L26
.L27:
	cmpl	%esi, %r15d
	jne	.L16
	movq	16(%rsp), %rdx
	leal	(%r10,%rcx), %eax
	movl	%ecx, %r9d
	cmpl	%edx, %eax
	jl	.L33
	movl	8(%rsp), %eax
	leal	(%rax,%rcx), %r11d
	movl	$1, %eax
	addq	72(%rsp), %r11
	.p2align 4,,10
	.p2align 3
.L18:
	imulq	%rdx, %rax
	addq	$1, %rdx
	cmpq	%r11, %rdx
	jne	.L18
.L17:
	testq	%rbp, %rbp
	je	.L23
	movl	12(%rsp), %edx
	testl	%edx, %edx
	je	.L34
	movl	40(%rsp), %r11d
	testl	%r11d, %r11d
	je	.L35
	cmpq	$3, %rbp
	je	.L36
	cmpq	$4, %rbp
	je	.L37
	cmpq	$5, %rbp
	je	.L38
	cmpq	$6, %rbp
	je	.L39
	cmpq	$7, %rbp
	je	.L40
	cmpq	$8, %rbp
	je	.L41
	cmpq	$9, %rbp
	je	.L42
	cmpq	$10, %rbp
	je	.L43
	cmpq	$11, %rbp
	je	.L44
	cmpq	$12, %rbp
	je	.L45
	cmpq	$13, %rbp
	je	.L46
	movl	44(%rsp), %edx
	movq	32(%rsp), %r11
	testl	%edx, %edx
	cmovne	24(%rsp), %r11
.L22:
	cqto
	idivq	%r11
.L23:
	testq	%rdi, %rdi
	je	.L20
	movq	%rdi, %r11
	testl	%ecx, %ecx
	je	.L25
	imulq	%rcx, %r11
	cmpl	$1, %r9d
	je	.L25
	leaq	-1(%rcx), %rdx
	imulq	%rdx, %r11
	cmpl	$2, %r9d
	je	.L25
	leaq	-2(%rcx), %rdx
	imulq	%rdx, %r11
	cmpl	$3, %r9d
	je	.L25
	leaq	-3(%rcx), %rdx
	imulq	%rdx, %r11
	cmpl	$4, %r9d
	je	.L25
	leaq	-4(%rcx), %rdx
	imulq	%rdx, %r11
	cmpl	$5, %r9d
	je	.L25
	leaq	-5(%rcx), %rdx
	imulq	%rdx, %r11
	cmpl	$6, %r9d
	je	.L25
	leaq	-6(%rcx), %rdx
	imulq	%rdx, %r11
	cmpl	$7, %r9d
	je	.L25
	leaq	-7(%rcx), %rdx
	imulq	%rdx, %r11
	testl	%r8d, %r8d
	je	.L25
	imulq	%r8, %r11
.L25:
	cqto
	idivq	%r11
.L20:
	addq	%rax, 48(%rsp)
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L26:
	addq	$1, %rbp
	addl	$2, %ebx
	addq	$1, %r14
	addq	$1, %r12
	addq	$1, %r13
	cmpq	$16, %rbp
	jne	.L30
	addq	$1, 16(%rsp)
	movq	16(%rsp), %rax
	addq	$1, 160(%rsp)
	cmpq	$32, %rax
	jne	.L15
	movq	48(%rsp), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	movabsq	$-8096351782488411421, %rax
	shrq	%rdx
	mulq	%rdx
	xorl	%eax, %eax
	shrq	$10, %rdx
	addq	$1, %rdx
	call	__printf_chk@PLT
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L33:
	movl	$1, %eax
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L34:
	movq	%rbp, %r11
	jmp	.L22
.L35:
	movq	56(%rsp), %r11
	jmp	.L22
.L36:
	movq	64(%rsp), %r11
	jmp	.L22
.L37:
	movq	80(%rsp), %r11
	jmp	.L22
.L38:
	movq	88(%rsp), %r11
	jmp	.L22
.L39:
	movq	96(%rsp), %r11
	jmp	.L22
.L40:
	movq	104(%rsp), %r11
	jmp	.L22
.L41:
	movq	112(%rsp), %r11
	jmp	.L22
.L42:
	movq	120(%rsp), %r11
	jmp	.L22
.L43:
	movq	128(%rsp), %r11
	jmp	.L22
.L44:
	movq	136(%rsp), %r11
	jmp	.L22
.L45:
	movq	144(%rsp), %r11
	jmp	.L22
.L46:
	movq	152(%rsp), %r11
	jmp	.L22
.L14:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L76
	addq	$200, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L76:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.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
	.p2align 4
	.globl	fac
	.type	fac, @function
fac:
.LFB23:
	.cfi_startproc
	endbr64
	movl	$1, %r8d
	testl	%edi, %edi
	je	.L1
	movslq	%edi, %rdx
	leal	-1(%rdi), %esi
	movl	$1, %r8d
	leaq	-1(%rdx), %rax
	movq	%rax, %rcx
	subq	%rsi, %rcx
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L6:
	subq	$1, %rax
.L4:
	imulq	%rdx, %r8
	movq	%rax, %rdx
	cmpq	%rcx, %rax
	jne	.L6
.L1:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE23:
	.size	fac, .-fac
	.p2align 4
	.globl	pp
	.type	pp, @function
pp:
.LFB24:
	.cfi_startproc
	endbr64
	cmpl	%edi, %esi
	jg	.L10
	movslq	%esi, %rdx
	subl	%esi, %edi
	movl	$1, %r8d
	leaq	1(%rdx), %rax
	leaq	(%rax,%rdi), %rcx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L12:
	addq	$1, %rax
.L9:
	imulq	%rdx, %r8
	movq	%rax, %rdx
	cmpq	%rcx, %rax
	jne	.L12
	movq	%r8, %rax
	ret
	.p2align 4,,10
	.p2align 3
.L10:
	movl	$1, %r8d
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE24:
	.size	pp, .-pp
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	" %d"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$200, %rsp
	.cfi_def_cfa_offset 256
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	180(%rsp), %rax
	movq	%rax, 168(%rsp)
.L31:
	movq	168(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	180(%rsp), %r15d
	testl	%r15d, %r15d
	je	.L14
	movq	$1, 16(%rsp)
	movq	$0, 160(%rsp)
	movq	$0, 48(%rsp)
.L15:
	movq	$-2, %r13
	movq	$-1, %r12
	movq	$-14, %r14
	xorl	%ebp, %ebp
	movq	160(%rsp), %rax
	movl	%eax, %r10d
	movl	%eax, %ebx
	addq	$2, %rax
	movq	%rax, 72(%rsp)
	.p2align 4,,10
	.p2align 3
.L30:
	movq	%rbp, %rdi
	leaq	-3(%rbp), %rax
	movl	%ebp, 8(%rsp)
	addl	$1, %r10d
	imulq	%r12, %rdi
	movl	%r12d, 12(%rsp)
	movq	$-9, %r8
	movl	%r13d, 40(%rsp)
	movl	%r14d, 44(%rsp)
	movq	%rdi, 56(%rsp)
	imulq	%r13, %rdi
	imulq	%rdi, %rax
	movq	%rdi, 64(%rsp)
	movq	%rax, %rsi
	movq	%rax, 80(%rsp)
	leaq	-4(%rbp), %rax
	imulq	%rsi, %rax
	movq	%rax, %rsi
	movq	%rax, 88(%rsp)
	leaq	-5(%rbp), %rax
	imulq	%rsi, %rax
	movq	%rax, %rcx
	movq	%rax, 96(%rsp)
	leaq	-6(%rbp), %rax
	imulq	%rcx, %rax
	movq	%rax, %rdi
	movq	%rax, 104(%rsp)
	leaq	-7(%rbp), %rax
	imulq	%rdi, %rax
	movq	%rax, %rsi
	movq	%rax, 112(%rsp)
	leaq	-8(%rbp), %rax
	imulq	%rsi, %rax
	movq	%rax, %rcx
	movq	%rax, 120(%rsp)
	leaq	-9(%rbp), %rax
	imulq	%rcx, %rax
	movq	%rax, %rdi
	movq	%rax, 128(%rsp)
	leaq	-10(%rbp), %rax
	imulq	%rdi, %rax
	movq	%rax, %rsi
	movq	%rax, 136(%rsp)
	leaq	-11(%rbp), %rax
	imulq	%rsi, %rax
	movl	%ebx, %esi
	movq	%rax, %rcx
	movq	%rax, 144(%rsp)
	leaq	-12(%rbp), %rax
	imulq	%rcx, %rax
	movq	$-1, %rcx
	movq	%rax, %rdi
	movq	%rax, 152(%rsp)
	leaq	-13(%rbp), %rax
	imulq	%rdi, %rax
	xorl	%edi, %edi
	movq	%rax, 32(%rsp)
	imulq	%r14, %rax
	movq	%rax, 24(%rsp)
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L16:
	jl	.L26
.L24:
	addq	$1, %rcx
	addq	$1, %rdi
	addl	$3, %esi
	addq	$1, %r8
	cmpq	$10, %rcx
	je	.L26
.L27:
	cmpl	%esi, %r15d
	jne	.L16
	movq	16(%rsp), %rdx
	leal	(%r10,%rcx), %eax
	movl	%ecx, %r9d
	cmpl	%edx, %eax
	jl	.L33
	movl	8(%rsp), %eax
	leal	(%rax,%rcx), %r11d
	movl	$1, %eax
	addq	72(%rsp), %r11
	.p2align 4,,10
	.p2align 3
.L18:
	imulq	%rdx, %rax
	addq	$1, %rdx
	cmpq	%r11, %rdx
	jne	.L18
.L17:
	testq	%rbp, %rbp
	je	.L23
	movl	12(%rsp), %edx
	testl	%edx, %edx
	je	.L34
	movl	40(%rsp), %r11d
	testl	%r11d, %r11d
	je	.L35
	cmpq	$3, %rbp
	je	.L36
	cmpq	$4, %rbp
	je	.L37
	cmpq	$5, %rbp
	je	.L38
	cmpq	$6, %rbp
	je	.L39
	cmpq	$7, %rbp
	je	.L40
	cmpq	$8, %rbp
	je	.L41
	cmpq	$9, %rbp
	je	.L42
	cmpq	$10, %rbp
	je	.L43
	cmpq	$11, %rbp
	je	.L44
	cmpq	$12, %rbp
	je	.L45
	cmpq	$13, %rbp
	je	.L46
	movl	44(%rsp), %edx
	movq	32(%rsp), %r11
	testl	%edx, %edx
	cmovne	24(%rsp), %r11
.L22:
	cqto
	idivq	%r11
.L23:
	testq	%rdi, %rdi
	je	.L20
	movq	%rdi, %r11
	testl	%ecx, %ecx
	je	.L25
	imulq	%rcx, %r11
	cmpl	$1, %r9d
	je	.L25
	leaq	-1(%rcx), %rdx
	imulq	%rdx, %r11
	cmpl	$2, %r9d
	je	.L25
	leaq	-2(%rcx), %rdx
	imulq	%rdx, %r11
	cmpl	$3, %r9d
	je	.L25
	leaq	-3(%rcx), %rdx
	imulq	%rdx, %r11
	cmpl	$4, %r9d
	je	.L25
	leaq	-4(%rcx), %rdx
	imulq	%rdx, %r11
	cmpl	$5, %r9d
	je	.L25
	leaq	-5(%rcx), %rdx
	imulq	%rdx, %r11
	cmpl	$6, %r9d
	je	.L25
	leaq	-6(%rcx), %rdx
	imulq	%rdx, %r11
	cmpl	$7, %r9d
	je	.L25
	leaq	-7(%rcx), %rdx
	imulq	%rdx, %r11
	testl	%r8d, %r8d
	je	.L25
	imulq	%r8, %r11
.L25:
	cqto
	idivq	%r11
.L20:
	addq	%rax, 48(%rsp)
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L26:
	addq	$1, %rbp
	addl	$2, %ebx
	addq	$1, %r14
	addq	$1, %r12
	addq	$1, %r13
	cmpq	$16, %rbp
	jne	.L30
	addq	$1, 16(%rsp)
	movq	16(%rsp), %rax
	addq	$1, 160(%rsp)
	cmpq	$32, %rax
	jne	.L15
	movq	48(%rsp), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	movabsq	$-8096351782488411421, %rax
	shrq	%rdx
	mulq	%rdx
	xorl	%eax, %eax
	shrq	$10, %rdx
	addq	$1, %rdx
	call	__printf_chk@PLT
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L33:
	movl	$1, %eax
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L34:
	movq	%rbp, %r11
	jmp	.L22
.L35:
	movq	56(%rsp), %r11
	jmp	.L22
.L36:
	movq	64(%rsp), %r11
	jmp	.L22
.L37:
	movq	80(%rsp), %r11
	jmp	.L22
.L38:
	movq	88(%rsp), %r11
	jmp	.L22
.L39:
	movq	96(%rsp), %r11
	jmp	.L22
.L40:
	movq	104(%rsp), %r11
	jmp	.L22
.L41:
	movq	112(%rsp), %r11
	jmp	.L22
.L42:
	movq	120(%rsp), %r11
	jmp	.L22
.L43:
	movq	128(%rsp), %r11
	jmp	.L22
.L44:
	movq	136(%rsp), %r11
	jmp	.L22
.L45:
	movq	144(%rsp), %r11
	jmp	.L22
.L46:
	movq	152(%rsp), %r11
	jmp	.L22
.L14:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L76
	addq	$200, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L76:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.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>

long fac(int x){
	if(x==0) return 1;
	else return x*fac(x-1);
}

long pp(int a, int b){
	int i;
	long ans=1;
	
	for(i=b; i<=a; i++) ans*=i;
	
	return ans;
}

int main(void){
	while(1){
		long count=0;
		int i, j, k, n;		
		
		scanf(" %d", &n);
		if(n==0) break;
		
		for(i=0; i<=30; i++){
			for(j=0; j<=15; j++){
				for(k=0; k<=10; k++){
					if(i + 2*j + 3*k == n) count += pp(i+j+k, i+1)/fac(j)/fac(k);
					else if(i + 2*j + 3*k > n) break;
				}		
			}
		}
		
		printf("%ld\n", count / 3650 + 1);
	}
	
	return 0;
}
1
10
14
25
0
 1
10
14
23
0
 1
10
14
6
0
 1
1
20
25
0
 1
10
14
24
0
 1
10
0
25
0
 1
19
14
5
0
 1
18
0
25
0
 1
18
1
25
0
 1
0
14
6
0

1
1
1
701
 1
1
1
207
 1
1
1
1
 1
1
34
701
 1
1
1
381
 1
1
 1
19
1
1
 1
10
 1
10
1
701
 1

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>

long fac(int x){
	if(x==0) return 1;
	else return x*fac(x-1);
}

long pp(int a, int b){
	int i;
	long ans=1;
	
	for(i=b; i<=a; i++) ans*=i;
	
	return ans;
}

int main(void){
	while(1){
		long count=0;
		int i, j, k, n;		
		
		scanf(" %d", &n);
		if(n==0) break;
		
		for(i=0; i<=30; i++){
			for(j=0; j<=15; j++){
				for(k=0; k<=10; k++){
					if(i + 2*j + 3*k == n) count += pp(i+j+k, i+1)/fac(j)/fac(k);
					else if(i + 2*j + 3*k > n) break;
				}		
			}
		}
		
		printf("%ld\n", count / 3650 + 1);
	}
	
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	fac
	.type	fac, @function
fac:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movl	%edi, -20(%rbp)
	cmpl	$0, -20(%rbp)
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movl	-20(%rbp), %eax
	movslq	%eax, %rbx
	movl	-20(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %edi
	call	fac
	imulq	%rbx, %rax
.L3:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	fac, .-fac
	.globl	pp
	.type	pp, @function
pp:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movq	$1, -8(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L5
.L6:
	movl	-12(%rbp), %eax
	cltq
	movq	-8(%rbp), %rdx
	imulq	%rdx, %rax
	movq	%rax, -8(%rbp)
	addl	$1, -12(%rbp)
.L5:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L6
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	pp, .-pp
	.section	.rodata
.LC0:
	.string	" %d"
.LC1:
	.string	"%ld\n"
	.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
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
.L20:
	movq	$0, -32(%rbp)
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-48(%rbp), %eax
	testl	%eax, %eax
	jne	.L9
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	jmp	.L22
.L9:
	movl	$0, -44(%rbp)
	jmp	.L11
.L19:
	movl	$0, -40(%rbp)
	jmp	.L12
.L18:
	movl	$0, -36(%rbp)
	jmp	.L13
.L17:
	movl	-40(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-44(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-36(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	leal	(%rcx,%rax), %edx
	movl	-48(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L14
	movl	-44(%rbp), %eax
	leal	1(%rax), %edx
	movl	-44(%rbp), %ecx
	movl	-40(%rbp), %eax
	addl	%eax, %ecx
	movl	-36(%rbp), %eax
	addl	%ecx, %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	pp
	movq	%rax, %rbx
	movl	-40(%rbp), %eax
	movl	%eax, %edi
	call	fac
	movq	%rax, %rsi
	movq	%rbx, %rax
	cqto
	idivq	%rsi
	movq	%rax, %rbx
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	fac
	movq	%rax, %rsi
	movq	%rbx, %rax
	cqto
	idivq	%rsi
	addq	%rax, -32(%rbp)
	jmp	.L15
.L14:
	movl	-40(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-44(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-36(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	leal	(%rcx,%rax), %edx
	movl	-48(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L23
.L15:
	addl	$1, -36(%rbp)
.L13:
	cmpl	$10, -36(%rbp)
	jle	.L17
	jmp	.L16
.L23:
	nop
.L16:
	addl	$1, -40(%rbp)
.L12:
	cmpl	$15, -40(%rbp)
	jle	.L18
	addl	$1, -44(%rbp)
.L11:
	cmpl	$30, -44(%rbp)
	jle	.L19
	movq	-32(%rbp), %rcx
	movabsq	$-8096351782488411421, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$11, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	addq	$1, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L20
.L22:
	call	__stack_chk_fail@PLT
.L21:
	movq	-8(%rbp), %rbx
	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	fac
	.type	fac, @function
fac:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movl	%edi, -20(%rbp)
	cmpl	$0, -20(%rbp)
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movl	-20(%rbp), %eax
	movslq	%eax, %rbx
	movl	-20(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %edi
	call	fac
	imulq	%rbx, %rax
.L3:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	fac, .-fac
	.globl	pp
	.type	pp, @function
pp:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movq	$1, -8(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L5
.L6:
	movl	-12(%rbp), %eax
	cltq
	movq	-8(%rbp), %rdx
	imulq	%rdx, %rax
	movq	%rax, -8(%rbp)
	addl	$1, -12(%rbp)
.L5:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L6
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	pp, .-pp
	.section	.rodata
.LC0:
	.string	" %d"
.LC1:
	.string	"%ld\n"
	.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
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
.L20:
	movq	$0, -32(%rbp)
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-48(%rbp), %eax
	testl	%eax, %eax
	jne	.L9
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	jmp	.L22
.L9:
	movl	$0, -44(%rbp)
	jmp	.L11
.L19:
	movl	$0, -40(%rbp)
	jmp	.L12
.L18:
	movl	$0, -36(%rbp)
	jmp	.L13
.L17:
	movl	-40(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-44(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-36(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	leal	(%rcx,%rax), %edx
	movl	-48(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L14
	movl	-44(%rbp), %eax
	leal	1(%rax), %edx
	movl	-44(%rbp), %ecx
	movl	-40(%rbp), %eax
	addl	%eax, %ecx
	movl	-36(%rbp), %eax
	addl	%ecx, %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	pp
	movq	%rax, %rbx
	movl	-40(%rbp), %eax
	movl	%eax, %edi
	call	fac
	movq	%rax, %rsi
	movq	%rbx, %rax
	cqto
	idivq	%rsi
	movq	%rax, %rbx
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	fac
	movq	%rax, %rsi
	movq	%rbx, %rax
	cqto
	idivq	%rsi
	addq	%rax, -32(%rbp)
	jmp	.L15
.L14:
	movl	-40(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-44(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-36(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	leal	(%rcx,%rax), %edx
	movl	-48(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L23
.L15:
	addl	$1, -36(%rbp)
.L13:
	cmpl	$10, -36(%rbp)
	jle	.L17
	jmp	.L16
.L23:
	nop
.L16:
	addl	$1, -40(%rbp)
.L12:
	cmpl	$15, -40(%rbp)
	jle	.L18
	addl	$1, -44(%rbp)
.L11:
	cmpl	$30, -44(%rbp)
	jle	.L19
	movq	-32(%rbp), %rcx
	movabsq	$-8096351782488411421, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$11, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	addq	$1, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L20
.L22:
	call	__stack_chk_fail@PLT
.L21:
	movq	-8(%rbp), %rbx
	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:
