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>
#define int long long

typedef struct {
	int val;
	int num;
}pair;

signed compare(const void *a, const void *b){
	int sub = *(int *)a - *(int *)b;
	if(sub < 0){
		return -1;
	}
	else if(sub == 0){
		return 0;
	}
	else{
		return 1;
	}
}

int min(int a, int b){
	return a <= b ? a : b;
}

int next_pow(int n){
	int ans = 1;
	while(ans <= n){
		ans *= 2;
	}
	return ans;
}

signed main(){
	int N, i, j, ans = 0;
	scanf("%lld", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
	}
	qsort(A, N, sizeof(int), compare);
	pair *B = (pair *)malloc(sizeof(pair) * N);
	for(i = 1, j = 0, B[0].val = A[0], B[0].num = 1; i < N; i++){
		if(A[i] == A[i - 1]){
			B[j].num++;
		}
		else{
			j++;
			B[j].val = A[i];
			B[j].num = 1;
		}
	}
	N = j + 1;
	int l, h, r, k, minnum;
	for(i = N - 1; i >= 0; i--){
		if(B[i].num > 0){
			k = next_pow(B[i].val);
			l = -1;
			r = i + 1;
			while(r - l > 1){
				h = (l + r) / 2;
				if(B[h].val < k - B[i].val){
					l = h;
				}
				else{
					r = h;
				}
			}
			if(B[r].val + B[i].val == k){
				if(r == i){
					ans += B[i].num / 2;
					B[i].num %= 2;
				}
				else{
					minnum = min(B[r].num, B[i].num);
					ans += minnum;
					B[r].num -= minnum;
					B[i].num -= minnum;
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	compare
	.type	compare, @function
compare:
.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
	movq	(%rax), %rdx
	movq	-32(%rbp), %rax
	movq	(%rax), %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	movq	%rax, -8(%rbp)
	cmpq	$0, -8(%rbp)
	jns	.L2
	movl	$-1, %eax
	jmp	.L3
.L2:
	cmpq	$0, -8(%rbp)
	jne	.L4
	movl	$0, %eax
	jmp	.L3
.L4:
	movl	$1, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	compare, .-compare
	.globl	min
	.type	min, @function
min:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rdx
	movq	-16(%rbp), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	min, .-min
	.globl	next_pow
	.type	next_pow, @function
next_pow:
.LFB8:
	.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	$1, -8(%rbp)
	jmp	.L8
.L9:
	salq	-8(%rbp)
.L8:
	movq	-8(%rbp), %rax
	cmpq	-24(%rbp), %rax
	jle	.L9
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	next_pow, .-next_pow
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$96, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -72(%rbp)
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-96(%rbp), %rax
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -48(%rbp)
	movq	$0, -88(%rbp)
	jmp	.L12
.L13:
	movq	-88(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$1, -88(%rbp)
.L12:
	movq	-96(%rbp), %rax
	cmpq	%rax, -88(%rbp)
	jl	.L13
	movq	-96(%rbp), %rax
	movq	%rax, %rsi
	movq	-48(%rbp), %rax
	leaq	compare(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movq	-96(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40(%rbp)
	movq	$1, -88(%rbp)
	movq	$0, -80(%rbp)
	movq	-48(%rbp), %rax
	movq	(%rax), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, (%rax)
	movq	-40(%rbp), %rax
	movq	$1, 8(%rax)
	jmp	.L14
.L17:
	movq	-88(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-88(%rbp), %rax
	salq	$3, %rax
	leaq	-8(%rax), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jne	.L15
	movq	-80(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rdx
	addq	$1, %rdx
	movq	%rdx, 8(%rax)
	jmp	.L16
.L15:
	addq	$1, -80(%rbp)
	movq	-88(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	-80(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movq	-80(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	$1, 8(%rax)
.L16:
	addq	$1, -88(%rbp)
.L14:
	movq	-96(%rbp), %rax
	cmpq	%rax, -88(%rbp)
	jl	.L17
	movq	-80(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -96(%rbp)
	movq	-96(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -88(%rbp)
	jmp	.L18
.L24:
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jle	.L19
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	next_pow
	movq	%rax, -32(%rbp)
	movq	$-1, -64(%rbp)
	movq	-88(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -56(%rbp)
	jmp	.L20
.L22:
	movq	-64(%rbp), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	-88(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rdx), %rcx
	movq	-32(%rbp), %rdx
	subq	%rcx, %rdx
	cmpq	%rdx, %rax
	jge	.L21
	movq	-16(%rbp), %rax
	movq	%rax, -64(%rbp)
	jmp	.L20
.L21:
	movq	-16(%rbp), %rax
	movq	%rax, -56(%rbp)
.L20:
	movq	-56(%rbp), %rax
	subq	-64(%rbp), %rax
	cmpq	$1, %rax
	jg	.L22
	movq	-56(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-40(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	addq	%rdx, %rax
	cmpq	%rax, -32(%rbp)
	jne	.L19
	movq	-56(%rbp), %rax
	cmpq	-88(%rbp), %rax
	jne	.L23
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	addq	%rax, -72(%rbp)
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	-88(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rax, %rcx
	sarq	$63, %rcx
	shrq	$63, %rcx
	addq	%rcx, %rax
	andl	$1, %eax
	subq	%rcx, %rax
	movq	%rax, 8(%rdx)
	jmp	.L19
.L23:
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rdx
	movq	-56(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-40(%rbp), %rax
	addq	%rcx, %rax
	movq	8(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	min
	movq	%rax, -24(%rbp)
	movq	-24(%rbp), %rax
	addq	%rax, -72(%rbp)
	movq	-56(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	-56(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	subq	-24(%rbp), %rax
	movq	%rax, 8(%rdx)
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	-88(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	subq	-24(%rbp), %rax
	movq	%rax, 8(%rdx)
.L19:
	subq	$1, -88(%rbp)
.L18:
	cmpq	$0, -88(%rbp)
	jns	.L24
	movq	-72(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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	compare
	.type	compare, @function
compare:
.LFB39:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rdx
	movl	$-1, %eax
	cmpq	%rdx, (%rdi)
	js	.L1
	setne	%al
	movzbl	%al, %eax
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	compare, .-compare
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB40:
	.cfi_startproc
	endbr64
	cmpq	%rsi, %rdi
	movq	%rsi, %rax
	cmovle	%rdi, %rax
	ret
	.cfi_endproc
.LFE40:
	.size	min, .-min
	.p2align 4
	.globl	next_pow
	.type	next_pow, @function
next_pow:
.LFB41:
	.cfi_startproc
	endbr64
	movl	$1, %eax
	testq	%rdi, %rdi
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L8:
	addq	%rax, %rax
	cmpq	%rax, %rdi
	jge	.L8
	ret
	.p2align 4,,10
	.p2align 3
.L9:
	ret
	.cfi_endproc
.LFE41:
	.size	next_pow, .-next_pow
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%r14, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %r13
	leaq	0(,%r13,8), %rdi
	call	malloc@PLT
	movq	%rax, %r12
	testq	%r13, %r13
	jle	.L12
	movq	%rax, %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbp, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	movq	(%rsp), %r13
	addq	$8, %rbp
	cmpq	%rbx, %r13
	jg	.L13
.L12:
	leaq	compare(%rip), %rcx
	movl	$8, %edx
	movq	%r13, %rsi
	movq	%r12, %rdi
	call	qsort@PLT
	movq	(%rsp), %rbx
	movq	%rbx, %rdi
	salq	$4, %rdi
	call	malloc@PLT
	movq	(%r12), %rcx
	movq	$1, 8(%rax)
	movq	%rax, %rdi
	movq	%rcx, (%rax)
	cmpq	$1, %rbx
	jle	.L33
	cmpq	$3, %rbx
	jle	.L34
	leaq	-4(%rbx), %rax
	movl	$1, %edx
	xorl	%r10d, %r10d
	movl	$1, %esi
	andq	$-2, %rax
	addq	$3, %rax
	jmp	.L20
.L16:
	addq	$1, %r10
	movq	%r10, %rdx
	salq	$4, %rdx
	addq	%rdi, %rdx
	movq	%r8, (%rdx)
	movq	$1, 8(%rdx)
	movl	$1, %edx
.L17:
	movq	8(%r12,%rsi,8), %rcx
	cmpq	%rcx, %r8
	je	.L18
	addq	$1, %r10
	movq	%r10, %rdx
	salq	$4, %rdx
	addq	%rdi, %rdx
	movq	%rcx, (%rdx)
	movq	$1, 8(%rdx)
	movl	$1, %edx
.L19:
	addq	$2, %rsi
	cmpq	%rax, %rsi
	je	.L23
.L20:
	movq	(%r12,%rsi,8), %r8
	cmpq	%rcx, %r8
	jne	.L16
	movq	%r10, %rcx
	addq	$1, %rdx
	salq	$4, %rcx
	movq	%rdx, 8(%rdi,%rcx)
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L21:
	addq	$1, %r10
	addq	$1, %rax
	movq	%r10, %rdx
	salq	$4, %rdx
	addq	%rdi, %rdx
	movq	%rcx, (%rdx)
	movq	$1, 8(%rdx)
	movl	$1, %edx
	cmpq	%rax, %rbx
	jle	.L14
.L23:
	movq	(%r12,%rax,8), %rcx
	cmpq	%rcx, -8(%r12,%rax,8)
	jne	.L21
	movq	%r10, %rcx
	addq	$1, %rdx
	addq	$1, %rax
	salq	$4, %rcx
	movq	%rdx, 8(%rdi,%rcx)
	cmpq	%rax, %rbx
	jg	.L23
.L14:
	movq	%r10, %rbx
	leaq	1(%r10), %rax
	xorl	%r12d, %r12d
	salq	$4, %rbx
	movq	%rax, (%rsp)
	addq	%rdi, %rbx
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L24:
	subq	$1, %r10
	subq	$16, %rbx
	cmpq	$-1, %r10
	je	.L43
.L31:
	movq	8(%rbx), %rbp
	testq	%rbp, %rbp
	jle	.L24
	movq	(%rbx), %r11
	movl	$1, %r9d
	testq	%r11, %r11
	jle	.L25
	.p2align 4,,10
	.p2align 3
.L26:
	addq	%r9, %r9
	cmpq	%r9, %r11
	jge	.L26
.L25:
	movq	%r9, %r8
	leaq	1(%r10), %rdx
	movq	$-1, %rcx
	subq	%r11, %r8
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L29:
	leaq	(%rdx,%rcx), %rsi
	movq	%rsi, %rax
	shrq	$63, %rax
	addq	%rsi, %rax
	sarq	%rax
	movq	%rax, %rsi
	salq	$4, %rsi
	cmpq	%r8, (%rdi,%rsi)
	cmovge	%rax, %rdx
	cmovl	%rax, %rcx
.L28:
	movq	%rdx, %rax
	subq	%rcx, %rax
	cmpq	$1, %rax
	jg	.L29
	movq	%rdx, %rax
	salq	$4, %rax
	addq	%rdi, %rax
	addq	(%rax), %r11
	cmpq	%r9, %r11
	jne	.L24
	cmpq	%r10, %rdx
	je	.L44
	movq	8(%rax), %rdx
	cmpq	%rdx, %rbp
	cmovg	%rdx, %rbp
	subq	%rbp, %rdx
	addq	%rbp, %r12
	movq	%rdx, 8(%rax)
	subq	%rbp, 8(%rbx)
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L43:
	xorl	%eax, %eax
	movq	%r12, %rdx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L45
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L44:
	.cfi_restore_state
	movq	%rbp, %rax
	andl	$1, %ebp
	sarq	%rax
	movq	%rbp, 8(%rbx)
	addq	%rax, %r12
	jmp	.L24
.L18:
	movq	%r10, %r8
	addq	$1, %rdx
	salq	$4, %r8
	movq	%rdx, 8(%rdi,%r8)
	jmp	.L19
.L33:
	xorl	%r10d, %r10d
	jmp	.L14
.L34:
	movl	$1, %edx
	xorl	%r10d, %r10d
	movl	$1, %eax
	jmp	.L23
.L45:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.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:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	compare
	.type	compare, @function
compare:
.LFB39:
	.cfi_startproc
	endbr64
	movq	(%rsi), %rdx
	movl	$-1, %eax
	cmpq	%rdx, (%rdi)
	js	.L1
	setne	%al
	movzbl	%al, %eax
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	compare, .-compare
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB40:
	.cfi_startproc
	endbr64
	cmpq	%rsi, %rdi
	movq	%rsi, %rax
	cmovle	%rdi, %rax
	ret
	.cfi_endproc
.LFE40:
	.size	min, .-min
	.p2align 4
	.globl	next_pow
	.type	next_pow, @function
next_pow:
.LFB41:
	.cfi_startproc
	endbr64
	movl	$1, %eax
	testq	%rdi, %rdi
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L8:
	addq	%rax, %rax
	cmpq	%rax, %rdi
	jge	.L8
	ret
	.p2align 4,,10
	.p2align 3
.L9:
	ret
	.cfi_endproc
.LFE41:
	.size	next_pow, .-next_pow
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%r14, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %r13
	leaq	0(,%r13,8), %rdi
	call	malloc@PLT
	movq	%rax, %r12
	testq	%r13, %r13
	jle	.L12
	movq	%rax, %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbp, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	movq	(%rsp), %r13
	addq	$8, %rbp
	cmpq	%rbx, %r13
	jg	.L13
.L12:
	leaq	compare(%rip), %rcx
	movl	$8, %edx
	movq	%r13, %rsi
	movq	%r12, %rdi
	call	qsort@PLT
	movq	(%rsp), %rbx
	movq	%rbx, %rdi
	salq	$4, %rdi
	call	malloc@PLT
	movq	(%r12), %rcx
	movq	$1, 8(%rax)
	movq	%rax, %rdi
	movq	%rcx, (%rax)
	cmpq	$1, %rbx
	jle	.L33
	cmpq	$3, %rbx
	jle	.L34
	leaq	-4(%rbx), %rax
	movl	$1, %edx
	xorl	%r10d, %r10d
	movl	$1, %esi
	andq	$-2, %rax
	addq	$3, %rax
	jmp	.L20
.L16:
	addq	$1, %r10
	movq	%r10, %rdx
	salq	$4, %rdx
	addq	%rdi, %rdx
	movq	%r8, (%rdx)
	movq	$1, 8(%rdx)
	movl	$1, %edx
.L17:
	movq	8(%r12,%rsi,8), %rcx
	cmpq	%rcx, %r8
	je	.L18
	addq	$1, %r10
	movq	%r10, %rdx
	salq	$4, %rdx
	addq	%rdi, %rdx
	movq	%rcx, (%rdx)
	movq	$1, 8(%rdx)
	movl	$1, %edx
.L19:
	addq	$2, %rsi
	cmpq	%rax, %rsi
	je	.L23
.L20:
	movq	(%r12,%rsi,8), %r8
	cmpq	%rcx, %r8
	jne	.L16
	movq	%r10, %rcx
	addq	$1, %rdx
	salq	$4, %rcx
	movq	%rdx, 8(%rdi,%rcx)
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L21:
	addq	$1, %r10
	addq	$1, %rax
	movq	%r10, %rdx
	salq	$4, %rdx
	addq	%rdi, %rdx
	movq	%rcx, (%rdx)
	movq	$1, 8(%rdx)
	movl	$1, %edx
	cmpq	%rax, %rbx
	jle	.L14
.L23:
	movq	(%r12,%rax,8), %rcx
	cmpq	%rcx, -8(%r12,%rax,8)
	jne	.L21
	movq	%r10, %rcx
	addq	$1, %rdx
	addq	$1, %rax
	salq	$4, %rcx
	movq	%rdx, 8(%rdi,%rcx)
	cmpq	%rax, %rbx
	jg	.L23
.L14:
	movq	%r10, %rbx
	leaq	1(%r10), %rax
	xorl	%r12d, %r12d
	salq	$4, %rbx
	movq	%rax, (%rsp)
	addq	%rdi, %rbx
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L24:
	subq	$1, %r10
	subq	$16, %rbx
	cmpq	$-1, %r10
	je	.L43
.L31:
	movq	8(%rbx), %rbp
	testq	%rbp, %rbp
	jle	.L24
	movq	(%rbx), %r11
	movl	$1, %r9d
	testq	%r11, %r11
	jle	.L25
	.p2align 4,,10
	.p2align 3
.L26:
	addq	%r9, %r9
	cmpq	%r9, %r11
	jge	.L26
.L25:
	movq	%r9, %r8
	leaq	1(%r10), %rdx
	movq	$-1, %rcx
	subq	%r11, %r8
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L29:
	leaq	(%rdx,%rcx), %rsi
	movq	%rsi, %rax
	shrq	$63, %rax
	addq	%rsi, %rax
	sarq	%rax
	movq	%rax, %rsi
	salq	$4, %rsi
	cmpq	%r8, (%rdi,%rsi)
	cmovge	%rax, %rdx
	cmovl	%rax, %rcx
.L28:
	movq	%rdx, %rax
	subq	%rcx, %rax
	cmpq	$1, %rax
	jg	.L29
	movq	%rdx, %rax
	salq	$4, %rax
	addq	%rdi, %rax
	addq	(%rax), %r11
	cmpq	%r9, %r11
	jne	.L24
	cmpq	%r10, %rdx
	je	.L44
	movq	8(%rax), %rdx
	cmpq	%rdx, %rbp
	cmovg	%rdx, %rbp
	subq	%rbp, %rdx
	addq	%rbp, %r12
	movq	%rdx, 8(%rax)
	subq	%rbp, 8(%rbx)
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L43:
	xorl	%eax, %eax
	movq	%r12, %rdx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L45
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L44:
	.cfi_restore_state
	movq	%rbp, %rax
	andl	$1, %ebp
	sarq	%rax
	movq	%rbp, 8(%rbx)
	addq	%rax, %r12
	jmp	.L24
.L18:
	movq	%r10, %r8
	addq	$1, %rdx
	salq	$4, %r8
	movq	%rdx, 8(%rdi,%r8)
	jmp	.L19
.L33:
	xorl	%r10d, %r10d
	jmp	.L14
.L34:
	movl	$1, %edx
	xorl	%r10d, %r10d
	movl	$1, %eax
	jmp	.L23
.L45:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.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:

#include <stdio.h>
#include <stdlib.h>
#define int long long

typedef struct {
	int val;
	int num;
}pair;

signed compare(const void *a, const void *b){
	int sub = *(int *)a - *(int *)b;
	if(sub < 0){
		return -1;
	}
	else if(sub == 0){
		return 0;
	}
	else{
		return 1;
	}
}

int min(int a, int b){
	return a <= b ? a : b;
}

int next_pow(int n){
	int ans = 1;
	while(ans <= n){
		ans *= 2;
	}
	return ans;
}

signed main(){
	int N, i, j, ans = 0;
	scanf("%lld", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
	}
	qsort(A, N, sizeof(int), compare);
	pair *B = (pair *)malloc(sizeof(pair) * N);
	for(i = 1, j = 0, B[0].val = A[0], B[0].num = 1; i < N; i++){
		if(A[i] == A[i - 1]){
			B[j].num++;
		}
		else{
			j++;
			B[j].val = A[i];
			B[j].num = 1;
		}
	}
	N = j + 1;
	int l, h, r, k, minnum;
	for(i = N - 1; i >= 0; i--){
		if(B[i].num > 0){
			k = next_pow(B[i].val);
			l = -1;
			r = i + 1;
			while(r - l > 1){
				h = (l + r) / 2;
				if(B[h].val < k - B[i].val){
					l = h;
				}
				else{
					r = h;
				}
			}
			if(B[r].val + B[i].val == k){
				if(r == i){
					ans += B[i].num / 2;
					B[i].num %= 2;
				}
				else{
					minnum = min(B[r].num, B[i].num);
					ans += minnum;
					B[r].num -= minnum;
					B[i].num -= minnum;
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}
5
3 21 14 5 13
 5
2 3 24 6 13
 5
2 3 38 3 10
 5
3 24 14 5 13
 5
3 24 14 10 13
 5
3 24 16 10 13
 5
3 36 16 10 13
 5
3 36 16 14 13
 5
3 3 16 14 13
 5
3 3 24 14 13

1
 2
 0
 1
 1
 1
 1
 1
 1
 1

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>
#define int long long

typedef struct {
	int val;
	int num;
}pair;

signed compare(const void *a, const void *b){
	int sub = *(int *)a - *(int *)b;
	if(sub < 0){
		return -1;
	}
	else if(sub == 0){
		return 0;
	}
	else{
		return 1;
	}
}

int min(int a, int b){
	return a <= b ? a : b;
}

int next_pow(int n){
	int ans = 1;
	while(ans <= n){
		ans *= 2;
	}
	return ans;
}

signed main(){
	int N, i, j, ans = 0;
	scanf("%lld", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
	}
	qsort(A, N, sizeof(int), compare);
	pair *B = (pair *)malloc(sizeof(pair) * N);
	for(i = 1, j = 0, B[0].val = A[0], B[0].num = 1; i < N; i++){
		if(A[i] == A[i - 1]){
			B[j].num++;
		}
		else{
			j++;
			B[j].val = A[i];
			B[j].num = 1;
		}
	}
	N = j + 1;
	int l, h, r, k, minnum;
	for(i = N - 1; i >= 0; i--){
		if(B[i].num > 0){
			k = next_pow(B[i].val);
			l = -1;
			r = i + 1;
			while(r - l > 1){
				h = (l + r) / 2;
				if(B[h].val < k - B[i].val){
					l = h;
				}
				else{
					r = h;
				}
			}
			if(B[r].val + B[i].val == k){
				if(r == i){
					ans += B[i].num / 2;
					B[i].num %= 2;
				}
				else{
					minnum = min(B[r].num, B[i].num);
					ans += minnum;
					B[r].num -= minnum;
					B[i].num -= minnum;
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	compare
	.type	compare, @function
compare:
.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
	movq	(%rax), %rdx
	movq	-32(%rbp), %rax
	movq	(%rax), %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	movq	%rax, -8(%rbp)
	cmpq	$0, -8(%rbp)
	jns	.L2
	movl	$-1, %eax
	jmp	.L3
.L2:
	cmpq	$0, -8(%rbp)
	jne	.L4
	movl	$0, %eax
	jmp	.L3
.L4:
	movl	$1, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	compare, .-compare
	.globl	min
	.type	min, @function
min:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rdx
	movq	-16(%rbp), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	min, .-min
	.globl	next_pow
	.type	next_pow, @function
next_pow:
.LFB8:
	.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	$1, -8(%rbp)
	jmp	.L8
.L9:
	salq	-8(%rbp)
.L8:
	movq	-8(%rbp), %rax
	cmpq	-24(%rbp), %rax
	jle	.L9
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	next_pow, .-next_pow
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$96, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -72(%rbp)
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-96(%rbp), %rax
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -48(%rbp)
	movq	$0, -88(%rbp)
	jmp	.L12
.L13:
	movq	-88(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$1, -88(%rbp)
.L12:
	movq	-96(%rbp), %rax
	cmpq	%rax, -88(%rbp)
	jl	.L13
	movq	-96(%rbp), %rax
	movq	%rax, %rsi
	movq	-48(%rbp), %rax
	leaq	compare(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movq	-96(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40(%rbp)
	movq	$1, -88(%rbp)
	movq	$0, -80(%rbp)
	movq	-48(%rbp), %rax
	movq	(%rax), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, (%rax)
	movq	-40(%rbp), %rax
	movq	$1, 8(%rax)
	jmp	.L14
.L17:
	movq	-88(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-88(%rbp), %rax
	salq	$3, %rax
	leaq	-8(%rax), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jne	.L15
	movq	-80(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rdx
	addq	$1, %rdx
	movq	%rdx, 8(%rax)
	jmp	.L16
.L15:
	addq	$1, -80(%rbp)
	movq	-88(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	-80(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movq	-80(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	$1, 8(%rax)
.L16:
	addq	$1, -88(%rbp)
.L14:
	movq	-96(%rbp), %rax
	cmpq	%rax, -88(%rbp)
	jl	.L17
	movq	-80(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -96(%rbp)
	movq	-96(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -88(%rbp)
	jmp	.L18
.L24:
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jle	.L19
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	next_pow
	movq	%rax, -32(%rbp)
	movq	$-1, -64(%rbp)
	movq	-88(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -56(%rbp)
	jmp	.L20
.L22:
	movq	-64(%rbp), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	-88(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rdx), %rcx
	movq	-32(%rbp), %rdx
	subq	%rcx, %rdx
	cmpq	%rdx, %rax
	jge	.L21
	movq	-16(%rbp), %rax
	movq	%rax, -64(%rbp)
	jmp	.L20
.L21:
	movq	-16(%rbp), %rax
	movq	%rax, -56(%rbp)
.L20:
	movq	-56(%rbp), %rax
	subq	-64(%rbp), %rax
	cmpq	$1, %rax
	jg	.L22
	movq	-56(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-40(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	addq	%rdx, %rax
	cmpq	%rax, -32(%rbp)
	jne	.L19
	movq	-56(%rbp), %rax
	cmpq	-88(%rbp), %rax
	jne	.L23
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	addq	%rax, -72(%rbp)
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	-88(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rax, %rcx
	sarq	$63, %rcx
	shrq	$63, %rcx
	addq	%rcx, %rax
	andl	$1, %eax
	subq	%rcx, %rax
	movq	%rax, 8(%rdx)
	jmp	.L19
.L23:
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rdx
	movq	-56(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-40(%rbp), %rax
	addq	%rcx, %rax
	movq	8(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	min
	movq	%rax, -24(%rbp)
	movq	-24(%rbp), %rax
	addq	%rax, -72(%rbp)
	movq	-56(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	-56(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	subq	-24(%rbp), %rax
	movq	%rax, 8(%rdx)
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	-88(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	subq	-24(%rbp), %rax
	movq	%rax, 8(%rdx)
.L19:
	subq	$1, -88(%rbp)
.L18:
	cmpq	$0, -88(%rbp)
	jns	.L24
	movq	-72(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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	compare
	.type	compare, @function
compare:
.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
	movq	(%rax), %rdx
	movq	-32(%rbp), %rax
	movq	(%rax), %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	movq	%rax, -8(%rbp)
	cmpq	$0, -8(%rbp)
	jns	.L2
	movl	$-1, %eax
	jmp	.L3
.L2:
	cmpq	$0, -8(%rbp)
	jne	.L4
	movl	$0, %eax
	jmp	.L3
.L4:
	movl	$1, %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	compare, .-compare
	.globl	min
	.type	min, @function
min:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rdx
	movq	-16(%rbp), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	min, .-min
	.globl	next_pow
	.type	next_pow, @function
next_pow:
.LFB8:
	.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	$1, -8(%rbp)
	jmp	.L8
.L9:
	salq	-8(%rbp)
.L8:
	movq	-8(%rbp), %rax
	cmpq	-24(%rbp), %rax
	jle	.L9
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	next_pow, .-next_pow
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$96, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -72(%rbp)
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-96(%rbp), %rax
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -48(%rbp)
	movq	$0, -88(%rbp)
	jmp	.L12
.L13:
	movq	-88(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$1, -88(%rbp)
.L12:
	movq	-96(%rbp), %rax
	cmpq	%rax, -88(%rbp)
	jl	.L13
	movq	-96(%rbp), %rax
	movq	%rax, %rsi
	movq	-48(%rbp), %rax
	leaq	compare(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movq	-96(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40(%rbp)
	movq	$1, -88(%rbp)
	movq	$0, -80(%rbp)
	movq	-48(%rbp), %rax
	movq	(%rax), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, (%rax)
	movq	-40(%rbp), %rax
	movq	$1, 8(%rax)
	jmp	.L14
.L17:
	movq	-88(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-88(%rbp), %rax
	salq	$3, %rax
	leaq	-8(%rax), %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jne	.L15
	movq	-80(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rdx
	addq	$1, %rdx
	movq	%rdx, 8(%rax)
	jmp	.L16
.L15:
	addq	$1, -80(%rbp)
	movq	-88(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	-80(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	movq	-80(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	$1, 8(%rax)
.L16:
	addq	$1, -88(%rbp)
.L14:
	movq	-96(%rbp), %rax
	cmpq	%rax, -88(%rbp)
	jl	.L17
	movq	-80(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -96(%rbp)
	movq	-96(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -88(%rbp)
	jmp	.L18
.L24:
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jle	.L19
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	next_pow
	movq	%rax, -32(%rbp)
	movq	$-1, -64(%rbp)
	movq	-88(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -56(%rbp)
	jmp	.L20
.L22:
	movq	-64(%rbp), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	-88(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rdx), %rcx
	movq	-32(%rbp), %rdx
	subq	%rcx, %rdx
	cmpq	%rdx, %rax
	jge	.L21
	movq	-16(%rbp), %rax
	movq	%rax, -64(%rbp)
	jmp	.L20
.L21:
	movq	-16(%rbp), %rax
	movq	%rax, -56(%rbp)
.L20:
	movq	-56(%rbp), %rax
	subq	-64(%rbp), %rax
	cmpq	$1, %rax
	jg	.L22
	movq	-56(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-40(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	addq	%rdx, %rax
	cmpq	%rax, -32(%rbp)
	jne	.L19
	movq	-56(%rbp), %rax
	cmpq	-88(%rbp), %rax
	jne	.L23
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	addq	%rax, -72(%rbp)
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	-88(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rax, %rcx
	sarq	$63, %rcx
	shrq	$63, %rcx
	addq	%rcx, %rax
	andl	$1, %eax
	subq	%rcx, %rax
	movq	%rax, 8(%rdx)
	jmp	.L19
.L23:
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rdx
	movq	-56(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-40(%rbp), %rax
	addq	%rcx, %rax
	movq	8(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	min
	movq	%rax, -24(%rbp)
	movq	-24(%rbp), %rax
	addq	%rax, -72(%rbp)
	movq	-56(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	-56(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	subq	-24(%rbp), %rax
	movq	%rax, 8(%rdx)
	movq	-88(%rbp), %rax
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	-88(%rbp), %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-40(%rbp), %rdx
	addq	%rcx, %rdx
	subq	-24(%rbp), %rax
	movq	%rax, 8(%rdx)
.L19:
	subq	$1, -88(%rbp)
.L18:
	cmpq	$0, -88(%rbp)
	jns	.L24
	movq	-72(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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:
