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 memo[100][4][4];
int rireki[102];
int calc(int yotei[100],int day,int max);

int main(int argc,char* argv[]) {
	int N,K;
	int yotei[100]={0};
	int rireki[200];
	int i,j;
	int oneyotei,onepasta;
	scanf("%d %d",&N,&K);
	for(i=0;i<K;i++) {
		scanf("%d %d",&oneyotei,&onepasta);
		yotei[oneyotei-1]=onepasta;
	}
	for(i=0;i<100;i++) {
		for(j=0;j<4;j++) {
			memo[i][j][0]=-1;
			memo[i][j][1]=-1;
			memo[i][j][2]=-1;
			memo[i][j][3]=-1;
		}
	}
	rireki[0]=0;
	rireki[1]=0;
	printf("%d\n",calc(yotei,0,N));
	return 0;
}

int calc(int yotei[100],int day,int max) {
	int mode;
	int result=0;
	if(rireki[day]==rireki[day+1])mode=rireki[day];
	else mode=0;
	if(day>=max)return 1;
	if(memo[day][rireki[day]][rireki[day+1]]>=0)
		return memo[day][rireki[day]][rireki[day+1]];
	if(yotei[day]!=0) {
		if(mode!=yotei[day]) {
			rireki[day+2]=yotei[day];
			result+=calc(yotei,day+1,max);
		}
	} else {
		if(mode!=1) {
			rireki[day+2]=1;
			result+=calc(yotei,day+1,max);
		}
		if(mode!=2) {
			rireki[day+2]=2;
			result+=calc(yotei,day+1,max);
		}
		if(mode!=3) {
			rireki[day+2]=3;
			result+=calc(yotei,day+1,max);
		}
	}
	result%=10000;
	memo[day][rireki[day]][rireki[day+1]]=result;
	return result;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	memo
	.bss
	.align 32
	.type	memo, @object
	.size	memo, 6400
memo:
	.zero	6400
	.globl	rireki
	.align 32
	.type	rireki, @object
	.size	rireki, 408
rireki:
	.zero	408
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.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
	subq	$1264, %rsp
	movl	%edi, -1252(%rbp)
	movq	%rsi, -1264(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-1216(%rbp), %rdx
	movl	$0, %eax
	movl	$50, %ecx
	movq	%rdx, %rdi
	rep stosq
	leaq	-1236(%rbp), %rdx
	leaq	-1240(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1224(%rbp)
	jmp	.L2
.L3:
	leaq	-1228(%rbp), %rdx
	leaq	-1232(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-1232(%rbp), %eax
	subl	$1, %eax
	movl	-1228(%rbp), %edx
	cltq
	movl	%edx, -1216(%rbp,%rax,4)
	addl	$1, -1224(%rbp)
.L2:
	movl	-1236(%rbp), %eax
	cmpl	%eax, -1224(%rbp)
	jl	.L3
	movl	$0, -1224(%rbp)
	jmp	.L4
.L7:
	movl	$0, -1220(%rbp)
	jmp	.L5
.L6:
	movl	-1220(%rbp), %eax
	movslq	%eax, %rdx
	movl	-1224(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	memo(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-1220(%rbp), %eax
	movslq	%eax, %rdx
	movl	-1224(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	4+memo(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-1220(%rbp), %eax
	movslq	%eax, %rdx
	movl	-1224(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	8+memo(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-1220(%rbp), %eax
	movslq	%eax, %rdx
	movl	-1224(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	12+memo(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -1220(%rbp)
.L5:
	cmpl	$3, -1220(%rbp)
	jle	.L6
	addl	$1, -1224(%rbp)
.L4:
	cmpl	$99, -1224(%rbp)
	jle	.L7
	movl	$0, -816(%rbp)
	movl	$0, -812(%rbp)
	movl	-1240(%rbp), %edx
	leaq	-1216(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	calc
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	calc
	.type	calc, @function
calc:
.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
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	$0, -4(%rbp)
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rireki(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L11
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	jmp	.L12
.L11:
	movl	$0, -8(%rbp)
.L12:
	movl	-28(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jl	.L13
	movl	$1, %eax
	jmp	.L14
.L13:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rireki(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	cltq
	movslq	%edx, %rdx
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	memo(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L15
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rireki(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	cltq
	movslq	%edx, %rdx
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	memo(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L14
.L15:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L16
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -8(%rbp)
	je	.L17
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-28(%rbp), %edx
	addl	$2, %edx
	movl	(%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	rireki(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-28(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	calc
	addl	%eax, -4(%rbp)
	jmp	.L17
.L16:
	cmpl	$1, -8(%rbp)
	je	.L18
	movl	-28(%rbp), %eax
	addl	$2, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-28(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	calc
	addl	%eax, -4(%rbp)
.L18:
	cmpl	$2, -8(%rbp)
	je	.L19
	movl	-28(%rbp), %eax
	addl	$2, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	$2, (%rdx,%rax)
	movl	-28(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	calc
	addl	%eax, -4(%rbp)
.L19:
	cmpl	$3, -8(%rbp)
	je	.L17
	movl	-28(%rbp), %eax
	addl	$2, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	$3, (%rdx,%rax)
	movl	-28(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	calc
	addl	%eax, -4(%rbp)
.L17:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1759218605, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$12, %edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	imull	$10000, %edx, %edx
	subl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rireki(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	cltq
	movslq	%edx, %rdx
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	memo(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	calc, .-calc
	.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	calc
	.type	calc, @function
calc:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%r15d, %r15d
	movl	$1, %r8d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movslq	%esi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leal	1(%r14), %esi
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movslq	%esi, %rcx
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	rireki(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movslq	0(%rbp,%r14,4), %rdx
	movslq	0(%rbp,%rcx,4), %rdi
	cmpl	%edi, %edx
	cmove	%edx, %r15d
	cmpl	%r12d, %r14d
	jge	.L1
	leaq	(%rdx,%r14,4), %r8
	leaq	memo(%rip), %rbx
	leaq	(%rdi,%r8,4), %r8
	movl	(%rbx,%r8,4), %r8d
	testl	%r8d, %r8d
	jns	.L1
	movl	0(%r13,%r14,4), %r10d
	movq	%r14, %rax
	testl	%r10d, %r10d
	je	.L4
	movq	%rcx, (%rsp)
	xorl	%r8d, %r8d
	cmpl	%r15d, %r10d
	je	.L5
	addl	$2, %eax
	movl	%r12d, %edx
	movq	%r13, %rdi
	cltq
	movl	%r10d, 0(%rbp,%rax,4)
	call	calc
	movq	(%rsp), %rcx
	movslq	%eax, %r8
	cltd
	imulq	$1759218605, %r8, %r8
	movslq	0(%rbp,%rcx,4), %rdi
	sarq	$44, %r8
	subl	%edx, %r8d
	imull	$10000, %r8d, %edx
	subl	%edx, %eax
	movslq	0(%rbp,%r14,4), %rdx
	movl	%eax, %r8d
.L5:
	leaq	(%rdx,%r14,4), %rax
	leaq	(%rdi,%rax,4), %rax
	movl	%r8d, (%rbx,%rax,4)
.L1:
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r8d, %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
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	addl	$2, %eax
	movq	%rcx, 16(%rsp)
	cltq
	movq	%rax, (%rsp)
	cmpl	$1, %r15d
	jne	.L16
	movl	%r12d, %edx
	movq	%r13, %rdi
	movl	%esi, 12(%rsp)
	movl	$2, 0(%rbp,%rax,4)
	call	calc
	movl	12(%rsp), %esi
	movq	16(%rsp), %rcx
	movl	%eax, %r10d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L16:
	movl	%r12d, %edx
	movq	%r13, %rdi
	movl	%esi, 12(%rsp)
	movl	$1, 0(%rbp,%rax,4)
	call	calc
	cmpl	$2, %r15d
	movl	12(%rsp), %esi
	movq	16(%rsp), %rcx
	movl	%eax, %r10d
	jne	.L17
.L7:
	movq	(%rsp), %rax
	movl	%r12d, %edx
	movq	%r13, %rdi
	movq	%rcx, 16(%rsp)
	movl	%r10d, 12(%rsp)
	movl	$3, 0(%rbp,%rax,4)
	call	calc
	movl	12(%rsp), %r10d
	movq	16(%rsp), %rcx
	addl	%r10d, %eax
	movslq	0(%rbp,%rcx,4), %rdi
	movslq	%eax, %r8
	cltd
	imulq	$1759218605, %r8, %r8
	sarq	$44, %r8
	subl	%edx, %r8d
	imull	$10000, %r8d, %edx
	subl	%edx, %eax
	movslq	0(%rbp,%r14,4), %rdx
	movl	%eax, %r8d
	jmp	.L5
.L17:
	movl	%eax, 16(%rsp)
	movq	(%rsp), %rax
	movl	%r12d, %edx
	movq	%r13, %rdi
	movq	%rcx, 24(%rsp)
	movl	$2, 0(%rbp,%rax,4)
	call	calc
	movl	16(%rsp), %r10d
	movl	12(%rsp), %esi
	movq	24(%rsp), %rcx
	addl	%eax, %r10d
	cmpl	$3, %r15d
	jne	.L7
	movslq	%r10d, %r8
	movl	%r10d, %eax
	movslq	0(%rbp,%rcx,4), %rdi
	movslq	0(%rbp,%r14,4), %rdx
	imulq	$1759218605, %r8, %r8
	sarl	$31, %eax
	sarq	$44, %r8
	subl	%eax, %r8d
	imull	$10000, %r8d, %eax
	subl	%eax, %r10d
	movl	%r10d, %r8d
	jmp	.L5
	.cfi_endproc
.LFE24:
	.size	calc, .-calc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$50, %ecx
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC0(%rip), %rbx
	subq	$432, %rsp
	.cfi_def_cfa_offset 480
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rbp
	leaq	4(%rsp), %rdx
	movq	%rsp, %rsi
	movq	%rbp, %rdi
	rep stosq
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	testl	%eax, %eax
	jle	.L19
	xorl	%r14d, %r14d
	leaq	12(%rsp), %r13
	leaq	8(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L20:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %eax
	movl	12(%rsp), %edx
	addl	$1, %r14d
	subl	$1, %eax
	cltq
	movl	%edx, 16(%rsp,%rax,4)
	cmpl	%r14d, 4(%rsp)
	jg	.L20
.L19:
	leaq	memo(%rip), %rax
	pcmpeqd	%xmm0, %xmm0
	leaq	6400(%rax), %rdx
	.p2align 4,,10
	.p2align 3
.L21:
	movaps	%xmm0, (%rax)
	addq	$64, %rax
	movaps	%xmm0, -48(%rax)
	movaps	%xmm0, -32(%rax)
	movaps	%xmm0, -16(%rax)
	cmpq	%rdx, %rax
	jne	.L21
	movl	(%rsp), %edx
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	calc
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	addq	$432, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L26:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	rireki
	.bss
	.align 32
	.type	rireki, @object
	.size	rireki, 408
rireki:
	.zero	408
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 6400
memo:
	.zero	6400
	.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	calc
	.type	calc, @function
calc:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%r15d, %r15d
	movl	$1, %r8d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movslq	%esi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leal	1(%r14), %esi
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movslq	%esi, %rcx
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	rireki(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movslq	0(%rbp,%r14,4), %rdx
	movslq	0(%rbp,%rcx,4), %rdi
	cmpl	%edi, %edx
	cmove	%edx, %r15d
	cmpl	%r12d, %r14d
	jge	.L1
	leaq	(%rdx,%r14,4), %r8
	leaq	memo(%rip), %rbx
	leaq	(%rdi,%r8,4), %r8
	movl	(%rbx,%r8,4), %r8d
	testl	%r8d, %r8d
	jns	.L1
	movl	0(%r13,%r14,4), %r10d
	movq	%r14, %rax
	testl	%r10d, %r10d
	je	.L4
	movq	%rcx, (%rsp)
	xorl	%r8d, %r8d
	cmpl	%r15d, %r10d
	je	.L5
	addl	$2, %eax
	movl	%r12d, %edx
	movq	%r13, %rdi
	cltq
	movl	%r10d, 0(%rbp,%rax,4)
	call	calc
	movq	(%rsp), %rcx
	movslq	%eax, %r8
	cltd
	imulq	$1759218605, %r8, %r8
	movslq	0(%rbp,%rcx,4), %rdi
	sarq	$44, %r8
	subl	%edx, %r8d
	imull	$10000, %r8d, %edx
	subl	%edx, %eax
	movslq	0(%rbp,%r14,4), %rdx
	movl	%eax, %r8d
.L5:
	leaq	(%rdx,%r14,4), %rax
	leaq	(%rdi,%rax,4), %rax
	movl	%r8d, (%rbx,%rax,4)
.L1:
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r8d, %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
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	addl	$2, %eax
	movq	%rcx, 16(%rsp)
	cltq
	movq	%rax, (%rsp)
	cmpl	$1, %r15d
	jne	.L16
	movl	%r12d, %edx
	movq	%r13, %rdi
	movl	%esi, 12(%rsp)
	movl	$2, 0(%rbp,%rax,4)
	call	calc
	movl	12(%rsp), %esi
	movq	16(%rsp), %rcx
	movl	%eax, %r10d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L16:
	movl	%r12d, %edx
	movq	%r13, %rdi
	movl	%esi, 12(%rsp)
	movl	$1, 0(%rbp,%rax,4)
	call	calc
	cmpl	$2, %r15d
	movl	12(%rsp), %esi
	movq	16(%rsp), %rcx
	movl	%eax, %r10d
	jne	.L17
.L7:
	movq	(%rsp), %rax
	movl	%r12d, %edx
	movq	%r13, %rdi
	movq	%rcx, 16(%rsp)
	movl	%r10d, 12(%rsp)
	movl	$3, 0(%rbp,%rax,4)
	call	calc
	movl	12(%rsp), %r10d
	movq	16(%rsp), %rcx
	addl	%r10d, %eax
	movslq	0(%rbp,%rcx,4), %rdi
	movslq	%eax, %r8
	cltd
	imulq	$1759218605, %r8, %r8
	sarq	$44, %r8
	subl	%edx, %r8d
	imull	$10000, %r8d, %edx
	subl	%edx, %eax
	movslq	0(%rbp,%r14,4), %rdx
	movl	%eax, %r8d
	jmp	.L5
.L17:
	movl	%eax, 16(%rsp)
	movq	(%rsp), %rax
	movl	%r12d, %edx
	movq	%r13, %rdi
	movq	%rcx, 24(%rsp)
	movl	$2, 0(%rbp,%rax,4)
	call	calc
	movl	16(%rsp), %r10d
	movl	12(%rsp), %esi
	movq	24(%rsp), %rcx
	addl	%eax, %r10d
	cmpl	$3, %r15d
	jne	.L7
	movslq	%r10d, %r8
	movl	%r10d, %eax
	movslq	0(%rbp,%rcx,4), %rdi
	movslq	0(%rbp,%r14,4), %rdx
	imulq	$1759218605, %r8, %r8
	sarl	$31, %eax
	sarq	$44, %r8
	subl	%eax, %r8d
	imull	$10000, %r8d, %eax
	subl	%eax, %r10d
	movl	%r10d, %r8d
	jmp	.L5
	.cfi_endproc
.LFE24:
	.size	calc, .-calc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$50, %ecx
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC0(%rip), %rbx
	subq	$432, %rsp
	.cfi_def_cfa_offset 480
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rbp
	leaq	4(%rsp), %rdx
	movq	%rsp, %rsi
	movq	%rbp, %rdi
	rep stosq
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	testl	%eax, %eax
	jle	.L19
	xorl	%r14d, %r14d
	leaq	12(%rsp), %r13
	leaq	8(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L20:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %eax
	movl	12(%rsp), %edx
	addl	$1, %r14d
	subl	$1, %eax
	cltq
	movl	%edx, 16(%rsp,%rax,4)
	cmpl	%r14d, 4(%rsp)
	jg	.L20
.L19:
	leaq	memo(%rip), %rax
	pcmpeqd	%xmm0, %xmm0
	leaq	6400(%rax), %rdx
	.p2align 4,,10
	.p2align 3
.L21:
	movaps	%xmm0, (%rax)
	addq	$64, %rax
	movaps	%xmm0, -48(%rax)
	movaps	%xmm0, -32(%rax)
	movaps	%xmm0, -16(%rax)
	cmpq	%rdx, %rax
	jne	.L21
	movl	(%rsp), %edx
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	calc
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	addq	$432, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L26:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	rireki
	.bss
	.align 32
	.type	rireki, @object
	.size	rireki, 408
rireki:
	.zero	408
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 6400
memo:
	.zero	6400
	.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 memo[100][4][4];
int rireki[102];
int calc(int yotei[100],int day,int max);

int main(int argc,char* argv[]) {
	int N,K;
	int yotei[100]={0};
	int rireki[200];
	int i,j;
	int oneyotei,onepasta;
	scanf("%d %d",&N,&K);
	for(i=0;i<K;i++) {
		scanf("%d %d",&oneyotei,&onepasta);
		yotei[oneyotei-1]=onepasta;
	}
	for(i=0;i<100;i++) {
		for(j=0;j<4;j++) {
			memo[i][j][0]=-1;
			memo[i][j][1]=-1;
			memo[i][j][2]=-1;
			memo[i][j][3]=-1;
		}
	}
	rireki[0]=0;
	rireki[1]=0;
	printf("%d\n",calc(yotei,0,N));
	return 0;
}

int calc(int yotei[100],int day,int max) {
	int mode;
	int result=0;
	if(rireki[day]==rireki[day+1])mode=rireki[day];
	else mode=0;
	if(day>=max)return 1;
	if(memo[day][rireki[day]][rireki[day+1]]>=0)
		return memo[day][rireki[day]][rireki[day+1]];
	if(yotei[day]!=0) {
		if(mode!=yotei[day]) {
			rireki[day+2]=yotei[day];
			result+=calc(yotei,day+1,max);
		}
	} else {
		if(mode!=1) {
			rireki[day+2]=1;
			result+=calc(yotei,day+1,max);
		}
		if(mode!=2) {
			rireki[day+2]=2;
			result+=calc(yotei,day+1,max);
		}
		if(mode!=3) {
			rireki[day+2]=3;
			result+=calc(yotei,day+1,max);
		}
	}
	result%=10000;
	memo[day][rireki[day]][rireki[day+1]]=result;
	return result;
}
5 3
3 1
1 1
4 1
 5 3
5 1
1 1
4 1
 5 3
3 2
1 1
4 1
 5 2
3 1
1 1
4 1
 9 3
5 1
1 1
4 1
 5 1
3 1
1 1
4 1
 9 3
5 1
1 1
4 2
 5 3
4 1
1 1
4 1
 9 3
5 1
1 2
4 2
 5 3
5 2
1 1
4 2

4
 6
 9
 16
 264
 60
 420
 22
 480
 5

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 memo[100][4][4];
int rireki[102];
int calc(int yotei[100],int day,int max);

int main(int argc,char* argv[]) {
	int N,K;
	int yotei[100]={0};
	int rireki[200];
	int i,j;
	int oneyotei,onepasta;
	scanf("%d %d",&N,&K);
	for(i=0;i<K;i++) {
		scanf("%d %d",&oneyotei,&onepasta);
		yotei[oneyotei-1]=onepasta;
	}
	for(i=0;i<100;i++) {
		for(j=0;j<4;j++) {
			memo[i][j][0]=-1;
			memo[i][j][1]=-1;
			memo[i][j][2]=-1;
			memo[i][j][3]=-1;
		}
	}
	rireki[0]=0;
	rireki[1]=0;
	printf("%d\n",calc(yotei,0,N));
	return 0;
}

int calc(int yotei[100],int day,int max) {
	int mode;
	int result=0;
	if(rireki[day]==rireki[day+1])mode=rireki[day];
	else mode=0;
	if(day>=max)return 1;
	if(memo[day][rireki[day]][rireki[day+1]]>=0)
		return memo[day][rireki[day]][rireki[day+1]];
	if(yotei[day]!=0) {
		if(mode!=yotei[day]) {
			rireki[day+2]=yotei[day];
			result+=calc(yotei,day+1,max);
		}
	} else {
		if(mode!=1) {
			rireki[day+2]=1;
			result+=calc(yotei,day+1,max);
		}
		if(mode!=2) {
			rireki[day+2]=2;
			result+=calc(yotei,day+1,max);
		}
		if(mode!=3) {
			rireki[day+2]=3;
			result+=calc(yotei,day+1,max);
		}
	}
	result%=10000;
	memo[day][rireki[day]][rireki[day+1]]=result;
	return result;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	memo
	.bss
	.align 32
	.type	memo, @object
	.size	memo, 6400
memo:
	.zero	6400
	.globl	rireki
	.align 32
	.type	rireki, @object
	.size	rireki, 408
rireki:
	.zero	408
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.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
	subq	$1264, %rsp
	movl	%edi, -1252(%rbp)
	movq	%rsi, -1264(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-1216(%rbp), %rdx
	movl	$0, %eax
	movl	$50, %ecx
	movq	%rdx, %rdi
	rep stosq
	leaq	-1236(%rbp), %rdx
	leaq	-1240(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1224(%rbp)
	jmp	.L2
.L3:
	leaq	-1228(%rbp), %rdx
	leaq	-1232(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-1232(%rbp), %eax
	subl	$1, %eax
	movl	-1228(%rbp), %edx
	cltq
	movl	%edx, -1216(%rbp,%rax,4)
	addl	$1, -1224(%rbp)
.L2:
	movl	-1236(%rbp), %eax
	cmpl	%eax, -1224(%rbp)
	jl	.L3
	movl	$0, -1224(%rbp)
	jmp	.L4
.L7:
	movl	$0, -1220(%rbp)
	jmp	.L5
.L6:
	movl	-1220(%rbp), %eax
	movslq	%eax, %rdx
	movl	-1224(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	memo(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-1220(%rbp), %eax
	movslq	%eax, %rdx
	movl	-1224(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	4+memo(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-1220(%rbp), %eax
	movslq	%eax, %rdx
	movl	-1224(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	8+memo(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-1220(%rbp), %eax
	movslq	%eax, %rdx
	movl	-1224(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	12+memo(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -1220(%rbp)
.L5:
	cmpl	$3, -1220(%rbp)
	jle	.L6
	addl	$1, -1224(%rbp)
.L4:
	cmpl	$99, -1224(%rbp)
	jle	.L7
	movl	$0, -816(%rbp)
	movl	$0, -812(%rbp)
	movl	-1240(%rbp), %edx
	leaq	-1216(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	calc
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	calc
	.type	calc, @function
calc:
.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
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	$0, -4(%rbp)
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rireki(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L11
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	jmp	.L12
.L11:
	movl	$0, -8(%rbp)
.L12:
	movl	-28(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jl	.L13
	movl	$1, %eax
	jmp	.L14
.L13:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rireki(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	cltq
	movslq	%edx, %rdx
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	memo(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L15
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rireki(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	cltq
	movslq	%edx, %rdx
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	memo(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L14
.L15:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L16
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -8(%rbp)
	je	.L17
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-28(%rbp), %edx
	addl	$2, %edx
	movl	(%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	rireki(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-28(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	calc
	addl	%eax, -4(%rbp)
	jmp	.L17
.L16:
	cmpl	$1, -8(%rbp)
	je	.L18
	movl	-28(%rbp), %eax
	addl	$2, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-28(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	calc
	addl	%eax, -4(%rbp)
.L18:
	cmpl	$2, -8(%rbp)
	je	.L19
	movl	-28(%rbp), %eax
	addl	$2, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	$2, (%rdx,%rax)
	movl	-28(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	calc
	addl	%eax, -4(%rbp)
.L19:
	cmpl	$3, -8(%rbp)
	je	.L17
	movl	-28(%rbp), %eax
	addl	$2, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	$3, (%rdx,%rax)
	movl	-28(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	calc
	addl	%eax, -4(%rbp)
.L17:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1759218605, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$12, %edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	imull	$10000, %edx, %edx
	subl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rireki(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	cltq
	movslq	%edx, %rdx
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	memo(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	calc, .-calc
	.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	memo
	.bss
	.align 32
	.type	memo, @object
	.size	memo, 6400
memo:
	.zero	6400
	.globl	rireki
	.align 32
	.type	rireki, @object
	.size	rireki, 408
rireki:
	.zero	408
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.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
	subq	$1264, %rsp
	movl	%edi, -1252(%rbp)
	movq	%rsi, -1264(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-1216(%rbp), %rdx
	movl	$0, %eax
	movl	$50, %ecx
	movq	%rdx, %rdi
	rep stosq
	leaq	-1236(%rbp), %rdx
	leaq	-1240(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1224(%rbp)
	jmp	.L2
.L3:
	leaq	-1228(%rbp), %rdx
	leaq	-1232(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-1232(%rbp), %eax
	subl	$1, %eax
	movl	-1228(%rbp), %edx
	cltq
	movl	%edx, -1216(%rbp,%rax,4)
	addl	$1, -1224(%rbp)
.L2:
	movl	-1236(%rbp), %eax
	cmpl	%eax, -1224(%rbp)
	jl	.L3
	movl	$0, -1224(%rbp)
	jmp	.L4
.L7:
	movl	$0, -1220(%rbp)
	jmp	.L5
.L6:
	movl	-1220(%rbp), %eax
	movslq	%eax, %rdx
	movl	-1224(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	memo(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-1220(%rbp), %eax
	movslq	%eax, %rdx
	movl	-1224(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	4+memo(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-1220(%rbp), %eax
	movslq	%eax, %rdx
	movl	-1224(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	8+memo(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-1220(%rbp), %eax
	movslq	%eax, %rdx
	movl	-1224(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	12+memo(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -1220(%rbp)
.L5:
	cmpl	$3, -1220(%rbp)
	jle	.L6
	addl	$1, -1224(%rbp)
.L4:
	cmpl	$99, -1224(%rbp)
	jle	.L7
	movl	$0, -816(%rbp)
	movl	$0, -812(%rbp)
	movl	-1240(%rbp), %edx
	leaq	-1216(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	calc
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	calc
	.type	calc, @function
calc:
.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
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	$0, -4(%rbp)
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rireki(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L11
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	jmp	.L12
.L11:
	movl	$0, -8(%rbp)
.L12:
	movl	-28(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jl	.L13
	movl	$1, %eax
	jmp	.L14
.L13:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rireki(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	cltq
	movslq	%edx, %rdx
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	memo(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L15
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rireki(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	cltq
	movslq	%edx, %rdx
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	memo(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L14
.L15:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L16
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -8(%rbp)
	je	.L17
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-28(%rbp), %edx
	addl	$2, %edx
	movl	(%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	rireki(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-28(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	calc
	addl	%eax, -4(%rbp)
	jmp	.L17
.L16:
	cmpl	$1, -8(%rbp)
	je	.L18
	movl	-28(%rbp), %eax
	addl	$2, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-28(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	calc
	addl	%eax, -4(%rbp)
.L18:
	cmpl	$2, -8(%rbp)
	je	.L19
	movl	-28(%rbp), %eax
	addl	$2, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	$2, (%rdx,%rax)
	movl	-28(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	calc
	addl	%eax, -4(%rbp)
.L19:
	cmpl	$3, -8(%rbp)
	je	.L17
	movl	-28(%rbp), %eax
	addl	$2, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	$3, (%rdx,%rax)
	movl	-28(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	calc
	addl	%eax, -4(%rbp)
.L17:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1759218605, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$12, %edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	imull	$10000, %edx, %edx
	subl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rireki(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-28(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rireki(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	cltq
	movslq	%edx, %rdx
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	memo(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	calc, .-calc
	.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:
