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;
	int i,j;
	int num[50];
	int p,c;
	int temp[50];
	
	while(1){
		scanf("%d %d",&n,&r);
		
		if(n==0&&r==0){
			break;
		}
		for(i=0;i<n;i++){
			num[i]=n-i;
		}
		
		for(i=0;i<r;i++){
			scanf("%d %d",&p,&c);
			for(j=0;j<c;j++){
				temp[j]=num[p+j-1];
			}

			for(j=0;j<p-1;j++){
				temp[c+j]=num[j];
			}

			for(j=0;j<n-p-c+1;j++){
				temp[p+c+j-1]=num[p+c+j-1];
			}

			for(j=0;j<n;j++){
				num[j]=temp[j];
			}
		}
		printf("%d\n",num[0]);
			}
	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
.L16:
	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	.L20
.L2:
	movl	$0, -424(%rbp)
	jmp	.L4
.L5:
	movl	-440(%rbp), %eax
	subl	-424(%rbp), %eax
	movl	%eax, %edx
	movl	-424(%rbp), %eax
	cltq
	movl	%edx, -416(%rbp,%rax,4)
	addl	$1, -424(%rbp)
.L4:
	movl	-440(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L5
	movl	$0, -424(%rbp)
	jmp	.L6
.L15:
	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	-432(%rbp), %edx
	movl	-420(%rbp), %eax
	addl	%edx, %eax
	subl	$1, %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	-428(%rbp), %edx
	movl	-420(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-420(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %edx
	movslq	%ecx, %rax
	movl	%edx, -208(%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	-432(%rbp), %edx
	movl	-428(%rbp), %eax
	addl	%eax, %edx
	movl	-420(%rbp), %eax
	addl	%edx, %eax
	subl	$1, %eax
	movl	-432(%rbp), %ecx
	movl	-428(%rbp), %edx
	addl	%edx, %ecx
	movl	-420(%rbp), %edx
	addl	%ecx, %edx
	leal	-1(%rdx), %ecx
	cltq
	movl	-416(%rbp,%rax,4), %edx
	movslq	%ecx, %rax
	movl	%edx, -208(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L11:
	movl	-440(%rbp), %eax
	movl	-432(%rbp), %edx
	subl	%edx, %eax
	movl	-428(%rbp), %edx
	subl	%edx, %eax
	cmpl	%eax, -420(%rbp)
	jle	.L12
	movl	$0, -420(%rbp)
	jmp	.L13
.L14:
	movl	-420(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %edx
	movl	-420(%rbp), %eax
	cltq
	movl	%edx, -416(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L13:
	movl	-440(%rbp), %eax
	cmpl	%eax, -420(%rbp)
	jl	.L14
	addl	$1, -424(%rbp)
.L6:
	movl	-436(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L15
	movl	-416(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L16
.L20:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	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
.L10:
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %eax
	movl	36(%rsp), %ecx
	testl	%eax, %eax
	jne	.L63
	testl	%ecx, %ecx
	je	.L64
.L4:
	leaq	44(%rsp), %rax
	xorl	%ebp, %ebp
	leaq	256(%rsp), %rbx
	movq	%rax, 8(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, (%rsp)
	testl	%ecx, %ecx
	jg	.L9
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L65:
	movslq	40(%rsp), %rax
	movslq	%r13d, %rdx
	movq	%rbx, %rdi
	salq	$2, %rdx
	leaq	44(%rsp,%rax,4), %rsi
	movq	%rax, %r14
	call	memcpy@PLT
.L12:
	cmpl	$1, %r14d
	jle	.L16
	movslq	%r13d, %rax
	leaq	48(%rsp), %rsi
	leaq	(%rbx,%rax,4), %rdi
	leal	-2(%r14), %eax
	leaq	4(,%rax,4), %rdx
	call	memcpy@PLT
.L16:
	movl	32(%rsp), %r15d
	movl	%r15d, %eax
	subl	%r14d, %eax
	subl	%r13d, %eax
	js	.L15
	leal	(%r14,%r13), %ecx
	cltq
	movslq	%ecx, %rcx
	leaq	4(,%rax,4), %r9
	leaq	-4(,%rcx,4), %rdx
	leaq	(%rbx,%rdx), %rdi
	leaq	48(%rsp,%rdx), %rsi
	movq	%r9, %rdx
	call	memcpy@PLT
.L15:
	testl	%r15d, %r15d
	jle	.L61
	movslq	%r15d, %rdx
	leaq	48(%rsp), %rdi
	movq	%rbx, %rsi
	salq	$2, %rdx
	call	memcpy@PLT
.L61:
	addl	$1, %ebp
	cmpl	%ebp, 36(%rsp)
	jle	.L19
.L9:
	movq	8(%rsp), %rdx
	movq	(%rsp), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %r13d
	testl	%r13d, %r13d
	jg	.L65
	movl	40(%rsp), %r14d
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L19:
	movl	48(%rsp), %edx
	leaq	.LC13(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L10
.L63:
	jle	.L4
	leal	-1(%rax), %edx
	cmpl	$2, %edx
	jbe	.L22
	movd	%eax, %xmm2
	movl	%eax, %edx
	pshufd	$0, %xmm2, %xmm0
	shrl	$2, %edx
	movdqa	%xmm0, %xmm1
	psubd	.LC1(%rip), %xmm1
	movaps	%xmm1, 48(%rsp)
	cmpl	$1, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC2(%rip), %xmm1
	movaps	%xmm1, 64(%rsp)
	cmpl	$2, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC3(%rip), %xmm1
	movaps	%xmm1, 80(%rsp)
	cmpl	$3, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC4(%rip), %xmm1
	movaps	%xmm1, 96(%rsp)
	cmpl	$4, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC5(%rip), %xmm1
	movaps	%xmm1, 112(%rsp)
	cmpl	$5, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC6(%rip), %xmm1
	movaps	%xmm1, 128(%rsp)
	cmpl	$6, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC7(%rip), %xmm1
	movaps	%xmm1, 144(%rsp)
	cmpl	$7, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC8(%rip), %xmm1
	movaps	%xmm1, 160(%rsp)
	cmpl	$8, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC9(%rip), %xmm1
	movaps	%xmm1, 176(%rsp)
	cmpl	$9, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC10(%rip), %xmm1
	movaps	%xmm1, 192(%rsp)
	cmpl	$10, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC11(%rip), %xmm1
	movaps	%xmm1, 208(%rsp)
	cmpl	$11, %edx
	je	.L7
	psubd	.LC12(%rip), %xmm0
	movaps	%xmm0, 224(%rsp)
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%eax, %edx
	andl	$-4, %edx
	testb	$3, %al
	je	.L4
.L6:
	movl	%eax, %edi
	movslq	%edx, %rsi
	subl	%edx, %edi
	movl	%edi, 48(%rsp,%rsi,4)
	leal	1(%rdx), %esi
	cmpl	%esi, %eax
	jle	.L4
	movl	%eax, %r8d
	movslq	%esi, %rdi
	addl	$2, %edx
	subl	%esi, %r8d
	movl	%r8d, 48(%rsp,%rdi,4)
	cmpl	%edx, %eax
	jle	.L4
	movslq	%edx, %rsi
	subl	%edx, %eax
	movl	%eax, 48(%rsp,%rsi,4)
	jmp	.L4
.L22:
	xorl	%edx, %edx
	jmp	.L6
.L64:
	movq	456(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L66
	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
.L66:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC2:
	.long	4
	.long	5
	.long	6
	.long	7
	.align 16
.LC3:
	.long	8
	.long	9
	.long	10
	.long	11
	.align 16
.LC4:
	.long	12
	.long	13
	.long	14
	.long	15
	.align 16
.LC5:
	.long	16
	.long	17
	.long	18
	.long	19
	.align 16
.LC6:
	.long	20
	.long	21
	.long	22
	.long	23
	.align 16
.LC7:
	.long	24
	.long	25
	.long	26
	.long	27
	.align 16
.LC8:
	.long	28
	.long	29
	.long	30
	.long	31
	.align 16
.LC9:
	.long	32
	.long	33
	.long	34
	.long	35
	.align 16
.LC10:
	.long	36
	.long	37
	.long	38
	.long	39
	.align 16
.LC11:
	.long	40
	.long	41
	.long	42
	.long	43
	.align 16
.LC12:
	.long	44
	.long	45
	.long	46
	.long	47
	.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
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	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
.L10:
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %eax
	movl	36(%rsp), %ecx
	testl	%eax, %eax
	jne	.L63
	testl	%ecx, %ecx
	je	.L64
.L4:
	leaq	44(%rsp), %rax
	xorl	%ebp, %ebp
	leaq	256(%rsp), %rbx
	movq	%rax, 8(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, (%rsp)
	testl	%ecx, %ecx
	jg	.L9
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L65:
	movslq	40(%rsp), %rax
	movslq	%r13d, %rdx
	movq	%rbx, %rdi
	salq	$2, %rdx
	leaq	44(%rsp,%rax,4), %rsi
	movq	%rax, %r14
	call	memcpy@PLT
.L12:
	cmpl	$1, %r14d
	jle	.L16
	movslq	%r13d, %rax
	leaq	48(%rsp), %rsi
	leaq	(%rbx,%rax,4), %rdi
	leal	-2(%r14), %eax
	leaq	4(,%rax,4), %rdx
	call	memcpy@PLT
.L16:
	movl	32(%rsp), %r15d
	movl	%r15d, %eax
	subl	%r14d, %eax
	subl	%r13d, %eax
	js	.L15
	leal	(%r14,%r13), %ecx
	cltq
	movslq	%ecx, %rcx
	leaq	4(,%rax,4), %r9
	leaq	-4(,%rcx,4), %rdx
	leaq	(%rbx,%rdx), %rdi
	leaq	48(%rsp,%rdx), %rsi
	movq	%r9, %rdx
	call	memcpy@PLT
.L15:
	testl	%r15d, %r15d
	jle	.L61
	movslq	%r15d, %rdx
	leaq	48(%rsp), %rdi
	movq	%rbx, %rsi
	salq	$2, %rdx
	call	memcpy@PLT
.L61:
	addl	$1, %ebp
	cmpl	%ebp, 36(%rsp)
	jle	.L19
.L9:
	movq	8(%rsp), %rdx
	movq	(%rsp), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %r13d
	testl	%r13d, %r13d
	jg	.L65
	movl	40(%rsp), %r14d
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L19:
	movl	48(%rsp), %edx
	leaq	.LC13(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L10
.L63:
	jle	.L4
	leal	-1(%rax), %edx
	cmpl	$2, %edx
	jbe	.L22
	movd	%eax, %xmm2
	movl	%eax, %edx
	pshufd	$0, %xmm2, %xmm0
	shrl	$2, %edx
	movdqa	%xmm0, %xmm1
	psubd	.LC1(%rip), %xmm1
	movaps	%xmm1, 48(%rsp)
	cmpl	$1, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC2(%rip), %xmm1
	movaps	%xmm1, 64(%rsp)
	cmpl	$2, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC3(%rip), %xmm1
	movaps	%xmm1, 80(%rsp)
	cmpl	$3, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC4(%rip), %xmm1
	movaps	%xmm1, 96(%rsp)
	cmpl	$4, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC5(%rip), %xmm1
	movaps	%xmm1, 112(%rsp)
	cmpl	$5, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC6(%rip), %xmm1
	movaps	%xmm1, 128(%rsp)
	cmpl	$6, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC7(%rip), %xmm1
	movaps	%xmm1, 144(%rsp)
	cmpl	$7, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC8(%rip), %xmm1
	movaps	%xmm1, 160(%rsp)
	cmpl	$8, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC9(%rip), %xmm1
	movaps	%xmm1, 176(%rsp)
	cmpl	$9, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC10(%rip), %xmm1
	movaps	%xmm1, 192(%rsp)
	cmpl	$10, %edx
	je	.L7
	movdqa	%xmm0, %xmm1
	psubd	.LC11(%rip), %xmm1
	movaps	%xmm1, 208(%rsp)
	cmpl	$11, %edx
	je	.L7
	psubd	.LC12(%rip), %xmm0
	movaps	%xmm0, 224(%rsp)
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%eax, %edx
	andl	$-4, %edx
	testb	$3, %al
	je	.L4
.L6:
	movl	%eax, %edi
	movslq	%edx, %rsi
	subl	%edx, %edi
	movl	%edi, 48(%rsp,%rsi,4)
	leal	1(%rdx), %esi
	cmpl	%esi, %eax
	jle	.L4
	movl	%eax, %r8d
	movslq	%esi, %rdi
	addl	$2, %edx
	subl	%esi, %r8d
	movl	%r8d, 48(%rsp,%rdi,4)
	cmpl	%edx, %eax
	jle	.L4
	movslq	%edx, %rsi
	subl	%edx, %eax
	movl	%eax, 48(%rsp,%rsi,4)
	jmp	.L4
.L22:
	xorl	%edx, %edx
	jmp	.L6
.L64:
	movq	456(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L66
	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
.L66:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC2:
	.long	4
	.long	5
	.long	6
	.long	7
	.align 16
.LC3:
	.long	8
	.long	9
	.long	10
	.long	11
	.align 16
.LC4:
	.long	12
	.long	13
	.long	14
	.long	15
	.align 16
.LC5:
	.long	16
	.long	17
	.long	18
	.long	19
	.align 16
.LC6:
	.long	20
	.long	21
	.long	22
	.long	23
	.align 16
.LC7:
	.long	24
	.long	25
	.long	26
	.long	27
	.align 16
.LC8:
	.long	28
	.long	29
	.long	30
	.long	31
	.align 16
.LC9:
	.long	32
	.long	33
	.long	34
	.long	35
	.align 16
.LC10:
	.long	36
	.long	37
	.long	38
	.long	39
	.align 16
.LC11:
	.long	40
	.long	41
	.long	42
	.long	43
	.align 16
.LC12:
	.long	44
	.long	45
	.long	46
	.long	47
	.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;
	int i,j;
	int num[50];
	int p,c;
	int temp[50];
	
	while(1){
		scanf("%d %d",&n,&r);
		
		if(n==0&&r==0){
			break;
		}
		for(i=0;i<n;i++){
			num[i]=n-i;
		}
		
		for(i=0;i<r;i++){
			scanf("%d %d",&p,&c);
			for(j=0;j<c;j++){
				temp[j]=num[p+j-1];
			}

			for(j=0;j<p-1;j++){
				temp[c+j]=num[j];
			}

			for(j=0;j<n-p-c+1;j++){
				temp[p+c+j-1]=num[p+c+j-1];
			}

			for(j=0;j<n;j++){
				num[j]=temp[j];
			}
		}
		printf("%d\n",num[0]);
			}
	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
 5 0
3 1
3 1
3 3
1 10
10 1
11 0
0 0
 5 0
3 1
3 1
7 2
1 10
10 1
11 0
0 0
 5 0
3 1
3 1
10 2
1 10
10 1
2 -1
0 0
 1 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
 5
1
0
 5
1
0
11
 5
1
1
2
 1
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;
	int i,j;
	int num[50];
	int p,c;
	int temp[50];
	
	while(1){
		scanf("%d %d",&n,&r);
		
		if(n==0&&r==0){
			break;
		}
		for(i=0;i<n;i++){
			num[i]=n-i;
		}
		
		for(i=0;i<r;i++){
			scanf("%d %d",&p,&c);
			for(j=0;j<c;j++){
				temp[j]=num[p+j-1];
			}

			for(j=0;j<p-1;j++){
				temp[c+j]=num[j];
			}

			for(j=0;j<n-p-c+1;j++){
				temp[p+c+j-1]=num[p+c+j-1];
			}

			for(j=0;j<n;j++){
				num[j]=temp[j];
			}
		}
		printf("%d\n",num[0]);
			}
	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
.L16:
	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	.L20
.L2:
	movl	$0, -424(%rbp)
	jmp	.L4
.L5:
	movl	-440(%rbp), %eax
	subl	-424(%rbp), %eax
	movl	%eax, %edx
	movl	-424(%rbp), %eax
	cltq
	movl	%edx, -416(%rbp,%rax,4)
	addl	$1, -424(%rbp)
.L4:
	movl	-440(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L5
	movl	$0, -424(%rbp)
	jmp	.L6
.L15:
	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	-432(%rbp), %edx
	movl	-420(%rbp), %eax
	addl	%edx, %eax
	subl	$1, %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	-428(%rbp), %edx
	movl	-420(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-420(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %edx
	movslq	%ecx, %rax
	movl	%edx, -208(%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	-432(%rbp), %edx
	movl	-428(%rbp), %eax
	addl	%eax, %edx
	movl	-420(%rbp), %eax
	addl	%edx, %eax
	subl	$1, %eax
	movl	-432(%rbp), %ecx
	movl	-428(%rbp), %edx
	addl	%edx, %ecx
	movl	-420(%rbp), %edx
	addl	%ecx, %edx
	leal	-1(%rdx), %ecx
	cltq
	movl	-416(%rbp,%rax,4), %edx
	movslq	%ecx, %rax
	movl	%edx, -208(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L11:
	movl	-440(%rbp), %eax
	movl	-432(%rbp), %edx
	subl	%edx, %eax
	movl	-428(%rbp), %edx
	subl	%edx, %eax
	cmpl	%eax, -420(%rbp)
	jle	.L12
	movl	$0, -420(%rbp)
	jmp	.L13
.L14:
	movl	-420(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %edx
	movl	-420(%rbp), %eax
	cltq
	movl	%edx, -416(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L13:
	movl	-440(%rbp), %eax
	cmpl	%eax, -420(%rbp)
	jl	.L14
	addl	$1, -424(%rbp)
.L6:
	movl	-436(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L15
	movl	-416(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L16
.L20:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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
.L16:
	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	.L20
.L2:
	movl	$0, -424(%rbp)
	jmp	.L4
.L5:
	movl	-440(%rbp), %eax
	subl	-424(%rbp), %eax
	movl	%eax, %edx
	movl	-424(%rbp), %eax
	cltq
	movl	%edx, -416(%rbp,%rax,4)
	addl	$1, -424(%rbp)
.L4:
	movl	-440(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L5
	movl	$0, -424(%rbp)
	jmp	.L6
.L15:
	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	-432(%rbp), %edx
	movl	-420(%rbp), %eax
	addl	%edx, %eax
	subl	$1, %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	-428(%rbp), %edx
	movl	-420(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-420(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %edx
	movslq	%ecx, %rax
	movl	%edx, -208(%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	-432(%rbp), %edx
	movl	-428(%rbp), %eax
	addl	%eax, %edx
	movl	-420(%rbp), %eax
	addl	%edx, %eax
	subl	$1, %eax
	movl	-432(%rbp), %ecx
	movl	-428(%rbp), %edx
	addl	%edx, %ecx
	movl	-420(%rbp), %edx
	addl	%ecx, %edx
	leal	-1(%rdx), %ecx
	cltq
	movl	-416(%rbp,%rax,4), %edx
	movslq	%ecx, %rax
	movl	%edx, -208(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L11:
	movl	-440(%rbp), %eax
	movl	-432(%rbp), %edx
	subl	%edx, %eax
	movl	-428(%rbp), %edx
	subl	%edx, %eax
	cmpl	%eax, -420(%rbp)
	jle	.L12
	movl	$0, -420(%rbp)
	jmp	.L13
.L14:
	movl	-420(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %edx
	movl	-420(%rbp), %eax
	cltq
	movl	%edx, -416(%rbp,%rax,4)
	addl	$1, -420(%rbp)
.L13:
	movl	-440(%rbp), %eax
	cmpl	%eax, -420(%rbp)
	jl	.L14
	addl	$1, -424(%rbp)
.L6:
	movl	-436(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L15
	movl	-416(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L16
.L20:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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:
