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()
{
	int deck[50], buf[50];
	int n, r, p, c;
	int i, j, k;
	
	while(1)
	{
		scanf("%d%d", &n, &r);
		
		if(n == 0 && r == 0) break;
		
		for(i = 0; i < n; i++)
		{
			deck[i] = i + 1;
			buf[i] = 0;
		}
		
		for(i = 0; i < r; i++)
		{
			scanf("%d%d", &p, &c);
			
			for(j = 0; j < c; j++)
			{
				buf[j] = deck[n - p - c + 1 + j];
			}
			
			for(j = 0; j < p - 1; j++)
			{
				deck[n - p - c + 1 + j] = deck[n - p + 1 + j];
			}
			
			for(j = 0; j < c; j++)
			{
				deck[n - c + j] = buf[j];
				buf[j] = 0;
			}
		}
		
		printf("%d\n", deck[n - 1]);
	}
	
	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	$448, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L14:
	leaq	-436(%rbp), %rdx
	leaq	-440(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-440(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-436(%rbp), %eax
	testl	%eax, %eax
	je	.L18
.L2:
	movl	$0, -424(%rbp)
	jmp	.L4
.L5:
	movl	-424(%rbp), %eax
	leal	1(%rax), %edx
	movl	-424(%rbp), %eax
	cltq
	movl	%edx, -416(%rbp,%rax,4)
	movl	-424(%rbp), %eax
	cltq
	movl	$0, -208(%rbp,%rax,4)
	addl	$1, -424(%rbp)
.L4:
	movl	-440(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L5
	movl	$0, -424(%rbp)
	jmp	.L6
.L13:
	leaq	-428(%rbp), %rdx
	leaq	-432(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -420(%rbp)
	jmp	.L7
.L8:
	movl	-440(%rbp), %eax
	movl	-432(%rbp), %edx
	subl	%edx, %eax
	movl	-428(%rbp), %edx
	subl	%edx, %eax
	leal	1(%rax), %edx
	movl	-420(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-416(%rbp,%rax,4), %edx
	movl	-420(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L7:
	movl	-428(%rbp), %eax
	cmpl	%eax, -420(%rbp)
	jl	.L8
	movl	$0, -420(%rbp)
	jmp	.L9
.L10:
	movl	-440(%rbp), %eax
	movl	-432(%rbp), %edx
	subl	%edx, %eax
	leal	1(%rax), %edx
	movl	-420(%rbp), %eax
	addl	%eax, %edx
	movl	-440(%rbp), %eax
	movl	-432(%rbp), %ecx
	subl	%ecx, %eax
	movl	-428(%rbp), %ecx
	subl	%ecx, %eax
	leal	1(%rax), %ecx
	movl	-420(%rbp), %eax
	addl	%eax, %ecx
	movslq	%edx, %rax
	movl	-416(%rbp,%rax,4), %edx
	movslq	%ecx, %rax
	movl	%edx, -416(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L9:
	movl	-432(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -420(%rbp)
	jl	.L10
	movl	$0, -420(%rbp)
	jmp	.L11
.L12:
	movl	-440(%rbp), %eax
	movl	-428(%rbp), %edx
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-420(%rbp), %eax
	addl	%eax, %ecx
	movl	-420(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %edx
	movslq	%ecx, %rax
	movl	%edx, -416(%rbp,%rax,4)
	movl	-420(%rbp), %eax
	cltq
	movl	$0, -208(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L11:
	movl	-428(%rbp), %eax
	cmpl	%eax, -420(%rbp)
	jl	.L12
	addl	$1, -424(%rbp)
.L6:
	movl	-436(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L13
	movl	-440(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L14
.L18:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	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
.LC0:
	.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
	leaq	.LC0(%rip), %r13
	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	$472, %rsp
	.cfi_def_cfa_offset 528
	movq	%fs:40, %rax
	movq	%rax, 456(%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
.L24:
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %ebx
	movl	36(%rsp), %ebp
	testl	%ebx, %ebx
	jne	.L103
	testl	%ebp, %ebp
	je	.L104
.L4:
	testl	%ebp, %ebp
	jle	.L9
	xorl	%ebp, %ebp
	leaq	44(%rsp), %r15
	leaq	40(%rsp), %r14
	leaq	256(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L22:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %ebx
	testl	%ebx, %ebx
	jle	.L10
	movl	40(%rsp), %ecx
	movl	32(%rsp), %eax
	movslq	%ebx, %rdx
	movq	%r12, %rdi
	salq	$2, %rdx
	subl	%ecx, %eax
	movl	%ecx, 8(%rsp)
	subl	%ebx, %eax
	addl	$1, %eax
	cltq
	leaq	48(%rsp,%rax,4), %rsi
	call	memcpy@PLT
	movslq	8(%rsp), %rcx
.L11:
	leal	-1(%rcx), %edx
	testl	%edx, %edx
	jle	.L17
	movslq	32(%rsp), %rax
	leal	-2(%rcx), %r10d
	movl	%eax, %r9d
	subl	%ecx, %r9d
	movl	%r9d, %esi
	leal	1(%r9), %r8d
	subl	%ebx, %esi
	movl	%esi, %r11d
	leal	1(%rsi), %edi
	subl	%r9d, %r11d
	subl	$1, %r11d
	cmpl	$2, %r11d
	jbe	.L15
	cmpl	$2, %r10d
	jbe	.L15
	subq	%rcx, %rax
	movslq	%ebx, %r9
	movl	%edx, %esi
	leaq	52(%rsp,%rax,4), %rcx
	subq	%r9, %rax
	shrl	$2, %esi
	movdqu	(%rcx), %xmm1
	leaq	52(%rsp,%rax,4), %rax
	movups	%xmm1, (%rax)
	cmpl	$1, %esi
	je	.L16
	movdqu	16(%rcx), %xmm2
	movups	%xmm2, 16(%rax)
	cmpl	$2, %esi
	je	.L16
	movdqu	32(%rcx), %xmm3
	movups	%xmm3, 32(%rax)
	cmpl	$3, %esi
	je	.L16
	movdqu	48(%rcx), %xmm4
	movups	%xmm4, 48(%rax)
	cmpl	$4, %esi
	je	.L16
	movdqu	64(%rcx), %xmm5
	movups	%xmm5, 64(%rax)
	cmpl	$5, %esi
	je	.L16
	movdqu	80(%rcx), %xmm6
	movups	%xmm6, 80(%rax)
	cmpl	$6, %esi
	je	.L16
	movdqu	96(%rcx), %xmm7
	movups	%xmm7, 96(%rax)
	cmpl	$7, %esi
	je	.L16
	movdqu	112(%rcx), %xmm0
	movups	%xmm0, 112(%rax)
	cmpl	$8, %esi
	je	.L16
	movdqu	128(%rcx), %xmm7
	movups	%xmm7, 128(%rax)
	cmpl	$9, %esi
	je	.L16
	movdqu	144(%rcx), %xmm6
	movups	%xmm6, 144(%rax)
	cmpl	$10, %esi
	je	.L16
	movdqu	160(%rcx), %xmm5
	movups	%xmm5, 160(%rax)
	cmpl	$11, %esi
	je	.L16
	movdqu	176(%rcx), %xmm7
	movups	%xmm7, 176(%rax)
	.p2align 4,,10
	.p2align 3
.L16:
	movl	%edx, %eax
	andl	$-4, %eax
	testb	$3, %dl
	je	.L17
	leal	(%r8,%rax), %ecx
	movslq	%ecx, %rcx
	movl	48(%rsp,%rcx,4), %esi
	leal	(%rdi,%rax), %ecx
	movslq	%ecx, %rcx
	movl	%esi, 48(%rsp,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%edx, %ecx
	jge	.L17
	leal	(%r8,%rcx), %esi
	addl	%edi, %ecx
	addl	$2, %eax
	movslq	%esi, %rsi
	movslq	%ecx, %rcx
	movl	48(%rsp,%rsi,4), %esi
	movl	%esi, 48(%rsp,%rcx,4)
	cmpl	%eax, %edx
	jle	.L17
	addl	%eax, %r8d
	addl	%eax, %edi
	movslq	%r8d, %r8
	movslq	%edi, %rdi
	movl	48(%rsp,%r8,4), %edx
	movl	%edx, 48(%rsp,%rdi,4)
.L17:
	testl	%ebx, %ebx
	jle	.L105
.L13:
	movl	32(%rsp), %eax
	movslq	%ebx, %rdx
	movq	%r12, %rsi
	addl	$1, %ebp
	salq	$2, %rdx
	subl	%ebx, %eax
	movq	%rdx, 8(%rsp)
	cltq
	leaq	48(%rsp,%rax,4), %rdi
	call	memcpy@PLT
	movq	8(%rsp), %rdx
	xorl	%esi, %esi
	movq	%r12, %rdi
	call	memset@PLT
	cmpl	36(%rsp), %ebp
	jl	.L22
.L21:
	movl	32(%rsp), %ebx
.L9:
	leal	-1(%rbx), %eax
	leaq	.LC13(%rip), %rsi
	movl	$1, %edi
	cltq
	movl	48(%rsp,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	%r9d, %r9
	movslq	%esi, %rsi
	addq	%r9, %r10
	leaq	48(%rsp,%r9,4), %rax
	subq	%r9, %rsi
	leaq	52(%rsp,%r10,4), %rcx
	.p2align 4,,10
	.p2align 3
.L19:
	movl	4(%rax), %edx
	movl	%edx, 4(%rax,%rsi,4)
	addq	$4, %rax
	cmpq	%rcx, %rax
	jne	.L19
	testl	%ebx, %ebx
	jg	.L13
	.p2align 4,,10
	.p2align 3
.L105:
	addl	$1, %ebp
	cmpl	%ebp, 36(%rsp)
	jg	.L22
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L10:
	movslq	40(%rsp), %rcx
	jmp	.L11
.L103:
	jle	.L4
	leal	-1(%rbx), %eax
	cmpl	$2, %eax
	jbe	.L26
	movdqa	.LC1(%rip), %xmm0
	movl	%ebx, %eax
	shrl	$2, %eax
	movaps	%xmm0, 48(%rsp)
	cmpl	$1, %eax
	je	.L7
	movdqa	.LC2(%rip), %xmm4
	movaps	%xmm4, 64(%rsp)
	cmpl	$2, %eax
	je	.L7
	movdqa	.LC3(%rip), %xmm6
	movaps	%xmm6, 80(%rsp)
	cmpl	$3, %eax
	je	.L7
	movdqa	.LC4(%rip), %xmm5
	movaps	%xmm5, 96(%rsp)
	cmpl	$4, %eax
	je	.L7
	movdqa	.LC5(%rip), %xmm0
	movaps	%xmm0, 112(%rsp)
	cmpl	$5, %eax
	je	.L7
	movdqa	.LC6(%rip), %xmm0
	movaps	%xmm0, 128(%rsp)
	cmpl	$6, %eax
	je	.L7
	movdqa	.LC7(%rip), %xmm0
	movaps	%xmm0, 144(%rsp)
	cmpl	$7, %eax
	je	.L7
	movdqa	.LC8(%rip), %xmm0
	movaps	%xmm0, 160(%rsp)
	cmpl	$8, %eax
	je	.L7
	movdqa	.LC9(%rip), %xmm0
	movaps	%xmm0, 176(%rsp)
	cmpl	$9, %eax
	je	.L7
	movdqa	.LC10(%rip), %xmm0
	movaps	%xmm0, 192(%rsp)
	cmpl	$10, %eax
	je	.L7
	movdqa	.LC11(%rip), %xmm0
	movaps	%xmm0, 208(%rsp)
	cmpl	$11, %eax
	je	.L7
	movdqa	.LC12(%rip), %xmm0
	movaps	%xmm0, 224(%rsp)
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%ebx, %eax
	andl	$-4, %eax
	testb	$3, %bl
	je	.L8
.L6:
	leal	1(%rax), %edx
	movslq	%eax, %rcx
	movl	%edx, 48(%rsp,%rcx,4)
	cmpl	%edx, %ebx
	jle	.L8
	leal	2(%rax), %ecx
	movslq	%edx, %rdx
	movl	%ecx, 48(%rsp,%rdx,4)
	cmpl	%ecx, %ebx
	jle	.L8
	movslq	%ecx, %rcx
	addl	$3, %eax
	movl	%eax, 48(%rsp,%rcx,4)
.L8:
	movl	%ebx, %edx
	leaq	256(%rsp), %rdi
	xorl	%esi, %esi
	salq	$2, %rdx
	call	memset@PLT
	jmp	.L4
.L26:
	xorl	%eax, %eax
	jmp	.L6
.L104:
	movq	456(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L106
	addq	$472, %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
.L106:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	1
	.long	2
	.long	3
	.long	4
	.align 16
.LC2:
	.long	5
	.long	6
	.long	7
	.long	8
	.align 16
.LC3:
	.long	9
	.long	10
	.long	11
	.long	12
	.align 16
.LC4:
	.long	13
	.long	14
	.long	15
	.long	16
	.align 16
.LC5:
	.long	17
	.long	18
	.long	19
	.long	20
	.align 16
.LC6:
	.long	21
	.long	22
	.long	23
	.long	24
	.align 16
.LC7:
	.long	25
	.long	26
	.long	27
	.long	28
	.align 16
.LC8:
	.long	29
	.long	30
	.long	31
	.long	32
	.align 16
.LC9:
	.long	33
	.long	34
	.long	35
	.long	36
	.align 16
.LC10:
	.long	37
	.long	38
	.long	39
	.long	40
	.align 16
.LC11:
	.long	41
	.long	42
	.long	43
	.long	44
	.align 16
.LC12:
	.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
.LC0:
	.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
	leaq	.LC0(%rip), %r13
	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	$472, %rsp
	.cfi_def_cfa_offset 528
	movq	%fs:40, %rax
	movq	%rax, 456(%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
.L24:
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %ebx
	movl	36(%rsp), %ebp
	testl	%ebx, %ebx
	jne	.L103
	testl	%ebp, %ebp
	je	.L104
.L4:
	testl	%ebp, %ebp
	jle	.L9
	xorl	%ebp, %ebp
	leaq	44(%rsp), %r15
	leaq	40(%rsp), %r14
	leaq	256(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L22:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %ebx
	testl	%ebx, %ebx
	jle	.L10
	movl	40(%rsp), %ecx
	movl	32(%rsp), %eax
	movslq	%ebx, %rdx
	movq	%r12, %rdi
	salq	$2, %rdx
	subl	%ecx, %eax
	movl	%ecx, 8(%rsp)
	subl	%ebx, %eax
	addl	$1, %eax
	cltq
	leaq	48(%rsp,%rax,4), %rsi
	call	memcpy@PLT
	movslq	8(%rsp), %rcx
.L11:
	leal	-1(%rcx), %edx
	testl	%edx, %edx
	jle	.L17
	movslq	32(%rsp), %rax
	leal	-2(%rcx), %r10d
	movl	%eax, %r9d
	subl	%ecx, %r9d
	movl	%r9d, %esi
	leal	1(%r9), %r8d
	subl	%ebx, %esi
	movl	%esi, %r11d
	leal	1(%rsi), %edi
	subl	%r9d, %r11d
	subl	$1, %r11d
	cmpl	$2, %r11d
	jbe	.L15
	cmpl	$2, %r10d
	jbe	.L15
	subq	%rcx, %rax
	movslq	%ebx, %r9
	movl	%edx, %esi
	leaq	52(%rsp,%rax,4), %rcx
	subq	%r9, %rax
	shrl	$2, %esi
	movdqu	(%rcx), %xmm1
	leaq	52(%rsp,%rax,4), %rax
	movups	%xmm1, (%rax)
	cmpl	$1, %esi
	je	.L16
	movdqu	16(%rcx), %xmm2
	movups	%xmm2, 16(%rax)
	cmpl	$2, %esi
	je	.L16
	movdqu	32(%rcx), %xmm3
	movups	%xmm3, 32(%rax)
	cmpl	$3, %esi
	je	.L16
	movdqu	48(%rcx), %xmm4
	movups	%xmm4, 48(%rax)
	cmpl	$4, %esi
	je	.L16
	movdqu	64(%rcx), %xmm5
	movups	%xmm5, 64(%rax)
	cmpl	$5, %esi
	je	.L16
	movdqu	80(%rcx), %xmm6
	movups	%xmm6, 80(%rax)
	cmpl	$6, %esi
	je	.L16
	movdqu	96(%rcx), %xmm7
	movups	%xmm7, 96(%rax)
	cmpl	$7, %esi
	je	.L16
	movdqu	112(%rcx), %xmm0
	movups	%xmm0, 112(%rax)
	cmpl	$8, %esi
	je	.L16
	movdqu	128(%rcx), %xmm7
	movups	%xmm7, 128(%rax)
	cmpl	$9, %esi
	je	.L16
	movdqu	144(%rcx), %xmm6
	movups	%xmm6, 144(%rax)
	cmpl	$10, %esi
	je	.L16
	movdqu	160(%rcx), %xmm5
	movups	%xmm5, 160(%rax)
	cmpl	$11, %esi
	je	.L16
	movdqu	176(%rcx), %xmm7
	movups	%xmm7, 176(%rax)
	.p2align 4,,10
	.p2align 3
.L16:
	movl	%edx, %eax
	andl	$-4, %eax
	testb	$3, %dl
	je	.L17
	leal	(%r8,%rax), %ecx
	movslq	%ecx, %rcx
	movl	48(%rsp,%rcx,4), %esi
	leal	(%rdi,%rax), %ecx
	movslq	%ecx, %rcx
	movl	%esi, 48(%rsp,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%edx, %ecx
	jge	.L17
	leal	(%r8,%rcx), %esi
	addl	%edi, %ecx
	addl	$2, %eax
	movslq	%esi, %rsi
	movslq	%ecx, %rcx
	movl	48(%rsp,%rsi,4), %esi
	movl	%esi, 48(%rsp,%rcx,4)
	cmpl	%eax, %edx
	jle	.L17
	addl	%eax, %r8d
	addl	%eax, %edi
	movslq	%r8d, %r8
	movslq	%edi, %rdi
	movl	48(%rsp,%r8,4), %edx
	movl	%edx, 48(%rsp,%rdi,4)
.L17:
	testl	%ebx, %ebx
	jle	.L105
.L13:
	movl	32(%rsp), %eax
	movslq	%ebx, %rdx
	movq	%r12, %rsi
	addl	$1, %ebp
	salq	$2, %rdx
	subl	%ebx, %eax
	movq	%rdx, 8(%rsp)
	cltq
	leaq	48(%rsp,%rax,4), %rdi
	call	memcpy@PLT
	movq	8(%rsp), %rdx
	xorl	%esi, %esi
	movq	%r12, %rdi
	call	memset@PLT
	cmpl	36(%rsp), %ebp
	jl	.L22
.L21:
	movl	32(%rsp), %ebx
.L9:
	leal	-1(%rbx), %eax
	leaq	.LC13(%rip), %rsi
	movl	$1, %edi
	cltq
	movl	48(%rsp,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	%r9d, %r9
	movslq	%esi, %rsi
	addq	%r9, %r10
	leaq	48(%rsp,%r9,4), %rax
	subq	%r9, %rsi
	leaq	52(%rsp,%r10,4), %rcx
	.p2align 4,,10
	.p2align 3
.L19:
	movl	4(%rax), %edx
	movl	%edx, 4(%rax,%rsi,4)
	addq	$4, %rax
	cmpq	%rcx, %rax
	jne	.L19
	testl	%ebx, %ebx
	jg	.L13
	.p2align 4,,10
	.p2align 3
.L105:
	addl	$1, %ebp
	cmpl	%ebp, 36(%rsp)
	jg	.L22
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L10:
	movslq	40(%rsp), %rcx
	jmp	.L11
.L103:
	jle	.L4
	leal	-1(%rbx), %eax
	cmpl	$2, %eax
	jbe	.L26
	movdqa	.LC1(%rip), %xmm0
	movl	%ebx, %eax
	shrl	$2, %eax
	movaps	%xmm0, 48(%rsp)
	cmpl	$1, %eax
	je	.L7
	movdqa	.LC2(%rip), %xmm4
	movaps	%xmm4, 64(%rsp)
	cmpl	$2, %eax
	je	.L7
	movdqa	.LC3(%rip), %xmm6
	movaps	%xmm6, 80(%rsp)
	cmpl	$3, %eax
	je	.L7
	movdqa	.LC4(%rip), %xmm5
	movaps	%xmm5, 96(%rsp)
	cmpl	$4, %eax
	je	.L7
	movdqa	.LC5(%rip), %xmm0
	movaps	%xmm0, 112(%rsp)
	cmpl	$5, %eax
	je	.L7
	movdqa	.LC6(%rip), %xmm0
	movaps	%xmm0, 128(%rsp)
	cmpl	$6, %eax
	je	.L7
	movdqa	.LC7(%rip), %xmm0
	movaps	%xmm0, 144(%rsp)
	cmpl	$7, %eax
	je	.L7
	movdqa	.LC8(%rip), %xmm0
	movaps	%xmm0, 160(%rsp)
	cmpl	$8, %eax
	je	.L7
	movdqa	.LC9(%rip), %xmm0
	movaps	%xmm0, 176(%rsp)
	cmpl	$9, %eax
	je	.L7
	movdqa	.LC10(%rip), %xmm0
	movaps	%xmm0, 192(%rsp)
	cmpl	$10, %eax
	je	.L7
	movdqa	.LC11(%rip), %xmm0
	movaps	%xmm0, 208(%rsp)
	cmpl	$11, %eax
	je	.L7
	movdqa	.LC12(%rip), %xmm0
	movaps	%xmm0, 224(%rsp)
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%ebx, %eax
	andl	$-4, %eax
	testb	$3, %bl
	je	.L8
.L6:
	leal	1(%rax), %edx
	movslq	%eax, %rcx
	movl	%edx, 48(%rsp,%rcx,4)
	cmpl	%edx, %ebx
	jle	.L8
	leal	2(%rax), %ecx
	movslq	%edx, %rdx
	movl	%ecx, 48(%rsp,%rdx,4)
	cmpl	%ecx, %ebx
	jle	.L8
	movslq	%ecx, %rcx
	addl	$3, %eax
	movl	%eax, 48(%rsp,%rcx,4)
.L8:
	movl	%ebx, %edx
	leaq	256(%rsp), %rdi
	xorl	%esi, %esi
	salq	$2, %rdx
	call	memset@PLT
	jmp	.L4
.L26:
	xorl	%eax, %eax
	jmp	.L6
.L104:
	movq	456(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L106
	addq	$472, %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
.L106:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	1
	.long	2
	.long	3
	.long	4
	.align 16
.LC2:
	.long	5
	.long	6
	.long	7
	.long	8
	.align 16
.LC3:
	.long	9
	.long	10
	.long	11
	.long	12
	.align 16
.LC4:
	.long	13
	.long	14
	.long	15
	.long	16
	.align 16
.LC5:
	.long	17
	.long	18
	.long	19
	.long	20
	.align 16
.LC6:
	.long	21
	.long	22
	.long	23
	.long	24
	.align 16
.LC7:
	.long	25
	.long	26
	.long	27
	.long	28
	.align 16
.LC8:
	.long	29
	.long	30
	.long	31
	.long	32
	.align 16
.LC9:
	.long	33
	.long	34
	.long	35
	.long	36
	.align 16
.LC10:
	.long	37
	.long	38
	.long	39
	.long	40
	.align 16
.LC11:
	.long	41
	.long	42
	.long	43
	.long	44
	.align 16
.LC12:
	.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()
{
	int deck[50], buf[50];
	int n, r, p, c;
	int i, j, k;
	
	while(1)
	{
		scanf("%d%d", &n, &r);
		
		if(n == 0 && r == 0) break;
		
		for(i = 0; i < n; i++)
		{
			deck[i] = i + 1;
			buf[i] = 0;
		}
		
		for(i = 0; i < r; i++)
		{
			scanf("%d%d", &p, &c);
			
			for(j = 0; j < c; j++)
			{
				buf[j] = deck[n - p - c + 1 + j];
			}
			
			for(j = 0; j < p - 1; j++)
			{
				deck[n - p - c + 1 + j] = deck[n - p + 1 + j];
			}
			
			for(j = 0; j < c; j++)
			{
				deck[n - c + j] = buf[j];
				buf[j] = 0;
			}
		}
		
		printf("%d\n", deck[n - 1]);
	}
	
	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()
{
	int deck[50], buf[50];
	int n, r, p, c;
	int i, j, k;
	
	while(1)
	{
		scanf("%d%d", &n, &r);
		
		if(n == 0 && r == 0) break;
		
		for(i = 0; i < n; i++)
		{
			deck[i] = i + 1;
			buf[i] = 0;
		}
		
		for(i = 0; i < r; i++)
		{
			scanf("%d%d", &p, &c);
			
			for(j = 0; j < c; j++)
			{
				buf[j] = deck[n - p - c + 1 + j];
			}
			
			for(j = 0; j < p - 1; j++)
			{
				deck[n - p - c + 1 + j] = deck[n - p + 1 + j];
			}
			
			for(j = 0; j < c; j++)
			{
				deck[n - c + j] = buf[j];
				buf[j] = 0;
			}
		}
		
		printf("%d\n", deck[n - 1]);
	}
	
	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	$448, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L14:
	leaq	-436(%rbp), %rdx
	leaq	-440(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-440(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-436(%rbp), %eax
	testl	%eax, %eax
	je	.L18
.L2:
	movl	$0, -424(%rbp)
	jmp	.L4
.L5:
	movl	-424(%rbp), %eax
	leal	1(%rax), %edx
	movl	-424(%rbp), %eax
	cltq
	movl	%edx, -416(%rbp,%rax,4)
	movl	-424(%rbp), %eax
	cltq
	movl	$0, -208(%rbp,%rax,4)
	addl	$1, -424(%rbp)
.L4:
	movl	-440(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L5
	movl	$0, -424(%rbp)
	jmp	.L6
.L13:
	leaq	-428(%rbp), %rdx
	leaq	-432(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -420(%rbp)
	jmp	.L7
.L8:
	movl	-440(%rbp), %eax
	movl	-432(%rbp), %edx
	subl	%edx, %eax
	movl	-428(%rbp), %edx
	subl	%edx, %eax
	leal	1(%rax), %edx
	movl	-420(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-416(%rbp,%rax,4), %edx
	movl	-420(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L7:
	movl	-428(%rbp), %eax
	cmpl	%eax, -420(%rbp)
	jl	.L8
	movl	$0, -420(%rbp)
	jmp	.L9
.L10:
	movl	-440(%rbp), %eax
	movl	-432(%rbp), %edx
	subl	%edx, %eax
	leal	1(%rax), %edx
	movl	-420(%rbp), %eax
	addl	%eax, %edx
	movl	-440(%rbp), %eax
	movl	-432(%rbp), %ecx
	subl	%ecx, %eax
	movl	-428(%rbp), %ecx
	subl	%ecx, %eax
	leal	1(%rax), %ecx
	movl	-420(%rbp), %eax
	addl	%eax, %ecx
	movslq	%edx, %rax
	movl	-416(%rbp,%rax,4), %edx
	movslq	%ecx, %rax
	movl	%edx, -416(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L9:
	movl	-432(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -420(%rbp)
	jl	.L10
	movl	$0, -420(%rbp)
	jmp	.L11
.L12:
	movl	-440(%rbp), %eax
	movl	-428(%rbp), %edx
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-420(%rbp), %eax
	addl	%eax, %ecx
	movl	-420(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %edx
	movslq	%ecx, %rax
	movl	%edx, -416(%rbp,%rax,4)
	movl	-420(%rbp), %eax
	cltq
	movl	$0, -208(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L11:
	movl	-428(%rbp), %eax
	cmpl	%eax, -420(%rbp)
	jl	.L12
	addl	$1, -424(%rbp)
.L6:
	movl	-436(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L13
	movl	-440(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L14
.L18:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	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	$448, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L14:
	leaq	-436(%rbp), %rdx
	leaq	-440(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-440(%rbp), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-436(%rbp), %eax
	testl	%eax, %eax
	je	.L18
.L2:
	movl	$0, -424(%rbp)
	jmp	.L4
.L5:
	movl	-424(%rbp), %eax
	leal	1(%rax), %edx
	movl	-424(%rbp), %eax
	cltq
	movl	%edx, -416(%rbp,%rax,4)
	movl	-424(%rbp), %eax
	cltq
	movl	$0, -208(%rbp,%rax,4)
	addl	$1, -424(%rbp)
.L4:
	movl	-440(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L5
	movl	$0, -424(%rbp)
	jmp	.L6
.L13:
	leaq	-428(%rbp), %rdx
	leaq	-432(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -420(%rbp)
	jmp	.L7
.L8:
	movl	-440(%rbp), %eax
	movl	-432(%rbp), %edx
	subl	%edx, %eax
	movl	-428(%rbp), %edx
	subl	%edx, %eax
	leal	1(%rax), %edx
	movl	-420(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-416(%rbp,%rax,4), %edx
	movl	-420(%rbp), %eax
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L7:
	movl	-428(%rbp), %eax
	cmpl	%eax, -420(%rbp)
	jl	.L8
	movl	$0, -420(%rbp)
	jmp	.L9
.L10:
	movl	-440(%rbp), %eax
	movl	-432(%rbp), %edx
	subl	%edx, %eax
	leal	1(%rax), %edx
	movl	-420(%rbp), %eax
	addl	%eax, %edx
	movl	-440(%rbp), %eax
	movl	-432(%rbp), %ecx
	subl	%ecx, %eax
	movl	-428(%rbp), %ecx
	subl	%ecx, %eax
	leal	1(%rax), %ecx
	movl	-420(%rbp), %eax
	addl	%eax, %ecx
	movslq	%edx, %rax
	movl	-416(%rbp,%rax,4), %edx
	movslq	%ecx, %rax
	movl	%edx, -416(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L9:
	movl	-432(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -420(%rbp)
	jl	.L10
	movl	$0, -420(%rbp)
	jmp	.L11
.L12:
	movl	-440(%rbp), %eax
	movl	-428(%rbp), %edx
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-420(%rbp), %eax
	addl	%eax, %ecx
	movl	-420(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %edx
	movslq	%ecx, %rax
	movl	%edx, -416(%rbp,%rax,4)
	movl	-420(%rbp), %eax
	cltq
	movl	$0, -208(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L11:
	movl	-428(%rbp), %eax
	cmpl	%eax, -420(%rbp)
	jl	.L12
	addl	$1, -424(%rbp)
.L6:
	movl	-436(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L13
	movl	-440(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L14
.L18:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	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:
