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 cards_num;
int cards[50];

void cards_init(int num) {
	int i;
	cards_num=num;
	for(i=0;i<num;i++)cards[i]=i;
}

void rs(int c) {
	int cards2[50];
	int a_start,a_end;
	int b_start,b_end;
	int c_pos=0;
	int i;
	b_start=0;b_end=cards_num/2;
	a_start=b_end;a_end=cards_num;
	while(a_start<a_end || b_start<b_end) {
		for(i=0;a_start<a_end && i<c;i++)cards2[c_pos++]=cards[a_start++];
		for(i=0;b_start<b_end && i<c;i++)cards2[c_pos++]=cards[b_start++];
	}
	for(i=0;i<cards_num;i++)cards[i]=cards2[i];
}

int main(void) {
	int i;
	int cn,rsn,c;
	while(scanf("%d%d",&cn,&rsn)==2) {
		cards_init(cn);
		for(i=0;i<rsn;i++) {
			scanf("%d",&c);
			rs(c);
		}
		printf("%d\n",cards[cn-1]);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	cards_num
	.bss
	.align 4
	.type	cards_num, @object
	.size	cards_num, 4
cards_num:
	.zero	4
	.globl	cards
	.align 32
	.type	cards, @object
	.size	cards, 200
cards:
	.zero	200
	.text
	.globl	cards_init
	.type	cards_init, @function
cards_init:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, cards_num(%rip)
	movl	$0, -4(%rbp)
	jmp	.L2
.L3:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	cards(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -4(%rbp)
.L2:
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jl	.L3
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	cards_init, .-cards_init
	.globl	rs
	.type	rs, @function
rs:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$256, %rsp
	movl	%edi, -244(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -224(%rbp)
	movl	$0, -228(%rbp)
	movl	cards_num(%rip), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -216(%rbp)
	movl	-216(%rbp), %eax
	movl	%eax, -232(%rbp)
	movl	cards_num(%rip), %eax
	movl	%eax, -212(%rbp)
	jmp	.L5
.L11:
	movl	$0, -220(%rbp)
	jmp	.L6
.L8:
	movl	-232(%rbp), %edx
	leal	1(%rdx), %eax
	movl	%eax, -232(%rbp)
	movl	-224(%rbp), %eax
	leal	1(%rax), %ecx
	movl	%ecx, -224(%rbp)
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cards(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	addl	$1, -220(%rbp)
.L6:
	movl	-232(%rbp), %eax
	cmpl	-212(%rbp), %eax
	jge	.L7
	movl	-220(%rbp), %eax
	cmpl	-244(%rbp), %eax
	jl	.L8
.L7:
	movl	$0, -220(%rbp)
	jmp	.L9
.L10:
	movl	-228(%rbp), %edx
	leal	1(%rdx), %eax
	movl	%eax, -228(%rbp)
	movl	-224(%rbp), %eax
	leal	1(%rax), %ecx
	movl	%ecx, -224(%rbp)
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cards(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	addl	$1, -220(%rbp)
.L9:
	movl	-228(%rbp), %eax
	cmpl	-216(%rbp), %eax
	jge	.L5
	movl	-220(%rbp), %eax
	cmpl	-244(%rbp), %eax
	jl	.L10
.L5:
	movl	-232(%rbp), %eax
	cmpl	-212(%rbp), %eax
	jl	.L11
	movl	-228(%rbp), %eax
	cmpl	-216(%rbp), %eax
	jl	.L11
	movl	$0, -220(%rbp)
	jmp	.L12
.L13:
	movl	-220(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	movl	-220(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cards(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -220(%rbp)
.L12:
	movl	cards_num(%rip), %eax
	cmpl	%eax, -220(%rbp)
	jl	.L13
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	rs, .-rs
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L16
.L19:
	movl	-24(%rbp), %eax
	movl	%eax, %edi
	call	cards_init
	movl	$0, -12(%rbp)
	jmp	.L17
.L18:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	rs
	addl	$1, -12(%rbp)
.L17:
	movl	-20(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L18
	movl	-24(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cards(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L16:
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L19
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	cards_init
	.type	cards_init, @function
cards_init:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%edi, cards_num(%rip)
	testl	%edi, %edi
	jle	.L1
	leal	-1(%rdi), %eax
	cmpl	$2, %eax
	jbe	.L6
	movdqa	.LC0(%rip), %xmm0
	movl	%edi, %eax
	shrl	$2, %eax
	movaps	%xmm0, cards(%rip)
	cmpl	$1, %eax
	je	.L4
	movdqa	.LC1(%rip), %xmm0
	movaps	%xmm0, 16+cards(%rip)
	cmpl	$2, %eax
	je	.L4
	movdqa	.LC2(%rip), %xmm0
	movaps	%xmm0, 32+cards(%rip)
	cmpl	$3, %eax
	je	.L4
	movdqa	.LC3(%rip), %xmm0
	movaps	%xmm0, 48+cards(%rip)
	cmpl	$4, %eax
	je	.L4
	movdqa	.LC4(%rip), %xmm0
	movaps	%xmm0, 64+cards(%rip)
	cmpl	$5, %eax
	je	.L4
	movdqa	.LC5(%rip), %xmm0
	movaps	%xmm0, 80+cards(%rip)
	cmpl	$6, %eax
	je	.L4
	movdqa	.LC6(%rip), %xmm0
	movaps	%xmm0, 96+cards(%rip)
	cmpl	$7, %eax
	je	.L4
	movdqa	.LC7(%rip), %xmm0
	movaps	%xmm0, 112+cards(%rip)
	cmpl	$8, %eax
	je	.L4
	movdqa	.LC8(%rip), %xmm0
	movaps	%xmm0, 128+cards(%rip)
	cmpl	$9, %eax
	je	.L4
	movdqa	.LC9(%rip), %xmm0
	movaps	%xmm0, 144+cards(%rip)
	cmpl	$10, %eax
	je	.L4
	movdqa	.LC10(%rip), %xmm0
	movaps	%xmm0, 160+cards(%rip)
	cmpl	$11, %eax
	je	.L4
	movdqa	.LC11(%rip), %xmm0
	movaps	%xmm0, 176+cards(%rip)
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edi, %eax
	andl	$-4, %eax
	testb	$3, %dil
	je	.L41
.L3:
	movslq	%eax, %rdx
	leaq	cards(%rip), %rcx
	movl	%eax, (%rcx,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%edx, %edi
	jle	.L1
	movslq	%edx, %rsi
	addl	$2, %eax
	movl	%edx, (%rcx,%rsi,4)
	cmpl	%eax, %edi
	jle	.L1
	movslq	%eax, %rdx
	movl	%eax, (%rcx,%rdx,4)
.L1:
	ret
	.p2align 4,,10
	.p2align 3
.L41:
	ret
.L6:
	xorl	%eax, %eax
	jmp	.L3
	.cfi_endproc
.LFE23:
	.size	cards_init, .-cards_init
	.p2align 4
	.globl	rs
	.type	rs, @function
rs:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$232, %rsp
	.cfi_def_cfa_offset 288
	movl	cards_num(%rip), %ebp
	movq	%fs:40, %rax
	movq	%rax, 216(%rsp)
	xorl	%eax, %eax
	movl	$1, %eax
	movl	%ebp, %r9d
	shrl	$31, %r9d
	addl	%ebp, %r9d
	sarl	%r9d
	testl	%r9d, %r9d
	cmovle	%r9d, %eax
	cmpl	%eax, %ebp
	jle	.L43
	testl	%edi, %edi
	movslq	%r9d, %rbx
	leaq	16(%rsp), %r15
	setg	%r14b
	leaq	-4+cards(%rip), %r11
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L44:
	cmpl	%ebx, %ebp
	movl	%r14d, %eax
	setg	%r8b
	andb	%r8b, %al
	movb	%al, 15(%rsp)
	je	.L57
	movslq	%ecx, %rdx
	leal	1(%rbx), %eax
	leal	1(%rcx), %r12d
	subq	%rbx, %rdx
	cltq
	leaq	(%r15,%rdx,4), %r10
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L45:
	movl	(%r11,%rax,4), %r8d
	leal	(%r12,%rdx), %ecx
	addl	$1, %edx
	cmpl	%eax, %ebp
	movslq	%eax, %rbx
	movl	%r8d, -4(%r10,%rax,4)
	setg	%r8b
	addq	$1, %rax
	cmpl	%edx, %edi
	jle	.L57
	testb	%r8b, %r8b
	jne	.L45
.L57:
	cmpl	%esi, %r9d
	setg	%al
	movl	%eax, %r10d
	testb	%r14b, %r14b
	je	.L47
	testb	%al, %al
	je	.L47
	movslq	%ecx, %rdx
	leal	1(%rsi), %eax
	leal	1(%rcx), %r12d
	subq	%rsi, %rdx
	cltq
	leaq	(%r15,%rdx,4), %r13
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L48:
	movl	(%r11,%rax,4), %r10d
	leal	(%r12,%rdx), %ecx
	addl	$1, %edx
	cmpl	%eax, %r9d
	movslq	%eax, %rsi
	movl	%r10d, -4(%r13,%rax,4)
	setg	%r10b
	addq	$1, %rax
	cmpl	%edx, %edi
	jle	.L47
	testb	%r10b, %r10b
	jne	.L48
.L47:
	testb	%r8b, %r8b
	jne	.L50
	testb	%r10b, %r10b
	je	.L43
.L50:
	cmpb	$0, 15(%rsp)
	jne	.L44
	leaq	16(%rsp), %r12
	leaq	-4+cards(%rip), %r10
.L81:
	cmpl	%ebx, %ebp
	setg	%r15b
	cmpl	%esi, %r9d
	setg	%r8b
	jle	.L51
	testb	%r14b, %r14b
	je	.L51
	movslq	%ecx, %rdx
	leal	1(%rsi), %eax
	leal	1(%rcx), %r11d
	subq	%rsi, %rdx
	cltq
	leaq	(%r12,%rdx,4), %r13
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L52:
	movl	(%r10,%rax,4), %r8d
	leal	(%r11,%rdx), %ecx
	addl	$1, %edx
	cmpl	%eax, %r9d
	movslq	%eax, %rsi
	movl	%r8d, -4(%r13,%rax,4)
	setg	%r8b
	addq	$1, %rax
	cmpl	%edx, %edi
	jle	.L51
	testb	%r8b, %r8b
	jne	.L52
.L51:
	testb	%r15b, %r15b
	jne	.L81
	testb	%r8b, %r8b
	jne	.L81
.L43:
	testl	%ebp, %ebp
	jle	.L42
	movslq	%ebp, %rdx
	leaq	16(%rsp), %rsi
	leaq	cards(%rip), %rdi
	salq	$2, %rdx
	call	memcpy@PLT
.L42:
	movq	216(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L93
	addq	$232, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L93:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	rs, .-rs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC12:
	.string	"%d"
.LC13:
	.string	"%d\n"
.LC14:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %r15
	leaq	12(%rsp), %r14
	.p2align 4,,10
	.p2align 3
.L95:
	xorl	%eax, %eax
	movq	%r15, %rdx
	leaq	.LC14(%rip), %rdi
	movq	%r14, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L143
	movl	12(%rsp), %eax
	movl	%eax, cards_num(%rip)
	testl	%eax, %eax
	jle	.L144
	leal	-1(%rax), %edx
	cmpl	$2, %edx
	jbe	.L106
	movdqa	.LC0(%rip), %xmm1
	movl	%eax, %edx
	leaq	cards(%rip), %r12
	shrl	$2, %edx
	movaps	%xmm1, cards(%rip)
	cmpl	$1, %edx
	je	.L100
	movdqa	.LC1(%rip), %xmm2
	movaps	%xmm2, 16+cards(%rip)
	cmpl	$2, %edx
	je	.L100
	movdqa	.LC2(%rip), %xmm3
	movaps	%xmm3, 32+cards(%rip)
	cmpl	$3, %edx
	je	.L100
	movdqa	.LC3(%rip), %xmm4
	movaps	%xmm4, 48+cards(%rip)
	cmpl	$4, %edx
	je	.L100
	movdqa	.LC4(%rip), %xmm0
	movaps	%xmm0, 64+cards(%rip)
	cmpl	$5, %edx
	je	.L100
	movdqa	.LC5(%rip), %xmm0
	movaps	%xmm0, 80+cards(%rip)
	cmpl	$6, %edx
	je	.L100
	movdqa	.LC6(%rip), %xmm0
	movaps	%xmm0, 96+cards(%rip)
	cmpl	$7, %edx
	je	.L100
	movdqa	.LC7(%rip), %xmm0
	movaps	%xmm0, 112+cards(%rip)
	cmpl	$8, %edx
	je	.L100
	movdqa	.LC8(%rip), %xmm0
	movaps	%xmm0, 128+cards(%rip)
	cmpl	$9, %edx
	je	.L100
	movdqa	.LC9(%rip), %xmm0
	movaps	%xmm0, 144+cards(%rip)
	cmpl	$10, %edx
	je	.L100
	movdqa	.LC10(%rip), %xmm0
	movaps	%xmm0, 160+cards(%rip)
	cmpl	$11, %edx
	je	.L100
	movdqa	.LC11(%rip), %xmm0
	movaps	%xmm0, 176+cards(%rip)
	.p2align 4,,10
	.p2align 3
.L100:
	movl	%eax, %edx
	andl	$-4, %edx
	testb	$3, %al
	je	.L101
.L99:
	movslq	%edx, %rcx
	movl	%edx, (%r12,%rcx,4)
	leal	1(%rdx), %ecx
	cmpl	%ecx, %eax
	jle	.L101
	movslq	%ecx, %rsi
	addl	$2, %edx
	movl	%ecx, (%r12,%rsi,4)
	cmpl	%edx, %eax
	jle	.L101
	movslq	%edx, %rcx
	movl	%edx, (%r12,%rcx,4)
.L101:
	movl	16(%rsp), %edx
	xorl	%r13d, %r13d
	leaq	20(%rsp), %rbp
	leaq	.LC12(%rip), %rbx
	testl	%edx, %edx
	jle	.L98
	.p2align 4,,10
	.p2align 3
.L97:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %edi
	call	rs
	cmpl	%r13d, 16(%rsp)
	jg	.L97
	movl	12(%rsp), %eax
.L98:
	subl	$1, %eax
	leaq	.LC13(%rip), %rsi
	movl	$1, %edi
	cltq
	movl	(%r12,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L95
	.p2align 4,,10
	.p2align 3
.L143:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L145
	addq	$40, %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
	.p2align 4,,10
	.p2align 3
.L144:
	.cfi_restore_state
	leaq	cards(%rip), %r12
	jmp	.L101
.L106:
	xorl	%edx, %edx
	leaq	cards(%rip), %r12
	jmp	.L99
.L145:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.size	main, .-main
	.globl	cards
	.bss
	.align 32
	.type	cards, @object
	.size	cards, 200
cards:
	.zero	200
	.globl	cards_num
	.align 4
	.type	cards_num, @object
	.size	cards_num, 4
cards_num:
	.zero	4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC1:
	.long	4
	.long	5
	.long	6
	.long	7
	.align 16
.LC2:
	.long	8
	.long	9
	.long	10
	.long	11
	.align 16
.LC3:
	.long	12
	.long	13
	.long	14
	.long	15
	.align 16
.LC4:
	.long	16
	.long	17
	.long	18
	.long	19
	.align 16
.LC5:
	.long	20
	.long	21
	.long	22
	.long	23
	.align 16
.LC6:
	.long	24
	.long	25
	.long	26
	.long	27
	.align 16
.LC7:
	.long	28
	.long	29
	.long	30
	.long	31
	.align 16
.LC8:
	.long	32
	.long	33
	.long	34
	.long	35
	.align 16
.LC9:
	.long	36
	.long	37
	.long	38
	.long	39
	.align 16
.LC10:
	.long	40
	.long	41
	.long	42
	.long	43
	.align 16
.LC11:
	.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
	.p2align 4
	.globl	cards_init
	.type	cards_init, @function
cards_init:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%edi, cards_num(%rip)
	testl	%edi, %edi
	jle	.L1
	leal	-1(%rdi), %eax
	cmpl	$2, %eax
	jbe	.L6
	movdqa	.LC0(%rip), %xmm0
	movl	%edi, %eax
	shrl	$2, %eax
	movaps	%xmm0, cards(%rip)
	cmpl	$1, %eax
	je	.L4
	movdqa	.LC1(%rip), %xmm0
	movaps	%xmm0, 16+cards(%rip)
	cmpl	$2, %eax
	je	.L4
	movdqa	.LC2(%rip), %xmm0
	movaps	%xmm0, 32+cards(%rip)
	cmpl	$3, %eax
	je	.L4
	movdqa	.LC3(%rip), %xmm0
	movaps	%xmm0, 48+cards(%rip)
	cmpl	$4, %eax
	je	.L4
	movdqa	.LC4(%rip), %xmm0
	movaps	%xmm0, 64+cards(%rip)
	cmpl	$5, %eax
	je	.L4
	movdqa	.LC5(%rip), %xmm0
	movaps	%xmm0, 80+cards(%rip)
	cmpl	$6, %eax
	je	.L4
	movdqa	.LC6(%rip), %xmm0
	movaps	%xmm0, 96+cards(%rip)
	cmpl	$7, %eax
	je	.L4
	movdqa	.LC7(%rip), %xmm0
	movaps	%xmm0, 112+cards(%rip)
	cmpl	$8, %eax
	je	.L4
	movdqa	.LC8(%rip), %xmm0
	movaps	%xmm0, 128+cards(%rip)
	cmpl	$9, %eax
	je	.L4
	movdqa	.LC9(%rip), %xmm0
	movaps	%xmm0, 144+cards(%rip)
	cmpl	$10, %eax
	je	.L4
	movdqa	.LC10(%rip), %xmm0
	movaps	%xmm0, 160+cards(%rip)
	cmpl	$11, %eax
	je	.L4
	movdqa	.LC11(%rip), %xmm0
	movaps	%xmm0, 176+cards(%rip)
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edi, %eax
	andl	$-4, %eax
	testb	$3, %dil
	je	.L41
.L3:
	movslq	%eax, %rdx
	leaq	cards(%rip), %rcx
	movl	%eax, (%rcx,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%edx, %edi
	jle	.L1
	movslq	%edx, %rsi
	addl	$2, %eax
	movl	%edx, (%rcx,%rsi,4)
	cmpl	%eax, %edi
	jle	.L1
	movslq	%eax, %rdx
	movl	%eax, (%rcx,%rdx,4)
.L1:
	ret
	.p2align 4,,10
	.p2align 3
.L41:
	ret
.L6:
	xorl	%eax, %eax
	jmp	.L3
	.cfi_endproc
.LFE23:
	.size	cards_init, .-cards_init
	.p2align 4
	.globl	rs
	.type	rs, @function
rs:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$232, %rsp
	.cfi_def_cfa_offset 288
	movl	cards_num(%rip), %ebp
	movq	%fs:40, %rax
	movq	%rax, 216(%rsp)
	xorl	%eax, %eax
	movl	$1, %eax
	movl	%ebp, %r9d
	shrl	$31, %r9d
	addl	%ebp, %r9d
	sarl	%r9d
	testl	%r9d, %r9d
	cmovle	%r9d, %eax
	cmpl	%eax, %ebp
	jle	.L43
	testl	%edi, %edi
	movslq	%r9d, %rbx
	leaq	16(%rsp), %r15
	setg	%r14b
	leaq	-4+cards(%rip), %r11
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L44:
	cmpl	%ebx, %ebp
	movl	%r14d, %eax
	setg	%r8b
	andb	%r8b, %al
	movb	%al, 15(%rsp)
	je	.L57
	movslq	%ecx, %rdx
	leal	1(%rbx), %eax
	leal	1(%rcx), %r12d
	subq	%rbx, %rdx
	cltq
	leaq	(%r15,%rdx,4), %r10
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L45:
	movl	(%r11,%rax,4), %r8d
	leal	(%r12,%rdx), %ecx
	addl	$1, %edx
	cmpl	%eax, %ebp
	movslq	%eax, %rbx
	movl	%r8d, -4(%r10,%rax,4)
	setg	%r8b
	addq	$1, %rax
	cmpl	%edx, %edi
	jle	.L57
	testb	%r8b, %r8b
	jne	.L45
.L57:
	cmpl	%esi, %r9d
	setg	%al
	movl	%eax, %r10d
	testb	%r14b, %r14b
	je	.L47
	testb	%al, %al
	je	.L47
	movslq	%ecx, %rdx
	leal	1(%rsi), %eax
	leal	1(%rcx), %r12d
	subq	%rsi, %rdx
	cltq
	leaq	(%r15,%rdx,4), %r13
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L48:
	movl	(%r11,%rax,4), %r10d
	leal	(%r12,%rdx), %ecx
	addl	$1, %edx
	cmpl	%eax, %r9d
	movslq	%eax, %rsi
	movl	%r10d, -4(%r13,%rax,4)
	setg	%r10b
	addq	$1, %rax
	cmpl	%edx, %edi
	jle	.L47
	testb	%r10b, %r10b
	jne	.L48
.L47:
	testb	%r8b, %r8b
	jne	.L50
	testb	%r10b, %r10b
	je	.L43
.L50:
	cmpb	$0, 15(%rsp)
	jne	.L44
	leaq	16(%rsp), %r12
	leaq	-4+cards(%rip), %r10
.L81:
	cmpl	%ebx, %ebp
	setg	%r15b
	cmpl	%esi, %r9d
	setg	%r8b
	jle	.L51
	testb	%r14b, %r14b
	je	.L51
	movslq	%ecx, %rdx
	leal	1(%rsi), %eax
	leal	1(%rcx), %r11d
	subq	%rsi, %rdx
	cltq
	leaq	(%r12,%rdx,4), %r13
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L52:
	movl	(%r10,%rax,4), %r8d
	leal	(%r11,%rdx), %ecx
	addl	$1, %edx
	cmpl	%eax, %r9d
	movslq	%eax, %rsi
	movl	%r8d, -4(%r13,%rax,4)
	setg	%r8b
	addq	$1, %rax
	cmpl	%edx, %edi
	jle	.L51
	testb	%r8b, %r8b
	jne	.L52
.L51:
	testb	%r15b, %r15b
	jne	.L81
	testb	%r8b, %r8b
	jne	.L81
.L43:
	testl	%ebp, %ebp
	jle	.L42
	movslq	%ebp, %rdx
	leaq	16(%rsp), %rsi
	leaq	cards(%rip), %rdi
	salq	$2, %rdx
	call	memcpy@PLT
.L42:
	movq	216(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L93
	addq	$232, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L93:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	rs, .-rs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC12:
	.string	"%d"
.LC13:
	.string	"%d\n"
.LC14:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %r15
	leaq	12(%rsp), %r14
	.p2align 4,,10
	.p2align 3
.L95:
	xorl	%eax, %eax
	movq	%r15, %rdx
	leaq	.LC14(%rip), %rdi
	movq	%r14, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L143
	movl	12(%rsp), %eax
	movl	%eax, cards_num(%rip)
	testl	%eax, %eax
	jle	.L144
	leal	-1(%rax), %edx
	cmpl	$2, %edx
	jbe	.L106
	movdqa	.LC0(%rip), %xmm1
	movl	%eax, %edx
	leaq	cards(%rip), %r12
	shrl	$2, %edx
	movaps	%xmm1, cards(%rip)
	cmpl	$1, %edx
	je	.L100
	movdqa	.LC1(%rip), %xmm2
	movaps	%xmm2, 16+cards(%rip)
	cmpl	$2, %edx
	je	.L100
	movdqa	.LC2(%rip), %xmm3
	movaps	%xmm3, 32+cards(%rip)
	cmpl	$3, %edx
	je	.L100
	movdqa	.LC3(%rip), %xmm4
	movaps	%xmm4, 48+cards(%rip)
	cmpl	$4, %edx
	je	.L100
	movdqa	.LC4(%rip), %xmm0
	movaps	%xmm0, 64+cards(%rip)
	cmpl	$5, %edx
	je	.L100
	movdqa	.LC5(%rip), %xmm0
	movaps	%xmm0, 80+cards(%rip)
	cmpl	$6, %edx
	je	.L100
	movdqa	.LC6(%rip), %xmm0
	movaps	%xmm0, 96+cards(%rip)
	cmpl	$7, %edx
	je	.L100
	movdqa	.LC7(%rip), %xmm0
	movaps	%xmm0, 112+cards(%rip)
	cmpl	$8, %edx
	je	.L100
	movdqa	.LC8(%rip), %xmm0
	movaps	%xmm0, 128+cards(%rip)
	cmpl	$9, %edx
	je	.L100
	movdqa	.LC9(%rip), %xmm0
	movaps	%xmm0, 144+cards(%rip)
	cmpl	$10, %edx
	je	.L100
	movdqa	.LC10(%rip), %xmm0
	movaps	%xmm0, 160+cards(%rip)
	cmpl	$11, %edx
	je	.L100
	movdqa	.LC11(%rip), %xmm0
	movaps	%xmm0, 176+cards(%rip)
	.p2align 4,,10
	.p2align 3
.L100:
	movl	%eax, %edx
	andl	$-4, %edx
	testb	$3, %al
	je	.L101
.L99:
	movslq	%edx, %rcx
	movl	%edx, (%r12,%rcx,4)
	leal	1(%rdx), %ecx
	cmpl	%ecx, %eax
	jle	.L101
	movslq	%ecx, %rsi
	addl	$2, %edx
	movl	%ecx, (%r12,%rsi,4)
	cmpl	%edx, %eax
	jle	.L101
	movslq	%edx, %rcx
	movl	%edx, (%r12,%rcx,4)
.L101:
	movl	16(%rsp), %edx
	xorl	%r13d, %r13d
	leaq	20(%rsp), %rbp
	leaq	.LC12(%rip), %rbx
	testl	%edx, %edx
	jle	.L98
	.p2align 4,,10
	.p2align 3
.L97:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	call	__isoc99_scanf@PLT
	movl	20(%rsp), %edi
	call	rs
	cmpl	%r13d, 16(%rsp)
	jg	.L97
	movl	12(%rsp), %eax
.L98:
	subl	$1, %eax
	leaq	.LC13(%rip), %rsi
	movl	$1, %edi
	cltq
	movl	(%r12,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L95
	.p2align 4,,10
	.p2align 3
.L143:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L145
	addq	$40, %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
	.p2align 4,,10
	.p2align 3
.L144:
	.cfi_restore_state
	leaq	cards(%rip), %r12
	jmp	.L101
.L106:
	xorl	%edx, %edx
	leaq	cards(%rip), %r12
	jmp	.L99
.L145:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.size	main, .-main
	.globl	cards
	.bss
	.align 32
	.type	cards, @object
	.size	cards, 200
cards:
	.zero	200
	.globl	cards_num
	.align 4
	.type	cards_num, @object
	.size	cards_num, 4
cards_num:
	.zero	4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC1:
	.long	4
	.long	5
	.long	6
	.long	7
	.align 16
.LC2:
	.long	8
	.long	9
	.long	10
	.long	11
	.align 16
.LC3:
	.long	12
	.long	13
	.long	14
	.long	15
	.align 16
.LC4:
	.long	16
	.long	17
	.long	18
	.long	19
	.align 16
.LC5:
	.long	20
	.long	21
	.long	22
	.long	23
	.align 16
.LC6:
	.long	24
	.long	25
	.long	26
	.long	27
	.align 16
.LC7:
	.long	28
	.long	29
	.long	30
	.long	31
	.align 16
.LC8:
	.long	32
	.long	33
	.long	34
	.long	35
	.align 16
.LC9:
	.long	36
	.long	37
	.long	38
	.long	39
	.align 16
.LC10:
	.long	40
	.long	41
	.long	42
	.long	43
	.align 16
.LC11:
	.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 cards_num;
int cards[50];

void cards_init(int num) {
	int i;
	cards_num=num;
	for(i=0;i<num;i++)cards[i]=i;
}

void rs(int c) {
	int cards2[50];
	int a_start,a_end;
	int b_start,b_end;
	int c_pos=0;
	int i;
	b_start=0;b_end=cards_num/2;
	a_start=b_end;a_end=cards_num;
	while(a_start<a_end || b_start<b_end) {
		for(i=0;a_start<a_end && i<c;i++)cards2[c_pos++]=cards[a_start++];
		for(i=0;b_start<b_end && i<c;i++)cards2[c_pos++]=cards[b_start++];
	}
	for(i=0;i<cards_num;i++)cards[i]=cards2[i];
}

int main(void) {
	int i;
	int cn,rsn,c;
	while(scanf("%d%d",&cn,&rsn)==2) {
		cards_init(cn);
		for(i=0;i<rsn;i++) {
			scanf("%d",&c);
			rs(c);
		}
		printf("%d\n",cards[cn-1]);
	}
	return 0;
}
9 1
3
9 4
1 2 6 4
 9 1
3
11 4
1 2 6 4
 9 1
3
9 4
1 1 6 6
 9 1
2
11 4
1 2 6 4
 8 1
3
16 4
1 1 3 4
 9 1
2
17 4
1 2 6 4
 9 1
3
15 4
2 1 6 6
 8 1
3
24 4
1 1 3 4
 9 1
4
5 4
1 2 6 4
 2 1
4
5 4
1 2 6 4

3
0
 3
10
 3
1
 8
10
 3
15
 8
1
 3
3
 3
13
 8
0
 0
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 cards_num;
int cards[50];

void cards_init(int num) {
	int i;
	cards_num=num;
	for(i=0;i<num;i++)cards[i]=i;
}

void rs(int c) {
	int cards2[50];
	int a_start,a_end;
	int b_start,b_end;
	int c_pos=0;
	int i;
	b_start=0;b_end=cards_num/2;
	a_start=b_end;a_end=cards_num;
	while(a_start<a_end || b_start<b_end) {
		for(i=0;a_start<a_end && i<c;i++)cards2[c_pos++]=cards[a_start++];
		for(i=0;b_start<b_end && i<c;i++)cards2[c_pos++]=cards[b_start++];
	}
	for(i=0;i<cards_num;i++)cards[i]=cards2[i];
}

int main(void) {
	int i;
	int cn,rsn,c;
	while(scanf("%d%d",&cn,&rsn)==2) {
		cards_init(cn);
		for(i=0;i<rsn;i++) {
			scanf("%d",&c);
			rs(c);
		}
		printf("%d\n",cards[cn-1]);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	cards_num
	.bss
	.align 4
	.type	cards_num, @object
	.size	cards_num, 4
cards_num:
	.zero	4
	.globl	cards
	.align 32
	.type	cards, @object
	.size	cards, 200
cards:
	.zero	200
	.text
	.globl	cards_init
	.type	cards_init, @function
cards_init:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, cards_num(%rip)
	movl	$0, -4(%rbp)
	jmp	.L2
.L3:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	cards(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -4(%rbp)
.L2:
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jl	.L3
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	cards_init, .-cards_init
	.globl	rs
	.type	rs, @function
rs:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$256, %rsp
	movl	%edi, -244(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -224(%rbp)
	movl	$0, -228(%rbp)
	movl	cards_num(%rip), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -216(%rbp)
	movl	-216(%rbp), %eax
	movl	%eax, -232(%rbp)
	movl	cards_num(%rip), %eax
	movl	%eax, -212(%rbp)
	jmp	.L5
.L11:
	movl	$0, -220(%rbp)
	jmp	.L6
.L8:
	movl	-232(%rbp), %edx
	leal	1(%rdx), %eax
	movl	%eax, -232(%rbp)
	movl	-224(%rbp), %eax
	leal	1(%rax), %ecx
	movl	%ecx, -224(%rbp)
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cards(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	addl	$1, -220(%rbp)
.L6:
	movl	-232(%rbp), %eax
	cmpl	-212(%rbp), %eax
	jge	.L7
	movl	-220(%rbp), %eax
	cmpl	-244(%rbp), %eax
	jl	.L8
.L7:
	movl	$0, -220(%rbp)
	jmp	.L9
.L10:
	movl	-228(%rbp), %edx
	leal	1(%rdx), %eax
	movl	%eax, -228(%rbp)
	movl	-224(%rbp), %eax
	leal	1(%rax), %ecx
	movl	%ecx, -224(%rbp)
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cards(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	addl	$1, -220(%rbp)
.L9:
	movl	-228(%rbp), %eax
	cmpl	-216(%rbp), %eax
	jge	.L5
	movl	-220(%rbp), %eax
	cmpl	-244(%rbp), %eax
	jl	.L10
.L5:
	movl	-232(%rbp), %eax
	cmpl	-212(%rbp), %eax
	jl	.L11
	movl	-228(%rbp), %eax
	cmpl	-216(%rbp), %eax
	jl	.L11
	movl	$0, -220(%rbp)
	jmp	.L12
.L13:
	movl	-220(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	movl	-220(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cards(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -220(%rbp)
.L12:
	movl	cards_num(%rip), %eax
	cmpl	%eax, -220(%rbp)
	jl	.L13
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	rs, .-rs
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L16
.L19:
	movl	-24(%rbp), %eax
	movl	%eax, %edi
	call	cards_init
	movl	$0, -12(%rbp)
	jmp	.L17
.L18:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	rs
	addl	$1, -12(%rbp)
.L17:
	movl	-20(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L18
	movl	-24(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cards(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L16:
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L19
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	cards_num
	.bss
	.align 4
	.type	cards_num, @object
	.size	cards_num, 4
cards_num:
	.zero	4
	.globl	cards
	.align 32
	.type	cards, @object
	.size	cards, 200
cards:
	.zero	200
	.text
	.globl	cards_init
	.type	cards_init, @function
cards_init:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, cards_num(%rip)
	movl	$0, -4(%rbp)
	jmp	.L2
.L3:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	cards(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -4(%rbp)
.L2:
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jl	.L3
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	cards_init, .-cards_init
	.globl	rs
	.type	rs, @function
rs:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$256, %rsp
	movl	%edi, -244(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -224(%rbp)
	movl	$0, -228(%rbp)
	movl	cards_num(%rip), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -216(%rbp)
	movl	-216(%rbp), %eax
	movl	%eax, -232(%rbp)
	movl	cards_num(%rip), %eax
	movl	%eax, -212(%rbp)
	jmp	.L5
.L11:
	movl	$0, -220(%rbp)
	jmp	.L6
.L8:
	movl	-232(%rbp), %edx
	leal	1(%rdx), %eax
	movl	%eax, -232(%rbp)
	movl	-224(%rbp), %eax
	leal	1(%rax), %ecx
	movl	%ecx, -224(%rbp)
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cards(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	addl	$1, -220(%rbp)
.L6:
	movl	-232(%rbp), %eax
	cmpl	-212(%rbp), %eax
	jge	.L7
	movl	-220(%rbp), %eax
	cmpl	-244(%rbp), %eax
	jl	.L8
.L7:
	movl	$0, -220(%rbp)
	jmp	.L9
.L10:
	movl	-228(%rbp), %edx
	leal	1(%rdx), %eax
	movl	%eax, -228(%rbp)
	movl	-224(%rbp), %eax
	leal	1(%rax), %ecx
	movl	%ecx, -224(%rbp)
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cards(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	cltq
	movl	%edx, -208(%rbp,%rax,4)
	addl	$1, -220(%rbp)
.L9:
	movl	-228(%rbp), %eax
	cmpl	-216(%rbp), %eax
	jge	.L5
	movl	-220(%rbp), %eax
	cmpl	-244(%rbp), %eax
	jl	.L10
.L5:
	movl	-232(%rbp), %eax
	cmpl	-212(%rbp), %eax
	jl	.L11
	movl	-228(%rbp), %eax
	cmpl	-216(%rbp), %eax
	jl	.L11
	movl	$0, -220(%rbp)
	jmp	.L12
.L13:
	movl	-220(%rbp), %eax
	cltq
	movl	-208(%rbp,%rax,4), %eax
	movl	-220(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cards(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -220(%rbp)
.L12:
	movl	cards_num(%rip), %eax
	cmpl	%eax, -220(%rbp)
	jl	.L13
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	rs, .-rs
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L16
.L19:
	movl	-24(%rbp), %eax
	movl	%eax, %edi
	call	cards_init
	movl	$0, -12(%rbp)
	jmp	.L17
.L18:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	rs
	addl	$1, -12(%rbp)
.L17:
	movl	-20(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L18
	movl	-24(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cards(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L16:
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L19
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
