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



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}

int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }

  if(b==0){
    return a;
  }

  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }

  return b;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  /*
  解法2
  (答え)=((総和の2乗)-(2乗の総和))/2
  ということがわかるので，それを実装

  2で割る部分は解法1と同じ

  */
  long int t=2;
  long int n;
  scanf("%ld",&n);

  long int A[n];
  
  //総和
  long int all=0;
  
  //2乗の総和
  long int sq_all=0;

  long int MOD=1e9+7;

  for(int i=0;i<n;i++){
    scanf("%ld",&A[i]);
    all+=A[i];

    //常にMODを取る！
    all%=MOD;

    sq_all+=modpow(A[i],t,MOD);
    
    //常にMODを取る！
    sq_all%=MOD;
  }


  //MOD上の2の逆元
  long int v=modinv(2,MOD);

  long int ans=modpow(all,t,MOD);
  ans-=sq_all;
  ans+=10*MOD;
  ans%=MOD;

  //常にMODを取る！
  printf("%ld\n",ans*v%MOD);

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	swap
	.type	swap, @function
swap:
.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, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	swap, .-swap
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$24, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L4
	leaq	-24(%rbp), %rdx
	leaq	-20(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L4:
	movl	-24(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	movl	-20(%rbp), %eax
	jmp	.L6
.L5:
	movl	-20(%rbp), %eax
	movl	-24(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -4(%rbp)
	jmp	.L7
.L8:
	movl	-24(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-20(%rbp), %eax
	movl	-24(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -4(%rbp)
.L7:
	cmpl	$0, -4(%rbp)
	jne	.L8
	movl	-24(%rbp), %eax
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	gcd, .-gcd
	.globl	dn
	.type	dn, @function
dn:
.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, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	dn, .-dn
	.globl	modpow
	.type	modpow, @function
modpow:
.LFB9:
	.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	%rdx, -40(%rbp)
	movq	$1, -8(%rbp)
	jmp	.L12
.L14:
	movq	-32(%rbp), %rax
	andl	$1, %eax
	testq	%rax, %rax
	je	.L13
	movq	-8(%rbp), %rax
	imulq	-24(%rbp), %rax
	cqto
	idivq	-40(%rbp)
	movq	%rdx, -8(%rbp)
.L13:
	movq	-24(%rbp), %rax
	imulq	%rax, %rax
	cqto
	idivq	-40(%rbp)
	movq	%rdx, -24(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -32(%rbp)
.L12:
	cmpq	$0, -32(%rbp)
	jg	.L14
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	modpow, .-modpow
	.globl	modinv
	.type	modinv, @function
modinv:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	leaq	-2(%rax), %rcx
	movq	-16(%rbp), %rdx
	movq	-8(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	modpow
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	modinv, .-modinv
	.globl	max
	.type	max, @function
max:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L19
	movl	-8(%rbp), %eax
	jmp	.L20
.L19:
	movl	-4(%rbp), %eax
.L20:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	max, .-max
	.globl	min
	.type	min, @function
min:
.LFB12:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L22
	movl	-4(%rbp), %eax
	jmp	.L23
.L22:
	movl	-8(%rbp), %eax
.L23:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.size	min, .-min
	.globl	chmax
	.type	chmax, @function
chmax:
.LFB13:
	.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)
	movl	%esi, -12(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L27
	movq	-8(%rbp), %rax
	movl	-12(%rbp), %edx
	movl	%edx, (%rax)
	nop
.L27:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE13:
	.size	chmax, .-chmax
	.globl	chmin
	.type	chmin, @function
chmin:
.LFB14:
	.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)
	movl	%esi, -12(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L31
	movq	-8(%rbp), %rax
	movl	-12(%rbp), %edx
	movl	%edx, (%rax)
	nop
.L31:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE14:
	.size	chmin, .-chmin
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB15:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$104, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	movq	$2, -104(%rbp)
	leaq	-128(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-128(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -96(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movq	%rax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L33:
	cmpq	%rdx, %rsp
	je	.L34
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L33
.L34:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L35
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L35:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -88(%rbp)
	movq	$0, -120(%rbp)
	movq	$0, -112(%rbp)
	movq	$1000000007, -80(%rbp)
	movl	$0, -132(%rbp)
	jmp	.L36
.L37:
	movl	-132(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-88(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-88(%rbp), %rax
	movl	-132(%rbp), %edx
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	addq	%rax, -120(%rbp)
	movq	-120(%rbp), %rax
	cqto
	idivq	-80(%rbp)
	movq	%rdx, -120(%rbp)
	movq	-88(%rbp), %rax
	movl	-132(%rbp), %edx
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	movq	-80(%rbp), %rdx
	movq	-104(%rbp), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	modpow
	addq	%rax, -112(%rbp)
	movq	-112(%rbp), %rax
	cqto
	idivq	-80(%rbp)
	movq	%rdx, -112(%rbp)
	addl	$1, -132(%rbp)
.L36:
	movl	-132(%rbp), %eax
	movslq	%eax, %rdx
	movq	-128(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L37
	movq	-80(%rbp), %rax
	movq	%rax, %rsi
	movl	$2, %edi
	call	modinv
	movq	%rax, -72(%rbp)
	movq	-80(%rbp), %rdx
	movq	-104(%rbp), %rcx
	movq	-120(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	modpow
	movq	%rax, -64(%rbp)
	movq	-112(%rbp), %rax
	subq	%rax, -64(%rbp)
	movq	-80(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rax, -64(%rbp)
	movq	-64(%rbp), %rax
	cqto
	idivq	-80(%rbp)
	movq	%rdx, -64(%rbp)
	movq	-64(%rbp), %rax
	imulq	-72(%rbp), %rax
	cqto
	idivq	-80(%rbp)
	movq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE15:
	.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	swap
	.type	swap, @function
swap:
.LFB51:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	movl	(%rsi), %edx
	movl	%edx, (%rdi)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE51:
	.size	swap, .-swap
	.p2align 4
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB52:
	.cfi_startproc
	endbr64
	movl	%edi, %r8d
	cmpl	%esi, %edi
	jge	.L4
	movl	%esi, %r8d
	movl	%edi, %esi
.L4:
	testl	%esi, %esi
	je	.L3
	movl	%r8d, %eax
	cltd
	idivl	%esi
	movl	%edx, %r8d
	testl	%edx, %edx
	jne	.L6
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L9:
	movl	%edx, %r8d
.L6:
	movl	%esi, %eax
	movl	%r8d, %esi
	cltd
	idivl	%r8d
	testl	%edx, %edx
	jne	.L9
.L3:
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%esi, %r8d
	jmp	.L3
	.cfi_endproc
.LFE52:
	.size	gcd, .-gcd
	.p2align 4
	.globl	dn
	.type	dn, @function
dn:
.LFB53:
	.cfi_startproc
	endbr64
	movl	(%rsi), %eax
	subl	(%rdi), %eax
	ret
	.cfi_endproc
.LFE53:
	.size	dn, .-dn
	.p2align 4
	.globl	modpow
	.type	modpow, @function
modpow:
.LFB54:
	.cfi_startproc
	endbr64
	movq	%rdx, %rcx
	movl	$1, %r8d
	testq	%rsi, %rsi
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L16:
	testb	$1, %sil
	je	.L15
	movq	%r8, %rax
	imulq	%rdi, %rax
	cqto
	idivq	%rcx
	movq	%rdx, %r8
.L15:
	imulq	%rdi, %rdi
	movq	%rdi, %rax
	cqto
	idivq	%rcx
	sarq	%rsi
	movq	%rdx, %rdi
	jne	.L16
.L13:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE54:
	.size	modpow, .-modpow
	.p2align 4
	.globl	modinv
	.type	modinv, @function
modinv:
.LFB55:
	.cfi_startproc
	endbr64
	leaq	-2(%rsi), %rcx
	movl	$1, %r8d
	testq	%rcx, %rcx
	jle	.L22
	.p2align 4,,10
	.p2align 3
.L25:
	testb	$1, %cl
	je	.L24
	movq	%r8, %rax
	imulq	%rdi, %rax
	cqto
	idivq	%rsi
	movq	%rdx, %r8
.L24:
	imulq	%rdi, %rdi
	movq	%rdi, %rax
	cqto
	idivq	%rsi
	sarq	%rcx
	movq	%rdx, %rdi
	jne	.L25
.L22:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE55:
	.size	modinv, .-modinv
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB56:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovge	%edi, %eax
	ret
	.cfi_endproc
.LFE56:
	.size	max, .-max
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB57:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovle	%edi, %eax
	ret
	.cfi_endproc
.LFE57:
	.size	min, .-min
	.p2align 4
	.globl	chmax
	.type	chmax, @function
chmax:
.LFB58:
	.cfi_startproc
	endbr64
	cmpl	%esi, (%rdi)
	jge	.L33
	movl	%esi, (%rdi)
.L33:
	ret
	.cfi_endproc
.LFE58:
	.size	chmax, .-chmax
	.p2align 4
	.globl	chmin
	.type	chmin, @function
chmin:
.LFB59:
	.cfi_startproc
	endbr64
	cmpl	%esi, (%rdi)
	jle	.L35
	movl	%esi, (%rdi)
.L35:
	ret
	.cfi_endproc
.LFE59:
	.size	chmin, .-chmin
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB60:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rcx
	movq	%rsp, %rsi
	leaq	15(,%rcx,8), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rsi
	andq	$-16, %rdx
	cmpq	%rsi, %rsp
	je	.L39
.L56:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L56
.L39:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L57
.L40:
	movq	%rsp, %rsi
	testq	%rcx, %rcx
	jle	.L46
	movq	%rsi, %r12
	xorl	%r15d, %r15d
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	movabsq	$-8543223828751151131, %r14
	.p2align 4,,10
	.p2align 3
.L42:
	movq	%r12, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	addq	$1, %r15
	call	__isoc99_scanf@PLT
	movq	(%r12), %rcx
	addq	$8, %r12
	leaq	(%rcx,%rbx), %rdi
	movq	%rdi, %rax
	imulq	%rcx, %rcx
	imulq	%r14
	movq	%rdi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rdi), %rbx
	sarq	$29, %rbx
	subq	%rax, %rbx
	imulq	$1000000007, %rbx, %rax
	subq	%rax, %rdi
	movq	%rcx, %rax
	mulq	%r14
	movq	%rdi, %rbx
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rdx
	subq	%rdx, %rcx
	addq	%r13, %rcx
	movq	%rcx, %rax
	mulq	%r14
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rax
	subq	%rax, %rcx
	movq	%rcx, %r13
	cmpq	%r15, -64(%rbp)
	jg	.L42
.L41:
	movl	$30, %r9d
	movl	$1, %edi
	movl	$2, %ecx
	movl	$1000000005, %r8d
	movabsq	$-8543223828751151131, %rsi
	.p2align 4,,10
	.p2align 3
.L44:
	testb	$1, %r8b
	je	.L43
	imulq	%rcx, %rdi
	movq	%rdi, %rax
	movq	%rdi, %r10
	imulq	%rsi
	movq	%r10, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rdi), %rdi
	sarq	$29, %rdi
	subq	%rax, %rdi
	imulq	$1000000007, %rdi, %rax
	movq	%r10, %rdi
	subq	%rax, %rdi
.L43:
	imulq	%rcx, %rcx
	sarq	%r8
	movq	%rcx, %rax
	mulq	%rsi
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rax
	subq	%rax, %rcx
	subl	$1, %r9d
	jne	.L44
	imulq	%rbx, %rbx
	movq	%rbx, %rax
	mulq	%rsi
	movabsq	$10000000070, %rax
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rdx
	subq	%rdx, %rbx
	subq	%r13, %rbx
	leaq	(%rbx,%rax), %rcx
	movq	%rcx, %rax
	mulq	%rsi
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rdx
	subq	%rdx, %rcx
	imulq	%rdi, %rcx
	movl	$1, %edi
	movq	%rcx, %rax
	imulq	%rsi
	leaq	.LC1(%rip), %rsi
	leaq	(%rdx,%rcx), %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	sarq	$29, %rax
	subq	%rdx, %rax
	movq	%rcx, %rdx
	imulq	$1000000007, %rax, %rax
	subq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L58
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L57:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rdx)
	jmp	.L40
.L46:
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	jmp	.L41
.L58:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE60:
	.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	swap
	.type	swap, @function
swap:
.LFB51:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	movl	(%rsi), %edx
	movl	%edx, (%rdi)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE51:
	.size	swap, .-swap
	.p2align 4
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB52:
	.cfi_startproc
	endbr64
	movl	%edi, %r8d
	cmpl	%esi, %edi
	jge	.L4
	movl	%esi, %r8d
	movl	%edi, %esi
.L4:
	testl	%esi, %esi
	je	.L3
	movl	%r8d, %eax
	cltd
	idivl	%esi
	movl	%edx, %r8d
	testl	%edx, %edx
	jne	.L6
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L9:
	movl	%edx, %r8d
.L6:
	movl	%esi, %eax
	movl	%r8d, %esi
	cltd
	idivl	%r8d
	testl	%edx, %edx
	jne	.L9
.L3:
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%esi, %r8d
	jmp	.L3
	.cfi_endproc
.LFE52:
	.size	gcd, .-gcd
	.p2align 4
	.globl	dn
	.type	dn, @function
dn:
.LFB53:
	.cfi_startproc
	endbr64
	movl	(%rsi), %eax
	subl	(%rdi), %eax
	ret
	.cfi_endproc
.LFE53:
	.size	dn, .-dn
	.p2align 4
	.globl	modpow
	.type	modpow, @function
modpow:
.LFB54:
	.cfi_startproc
	endbr64
	movq	%rdx, %rcx
	movl	$1, %r8d
	testq	%rsi, %rsi
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L16:
	testb	$1, %sil
	je	.L15
	movq	%r8, %rax
	imulq	%rdi, %rax
	cqto
	idivq	%rcx
	movq	%rdx, %r8
.L15:
	imulq	%rdi, %rdi
	movq	%rdi, %rax
	cqto
	idivq	%rcx
	sarq	%rsi
	movq	%rdx, %rdi
	jne	.L16
.L13:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE54:
	.size	modpow, .-modpow
	.p2align 4
	.globl	modinv
	.type	modinv, @function
modinv:
.LFB55:
	.cfi_startproc
	endbr64
	leaq	-2(%rsi), %rcx
	movl	$1, %r8d
	testq	%rcx, %rcx
	jle	.L22
	.p2align 4,,10
	.p2align 3
.L25:
	testb	$1, %cl
	je	.L24
	movq	%r8, %rax
	imulq	%rdi, %rax
	cqto
	idivq	%rsi
	movq	%rdx, %r8
.L24:
	imulq	%rdi, %rdi
	movq	%rdi, %rax
	cqto
	idivq	%rsi
	sarq	%rcx
	movq	%rdx, %rdi
	jne	.L25
.L22:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE55:
	.size	modinv, .-modinv
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB56:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovge	%edi, %eax
	ret
	.cfi_endproc
.LFE56:
	.size	max, .-max
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB57:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovle	%edi, %eax
	ret
	.cfi_endproc
.LFE57:
	.size	min, .-min
	.p2align 4
	.globl	chmax
	.type	chmax, @function
chmax:
.LFB58:
	.cfi_startproc
	endbr64
	cmpl	%esi, (%rdi)
	jge	.L33
	movl	%esi, (%rdi)
.L33:
	ret
	.cfi_endproc
.LFE58:
	.size	chmax, .-chmax
	.p2align 4
	.globl	chmin
	.type	chmin, @function
chmin:
.LFB59:
	.cfi_startproc
	endbr64
	cmpl	%esi, (%rdi)
	jle	.L35
	movl	%esi, (%rdi)
.L35:
	ret
	.cfi_endproc
.LFE59:
	.size	chmin, .-chmin
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB60:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rcx
	movq	%rsp, %rsi
	leaq	15(,%rcx,8), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rsi
	andq	$-16, %rdx
	cmpq	%rsi, %rsp
	je	.L39
.L56:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L56
.L39:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L57
.L40:
	movq	%rsp, %rsi
	testq	%rcx, %rcx
	jle	.L46
	movq	%rsi, %r12
	xorl	%r15d, %r15d
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	movabsq	$-8543223828751151131, %r14
	.p2align 4,,10
	.p2align 3
.L42:
	movq	%r12, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	addq	$1, %r15
	call	__isoc99_scanf@PLT
	movq	(%r12), %rcx
	addq	$8, %r12
	leaq	(%rcx,%rbx), %rdi
	movq	%rdi, %rax
	imulq	%rcx, %rcx
	imulq	%r14
	movq	%rdi, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rdi), %rbx
	sarq	$29, %rbx
	subq	%rax, %rbx
	imulq	$1000000007, %rbx, %rax
	subq	%rax, %rdi
	movq	%rcx, %rax
	mulq	%r14
	movq	%rdi, %rbx
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rdx
	subq	%rdx, %rcx
	addq	%r13, %rcx
	movq	%rcx, %rax
	mulq	%r14
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rax
	subq	%rax, %rcx
	movq	%rcx, %r13
	cmpq	%r15, -64(%rbp)
	jg	.L42
.L41:
	movl	$30, %r9d
	movl	$1, %edi
	movl	$2, %ecx
	movl	$1000000005, %r8d
	movabsq	$-8543223828751151131, %rsi
	.p2align 4,,10
	.p2align 3
.L44:
	testb	$1, %r8b
	je	.L43
	imulq	%rcx, %rdi
	movq	%rdi, %rax
	movq	%rdi, %r10
	imulq	%rsi
	movq	%r10, %rax
	sarq	$63, %rax
	leaq	(%rdx,%rdi), %rdi
	sarq	$29, %rdi
	subq	%rax, %rdi
	imulq	$1000000007, %rdi, %rax
	movq	%r10, %rdi
	subq	%rax, %rdi
.L43:
	imulq	%rcx, %rcx
	sarq	%r8
	movq	%rcx, %rax
	mulq	%rsi
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rax
	subq	%rax, %rcx
	subl	$1, %r9d
	jne	.L44
	imulq	%rbx, %rbx
	movq	%rbx, %rax
	mulq	%rsi
	movabsq	$10000000070, %rax
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rdx
	subq	%rdx, %rbx
	subq	%r13, %rbx
	leaq	(%rbx,%rax), %rcx
	movq	%rcx, %rax
	mulq	%rsi
	shrq	$29, %rdx
	imulq	$1000000007, %rdx, %rdx
	subq	%rdx, %rcx
	imulq	%rdi, %rcx
	movl	$1, %edi
	movq	%rcx, %rax
	imulq	%rsi
	leaq	.LC1(%rip), %rsi
	leaq	(%rdx,%rcx), %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	sarq	$29, %rax
	subq	%rdx, %rax
	movq	%rcx, %rdx
	imulq	$1000000007, %rax, %rax
	subq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L58
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L57:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rdx)
	jmp	.L40
.L46:
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	jmp	.L41
.L58:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE60:
	.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>
#include <math.h>
#include <string.h>



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}

int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }

  if(b==0){
    return a;
  }

  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }

  return b;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  /*
  解法2
  (答え)=((総和の2乗)-(2乗の総和))/2
  ということがわかるので，それを実装

  2で割る部分は解法1と同じ

  */
  long int t=2;
  long int n;
  scanf("%ld",&n);

  long int A[n];
  
  //総和
  long int all=0;
  
  //2乗の総和
  long int sq_all=0;

  long int MOD=1e9+7;

  for(int i=0;i<n;i++){
    scanf("%ld",&A[i]);
    all+=A[i];

    //常にMODを取る！
    all%=MOD;

    sq_all+=modpow(A[i],t,MOD);
    
    //常にMODを取る！
    sq_all%=MOD;
  }


  //MOD上の2の逆元
  long int v=modinv(2,MOD);

  long int ans=modpow(all,t,MOD);
  ans-=sq_all;
  ans+=10*MOD;
  ans%=MOD;

  //常にMODを取る！
  printf("%ld\n",ans*v%MOD);

  return 0;
}
3
0 2 3
 4
141421356 17320508 22360679 176612
 3
0 2 0
 4
141421356 17320508 44188846 176612
 4
141421356 15438004 44188846 176612
 4
141421356 15438004 10545868 176612
 4
141421356 22198551 10545868 176612
 4
141421356 22198551 4405286 176612
 4
141421356 5143928 4405286 176612
 4
141421356 1512598 4405286 176612

6
 432841470
 0
 442072669
 24018621
 309796111
 856634378
 907440962
 471127930
 478491412

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



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}

int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }

  if(b==0){
    return a;
  }

  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }

  return b;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  /*
  解法2
  (答え)=((総和の2乗)-(2乗の総和))/2
  ということがわかるので，それを実装

  2で割る部分は解法1と同じ

  */
  long int t=2;
  long int n;
  scanf("%ld",&n);

  long int A[n];
  
  //総和
  long int all=0;
  
  //2乗の総和
  long int sq_all=0;

  long int MOD=1e9+7;

  for(int i=0;i<n;i++){
    scanf("%ld",&A[i]);
    all+=A[i];

    //常にMODを取る！
    all%=MOD;

    sq_all+=modpow(A[i],t,MOD);
    
    //常にMODを取る！
    sq_all%=MOD;
  }


  //MOD上の2の逆元
  long int v=modinv(2,MOD);

  long int ans=modpow(all,t,MOD);
  ans-=sq_all;
  ans+=10*MOD;
  ans%=MOD;

  //常にMODを取る！
  printf("%ld\n",ans*v%MOD);

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	swap
	.type	swap, @function
swap:
.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, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	swap, .-swap
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$24, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L4
	leaq	-24(%rbp), %rdx
	leaq	-20(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L4:
	movl	-24(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	movl	-20(%rbp), %eax
	jmp	.L6
.L5:
	movl	-20(%rbp), %eax
	movl	-24(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -4(%rbp)
	jmp	.L7
.L8:
	movl	-24(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-20(%rbp), %eax
	movl	-24(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -4(%rbp)
.L7:
	cmpl	$0, -4(%rbp)
	jne	.L8
	movl	-24(%rbp), %eax
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	gcd, .-gcd
	.globl	dn
	.type	dn, @function
dn:
.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, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	dn, .-dn
	.globl	modpow
	.type	modpow, @function
modpow:
.LFB9:
	.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	%rdx, -40(%rbp)
	movq	$1, -8(%rbp)
	jmp	.L12
.L14:
	movq	-32(%rbp), %rax
	andl	$1, %eax
	testq	%rax, %rax
	je	.L13
	movq	-8(%rbp), %rax
	imulq	-24(%rbp), %rax
	cqto
	idivq	-40(%rbp)
	movq	%rdx, -8(%rbp)
.L13:
	movq	-24(%rbp), %rax
	imulq	%rax, %rax
	cqto
	idivq	-40(%rbp)
	movq	%rdx, -24(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -32(%rbp)
.L12:
	cmpq	$0, -32(%rbp)
	jg	.L14
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	modpow, .-modpow
	.globl	modinv
	.type	modinv, @function
modinv:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	leaq	-2(%rax), %rcx
	movq	-16(%rbp), %rdx
	movq	-8(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	modpow
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	modinv, .-modinv
	.globl	max
	.type	max, @function
max:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L19
	movl	-8(%rbp), %eax
	jmp	.L20
.L19:
	movl	-4(%rbp), %eax
.L20:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	max, .-max
	.globl	min
	.type	min, @function
min:
.LFB12:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L22
	movl	-4(%rbp), %eax
	jmp	.L23
.L22:
	movl	-8(%rbp), %eax
.L23:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.size	min, .-min
	.globl	chmax
	.type	chmax, @function
chmax:
.LFB13:
	.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)
	movl	%esi, -12(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L27
	movq	-8(%rbp), %rax
	movl	-12(%rbp), %edx
	movl	%edx, (%rax)
	nop
.L27:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE13:
	.size	chmax, .-chmax
	.globl	chmin
	.type	chmin, @function
chmin:
.LFB14:
	.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)
	movl	%esi, -12(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L31
	movq	-8(%rbp), %rax
	movl	-12(%rbp), %edx
	movl	%edx, (%rax)
	nop
.L31:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE14:
	.size	chmin, .-chmin
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB15:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$104, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	movq	$2, -104(%rbp)
	leaq	-128(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-128(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -96(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movq	%rax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L33:
	cmpq	%rdx, %rsp
	je	.L34
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L33
.L34:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L35
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L35:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -88(%rbp)
	movq	$0, -120(%rbp)
	movq	$0, -112(%rbp)
	movq	$1000000007, -80(%rbp)
	movl	$0, -132(%rbp)
	jmp	.L36
.L37:
	movl	-132(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-88(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-88(%rbp), %rax
	movl	-132(%rbp), %edx
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	addq	%rax, -120(%rbp)
	movq	-120(%rbp), %rax
	cqto
	idivq	-80(%rbp)
	movq	%rdx, -120(%rbp)
	movq	-88(%rbp), %rax
	movl	-132(%rbp), %edx
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	movq	-80(%rbp), %rdx
	movq	-104(%rbp), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	modpow
	addq	%rax, -112(%rbp)
	movq	-112(%rbp), %rax
	cqto
	idivq	-80(%rbp)
	movq	%rdx, -112(%rbp)
	addl	$1, -132(%rbp)
.L36:
	movl	-132(%rbp), %eax
	movslq	%eax, %rdx
	movq	-128(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L37
	movq	-80(%rbp), %rax
	movq	%rax, %rsi
	movl	$2, %edi
	call	modinv
	movq	%rax, -72(%rbp)
	movq	-80(%rbp), %rdx
	movq	-104(%rbp), %rcx
	movq	-120(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	modpow
	movq	%rax, -64(%rbp)
	movq	-112(%rbp), %rax
	subq	%rax, -64(%rbp)
	movq	-80(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rax, -64(%rbp)
	movq	-64(%rbp), %rax
	cqto
	idivq	-80(%rbp)
	movq	%rdx, -64(%rbp)
	movq	-64(%rbp), %rax
	imulq	-72(%rbp), %rax
	cqto
	idivq	-80(%rbp)
	movq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE15:
	.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	swap
	.type	swap, @function
swap:
.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, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	swap, .-swap
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$24, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L4
	leaq	-24(%rbp), %rdx
	leaq	-20(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L4:
	movl	-24(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	movl	-20(%rbp), %eax
	jmp	.L6
.L5:
	movl	-20(%rbp), %eax
	movl	-24(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -4(%rbp)
	jmp	.L7
.L8:
	movl	-24(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-20(%rbp), %eax
	movl	-24(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -4(%rbp)
.L7:
	cmpl	$0, -4(%rbp)
	jne	.L8
	movl	-24(%rbp), %eax
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	gcd, .-gcd
	.globl	dn
	.type	dn, @function
dn:
.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, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	dn, .-dn
	.globl	modpow
	.type	modpow, @function
modpow:
.LFB9:
	.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	%rdx, -40(%rbp)
	movq	$1, -8(%rbp)
	jmp	.L12
.L14:
	movq	-32(%rbp), %rax
	andl	$1, %eax
	testq	%rax, %rax
	je	.L13
	movq	-8(%rbp), %rax
	imulq	-24(%rbp), %rax
	cqto
	idivq	-40(%rbp)
	movq	%rdx, -8(%rbp)
.L13:
	movq	-24(%rbp), %rax
	imulq	%rax, %rax
	cqto
	idivq	-40(%rbp)
	movq	%rdx, -24(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -32(%rbp)
.L12:
	cmpq	$0, -32(%rbp)
	jg	.L14
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	modpow, .-modpow
	.globl	modinv
	.type	modinv, @function
modinv:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	leaq	-2(%rax), %rcx
	movq	-16(%rbp), %rdx
	movq	-8(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	modpow
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	modinv, .-modinv
	.globl	max
	.type	max, @function
max:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L19
	movl	-8(%rbp), %eax
	jmp	.L20
.L19:
	movl	-4(%rbp), %eax
.L20:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	max, .-max
	.globl	min
	.type	min, @function
min:
.LFB12:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L22
	movl	-4(%rbp), %eax
	jmp	.L23
.L22:
	movl	-8(%rbp), %eax
.L23:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.size	min, .-min
	.globl	chmax
	.type	chmax, @function
chmax:
.LFB13:
	.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)
	movl	%esi, -12(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L27
	movq	-8(%rbp), %rax
	movl	-12(%rbp), %edx
	movl	%edx, (%rax)
	nop
.L27:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE13:
	.size	chmax, .-chmax
	.globl	chmin
	.type	chmin, @function
chmin:
.LFB14:
	.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)
	movl	%esi, -12(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L31
	movq	-8(%rbp), %rax
	movl	-12(%rbp), %edx
	movl	%edx, (%rax)
	nop
.L31:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE14:
	.size	chmin, .-chmin
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB15:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$104, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	movq	$2, -104(%rbp)
	leaq	-128(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-128(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -96(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movq	%rax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L33:
	cmpq	%rdx, %rsp
	je	.L34
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L33
.L34:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L35
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L35:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -88(%rbp)
	movq	$0, -120(%rbp)
	movq	$0, -112(%rbp)
	movq	$1000000007, -80(%rbp)
	movl	$0, -132(%rbp)
	jmp	.L36
.L37:
	movl	-132(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-88(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-88(%rbp), %rax
	movl	-132(%rbp), %edx
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	addq	%rax, -120(%rbp)
	movq	-120(%rbp), %rax
	cqto
	idivq	-80(%rbp)
	movq	%rdx, -120(%rbp)
	movq	-88(%rbp), %rax
	movl	-132(%rbp), %edx
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	movq	-80(%rbp), %rdx
	movq	-104(%rbp), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	modpow
	addq	%rax, -112(%rbp)
	movq	-112(%rbp), %rax
	cqto
	idivq	-80(%rbp)
	movq	%rdx, -112(%rbp)
	addl	$1, -132(%rbp)
.L36:
	movl	-132(%rbp), %eax
	movslq	%eax, %rdx
	movq	-128(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L37
	movq	-80(%rbp), %rax
	movq	%rax, %rsi
	movl	$2, %edi
	call	modinv
	movq	%rax, -72(%rbp)
	movq	-80(%rbp), %rdx
	movq	-104(%rbp), %rcx
	movq	-120(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	modpow
	movq	%rax, -64(%rbp)
	movq	-112(%rbp), %rax
	subq	%rax, -64(%rbp)
	movq	-80(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rax, -64(%rbp)
	movq	-64(%rbp), %rax
	cqto
	idivq	-80(%rbp)
	movq	%rdx, -64(%rbp)
	movq	-64(%rbp), %rax
	imulq	-72(%rbp), %rax
	cqto
	idivq	-80(%rbp)
	movq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE15:
	.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:
