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>

typedef long long int int64;

int64 *tmp=NULL;
int64 calc(int64 *a,int n){
  if(n<=1) return 0;
  int m=n/2;
  int64 res=calc(a,m)+calc(a+m,n-m);
  int i=0;
  int j=m;
  int k=0;
  while(i<m && j<n){
    if(a[i]<=a[j]){
      tmp[k++]=a[i++];
    } else {
      res+=i;
      tmp[k++]=a[j++];
    }
  }
  while(i<m) tmp[k++]=a[i++];
  while(j<n){
    res+=i;
    tmp[k++]=a[j++];
  }
  for(i=0;i<n;i++) a[i]=tmp[i];
  return res;
}

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int64 *a=(int64 *)malloc(sizeof(int64)*(n+1));
  a[0]=0;
  int i;
  for(i=1;i<=n;i++){
    int x;
    scanf("%d",&x);
    a[i]=a[i-1]+x-k;
  }
  tmp=(int64 *)malloc(sizeof(int64)*(n+1));
  int64 ans=calc(a,n+1);
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	tmp
	.bss
	.align 8
	.type	tmp, @object
	.size	tmp, 8
tmp:
	.zero	8
	.text
	.globl	calc
	.type	calc, @function
calc:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -56(%rbp)
	movl	%esi, -60(%rbp)
	cmpl	$1, -60(%rbp)
	jg	.L2
	movl	$0, %eax
	jmp	.L3
.L2:
	movl	-60(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -28(%rbp)
	movl	-28(%rbp), %edx
	movq	-56(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	calc
	movq	%rax, %rbx
	movl	-60(%rbp), %eax
	subl	-28(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-56(%rbp), %rdx
	addq	%rcx, %rdx
	movl	%eax, %esi
	movq	%rdx, %rdi
	call	calc
	addq	%rbx, %rax
	movq	%rax, -24(%rbp)
	movl	$0, -40(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L4
.L7:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-56(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jg	.L5
	movl	-40(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -40(%rbp)
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	tmp(%rip), %rsi
	movl	-32(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -32(%rbp)
	cltq
	salq	$3, %rax
	leaq	(%rsi,%rax), %rdx
	movq	(%rcx), %rax
	movq	%rax, (%rdx)
	jmp	.L4
.L5:
	movl	-40(%rbp), %eax
	cltq
	addq	%rax, -24(%rbp)
	movl	-36(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -36(%rbp)
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	tmp(%rip), %rsi
	movl	-32(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -32(%rbp)
	cltq
	salq	$3, %rax
	leaq	(%rsi,%rax), %rdx
	movq	(%rcx), %rax
	movq	%rax, (%rdx)
.L4:
	movl	-40(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jge	.L8
	movl	-36(%rbp), %eax
	cmpl	-60(%rbp), %eax
	jl	.L7
	jmp	.L8
.L9:
	movl	-40(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -40(%rbp)
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	tmp(%rip), %rsi
	movl	-32(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -32(%rbp)
	cltq
	salq	$3, %rax
	leaq	(%rsi,%rax), %rdx
	movq	(%rcx), %rax
	movq	%rax, (%rdx)
.L8:
	movl	-40(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L9
	jmp	.L10
.L11:
	movl	-40(%rbp), %eax
	cltq
	addq	%rax, -24(%rbp)
	movl	-36(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -36(%rbp)
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	tmp(%rip), %rsi
	movl	-32(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -32(%rbp)
	cltq
	salq	$3, %rax
	leaq	(%rsi,%rax), %rdx
	movq	(%rcx), %rax
	movq	%rax, (%rdx)
.L10:
	movl	-36(%rbp), %eax
	cmpl	-60(%rbp), %eax
	jl	.L11
	movl	$0, -40(%rbp)
	jmp	.L12
.L13:
	movq	tmp(%rip), %rdx
	movl	-40(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-56(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	addl	$1, -40(%rbp)
.L12:
	movl	-40(%rbp), %eax
	cmpl	-60(%rbp), %eax
	jl	.L13
	movq	-24(%rbp), %rax
.L3:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\n"
	.text
	.globl	run
	.type	run, @function
run:
.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
	leaq	-36(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	$0, (%rax)
	movl	$1, -28(%rbp)
	jmp	.L15
.L16:
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movl	-32(%rbp), %eax
	cltq
	addq	%rax, %rdx
	movl	-36(%rbp), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	movq	-24(%rbp), %rax
	addq	%rsi, %rax
	subq	%rcx, %rdx
	movq	%rdx, (%rax)
	addl	$1, -28(%rbp)
.L15:
	movl	-40(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L16
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, tmp(%rip)
	movl	-40(%rbp), %eax
	leal	1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	calc
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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
	.type	calc.part.0, @function
calc.part.0:
.LFB42:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%ebp, %r13d
	movq	%rdi, %rbx
	sarl	%r13d
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	cmpl	$1, %r13d
	je	.L2
	movl	%r13d, %esi
	call	calc.part.0
	movq	%rax, %r12
.L2:
	movl	%ebp, %esi
	subl	%r13d, %esi
	cmpl	$1, %esi
	jle	.L3
	movslq	%r13d, %rax
	leaq	(%rbx,%rax,8), %rdi
	call	calc.part.0
	addq	%rax, %r12
.L3:
	cmpl	%r13d, %ebp
	jle	.L31
	movq	tmp(%rip), %rsi
	movl	%r13d, %eax
	xorl	%edx, %edx
	xorl	%r10d, %r10d
	movl	$1, %ecx
	movslq	%r13d, %r11
	.p2align 4,,10
	.p2align 3
.L9:
	movq	(%rbx,%r10,8), %r9
	movq	(%rbx,%r11,8), %r8
	movl	%ecx, %edi
	cmpq	%r9, %r8
	jl	.L5
.L71:
	movq	%r9, -8(%rsi,%rcx,8)
	addl	$1, %edx
	addq	$1, %rcx
	cmpl	%eax, %ebp
	jle	.L8
	cmpl	%edx, %r13d
	jle	.L32
	movslq	%edx, %r10
	movq	(%rbx,%r11,8), %r8
	movl	%ecx, %edi
	movq	(%rbx,%r10,8), %r9
	cmpq	%r9, %r8
	jge	.L71
.L5:
	addl	$1, %eax
	movq	%r8, -8(%rsi,%rcx,8)
	addq	%r10, %r12
	addq	$1, %rcx
	cmpl	%eax, %ebp
	jle	.L8
	cmpl	%edx, %r13d
	jle	.L32
	movslq	%eax, %r11
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L8:
	cmpl	%edx, %r13d
	jle	.L32
.L4:
	movl	%r13d, %r8d
	movslq	%edi, %r11
	movslq	%edx, %r9
	subl	%edx, %r8d
	salq	$3, %r11
	leaq	1(%r9), %rcx
	leal	-1(%r8), %r14d
	leaq	(%rsi,%r11), %r10
	leaq	0(,%rcx,8), %r15
	cmpl	$2, %r14d
	jbe	.L11
	leaq	(%rbx,%r15), %r14
	cmpq	%r14, %r10
	je	.L11
	movl	%r8d, %r9d
	leaq	-8(%rbx,%r15), %r11
	xorl	%ecx, %ecx
	shrl	%r9d
	salq	$4, %r9
	.p2align 4,,10
	.p2align 3
.L12:
	movdqu	(%r11,%rcx), %xmm0
	movups	%xmm0, (%r10,%rcx)
	addq	$16, %rcx
	cmpq	%r9, %rcx
	jne	.L12
	movl	%r8d, %r9d
	andl	$-2, %r9d
	leal	(%rdx,%r9), %ecx
	leal	(%rdi,%r9), %edx
	cmpl	%r9d, %r8d
	je	.L15
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	movq	(%rbx,%rcx,8), %rcx
	movq	%rcx, (%rsi,%rdx,8)
.L15:
	addl	%r8d, %edi
.L10:
	cmpl	%eax, %ebp
	jle	.L16
	movslq	%eax, %r8
	movslq	%edi, %r11
	movl	%ebp, %r9d
	movslq	%r13d, %r13
	leaq	1(%r8), %rdx
	salq	$3, %r11
	subl	%eax, %r9d
	leaq	0(,%rdx,8), %r14
	leaq	(%rsi,%r11), %r10
	leaq	(%rbx,%r14), %r15
	leal	-1(%r9), %ecx
	cmpq	%r15, %r10
	je	.L17
	cmpl	$2, %ecx
	jbe	.L17
	movl	%r9d, %r8d
	leaq	-8(%rbx,%r14), %r11
	xorl	%edx, %edx
	shrl	%r8d
	salq	$4, %r8
	.p2align 4,,10
	.p2align 3
.L18:
	movdqu	(%r11,%rdx), %xmm1
	movups	%xmm1, (%r10,%rdx)
	addq	$16, %rdx
	cmpq	%rdx, %r8
	jne	.L18
	movl	%r9d, %edx
	andl	$-2, %edx
	addl	%edx, %eax
	addl	%edx, %edi
	cmpl	%edx, %r9d
	je	.L21
	cltq
	movslq	%edi, %rdi
	movq	(%rbx,%rax,8), %rax
	movq	%rax, (%rsi,%rdi,8)
.L21:
	imulq	%r13, %rcx
	addq	%r13, %r12
	addq	%rcx, %r12
.L22:
	leaq	8(%rsi), %rax
	cmpq	%rax, %rbx
	je	.L23
	leal	-1(%rbp), %eax
	cmpl	$2, %eax
	jbe	.L23
	movl	%ebp, %edx
	xorl	%eax, %eax
	shrl	%edx
	salq	$4, %rdx
	.p2align 4,,10
	.p2align 3
.L24:
	movdqu	(%rsi,%rax), %xmm2
	movups	%xmm2, (%rbx,%rax)
	addq	$16, %rax
	cmpq	%rax, %rdx
	jne	.L24
	movl	%ebp, %eax
	andl	$-2, %eax
	andl	$1, %ebp
	je	.L1
	movq	(%rsi,%rax,8), %rdx
	movq	%rdx, (%rbx,%rax,8)
.L1:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movq	%r12, %rax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	movq	%r9, %rdx
	negq	%rdx
	leaq	(%r11,%rdx,8), %r10
	addq	%rsi, %r10
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L72:
	addq	$1, %rcx
.L14:
	movq	(%rbx,%r9,8), %rdx
	movq	%rdx, (%r10,%r9,8)
	movq	%rcx, %r9
	cmpl	%ecx, %r13d
	jg	.L72
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L23:
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L28:
	movq	(%rsi,%rax,8), %rdx
	movq	%rdx, (%rbx,%rax,8)
	addq	$1, %rax
	cmpq	%rbp, %rax
	jne	.L28
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%r8, %rax
	negq	%rax
	leaq	(%r11,%rax,8), %rdi
	addq	%rsi, %rdi
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L73:
	addq	$1, %rdx
.L20:
	movq	(%rbx,%r8,8), %rax
	movq	%rax, (%rdi,%r8,8)
	movq	%rdx, %r8
	cmpl	%edx, %ebp
	jg	.L73
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L16:
	testl	%ebp, %ebp
	jle	.L1
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L32:
	movl	%edx, %r13d
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L31:
	movq	tmp(%rip), %rsi
	movl	%r13d, %eax
	xorl	%edi, %edi
	xorl	%edx, %edx
	jmp	.L4
	.cfi_endproc
.LFE42:
	.size	calc.part.0, .-calc.part.0
	.p2align 4
	.globl	calc
	.type	calc, @function
calc:
.LFB39:
	.cfi_startproc
	endbr64
	cmpl	$1, %esi
	jle	.L75
	jmp	calc.part.0
	.p2align 4,,10
	.p2align 3
.L75:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	calc, .-calc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %ebx
	leal	1(%rbx), %ebp
	movslq	%ebp, %r12
	salq	$3, %r12
	movq	%r12, %rdi
	call	malloc@PLT
	movq	$0, (%rax)
	movq	%rax, %r13
	testl	%ebx, %ebx
	jle	.L77
	movl	$1, %ebx
	leaq	20(%rsp), %r12
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L78:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	16(%rsp), %rdx
	movslq	20(%rsp), %rax
	addq	-8(%r13,%rbx,8), %rax
	movl	12(%rsp), %esi
	subq	%rdx, %rax
	movq	%rax, 0(%r13,%rbx,8)
	addq	$1, %rbx
	cmpl	%ebx, %esi
	jge	.L78
	leal	1(%rsi), %ebp
	movslq	%ebp, %r12
	salq	$3, %r12
.L77:
	movq	%r12, %rdi
	call	malloc@PLT
	xorl	%edx, %edx
	movq	%rax, tmp(%rip)
	cmpl	$1, %ebp
	jle	.L79
	movl	%ebp, %esi
	movq	%r13, %rdi
	call	calc.part.0
	movq	%rax, %rdx
.L79:
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L84
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L84:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.globl	tmp
	.bss
	.align 8
	.type	tmp, @object
	.size	tmp, 8
tmp:
	.zero	8
	.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
	.type	calc.part.0, @function
calc.part.0:
.LFB42:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%ebp, %r13d
	movq	%rdi, %rbx
	sarl	%r13d
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	cmpl	$1, %r13d
	je	.L2
	movl	%r13d, %esi
	call	calc.part.0
	movq	%rax, %r12
.L2:
	movl	%ebp, %esi
	subl	%r13d, %esi
	cmpl	$1, %esi
	jle	.L3
	movslq	%r13d, %rax
	leaq	(%rbx,%rax,8), %rdi
	call	calc.part.0
	addq	%rax, %r12
.L3:
	cmpl	%r13d, %ebp
	jle	.L31
	movq	tmp(%rip), %rsi
	movl	%r13d, %eax
	xorl	%edx, %edx
	xorl	%r10d, %r10d
	movl	$1, %ecx
	movslq	%r13d, %r11
	.p2align 4,,10
	.p2align 3
.L9:
	movq	(%rbx,%r10,8), %r9
	movq	(%rbx,%r11,8), %r8
	movl	%ecx, %edi
	cmpq	%r9, %r8
	jl	.L5
.L71:
	movq	%r9, -8(%rsi,%rcx,8)
	addl	$1, %edx
	addq	$1, %rcx
	cmpl	%eax, %ebp
	jle	.L8
	cmpl	%edx, %r13d
	jle	.L32
	movslq	%edx, %r10
	movq	(%rbx,%r11,8), %r8
	movl	%ecx, %edi
	movq	(%rbx,%r10,8), %r9
	cmpq	%r9, %r8
	jge	.L71
.L5:
	addl	$1, %eax
	movq	%r8, -8(%rsi,%rcx,8)
	addq	%r10, %r12
	addq	$1, %rcx
	cmpl	%eax, %ebp
	jle	.L8
	cmpl	%edx, %r13d
	jle	.L32
	movslq	%eax, %r11
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L8:
	cmpl	%edx, %r13d
	jle	.L32
.L4:
	movl	%r13d, %r8d
	movslq	%edi, %r11
	movslq	%edx, %r9
	subl	%edx, %r8d
	salq	$3, %r11
	leaq	1(%r9), %rcx
	leal	-1(%r8), %r14d
	leaq	(%rsi,%r11), %r10
	leaq	0(,%rcx,8), %r15
	cmpl	$2, %r14d
	jbe	.L11
	leaq	(%rbx,%r15), %r14
	cmpq	%r14, %r10
	je	.L11
	movl	%r8d, %r9d
	leaq	-8(%rbx,%r15), %r11
	xorl	%ecx, %ecx
	shrl	%r9d
	salq	$4, %r9
	.p2align 4,,10
	.p2align 3
.L12:
	movdqu	(%r11,%rcx), %xmm0
	movups	%xmm0, (%r10,%rcx)
	addq	$16, %rcx
	cmpq	%r9, %rcx
	jne	.L12
	movl	%r8d, %r9d
	andl	$-2, %r9d
	leal	(%rdx,%r9), %ecx
	leal	(%rdi,%r9), %edx
	cmpl	%r9d, %r8d
	je	.L15
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	movq	(%rbx,%rcx,8), %rcx
	movq	%rcx, (%rsi,%rdx,8)
.L15:
	addl	%r8d, %edi
.L10:
	cmpl	%eax, %ebp
	jle	.L16
	movslq	%eax, %r8
	movslq	%edi, %r11
	movl	%ebp, %r9d
	movslq	%r13d, %r13
	leaq	1(%r8), %rdx
	salq	$3, %r11
	subl	%eax, %r9d
	leaq	0(,%rdx,8), %r14
	leaq	(%rsi,%r11), %r10
	leaq	(%rbx,%r14), %r15
	leal	-1(%r9), %ecx
	cmpq	%r15, %r10
	je	.L17
	cmpl	$2, %ecx
	jbe	.L17
	movl	%r9d, %r8d
	leaq	-8(%rbx,%r14), %r11
	xorl	%edx, %edx
	shrl	%r8d
	salq	$4, %r8
	.p2align 4,,10
	.p2align 3
.L18:
	movdqu	(%r11,%rdx), %xmm1
	movups	%xmm1, (%r10,%rdx)
	addq	$16, %rdx
	cmpq	%rdx, %r8
	jne	.L18
	movl	%r9d, %edx
	andl	$-2, %edx
	addl	%edx, %eax
	addl	%edx, %edi
	cmpl	%edx, %r9d
	je	.L21
	cltq
	movslq	%edi, %rdi
	movq	(%rbx,%rax,8), %rax
	movq	%rax, (%rsi,%rdi,8)
.L21:
	imulq	%r13, %rcx
	addq	%r13, %r12
	addq	%rcx, %r12
.L22:
	leaq	8(%rsi), %rax
	cmpq	%rax, %rbx
	je	.L23
	leal	-1(%rbp), %eax
	cmpl	$2, %eax
	jbe	.L23
	movl	%ebp, %edx
	xorl	%eax, %eax
	shrl	%edx
	salq	$4, %rdx
	.p2align 4,,10
	.p2align 3
.L24:
	movdqu	(%rsi,%rax), %xmm2
	movups	%xmm2, (%rbx,%rax)
	addq	$16, %rax
	cmpq	%rax, %rdx
	jne	.L24
	movl	%ebp, %eax
	andl	$-2, %eax
	andl	$1, %ebp
	je	.L1
	movq	(%rsi,%rax,8), %rdx
	movq	%rdx, (%rbx,%rax,8)
.L1:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movq	%r12, %rax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	movq	%r9, %rdx
	negq	%rdx
	leaq	(%r11,%rdx,8), %r10
	addq	%rsi, %r10
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L72:
	addq	$1, %rcx
.L14:
	movq	(%rbx,%r9,8), %rdx
	movq	%rdx, (%r10,%r9,8)
	movq	%rcx, %r9
	cmpl	%ecx, %r13d
	jg	.L72
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L23:
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L28:
	movq	(%rsi,%rax,8), %rdx
	movq	%rdx, (%rbx,%rax,8)
	addq	$1, %rax
	cmpq	%rbp, %rax
	jne	.L28
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%r8, %rax
	negq	%rax
	leaq	(%r11,%rax,8), %rdi
	addq	%rsi, %rdi
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L73:
	addq	$1, %rdx
.L20:
	movq	(%rbx,%r8,8), %rax
	movq	%rax, (%rdi,%r8,8)
	movq	%rdx, %r8
	cmpl	%edx, %ebp
	jg	.L73
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L16:
	testl	%ebp, %ebp
	jle	.L1
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L32:
	movl	%edx, %r13d
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L31:
	movq	tmp(%rip), %rsi
	movl	%r13d, %eax
	xorl	%edi, %edi
	xorl	%edx, %edx
	jmp	.L4
	.cfi_endproc
.LFE42:
	.size	calc.part.0, .-calc.part.0
	.p2align 4
	.globl	calc
	.type	calc, @function
calc:
.LFB39:
	.cfi_startproc
	endbr64
	cmpl	$1, %esi
	jle	.L75
	jmp	calc.part.0
	.p2align 4,,10
	.p2align 3
.L75:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	calc, .-calc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %ebx
	leal	1(%rbx), %ebp
	movslq	%ebp, %r12
	salq	$3, %r12
	movq	%r12, %rdi
	call	malloc@PLT
	movq	$0, (%rax)
	movq	%rax, %r13
	testl	%ebx, %ebx
	jle	.L77
	movl	$1, %ebx
	leaq	20(%rsp), %r12
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L78:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	16(%rsp), %rdx
	movslq	20(%rsp), %rax
	addq	-8(%r13,%rbx,8), %rax
	movl	12(%rsp), %esi
	subq	%rdx, %rax
	movq	%rax, 0(%r13,%rbx,8)
	addq	$1, %rbx
	cmpl	%ebx, %esi
	jge	.L78
	leal	1(%rsi), %ebp
	movslq	%ebp, %r12
	salq	$3, %r12
.L77:
	movq	%r12, %rdi
	call	malloc@PLT
	xorl	%edx, %edx
	movq	%rax, tmp(%rip)
	cmpl	$1, %ebp
	jle	.L79
	movl	%ebp, %esi
	movq	%r13, %rdi
	call	calc.part.0
	movq	%rax, %rdx
.L79:
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L84
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L84:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.globl	tmp
	.bss
	.align 8
	.type	tmp, @object
	.size	tmp, 8
tmp:
	.zero	8
	.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>

typedef long long int int64;

int64 *tmp=NULL;
int64 calc(int64 *a,int n){
  if(n<=1) return 0;
  int m=n/2;
  int64 res=calc(a,m)+calc(a+m,n-m);
  int i=0;
  int j=m;
  int k=0;
  while(i<m && j<n){
    if(a[i]<=a[j]){
      tmp[k++]=a[i++];
    } else {
      res+=i;
      tmp[k++]=a[j++];
    }
  }
  while(i<m) tmp[k++]=a[i++];
  while(j<n){
    res+=i;
    tmp[k++]=a[j++];
  }
  for(i=0;i<n;i++) a[i]=tmp[i];
  return res;
}

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int64 *a=(int64 *)malloc(sizeof(int64)*(n+1));
  a[0]=0;
  int i;
  for(i=1;i<=n;i++){
    int x;
    scanf("%d",&x);
    a[i]=a[i-1]+x-k;
  }
  tmp=(int64 *)malloc(sizeof(int64)*(n+1));
  int64 ans=calc(a,n+1);
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}

1 4
1
 3 6
7
5
10
 7 26
10
20
30
43
30
20
10
 1 6
10
20
27
12
30
20
12
 2 1
1
12
34
45
2
9
1
 2 1
0
18
19
56
0
4
-4
 3 5
7
5
7
 7 26
10
20
30
40
3
20
10
 4 1
1
12
34
45
4
3
1
 6 1
0
12
61
45
2
8
1

0
 5
 13
 1
 3
 2
 6
 4
 10
 20

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>

typedef long long int int64;

int64 *tmp=NULL;
int64 calc(int64 *a,int n){
  if(n<=1) return 0;
  int m=n/2;
  int64 res=calc(a,m)+calc(a+m,n-m);
  int i=0;
  int j=m;
  int k=0;
  while(i<m && j<n){
    if(a[i]<=a[j]){
      tmp[k++]=a[i++];
    } else {
      res+=i;
      tmp[k++]=a[j++];
    }
  }
  while(i<m) tmp[k++]=a[i++];
  while(j<n){
    res+=i;
    tmp[k++]=a[j++];
  }
  for(i=0;i<n;i++) a[i]=tmp[i];
  return res;
}

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int64 *a=(int64 *)malloc(sizeof(int64)*(n+1));
  a[0]=0;
  int i;
  for(i=1;i<=n;i++){
    int x;
    scanf("%d",&x);
    a[i]=a[i-1]+x-k;
  }
  tmp=(int64 *)malloc(sizeof(int64)*(n+1));
  int64 ans=calc(a,n+1);
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	tmp
	.bss
	.align 8
	.type	tmp, @object
	.size	tmp, 8
tmp:
	.zero	8
	.text
	.globl	calc
	.type	calc, @function
calc:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -56(%rbp)
	movl	%esi, -60(%rbp)
	cmpl	$1, -60(%rbp)
	jg	.L2
	movl	$0, %eax
	jmp	.L3
.L2:
	movl	-60(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -28(%rbp)
	movl	-28(%rbp), %edx
	movq	-56(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	calc
	movq	%rax, %rbx
	movl	-60(%rbp), %eax
	subl	-28(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-56(%rbp), %rdx
	addq	%rcx, %rdx
	movl	%eax, %esi
	movq	%rdx, %rdi
	call	calc
	addq	%rbx, %rax
	movq	%rax, -24(%rbp)
	movl	$0, -40(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L4
.L7:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-56(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jg	.L5
	movl	-40(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -40(%rbp)
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	tmp(%rip), %rsi
	movl	-32(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -32(%rbp)
	cltq
	salq	$3, %rax
	leaq	(%rsi,%rax), %rdx
	movq	(%rcx), %rax
	movq	%rax, (%rdx)
	jmp	.L4
.L5:
	movl	-40(%rbp), %eax
	cltq
	addq	%rax, -24(%rbp)
	movl	-36(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -36(%rbp)
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	tmp(%rip), %rsi
	movl	-32(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -32(%rbp)
	cltq
	salq	$3, %rax
	leaq	(%rsi,%rax), %rdx
	movq	(%rcx), %rax
	movq	%rax, (%rdx)
.L4:
	movl	-40(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jge	.L8
	movl	-36(%rbp), %eax
	cmpl	-60(%rbp), %eax
	jl	.L7
	jmp	.L8
.L9:
	movl	-40(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -40(%rbp)
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	tmp(%rip), %rsi
	movl	-32(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -32(%rbp)
	cltq
	salq	$3, %rax
	leaq	(%rsi,%rax), %rdx
	movq	(%rcx), %rax
	movq	%rax, (%rdx)
.L8:
	movl	-40(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L9
	jmp	.L10
.L11:
	movl	-40(%rbp), %eax
	cltq
	addq	%rax, -24(%rbp)
	movl	-36(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -36(%rbp)
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	tmp(%rip), %rsi
	movl	-32(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -32(%rbp)
	cltq
	salq	$3, %rax
	leaq	(%rsi,%rax), %rdx
	movq	(%rcx), %rax
	movq	%rax, (%rdx)
.L10:
	movl	-36(%rbp), %eax
	cmpl	-60(%rbp), %eax
	jl	.L11
	movl	$0, -40(%rbp)
	jmp	.L12
.L13:
	movq	tmp(%rip), %rdx
	movl	-40(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-56(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	addl	$1, -40(%rbp)
.L12:
	movl	-40(%rbp), %eax
	cmpl	-60(%rbp), %eax
	jl	.L13
	movq	-24(%rbp), %rax
.L3:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\n"
	.text
	.globl	run
	.type	run, @function
run:
.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
	leaq	-36(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	$0, (%rax)
	movl	$1, -28(%rbp)
	jmp	.L15
.L16:
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movl	-32(%rbp), %eax
	cltq
	addq	%rax, %rdx
	movl	-36(%rbp), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	movq	-24(%rbp), %rax
	addq	%rsi, %rax
	subq	%rcx, %rdx
	movq	%rdx, (%rax)
	addl	$1, -28(%rbp)
.L15:
	movl	-40(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L16
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, tmp(%rip)
	movl	-40(%rbp), %eax
	leal	1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	calc
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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	tmp
	.bss
	.align 8
	.type	tmp, @object
	.size	tmp, 8
tmp:
	.zero	8
	.text
	.globl	calc
	.type	calc, @function
calc:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -56(%rbp)
	movl	%esi, -60(%rbp)
	cmpl	$1, -60(%rbp)
	jg	.L2
	movl	$0, %eax
	jmp	.L3
.L2:
	movl	-60(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -28(%rbp)
	movl	-28(%rbp), %edx
	movq	-56(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	calc
	movq	%rax, %rbx
	movl	-60(%rbp), %eax
	subl	-28(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-56(%rbp), %rdx
	addq	%rcx, %rdx
	movl	%eax, %esi
	movq	%rdx, %rdi
	call	calc
	addq	%rbx, %rax
	movq	%rax, -24(%rbp)
	movl	$0, -40(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L4
.L7:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	movq	-56(%rbp), %rax
	addq	%rcx, %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdx
	jg	.L5
	movl	-40(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -40(%rbp)
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	tmp(%rip), %rsi
	movl	-32(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -32(%rbp)
	cltq
	salq	$3, %rax
	leaq	(%rsi,%rax), %rdx
	movq	(%rcx), %rax
	movq	%rax, (%rdx)
	jmp	.L4
.L5:
	movl	-40(%rbp), %eax
	cltq
	addq	%rax, -24(%rbp)
	movl	-36(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -36(%rbp)
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	tmp(%rip), %rsi
	movl	-32(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -32(%rbp)
	cltq
	salq	$3, %rax
	leaq	(%rsi,%rax), %rdx
	movq	(%rcx), %rax
	movq	%rax, (%rdx)
.L4:
	movl	-40(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jge	.L8
	movl	-36(%rbp), %eax
	cmpl	-60(%rbp), %eax
	jl	.L7
	jmp	.L8
.L9:
	movl	-40(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -40(%rbp)
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	tmp(%rip), %rsi
	movl	-32(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -32(%rbp)
	cltq
	salq	$3, %rax
	leaq	(%rsi,%rax), %rdx
	movq	(%rcx), %rax
	movq	%rax, (%rdx)
.L8:
	movl	-40(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L9
	jmp	.L10
.L11:
	movl	-40(%rbp), %eax
	cltq
	addq	%rax, -24(%rbp)
	movl	-36(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -36(%rbp)
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-56(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movq	tmp(%rip), %rsi
	movl	-32(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -32(%rbp)
	cltq
	salq	$3, %rax
	leaq	(%rsi,%rax), %rdx
	movq	(%rcx), %rax
	movq	%rax, (%rdx)
.L10:
	movl	-36(%rbp), %eax
	cmpl	-60(%rbp), %eax
	jl	.L11
	movl	$0, -40(%rbp)
	jmp	.L12
.L13:
	movq	tmp(%rip), %rdx
	movl	-40(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-56(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rax), %rax
	movq	%rax, (%rdx)
	addl	$1, -40(%rbp)
.L12:
	movl	-40(%rbp), %eax
	cmpl	-60(%rbp), %eax
	jl	.L13
	movq	-24(%rbp), %rax
.L3:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\n"
	.text
	.globl	run
	.type	run, @function
run:
.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
	leaq	-36(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	$0, (%rax)
	movl	$1, -28(%rbp)
	jmp	.L15
.L16:
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	cltq
	salq	$3, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movl	-32(%rbp), %eax
	cltq
	addq	%rax, %rdx
	movl	-36(%rbp), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	movq	-24(%rbp), %rax
	addq	%rsi, %rax
	subq	%rcx, %rdx
	movq	%rdx, (%rax)
	addl	$1, -28(%rbp)
.L15:
	movl	-40(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jle	.L16
	movl	-40(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, tmp(%rip)
	movl	-40(%rbp), %eax
	leal	1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	calc
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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:
