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

```c
#include<stdio.h>

int main(void)
{
int n,r,p,c,i,j;
int card[51];
int tem[51];

while(scanf("%d%d",&n,&r),n+r){

for(i=1;i<=n;i++){
card[i]=i;
}

for(i=0;i<r;i++){
scanf("%d%d",&p,&c);
for(j=n-p+1;j>n-p+1-c;j--){
tem[j]=card[j];
}
for(j++;j+c<=n;j++){
card[j]=card[j+c];
}
for(;j<=n;j++){
card[j]=tem[j-p+1];
}
}
printf("%d\n",card[n]);
}
return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.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	$464, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L13:
	movl	$1, -440(%rbp)
	jmp	.L3
.L4:
	movl	-440(%rbp), %eax
	cltq
	movl	-440(%rbp), %edx
	movl	%edx, -432(%rbp,%rax,4)
	addl	$1, -440(%rbp)
.L3:
	movl	-456(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	jle	.L4
	movl	$0, -440(%rbp)
	jmp	.L5
.L12:
	leaq	-444(%rbp), %rdx
	leaq	-448(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-456(%rbp), %eax
	movl	-448(%rbp), %edx
	subl	%edx, %eax
	addl	$1, %eax
	movl	%eax, -436(%rbp)
	jmp	.L6
.L7:
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-436(%rbp), %eax
	cltq
	movl	%edx, -224(%rbp,%rax,4)
	subl	$1, -436(%rbp)
.L6:
	movl	-456(%rbp), %eax
	movl	-448(%rbp), %edx
	subl	%edx, %eax
	addl	$1, %eax
	movl	-444(%rbp), %edx
	subl	%edx, %eax
	cmpl	%eax, -436(%rbp)
	jg	.L7
	addl	$1, -436(%rbp)
	jmp	.L8
.L9:
	movl	-444(%rbp), %edx
	movl	-436(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-436(%rbp), %eax
	cltq
	movl	%edx, -432(%rbp,%rax,4)
	addl	$1, -436(%rbp)
.L8:
	movl	-444(%rbp), %edx
	movl	-436(%rbp), %eax
	addl	%eax, %edx
	movl	-456(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L9
	jmp	.L10
.L11:
	movl	-448(%rbp), %edx
	movl	-436(%rbp), %eax
	subl	%edx, %eax
	addl	$1, %eax
	cltq
	movl	-224(%rbp,%rax,4), %edx
	movl	-436(%rbp), %eax
	cltq
	movl	%edx, -432(%rbp,%rax,4)
	addl	$1, -436(%rbp)
.L10:
	movl	-456(%rbp), %eax
	cmpl	%eax, -436(%rbp)
	jle	.L11
	addl	$1, -440(%rbp)
.L5:
	movl	-452(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	jl	.L12
	movl	-456(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-452(%rbp), %rdx
	leaq	-456(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-456(%rbp), %edx
	movl	-452(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	jne	.L13
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC12:
	.string	"%d%d"
.LC13:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC12(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$488, %rsp
	.cfi_def_cfa_offset 544
	movq	%fs:40, %rax
	movq	%rax, 472(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rax
	movq	%rax, 24(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 16(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movslq	32(%rsp), %r14
	movl	36(%rsp), %edx
	movl	%r14d, %eax
	addl	%edx, %eax
	je	.L18
	testl	%r14d, %r14d
	jle	.L20
	leal	-1(%r14), %eax
	cmpl	$2, %eax
	jbe	.L22
	movdqa	.LC0(%rip), %xmm5
	movl	%r14d, %eax
	shrl	$2, %eax
	movups	%xmm5, 52(%rsp)
	cmpl	$1, %eax
	je	.L4
	movdqa	.LC1(%rip), %xmm3
	movups	%xmm3, 68(%rsp)
	cmpl	$2, %eax
	je	.L4
	movdqa	.LC2(%rip), %xmm0
	movups	%xmm0, 84(%rsp)
	cmpl	$3, %eax
	je	.L4
	movdqa	.LC3(%rip), %xmm0
	movups	%xmm0, 100(%rsp)
	cmpl	$4, %eax
	je	.L4
	movdqa	.LC4(%rip), %xmm0
	movups	%xmm0, 116(%rsp)
	cmpl	$5, %eax
	je	.L4
	movdqa	.LC5(%rip), %xmm0
	movups	%xmm0, 132(%rsp)
	cmpl	$6, %eax
	je	.L4
	movdqa	.LC6(%rip), %xmm0
	movups	%xmm0, 148(%rsp)
	cmpl	$7, %eax
	je	.L4
	movdqa	.LC7(%rip), %xmm0
	movups	%xmm0, 164(%rsp)
	cmpl	$8, %eax
	je	.L4
	movdqa	.LC8(%rip), %xmm0
	movups	%xmm0, 180(%rsp)
	cmpl	$9, %eax
	je	.L4
	movdqa	.LC9(%rip), %xmm0
	movups	%xmm0, 196(%rsp)
	cmpl	$10, %eax
	je	.L4
	movdqa	.LC10(%rip), %xmm0
	movups	%xmm0, 212(%rsp)
	cmpl	$11, %eax
	je	.L4
	movdqa	.LC11(%rip), %xmm0
	movups	%xmm0, 228(%rsp)
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%r14d, %ecx
	andl	$-4, %ecx
	leal	1(%rcx), %eax
	cmpl	%ecx, %r14d
	je	.L20
.L3:
	movslq	%eax, %rcx
	movl	%eax, 48(%rsp,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %r14d
	jl	.L20
	movslq	%ecx, %rsi
	addl	$2, %eax
	movl	%ecx, 48(%rsp,%rsi,4)
	cmpl	%eax, %r14d
	jl	.L20
	movslq	%eax, %rcx
	movl	%eax, 48(%rsp,%rcx,4)
.L20:
	testl	%edx, %edx
	jle	.L6
	leaq	40(%rsp), %r12
	xorl	%ebx, %ebx
	leaq	44(%rsp), %r13
	movq	%r12, 8(%rsp)
	movl	%ebx, %r12d
	.p2align 4,,10
	.p2align 3
.L16:
	movq	8(%rsp), %rsi
	movq	%r13, %rdx
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	32(%rsp), %r14
	movslq	40(%rsp), %r9
	movl	44(%rsp), %ebx
	movl	%r14d, %r10d
	subl	%r9d, %r10d
	leal	1(%r10), %r15d
	movl	%r15d, %eax
	subl	%ebx, %eax
	cmpl	%eax, %r15d
	jle	.L7
	subl	%eax, %r10d
	movslq	%r15d, %rax
	movl	%r9d, 4(%rsp)
	movl	%r10d, %edx
	movl	%r10d, (%rsp)
	subq	%rdx, %rax
	leaq	4(,%rdx,4), %rdx
	salq	$2, %rax
	leaq	48(%rsp,%rax), %rsi
	leaq	256(%rsp,%rax), %rdi
	call	memcpy@PLT
	movl	(%rsp), %r10d
	movl	%r15d, %ecx
	movslq	4(%rsp), %r9
	subl	%r10d, %ecx
	leal	(%rcx,%rbx), %esi
	cmpl	%esi, %r14d
	jl	.L23
.L100:
	leal	1(%rcx), %r11d
	movl	%r14d, %eax
	leal	-1(%rcx), %edx
	leal	(%rbx,%r11), %edi
	subl	%esi, %edx
	leal	1(%r14), %r10d
	subl	%edi, %eax
	cmpl	$2, %edx
	leal	1(%rax), %edx
	seta	%r15b
	cmpl	$3, %edx
	seta	%dl
	testb	%dl, %r15b
	je	.L10
	cmpl	%r10d, %edi
	jg	.L10
	addl	$2, %eax
	movl	$1, %edx
	cmpl	%r10d, %edi
	movslq	%ebx, %rdi
	cmovg	%edx, %eax
	leaq	48(%rsp), %r11
	movd	%ecx, %xmm2
	movslq	%ecx, %rdx
	addq	%rdx, %rdi
	movdqa	.LC0(%rip), %xmm0
	pshufd	$0, %xmm2, %xmm1
	leaq	(%r11,%rdi,4), %rdi
	movl	%eax, %r10d
	leaq	(%r11,%rdx,4), %rdx
	movdqu	(%rdi), %xmm3
	shrl	$2, %r10d
	paddd	%xmm1, %xmm0
	movups	%xmm3, (%rdx)
	cmpl	$1, %r10d
	je	.L11
	movdqu	16(%rdi), %xmm4
	movdqa	.LC1(%rip), %xmm0
	movups	%xmm4, 16(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$2, %r10d
	je	.L11
	movdqu	32(%rdi), %xmm5
	movdqa	.LC2(%rip), %xmm0
	movups	%xmm5, 32(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$3, %r10d
	je	.L11
	movdqu	48(%rdi), %xmm6
	movdqa	.LC3(%rip), %xmm0
	movups	%xmm6, 48(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$4, %r10d
	je	.L11
	movdqu	64(%rdi), %xmm7
	movdqa	.LC4(%rip), %xmm0
	movups	%xmm7, 64(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$5, %r10d
	je	.L11
	movdqu	80(%rdi), %xmm7
	movdqa	.LC5(%rip), %xmm0
	movups	%xmm7, 80(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$6, %r10d
	je	.L11
	movdqu	96(%rdi), %xmm6
	movdqa	.LC6(%rip), %xmm0
	movups	%xmm6, 96(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$7, %r10d
	je	.L11
	movdqu	112(%rdi), %xmm5
	movdqa	.LC7(%rip), %xmm0
	movups	%xmm5, 112(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$8, %r10d
	je	.L11
	movdqu	128(%rdi), %xmm4
	movdqa	.LC8(%rip), %xmm0
	movups	%xmm4, 128(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$9, %r10d
	je	.L11
	movdqu	144(%rdi), %xmm7
	movdqa	.LC9(%rip), %xmm0
	movups	%xmm7, 144(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$10, %r10d
	je	.L11
	movdqu	160(%rdi), %xmm6
	movdqa	.LC10(%rip), %xmm0
	movups	%xmm6, 160(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$11, %r10d
	je	.L11
	movdqu	176(%rdi), %xmm2
	paddd	.LC11(%rip), %xmm1
	movups	%xmm2, 176(%rdx)
	movdqa	%xmm1, %xmm0
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%eax, %edi
	pshufd	$255, %xmm0, %xmm0
	andl	$-4, %edi
	movd	%xmm0, %edx
	addl	%edi, %esi
	addl	%edi, %ecx
	cmpl	%edi, %eax
	je	.L9
	movslq	%esi, %rsi
	movslq	%ecx, %rax
	movl	48(%rsp,%rsi,4), %edx
	movl	%edx, 48(%rsp,%rax,4)
	leal	1(%rcx), %edx
	leal	(%rdx,%rbx), %eax
	cmpl	%eax, %r14d
	jl	.L9
	cltq
	movslq	%edx, %rdx
	movl	48(%rsp,%rax,4), %eax
	movl	%eax, 48(%rsp,%rdx,4)
	leal	2(%rcx), %edx
	addl	%edx, %ebx
	cmpl	%ebx, %r14d
	jl	.L9
	movslq	%ebx, %rbx
	movslq	%edx, %rdx
	movl	48(%rsp,%rbx,4), %eax
	movl	%eax, 48(%rsp,%rdx,4)
	leal	3(%rcx), %edx
.L9:
	cmpl	%edx, %r14d
	jl	.L99
	movslq	%edx, %rax
	movl	%r14d, %ecx
	addl	$1, %r12d
	leaq	48(%rsp,%rax,4), %rdi
	subl	%edx, %ecx
	subq	%r9, %rax
	leaq	4(,%rcx,4), %rdx
	leaq	260(%rsp,%rax,4), %rsi
	call	memcpy@PLT
	cmpl	36(%rsp), %r12d
	jl	.L16
.L6:
	movl	48(%rsp,%r14,4), %edx
	leaq	.LC13(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L99:
	addl	$1, %r12d
	cmpl	%r12d, 36(%rsp)
	jg	.L16
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L10:
	movslq	%esi, %rsi
	movslq	%ecx, %rcx
	leaq	48(%rsp), %rdi
	movslq	%r11d, %rax
	subq	%rcx, %rsi
	leaq	(%rdi,%rsi,4), %r10
	leal	-1(%rbx), %esi
	.p2align 4,,10
	.p2align 3
.L13:
	movl	-4(%r10,%rax,4), %edx
	movl	%edx, -4(%rdi,%rax,4)
	movl	%eax, %edx
	addq	$1, %rax
	leal	(%rsi,%rax), %ecx
	cmpl	%ecx, %r14d
	jge	.L13
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L7:
	leal	2(%r10), %ecx
	leal	(%rcx,%rbx), %esi
	cmpl	%esi, %r14d
	jge	.L100
	.p2align 4,,10
	.p2align 3
.L23:
	movl	%ecx, %edx
	jmp	.L9
.L18:
	movq	472(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L101
	addq	$488, %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
.L22:
	.cfi_restore_state
	movl	$1, %eax
	jmp	.L3
.L101:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	1
	.long	2
	.long	3
	.long	4
	.align 16
.LC1:
	.long	5
	.long	6
	.long	7
	.long	8
	.align 16
.LC2:
	.long	9
	.long	10
	.long	11
	.long	12
	.align 16
.LC3:
	.long	13
	.long	14
	.long	15
	.long	16
	.align 16
.LC4:
	.long	17
	.long	18
	.long	19
	.long	20
	.align 16
.LC5:
	.long	21
	.long	22
	.long	23
	.long	24
	.align 16
.LC6:
	.long	25
	.long	26
	.long	27
	.long	28
	.align 16
.LC7:
	.long	29
	.long	30
	.long	31
	.long	32
	.align 16
.LC8:
	.long	33
	.long	34
	.long	35
	.long	36
	.align 16
.LC9:
	.long	37
	.long	38
	.long	39
	.long	40
	.align 16
.LC10:
	.long	41
	.long	42
	.long	43
	.long	44
	.align 16
.LC11:
	.long	45
	.long	46
	.long	47
	.long	48
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC12:
	.string	"%d%d"
.LC13:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC12(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$488, %rsp
	.cfi_def_cfa_offset 544
	movq	%fs:40, %rax
	movq	%rax, 472(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rax
	movq	%rax, 24(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 16(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movslq	32(%rsp), %r14
	movl	36(%rsp), %edx
	movl	%r14d, %eax
	addl	%edx, %eax
	je	.L18
	testl	%r14d, %r14d
	jle	.L20
	leal	-1(%r14), %eax
	cmpl	$2, %eax
	jbe	.L22
	movdqa	.LC0(%rip), %xmm5
	movl	%r14d, %eax
	shrl	$2, %eax
	movups	%xmm5, 52(%rsp)
	cmpl	$1, %eax
	je	.L4
	movdqa	.LC1(%rip), %xmm3
	movups	%xmm3, 68(%rsp)
	cmpl	$2, %eax
	je	.L4
	movdqa	.LC2(%rip), %xmm0
	movups	%xmm0, 84(%rsp)
	cmpl	$3, %eax
	je	.L4
	movdqa	.LC3(%rip), %xmm0
	movups	%xmm0, 100(%rsp)
	cmpl	$4, %eax
	je	.L4
	movdqa	.LC4(%rip), %xmm0
	movups	%xmm0, 116(%rsp)
	cmpl	$5, %eax
	je	.L4
	movdqa	.LC5(%rip), %xmm0
	movups	%xmm0, 132(%rsp)
	cmpl	$6, %eax
	je	.L4
	movdqa	.LC6(%rip), %xmm0
	movups	%xmm0, 148(%rsp)
	cmpl	$7, %eax
	je	.L4
	movdqa	.LC7(%rip), %xmm0
	movups	%xmm0, 164(%rsp)
	cmpl	$8, %eax
	je	.L4
	movdqa	.LC8(%rip), %xmm0
	movups	%xmm0, 180(%rsp)
	cmpl	$9, %eax
	je	.L4
	movdqa	.LC9(%rip), %xmm0
	movups	%xmm0, 196(%rsp)
	cmpl	$10, %eax
	je	.L4
	movdqa	.LC10(%rip), %xmm0
	movups	%xmm0, 212(%rsp)
	cmpl	$11, %eax
	je	.L4
	movdqa	.LC11(%rip), %xmm0
	movups	%xmm0, 228(%rsp)
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%r14d, %ecx
	andl	$-4, %ecx
	leal	1(%rcx), %eax
	cmpl	%ecx, %r14d
	je	.L20
.L3:
	movslq	%eax, %rcx
	movl	%eax, 48(%rsp,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %r14d
	jl	.L20
	movslq	%ecx, %rsi
	addl	$2, %eax
	movl	%ecx, 48(%rsp,%rsi,4)
	cmpl	%eax, %r14d
	jl	.L20
	movslq	%eax, %rcx
	movl	%eax, 48(%rsp,%rcx,4)
.L20:
	testl	%edx, %edx
	jle	.L6
	leaq	40(%rsp), %r12
	xorl	%ebx, %ebx
	leaq	44(%rsp), %r13
	movq	%r12, 8(%rsp)
	movl	%ebx, %r12d
	.p2align 4,,10
	.p2align 3
.L16:
	movq	8(%rsp), %rsi
	movq	%r13, %rdx
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	32(%rsp), %r14
	movslq	40(%rsp), %r9
	movl	44(%rsp), %ebx
	movl	%r14d, %r10d
	subl	%r9d, %r10d
	leal	1(%r10), %r15d
	movl	%r15d, %eax
	subl	%ebx, %eax
	cmpl	%eax, %r15d
	jle	.L7
	subl	%eax, %r10d
	movslq	%r15d, %rax
	movl	%r9d, 4(%rsp)
	movl	%r10d, %edx
	movl	%r10d, (%rsp)
	subq	%rdx, %rax
	leaq	4(,%rdx,4), %rdx
	salq	$2, %rax
	leaq	48(%rsp,%rax), %rsi
	leaq	256(%rsp,%rax), %rdi
	call	memcpy@PLT
	movl	(%rsp), %r10d
	movl	%r15d, %ecx
	movslq	4(%rsp), %r9
	subl	%r10d, %ecx
	leal	(%rcx,%rbx), %esi
	cmpl	%esi, %r14d
	jl	.L23
.L100:
	leal	1(%rcx), %r11d
	movl	%r14d, %eax
	leal	-1(%rcx), %edx
	leal	(%rbx,%r11), %edi
	subl	%esi, %edx
	leal	1(%r14), %r10d
	subl	%edi, %eax
	cmpl	$2, %edx
	leal	1(%rax), %edx
	seta	%r15b
	cmpl	$3, %edx
	seta	%dl
	testb	%dl, %r15b
	je	.L10
	cmpl	%r10d, %edi
	jg	.L10
	addl	$2, %eax
	movl	$1, %edx
	cmpl	%r10d, %edi
	movslq	%ebx, %rdi
	cmovg	%edx, %eax
	leaq	48(%rsp), %r11
	movd	%ecx, %xmm2
	movslq	%ecx, %rdx
	addq	%rdx, %rdi
	movdqa	.LC0(%rip), %xmm0
	pshufd	$0, %xmm2, %xmm1
	leaq	(%r11,%rdi,4), %rdi
	movl	%eax, %r10d
	leaq	(%r11,%rdx,4), %rdx
	movdqu	(%rdi), %xmm3
	shrl	$2, %r10d
	paddd	%xmm1, %xmm0
	movups	%xmm3, (%rdx)
	cmpl	$1, %r10d
	je	.L11
	movdqu	16(%rdi), %xmm4
	movdqa	.LC1(%rip), %xmm0
	movups	%xmm4, 16(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$2, %r10d
	je	.L11
	movdqu	32(%rdi), %xmm5
	movdqa	.LC2(%rip), %xmm0
	movups	%xmm5, 32(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$3, %r10d
	je	.L11
	movdqu	48(%rdi), %xmm6
	movdqa	.LC3(%rip), %xmm0
	movups	%xmm6, 48(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$4, %r10d
	je	.L11
	movdqu	64(%rdi), %xmm7
	movdqa	.LC4(%rip), %xmm0
	movups	%xmm7, 64(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$5, %r10d
	je	.L11
	movdqu	80(%rdi), %xmm7
	movdqa	.LC5(%rip), %xmm0
	movups	%xmm7, 80(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$6, %r10d
	je	.L11
	movdqu	96(%rdi), %xmm6
	movdqa	.LC6(%rip), %xmm0
	movups	%xmm6, 96(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$7, %r10d
	je	.L11
	movdqu	112(%rdi), %xmm5
	movdqa	.LC7(%rip), %xmm0
	movups	%xmm5, 112(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$8, %r10d
	je	.L11
	movdqu	128(%rdi), %xmm4
	movdqa	.LC8(%rip), %xmm0
	movups	%xmm4, 128(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$9, %r10d
	je	.L11
	movdqu	144(%rdi), %xmm7
	movdqa	.LC9(%rip), %xmm0
	movups	%xmm7, 144(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$10, %r10d
	je	.L11
	movdqu	160(%rdi), %xmm6
	movdqa	.LC10(%rip), %xmm0
	movups	%xmm6, 160(%rdx)
	paddd	%xmm1, %xmm0
	cmpl	$11, %r10d
	je	.L11
	movdqu	176(%rdi), %xmm2
	paddd	.LC11(%rip), %xmm1
	movups	%xmm2, 176(%rdx)
	movdqa	%xmm1, %xmm0
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%eax, %edi
	pshufd	$255, %xmm0, %xmm0
	andl	$-4, %edi
	movd	%xmm0, %edx
	addl	%edi, %esi
	addl	%edi, %ecx
	cmpl	%edi, %eax
	je	.L9
	movslq	%esi, %rsi
	movslq	%ecx, %rax
	movl	48(%rsp,%rsi,4), %edx
	movl	%edx, 48(%rsp,%rax,4)
	leal	1(%rcx), %edx
	leal	(%rdx,%rbx), %eax
	cmpl	%eax, %r14d
	jl	.L9
	cltq
	movslq	%edx, %rdx
	movl	48(%rsp,%rax,4), %eax
	movl	%eax, 48(%rsp,%rdx,4)
	leal	2(%rcx), %edx
	addl	%edx, %ebx
	cmpl	%ebx, %r14d
	jl	.L9
	movslq	%ebx, %rbx
	movslq	%edx, %rdx
	movl	48(%rsp,%rbx,4), %eax
	movl	%eax, 48(%rsp,%rdx,4)
	leal	3(%rcx), %edx
.L9:
	cmpl	%edx, %r14d
	jl	.L99
	movslq	%edx, %rax
	movl	%r14d, %ecx
	addl	$1, %r12d
	leaq	48(%rsp,%rax,4), %rdi
	subl	%edx, %ecx
	subq	%r9, %rax
	leaq	4(,%rcx,4), %rdx
	leaq	260(%rsp,%rax,4), %rsi
	call	memcpy@PLT
	cmpl	36(%rsp), %r12d
	jl	.L16
.L6:
	movl	48(%rsp,%r14,4), %edx
	leaq	.LC13(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L99:
	addl	$1, %r12d
	cmpl	%r12d, 36(%rsp)
	jg	.L16
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L10:
	movslq	%esi, %rsi
	movslq	%ecx, %rcx
	leaq	48(%rsp), %rdi
	movslq	%r11d, %rax
	subq	%rcx, %rsi
	leaq	(%rdi,%rsi,4), %r10
	leal	-1(%rbx), %esi
	.p2align 4,,10
	.p2align 3
.L13:
	movl	-4(%r10,%rax,4), %edx
	movl	%edx, -4(%rdi,%rax,4)
	movl	%eax, %edx
	addq	$1, %rax
	leal	(%rsi,%rax), %ecx
	cmpl	%ecx, %r14d
	jge	.L13
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L7:
	leal	2(%r10), %ecx
	leal	(%rcx,%rbx), %esi
	cmpl	%esi, %r14d
	jge	.L100
	.p2align 4,,10
	.p2align 3
.L23:
	movl	%ecx, %edx
	jmp	.L9
.L18:
	movq	472(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L101
	addq	$488, %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
.L22:
	.cfi_restore_state
	movl	$1, %eax
	jmp	.L3
.L101:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	1
	.long	2
	.long	3
	.long	4
	.align 16
.LC1:
	.long	5
	.long	6
	.long	7
	.long	8
	.align 16
.LC2:
	.long	9
	.long	10
	.long	11
	.long	12
	.align 16
.LC3:
	.long	13
	.long	14
	.long	15
	.long	16
	.align 16
.LC4:
	.long	17
	.long	18
	.long	19
	.long	20
	.align 16
.LC5:
	.long	21
	.long	22
	.long	23
	.long	24
	.align 16
.LC6:
	.long	25
	.long	26
	.long	27
	.long	28
	.align 16
.LC7:
	.long	29
	.long	30
	.long	31
	.long	32
	.align 16
.LC8:
	.long	33
	.long	34
	.long	35
	.long	36
	.align 16
.LC9:
	.long	37
	.long	38
	.long	39
	.long	40
	.align 16
.LC10:
	.long	41
	.long	42
	.long	43
	.long	44
	.align 16
.LC11:
	.long	45
	.long	46
	.long	47
	.long	48
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include<stdio.h>

int main(void)
{
int n,r,p,c,i,j;
int card[51];
int tem[51];

while(scanf("%d%d",&n,&r),n+r){

for(i=1;i<=n;i++){
card[i]=i;
}

for(i=0;i<r;i++){
scanf("%d%d",&p,&c);
for(j=n-p+1;j>n-p+1-c;j--){
tem[j]=card[j];
}
for(j++;j+c<=n;j++){
card[j]=card[j+c];
}
for(;j<=n;j++){
card[j]=tem[j-p+1];
}
}
printf("%d\n",card[n]);
}
return 0;
}
5 2
3 1
3 1
10 3
1 10
10 1
8 0
0 0
 5 0
3 1
3 1
10 3
1 10
10 1
8 0
0 0
 5 0
3 1
3 1
10 2
1 10
10 1
11 0
0 0
 5 2
3 1
3 1
10 3
1 11
10 1
8 3
0 0
 6 2
3 1
3 1
10 3
1 10
10 1
8 0
0 0
 5 0
3 1
3 1
10 3
2 10
10 1
8 0
0 0

4
1
 5
1
1
 5
1
1
11
 4
4
 5
1
 5
1
0

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

```c
#include<stdio.h>

int main(void)
{
int n,r,p,c,i,j;
int card[51];
int tem[51];

while(scanf("%d%d",&n,&r),n+r){

for(i=1;i<=n;i++){
card[i]=i;
}

for(i=0;i<r;i++){
scanf("%d%d",&p,&c);
for(j=n-p+1;j>n-p+1-c;j--){
tem[j]=card[j];
}
for(j++;j+c<=n;j++){
card[j]=card[j+c];
}
for(;j<=n;j++){
card[j]=tem[j-p+1];
}
}
printf("%d\n",card[n]);
}
return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.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	$464, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L13:
	movl	$1, -440(%rbp)
	jmp	.L3
.L4:
	movl	-440(%rbp), %eax
	cltq
	movl	-440(%rbp), %edx
	movl	%edx, -432(%rbp,%rax,4)
	addl	$1, -440(%rbp)
.L3:
	movl	-456(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	jle	.L4
	movl	$0, -440(%rbp)
	jmp	.L5
.L12:
	leaq	-444(%rbp), %rdx
	leaq	-448(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-456(%rbp), %eax
	movl	-448(%rbp), %edx
	subl	%edx, %eax
	addl	$1, %eax
	movl	%eax, -436(%rbp)
	jmp	.L6
.L7:
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-436(%rbp), %eax
	cltq
	movl	%edx, -224(%rbp,%rax,4)
	subl	$1, -436(%rbp)
.L6:
	movl	-456(%rbp), %eax
	movl	-448(%rbp), %edx
	subl	%edx, %eax
	addl	$1, %eax
	movl	-444(%rbp), %edx
	subl	%edx, %eax
	cmpl	%eax, -436(%rbp)
	jg	.L7
	addl	$1, -436(%rbp)
	jmp	.L8
.L9:
	movl	-444(%rbp), %edx
	movl	-436(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-436(%rbp), %eax
	cltq
	movl	%edx, -432(%rbp,%rax,4)
	addl	$1, -436(%rbp)
.L8:
	movl	-444(%rbp), %edx
	movl	-436(%rbp), %eax
	addl	%eax, %edx
	movl	-456(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L9
	jmp	.L10
.L11:
	movl	-448(%rbp), %edx
	movl	-436(%rbp), %eax
	subl	%edx, %eax
	addl	$1, %eax
	cltq
	movl	-224(%rbp,%rax,4), %edx
	movl	-436(%rbp), %eax
	cltq
	movl	%edx, -432(%rbp,%rax,4)
	addl	$1, -436(%rbp)
.L10:
	movl	-456(%rbp), %eax
	cmpl	%eax, -436(%rbp)
	jle	.L11
	addl	$1, -440(%rbp)
.L5:
	movl	-452(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	jl	.L12
	movl	-456(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-452(%rbp), %rdx
	leaq	-456(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-456(%rbp), %edx
	movl	-452(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	jne	.L13
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%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	$464, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L13:
	movl	$1, -440(%rbp)
	jmp	.L3
.L4:
	movl	-440(%rbp), %eax
	cltq
	movl	-440(%rbp), %edx
	movl	%edx, -432(%rbp,%rax,4)
	addl	$1, -440(%rbp)
.L3:
	movl	-456(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	jle	.L4
	movl	$0, -440(%rbp)
	jmp	.L5
.L12:
	leaq	-444(%rbp), %rdx
	leaq	-448(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-456(%rbp), %eax
	movl	-448(%rbp), %edx
	subl	%edx, %eax
	addl	$1, %eax
	movl	%eax, -436(%rbp)
	jmp	.L6
.L7:
	movl	-436(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-436(%rbp), %eax
	cltq
	movl	%edx, -224(%rbp,%rax,4)
	subl	$1, -436(%rbp)
.L6:
	movl	-456(%rbp), %eax
	movl	-448(%rbp), %edx
	subl	%edx, %eax
	addl	$1, %eax
	movl	-444(%rbp), %edx
	subl	%edx, %eax
	cmpl	%eax, -436(%rbp)
	jg	.L7
	addl	$1, -436(%rbp)
	jmp	.L8
.L9:
	movl	-444(%rbp), %edx
	movl	-436(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-432(%rbp,%rax,4), %edx
	movl	-436(%rbp), %eax
	cltq
	movl	%edx, -432(%rbp,%rax,4)
	addl	$1, -436(%rbp)
.L8:
	movl	-444(%rbp), %edx
	movl	-436(%rbp), %eax
	addl	%eax, %edx
	movl	-456(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L9
	jmp	.L10
.L11:
	movl	-448(%rbp), %edx
	movl	-436(%rbp), %eax
	subl	%edx, %eax
	addl	$1, %eax
	cltq
	movl	-224(%rbp,%rax,4), %edx
	movl	-436(%rbp), %eax
	cltq
	movl	%edx, -432(%rbp,%rax,4)
	addl	$1, -436(%rbp)
.L10:
	movl	-456(%rbp), %eax
	cmpl	%eax, -436(%rbp)
	jle	.L11
	addl	$1, -440(%rbp)
.L5:
	movl	-452(%rbp), %eax
	cmpl	%eax, -440(%rbp)
	jl	.L12
	movl	-456(%rbp), %eax
	cltq
	movl	-432(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-452(%rbp), %rdx
	leaq	-456(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-456(%rbp), %edx
	movl	-452(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	jne	.L13
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
