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>
#include <stdlib.h>

int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a > b ? -1 : a < b;
}

int N, M, C;
int l[114514];

int ballNums[114514];
int* balls[114514];

int asumisu;
int mizuhasu[114514];

int main(void) {
	int i;
	int answer = 0;
	if (scanf("%d%d%d", &N, &M, &C) != 3) return 1;
	for (i = 1; i <= C; i++) {
		if (scanf("%d" ,&l[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		int c, w;
		int* newBalls;
		if (scanf("%d%d", &c, &w) != 2) return 1;
		newBalls = realloc(balls[c], sizeof(*balls[c]) * (ballNums[c] + 1));
		if (newBalls == NULL) return 2;
		newBalls[ballNums[c]++] = w;
		balls[c] = newBalls;
	}
	for (i = 1; i <= C; i++) {
		if (ballNums[i] > 0) {
			int j;
			qsort(balls[i], ballNums[i], sizeof(*balls[i]), cmp);
			for (j = 0; j < ballNums[i] && j < l[i]; j++) {
				mizuhasu[asumisu++] = balls[i][j];
			}
		}
	}
	qsort(mizuhasu, asumisu, sizeof(*mizuhasu), cmp);
	for (i = 0; i < M && i < asumisu; i++) {
		answer += mizuhasu[i];
	}
	printf("%d\n", answer);
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	cmp
	.type	cmp, @function
cmp:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -8(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jg	.L2
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	setl	%al
	movzbl	%al, %eax
	jmp	.L4
.L2:
	movl	$-1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	cmp, .-cmp
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	C
	.align 4
	.type	C, @object
	.size	C, 4
C:
	.zero	4
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 458056
l:
	.zero	458056
	.globl	ballNums
	.align 32
	.type	ballNums, @object
	.size	ballNums, 458056
ballNums:
	.zero	458056
	.globl	balls
	.align 32
	.type	balls, @object
	.size	balls, 916112
balls:
	.zero	916112
	.globl	asumisu
	.align 4
	.type	asumisu, @object
	.size	asumisu, 4
asumisu:
	.zero	4
	.globl	mizuhasu
	.align 32
	.type	mizuhasu, @object
	.size	mizuhasu, 458056
mizuhasu:
	.zero	458056
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -24(%rbp)
	leaq	C(%rip), %rax
	movq	%rax, %rcx
	leaq	M(%rip), %rax
	movq	%rax, %rdx
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$3, %eax
	je	.L6
	movl	$1, %eax
	jmp	.L7
.L6:
	movl	$1, -28(%rbp)
	jmp	.L8
.L10:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	l(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L9
	movl	$1, %eax
	jmp	.L7
.L9:
	addl	$1, -28(%rbp)
.L8:
	movl	C(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L10
	movl	$0, -28(%rbp)
	jmp	.L11
.L15:
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L12
	movl	$1, %eax
	jmp	.L7
.L12:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ballNums(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	balls(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	movq	%rax, -16(%rbp)
	cmpq	$0, -16(%rbp)
	jne	.L14
	movl	$2, %eax
	jmp	.L7
.L14:
	movl	-36(%rbp), %edx
	movslq	%edx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	ballNums(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rsi
	leaq	ballNums(%rip), %rdx
	movl	%ecx, (%rsi,%rdx)
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-32(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	balls(%rip), %rdx
	movq	-16(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L11:
	movl	N(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L15
	movl	$1, -28(%rbp)
	jmp	.L16
.L20:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ballNums(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jle	.L17
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ballNums(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rsi
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	balls(%rip), %rax
	movq	(%rdx,%rax), %rax
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -20(%rbp)
	jmp	.L18
.L19:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	balls(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	(%rdx,%rax), %rcx
	movl	asumisu(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, asumisu(%rip)
	movl	(%rcx), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	mizuhasu(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -20(%rbp)
.L18:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ballNums(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jge	.L17
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	l(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L19
.L17:
	addl	$1, -28(%rbp)
.L16:
	movl	C(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L20
	movl	asumisu(%rip), %eax
	cltq
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	mizuhasu(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -28(%rbp)
	jmp	.L21
.L23:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	mizuhasu(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -24(%rbp)
	addl	$1, -28(%rbp)
.L21:
	movl	M(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jge	.L22
	movl	asumisu(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L23
.L22:
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L7:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	cmp
	.type	cmp, @function
cmp:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rsi), %eax
	cmpl	%eax, (%rdi)
	movl	$-1, %edx
	setl	%al
	movzbl	%al, %eax
	cmovg	%edx, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	cmp, .-cmp
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	C(%rip), %rcx
	leaq	M(%rip), %rdx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	N(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	cmpl	$3, %eax
	jne	.L26
	cmpl	$0, C(%rip)
	jle	.L8
	leaq	4+l(%rip), %rbx
	movl	$1, %ebp
	leaq	.LC1(%rip), %r12
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L39:
	addl	$1, %ebp
	addq	$4, %rbx
	cmpl	%ebp, C(%rip)
	jl	.L38
.L10:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L39
.L26:
	movl	$1, %r13d
.L5:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L40
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r13d, %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
.L38:
	.cfi_restore_state
	cmpl	$0, N(%rip)
	jle	.L11
.L24:
	xorl	%ebp, %ebp
	leaq	4(%rsp), %r15
	movq	%rsp, %r14
	leaq	ballNums(%rip), %rbx
	leaq	balls(%rip), %r12
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L41:
	movslq	(%rsp), %rax
	movl	(%rbx,%rax,4), %edi
	leal	1(%rdi), %esi
	movq	(%r12,%rax,8), %rdi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	realloc@PLT
	testq	%rax, %rax
	je	.L5
	movslq	(%rsp), %rcx
	addl	$1, %ebp
	movslq	(%rbx,%rcx,4), %rdx
	leal	1(%rdx), %esi
	movl	%esi, (%rbx,%rcx,4)
	movl	4(%rsp), %ecx
	movl	%ecx, (%rax,%rdx,4)
	movslq	(%rsp), %rdx
	cmpl	%ebp, N(%rip)
	movq	%rax, (%r12,%rdx,8)
	jle	.L11
.L13:
	movq	%r15, %rdx
	movq	%r14, %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, %r13d
	cmpl	$2, %eax
	je	.L41
	jmp	.L26
.L11:
	movl	C(%rip), %eax
	movl	$1, %ebx
	leaq	ballNums(%rip), %r14
	leaq	cmp(%rip), %r15
	leaq	mizuhasu(%rip), %r12
	leaq	balls(%rip), %r13
	leaq	l(%rip), %rbp
	testl	%eax, %eax
	jg	.L14
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$1, %rbx
	cmpl	%ebx, %eax
	jl	.L21
.L14:
	movslq	(%r14,%rbx,4), %rsi
	testl	%esi, %esi
	jle	.L17
	movq	0(%r13,%rbx,8), %rdi
	movq	%r15, %rcx
	movl	$4, %edx
	call	qsort@PLT
	movslq	(%r14,%rbx,4), %rdi
	testl	%edi, %edi
	jle	.L37
	movl	0(%rbp,%rbx,4), %r8d
	movslq	asumisu(%rip), %rdx
	xorl	%eax, %eax
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L20:
	movq	0(%r13,%rbx,8), %rsi
	leal	1(%rdx), %ecx
	movl	%ecx, asumisu(%rip)
	movl	(%rsi,%rax,4), %esi
	addq	$1, %rax
	movl	%esi, (%r12,%rdx,4)
	cmpq	%rax, %rdi
	je	.L37
	movslq	%ecx, %rdx
.L19:
	cmpl	%eax, %r8d
	jg	.L20
.L37:
	movl	C(%rip), %eax
	jmp	.L17
.L8:
	cmpl	$0, N(%rip)
	leaq	cmp(%rip), %r15
	leaq	mizuhasu(%rip), %r12
	jg	.L24
.L21:
	movslq	asumisu(%rip), %rsi
	movq	%r15, %rcx
	movl	$4, %edx
	movq	%r12, %rdi
	call	qsort@PLT
	movslq	M(%rip), %rcx
	xorl	%edx, %edx
	testl	%ecx, %ecx
	jle	.L16
	movl	asumisu(%rip), %esi
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L23:
	addl	(%r12,%rax,4), %edx
	addq	$1, %rax
	cmpq	%rax, %rcx
	je	.L16
.L22:
	cmpl	%eax, %esi
	jg	.L23
.L16:
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	xorl	%r13d, %r13d
	call	__printf_chk@PLT
	jmp	.L5
.L40:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	mizuhasu
	.bss
	.align 32
	.type	mizuhasu, @object
	.size	mizuhasu, 458056
mizuhasu:
	.zero	458056
	.globl	asumisu
	.align 4
	.type	asumisu, @object
	.size	asumisu, 4
asumisu:
	.zero	4
	.globl	balls
	.align 32
	.type	balls, @object
	.size	balls, 916112
balls:
	.zero	916112
	.globl	ballNums
	.align 32
	.type	ballNums, @object
	.size	ballNums, 458056
ballNums:
	.zero	458056
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 458056
l:
	.zero	458056
	.globl	C
	.align 4
	.type	C, @object
	.size	C, 4
C:
	.zero	4
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.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	cmp
	.type	cmp, @function
cmp:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rsi), %eax
	cmpl	%eax, (%rdi)
	movl	$-1, %edx
	setl	%al
	movzbl	%al, %eax
	cmovg	%edx, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	cmp, .-cmp
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	C(%rip), %rcx
	leaq	M(%rip), %rdx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	N(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	cmpl	$3, %eax
	jne	.L26
	cmpl	$0, C(%rip)
	jle	.L8
	leaq	4+l(%rip), %rbx
	movl	$1, %ebp
	leaq	.LC1(%rip), %r12
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L39:
	addl	$1, %ebp
	addq	$4, %rbx
	cmpl	%ebp, C(%rip)
	jl	.L38
.L10:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L39
.L26:
	movl	$1, %r13d
.L5:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L40
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r13d, %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
.L38:
	.cfi_restore_state
	cmpl	$0, N(%rip)
	jle	.L11
.L24:
	xorl	%ebp, %ebp
	leaq	4(%rsp), %r15
	movq	%rsp, %r14
	leaq	ballNums(%rip), %rbx
	leaq	balls(%rip), %r12
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L41:
	movslq	(%rsp), %rax
	movl	(%rbx,%rax,4), %edi
	leal	1(%rdi), %esi
	movq	(%r12,%rax,8), %rdi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	realloc@PLT
	testq	%rax, %rax
	je	.L5
	movslq	(%rsp), %rcx
	addl	$1, %ebp
	movslq	(%rbx,%rcx,4), %rdx
	leal	1(%rdx), %esi
	movl	%esi, (%rbx,%rcx,4)
	movl	4(%rsp), %ecx
	movl	%ecx, (%rax,%rdx,4)
	movslq	(%rsp), %rdx
	cmpl	%ebp, N(%rip)
	movq	%rax, (%r12,%rdx,8)
	jle	.L11
.L13:
	movq	%r15, %rdx
	movq	%r14, %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, %r13d
	cmpl	$2, %eax
	je	.L41
	jmp	.L26
.L11:
	movl	C(%rip), %eax
	movl	$1, %ebx
	leaq	ballNums(%rip), %r14
	leaq	cmp(%rip), %r15
	leaq	mizuhasu(%rip), %r12
	leaq	balls(%rip), %r13
	leaq	l(%rip), %rbp
	testl	%eax, %eax
	jg	.L14
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$1, %rbx
	cmpl	%ebx, %eax
	jl	.L21
.L14:
	movslq	(%r14,%rbx,4), %rsi
	testl	%esi, %esi
	jle	.L17
	movq	0(%r13,%rbx,8), %rdi
	movq	%r15, %rcx
	movl	$4, %edx
	call	qsort@PLT
	movslq	(%r14,%rbx,4), %rdi
	testl	%edi, %edi
	jle	.L37
	movl	0(%rbp,%rbx,4), %r8d
	movslq	asumisu(%rip), %rdx
	xorl	%eax, %eax
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L20:
	movq	0(%r13,%rbx,8), %rsi
	leal	1(%rdx), %ecx
	movl	%ecx, asumisu(%rip)
	movl	(%rsi,%rax,4), %esi
	addq	$1, %rax
	movl	%esi, (%r12,%rdx,4)
	cmpq	%rax, %rdi
	je	.L37
	movslq	%ecx, %rdx
.L19:
	cmpl	%eax, %r8d
	jg	.L20
.L37:
	movl	C(%rip), %eax
	jmp	.L17
.L8:
	cmpl	$0, N(%rip)
	leaq	cmp(%rip), %r15
	leaq	mizuhasu(%rip), %r12
	jg	.L24
.L21:
	movslq	asumisu(%rip), %rsi
	movq	%r15, %rcx
	movl	$4, %edx
	movq	%r12, %rdi
	call	qsort@PLT
	movslq	M(%rip), %rcx
	xorl	%edx, %edx
	testl	%ecx, %ecx
	jle	.L16
	movl	asumisu(%rip), %esi
	xorl	%eax, %eax
	xorl	%edx, %edx
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L23:
	addl	(%r12,%rax,4), %edx
	addq	$1, %rax
	cmpq	%rax, %rcx
	je	.L16
.L22:
	cmpl	%eax, %esi
	jg	.L23
.L16:
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	xorl	%r13d, %r13d
	call	__printf_chk@PLT
	jmp	.L5
.L40:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	mizuhasu
	.bss
	.align 32
	.type	mizuhasu, @object
	.size	mizuhasu, 458056
mizuhasu:
	.zero	458056
	.globl	asumisu
	.align 4
	.type	asumisu, @object
	.size	asumisu, 4
asumisu:
	.zero	4
	.globl	balls
	.align 32
	.type	balls, @object
	.size	balls, 916112
balls:
	.zero	916112
	.globl	ballNums
	.align 32
	.type	ballNums, @object
	.size	ballNums, 458056
ballNums:
	.zero	458056
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 458056
l:
	.zero	458056
	.globl	C
	.align 4
	.type	C, @object
	.size	C, 4
C:
	.zero	4
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.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>
#include <stdlib.h>

int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a > b ? -1 : a < b;
}

int N, M, C;
int l[114514];

int ballNums[114514];
int* balls[114514];

int asumisu;
int mizuhasu[114514];

int main(void) {
	int i;
	int answer = 0;
	if (scanf("%d%d%d", &N, &M, &C) != 3) return 1;
	for (i = 1; i <= C; i++) {
		if (scanf("%d" ,&l[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		int c, w;
		int* newBalls;
		if (scanf("%d%d", &c, &w) != 2) return 1;
		newBalls = realloc(balls[c], sizeof(*balls[c]) * (ballNums[c] + 1));
		if (newBalls == NULL) return 2;
		newBalls[ballNums[c]++] = w;
		balls[c] = newBalls;
	}
	for (i = 1; i <= C; i++) {
		if (ballNums[i] > 0) {
			int j;
			qsort(balls[i], ballNums[i], sizeof(*balls[i]), cmp);
			for (j = 0; j < ballNums[i] && j < l[i]; j++) {
				mizuhasu[asumisu++] = balls[i][j];
			}
		}
	}
	qsort(mizuhasu, asumisu, sizeof(*mizuhasu), cmp);
	for (i = 0; i < M && i < asumisu; i++) {
		answer += mizuhasu[i];
	}
	printf("%d\n", answer);
	return 0;
}


22 7 26
11 14 15 3 11 7 16 17 1 4 2 19 4 14 16 16 3 13 17 12 7 11 2 20 12 22
6 10
1 3
13 1
16 5
4 1
20 7
18 4
26 6
9 1
12 2
21 1
21 7
18 1
14 5
24 5
6 1
1 1
2 5
21 2
7 6
10 9
15 7
 3 3 3
1 0 1
1 1
2 100
1 1
 22 7 26
11 14 15 3 11 7 16 17 1 4 2 19 4 14 16 16 3 13 17 12 7 11 2 20 12 22
6 10
1 3
13 1
16 5
4 1
20 7
18 4
26 7
9 1
12 2
21 1
21 7
18 1
14 5
24 5
6 1
1 1
2 5
21 2
7 6
10 9
15 7
 3 3 2
1 1
1 1
1 100
2 16
 3 5 3
1 0 1
1 1
2 100
3 1
 22 7 26
11 14 15 3 11 7 16 17 1 4 2 17 4 14 16 16 3 13 17 12 7 11 2 20 12 22
6 10
1 3
13 1
16 5
4 1
20 7
18 4
26 7
9 1
12 2
21 1
21 7
18 1
14 5
24 5
6 1
1 1
2 5
21 2
7 6
10 14
15 7
 22 7 26
11 14 15 3 11 7 16 7 1 4 2 19 4 14 16 16 5 13 33 12 11 11 2 20 12 22
6 10
1 3
13 1
16 5
4 1
20 7
18 4
26 7
9 1
12 2
5 1
21 7
18 1
14 5
24 8
6 1
1 1
2 5
23 2
7 5
10 9
15 7
 3 4 2
1 1
1 1
1 100
2 30
 22 12 26
11 14 15 3 11 7 16 7 1 4 2 19 4 14 16 16 3 13 17 12 11 11 2 20 12 22
6 10
1 3
13 1
16 5
6 1
20 7
18 4
26 7
9 1
12 2
5 1
21 7
18 1
14 5
24 1
6 1
1 1
2 5
21 2
7 5
10 9
15 7
 3 4 2
1 0
1 1
1 100
2 30

52
 1
 53
 116
 2
 58
 55
 130
 74
 100

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>
#include <stdlib.h>

int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a > b ? -1 : a < b;
}

int N, M, C;
int l[114514];

int ballNums[114514];
int* balls[114514];

int asumisu;
int mizuhasu[114514];

int main(void) {
	int i;
	int answer = 0;
	if (scanf("%d%d%d", &N, &M, &C) != 3) return 1;
	for (i = 1; i <= C; i++) {
		if (scanf("%d" ,&l[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		int c, w;
		int* newBalls;
		if (scanf("%d%d", &c, &w) != 2) return 1;
		newBalls = realloc(balls[c], sizeof(*balls[c]) * (ballNums[c] + 1));
		if (newBalls == NULL) return 2;
		newBalls[ballNums[c]++] = w;
		balls[c] = newBalls;
	}
	for (i = 1; i <= C; i++) {
		if (ballNums[i] > 0) {
			int j;
			qsort(balls[i], ballNums[i], sizeof(*balls[i]), cmp);
			for (j = 0; j < ballNums[i] && j < l[i]; j++) {
				mizuhasu[asumisu++] = balls[i][j];
			}
		}
	}
	qsort(mizuhasu, asumisu, sizeof(*mizuhasu), cmp);
	for (i = 0; i < M && i < asumisu; i++) {
		answer += mizuhasu[i];
	}
	printf("%d\n", answer);
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	cmp
	.type	cmp, @function
cmp:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -8(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jg	.L2
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	setl	%al
	movzbl	%al, %eax
	jmp	.L4
.L2:
	movl	$-1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	cmp, .-cmp
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	C
	.align 4
	.type	C, @object
	.size	C, 4
C:
	.zero	4
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 458056
l:
	.zero	458056
	.globl	ballNums
	.align 32
	.type	ballNums, @object
	.size	ballNums, 458056
ballNums:
	.zero	458056
	.globl	balls
	.align 32
	.type	balls, @object
	.size	balls, 916112
balls:
	.zero	916112
	.globl	asumisu
	.align 4
	.type	asumisu, @object
	.size	asumisu, 4
asumisu:
	.zero	4
	.globl	mizuhasu
	.align 32
	.type	mizuhasu, @object
	.size	mizuhasu, 458056
mizuhasu:
	.zero	458056
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -24(%rbp)
	leaq	C(%rip), %rax
	movq	%rax, %rcx
	leaq	M(%rip), %rax
	movq	%rax, %rdx
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$3, %eax
	je	.L6
	movl	$1, %eax
	jmp	.L7
.L6:
	movl	$1, -28(%rbp)
	jmp	.L8
.L10:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	l(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L9
	movl	$1, %eax
	jmp	.L7
.L9:
	addl	$1, -28(%rbp)
.L8:
	movl	C(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L10
	movl	$0, -28(%rbp)
	jmp	.L11
.L15:
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L12
	movl	$1, %eax
	jmp	.L7
.L12:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ballNums(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	balls(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	movq	%rax, -16(%rbp)
	cmpq	$0, -16(%rbp)
	jne	.L14
	movl	$2, %eax
	jmp	.L7
.L14:
	movl	-36(%rbp), %edx
	movslq	%edx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	ballNums(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rsi
	leaq	ballNums(%rip), %rdx
	movl	%ecx, (%rsi,%rdx)
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-32(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	balls(%rip), %rdx
	movq	-16(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L11:
	movl	N(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L15
	movl	$1, -28(%rbp)
	jmp	.L16
.L20:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ballNums(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jle	.L17
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ballNums(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rsi
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	balls(%rip), %rax
	movq	(%rdx,%rax), %rax
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -20(%rbp)
	jmp	.L18
.L19:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	balls(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	(%rdx,%rax), %rcx
	movl	asumisu(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, asumisu(%rip)
	movl	(%rcx), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	mizuhasu(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -20(%rbp)
.L18:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ballNums(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jge	.L17
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	l(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L19
.L17:
	addl	$1, -28(%rbp)
.L16:
	movl	C(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L20
	movl	asumisu(%rip), %eax
	cltq
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	mizuhasu(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -28(%rbp)
	jmp	.L21
.L23:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	mizuhasu(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -24(%rbp)
	addl	$1, -28(%rbp)
.L21:
	movl	M(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jge	.L22
	movl	asumisu(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L23
.L22:
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L7:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	cmp
	.type	cmp, @function
cmp:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -8(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jg	.L2
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	setl	%al
	movzbl	%al, %eax
	jmp	.L4
.L2:
	movl	$-1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	cmp, .-cmp
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	C
	.align 4
	.type	C, @object
	.size	C, 4
C:
	.zero	4
	.globl	l
	.align 32
	.type	l, @object
	.size	l, 458056
l:
	.zero	458056
	.globl	ballNums
	.align 32
	.type	ballNums, @object
	.size	ballNums, 458056
ballNums:
	.zero	458056
	.globl	balls
	.align 32
	.type	balls, @object
	.size	balls, 916112
balls:
	.zero	916112
	.globl	asumisu
	.align 4
	.type	asumisu, @object
	.size	asumisu, 4
asumisu:
	.zero	4
	.globl	mizuhasu
	.align 32
	.type	mizuhasu, @object
	.size	mizuhasu, 458056
mizuhasu:
	.zero	458056
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -24(%rbp)
	leaq	C(%rip), %rax
	movq	%rax, %rcx
	leaq	M(%rip), %rax
	movq	%rax, %rdx
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$3, %eax
	je	.L6
	movl	$1, %eax
	jmp	.L7
.L6:
	movl	$1, -28(%rbp)
	jmp	.L8
.L10:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	l(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L9
	movl	$1, %eax
	jmp	.L7
.L9:
	addl	$1, -28(%rbp)
.L8:
	movl	C(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L10
	movl	$0, -28(%rbp)
	jmp	.L11
.L15:
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L12
	movl	$1, %eax
	jmp	.L7
.L12:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ballNums(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	balls(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	movq	%rax, -16(%rbp)
	cmpq	$0, -16(%rbp)
	jne	.L14
	movl	$2, %eax
	jmp	.L7
.L14:
	movl	-36(%rbp), %edx
	movslq	%edx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	ballNums(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rsi
	leaq	ballNums(%rip), %rdx
	movl	%ecx, (%rsi,%rdx)
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-32(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	balls(%rip), %rdx
	movq	-16(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L11:
	movl	N(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L15
	movl	$1, -28(%rbp)
	jmp	.L16
.L20:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ballNums(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jle	.L17
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ballNums(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rsi
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	balls(%rip), %rax
	movq	(%rdx,%rax), %rax
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -20(%rbp)
	jmp	.L18
.L19:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	balls(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	(%rdx,%rax), %rcx
	movl	asumisu(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, asumisu(%rip)
	movl	(%rcx), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	mizuhasu(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -20(%rbp)
.L18:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ballNums(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jge	.L17
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	l(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L19
.L17:
	addl	$1, -28(%rbp)
.L16:
	movl	C(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L20
	movl	asumisu(%rip), %eax
	cltq
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	mizuhasu(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, -28(%rbp)
	jmp	.L21
.L23:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	mizuhasu(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -24(%rbp)
	addl	$1, -28(%rbp)
.L21:
	movl	M(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jge	.L22
	movl	asumisu(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L23
.L22:
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L7:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
