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

typedef int32_t i32;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void add (i32 *bit, i32 x, i32 v) {
  i32 n = bit[0];
  for (i32 i = x; i <= n; i += i & -i) {
    bit[i] += v;
  }
}

i32 get_sum (i32 *bit, i32 x) {
  i32 sum = 0;
  for (i32 i = x; i > 0; i -= i & -i) {
    sum += bit[i];
  }
  return sum;
}

void init_bit (i32 *bit) {
  i32 n = bit[0];
  for (i32 i = 1; i <= n; ++i) {
    bit[i] = 0;
  }
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *w = ALLOC (n + 1, i32);
  i32 *b = ALLOC (n + 1, i32);
  for (i32 i = 1; i <= 2 * n; ++i) {
    char s[5];
    i32 a;
    scanf ("%s%" SCNi32, s, &a);
    if (s[0] == 'W') {
      w[a] = i;
    } else {
      b[a] = i;
    }
  }
  i32 *bit = ALLOC (2 * n + 1, i32);
  bit[0] = 2 * n;
  i32 *dp = ALLOC (n + 1, i32);
  for (i32 i = 1; i <= n; ++i) {
    add (bit, b[i], 1);
    dp[i] = dp[i - 1] + (i - get_sum (bit, b[i]));
  }
  for (i32 i = 1; i <= n; ++i) {
    init_bit (bit);
    dp[0] = 0;
    for (i32 j = 1; j <= i; ++j) {
      add (bit, w[j], 1);
      dp[0] += j - get_sum (bit, w[j]);
    }
    for (i32 j = 1; j <= n; ++j) {
      add (bit, b[j], 1);
      i32 x = dp[j - 1] + (i + j - get_sum (bit, b[j]));
      i32 y = dp[j] + (i + j - get_sum (bit, w[i]));
      dp[j] = x < y ? x : y;
    }
  }
  printf ("%" PRIi32 "\n", dp[n]);
}

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

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	add
	.type	add, @function
add:
.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)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L2
.L3:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-32(%rbp), %edx
	addl	%ecx, %edx
	movl	%edx, (%rax)
	movl	-8(%rbp), %eax
	negl	%eax
	andl	-8(%rbp), %eax
	addl	%eax, -8(%rbp)
.L2:
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L3
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	add, .-add
	.globl	get_sum
	.type	get_sum, @function
get_sum:
.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, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -8(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L5
.L6:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -8(%rbp)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	andl	%eax, -4(%rbp)
.L5:
	cmpl	$0, -4(%rbp)
	jg	.L6
	movl	-8(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	get_sum, .-get_sum
	.globl	init_bit
	.type	init_bit, @function
init_bit:
.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	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L9
.L10:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	addl	$1, -8(%rbp)
.L9:
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L10
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	init_bit, .-init_bit
	.section	.rodata
.LC0:
	.string	"%i"
.LC1:
	.string	"%s%i"
.LC2:
	.string	"%i\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r12
	pushq	%rbx
	subq	$96, %rsp
	.cfi_offset 12, -24
	.cfi_offset 3, -32
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-100(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-100(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -64(%rbp)
	movl	-100(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -56(%rbp)
	movl	$1, -92(%rbp)
	jmp	.L12
.L15:
	leaq	-96(%rbp), %rdx
	leaq	-29(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movzbl	-29(%rbp), %eax
	cmpb	$87, %al
	jne	.L13
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-92(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L14
.L13:
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rax, %rdx
	movl	-92(%rbp), %eax
	movl	%eax, (%rdx)
.L14:
	addl	$1, -92(%rbp)
.L12:
	movl	-100(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -92(%rbp)
	jle	.L15
	movl	-100(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -48(%rbp)
	movl	-100(%rbp), %eax
	leal	(%rax,%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movl	-100(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -40(%rbp)
	movl	$1, -88(%rbp)
	jmp	.L16
.L17:
	movl	-88(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movq	-48(%rbp), %rax
	movl	$1, %edx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	add
	movl	-88(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ebx
	movl	-88(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	get_sum
	movl	%eax, %edx
	movl	-88(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-88(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	leal	(%rbx,%rcx), %edx
	movl	%edx, (%rax)
	addl	$1, -88(%rbp)
.L16:
	movl	-100(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jle	.L17
	movl	$1, -84(%rbp)
	jmp	.L18
.L23:
	movq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	init_bit
	movq	-40(%rbp), %rax
	movl	$0, (%rax)
	movl	$1, -80(%rbp)
	jmp	.L19
.L20:
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movq	-48(%rbp), %rax
	movl	$1, %edx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	add
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	get_sum
	movl	%eax, %edx
	movl	-80(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movq	-40(%rbp), %rax
	movl	(%rax), %eax
	leal	(%rcx,%rax), %edx
	movq	-40(%rbp), %rax
	movl	%edx, (%rax)
	addl	$1, -80(%rbp)
.L19:
	movl	-80(%rbp), %eax
	cmpl	-84(%rbp), %eax
	jle	.L20
	movl	$1, -76(%rbp)
	jmp	.L21
.L22:
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movq	-48(%rbp), %rax
	movl	$1, %edx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	add
	movl	-76(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %r12d
	movl	-84(%rbp), %edx
	movl	-76(%rbp), %eax
	leal	(%rdx,%rax), %ebx
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	get_sum
	subl	%eax, %ebx
	movl	%ebx, %edx
	leal	(%r12,%rdx), %eax
	movl	%eax, -72(%rbp)
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %r12d
	movl	-84(%rbp), %edx
	movl	-76(%rbp), %eax
	leal	(%rdx,%rax), %ebx
	movl	-84(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	get_sum
	subl	%eax, %ebx
	movl	%ebx, %edx
	leal	(%r12,%rdx), %eax
	movl	%eax, -68(%rbp)
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-68(%rbp), %edx
	movl	-72(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, (%rcx)
	addl	$1, -76(%rbp)
.L21:
	movl	-100(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jle	.L22
	addl	$1, -84(%rbp)
.L18:
	movl	-100(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jle	.L23
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-24(%rbp), %rax
	subq	%fs:40, %rax
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	addq	$96, %rsp
	popq	%rbx
	popq	%r12
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB10:
	.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
.LFE10:
	.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	add
	.type	add, @function
add:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %ecx
	cmpl	%esi, %ecx
	jl	.L1
	.p2align 4,,10
	.p2align 3
.L3:
	movslq	%esi, %rax
	addl	%edx, (%rdi,%rax,4)
	movl	%esi, %eax
	negl	%eax
	andl	%esi, %eax
	addl	%eax, %esi
	cmpl	%esi, %ecx
	jge	.L3
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	add, .-add
	.p2align 4
	.globl	get_sum
	.type	get_sum, @function
get_sum:
.LFB40:
	.cfi_startproc
	endbr64
	xorl	%r8d, %r8d
	testl	%esi, %esi
	jle	.L6
	.p2align 4,,10
	.p2align 3
.L8:
	movslq	%esi, %rax
	addl	(%rdi,%rax,4), %r8d
	leal	-1(%rsi), %eax
	andl	%eax, %esi
	jne	.L8
.L6:
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE40:
	.size	get_sum, .-get_sum
	.p2align 4
	.globl	init_bit
	.type	init_bit, @function
init_bit:
.LFB41:
	.cfi_startproc
	endbr64
	movslq	(%rdi), %rdx
	testl	%edx, %edx
	jle	.L11
	salq	$2, %rdx
	addq	$4, %rdi
	xorl	%esi, %esi
	jmp	memset@PLT
	.p2align 4,,10
	.p2align 3
.L11:
	ret
	.cfi_endproc
.LFE41:
	.size	init_bit, .-init_bit
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%i"
.LC1:
	.string	"%s%i"
.LC2:
	.string	"%i\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %ebx
	movl	$4, %esi
	leal	1(%rbx), %r14d
	movl	%ebx, 12(%rsp)
	leal	(%rbx,%rbx), %ebp
	movslq	%r14d, %r12
	movq	%r12, %rdi
	call	calloc@PLT
	movl	$4, %esi
	movq	%r12, %rdi
	movq	%rax, (%rsp)
	call	calloc@PLT
	testl	%ebp, %ebp
	movq	(%rsp), %r8
	movq	%rax, %r15
	jle	.L14
	movl	$1, %r14d
	leaq	28(%rsp), %r13
	leaq	35(%rsp), %r12
	leaq	.LC1(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L18:
	xorl	%eax, %eax
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpb	$87, 35(%rsp)
	movslq	28(%rsp), %rax
	je	.L58
	movl	%r14d, (%r15,%rax,4)
	movl	24(%rsp), %eax
	addl	$1, %r14d
	leal	(%rax,%rax), %ebp
	cmpl	%r14d, %ebp
	jge	.L18
	movl	%eax, 12(%rsp)
	movq	(%rsp), %r8
.L17:
	leal	1(%rax), %r14d
	movslq	%r14d, %r12
.L14:
	leal	1(%rbp), %edi
	movl	$4, %esi
	movq	%r8, (%rsp)
	movslq	%edi, %rdi
	call	calloc@PLT
	movq	%r12, %rdi
	movl	$4, %esi
	movl	%ebp, (%rax)
	movq	%rax, %rbx
	call	calloc@PLT
	movq	%rax, %r12
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L19
	movq	(%rsp), %r8
	movl	%r14d, %r14d
	movl	$1, %esi
	.p2align 4,,10
	.p2align 3
.L24:
	movl	(%r15,%rsi,4), %edx
	movl	%esi, %edi
	cmpl	%ebp, %edx
	jg	.L20
	movl	%edx, %eax
	.p2align 4,,10
	.p2align 3
.L21:
	movslq	%eax, %rcx
	addl	$1, (%rbx,%rcx,4)
	movl	%eax, %ecx
	negl	%ecx
	andl	%eax, %ecx
	addl	%ecx, %eax
	cmpl	%ebp, %eax
	jle	.L21
	movl	(%rbx), %ebp
.L20:
	movl	-4(%r12,%rsi,4), %r9d
	testl	%edx, %edx
	jle	.L22
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L23:
	movslq	%edx, %rax
	addl	(%rbx,%rax,4), %ecx
	leal	-1(%rdx), %eax
	andl	%eax, %edx
	jne	.L23
	subl	%ecx, %edi
.L22:
	leal	(%r9,%rdi), %eax
	movl	%eax, (%r12,%rsi,4)
	addq	$1, %rsi
	cmpq	%rsi, %r14
	jne	.L24
	leaq	4(%rbx), %rax
	movl	%ebp, %ecx
	movl	$1, %r13d
	movq	%r8, %rbp
	movq	%rax, (%rsp)
	.p2align 4,,10
	.p2align 3
.L39:
	testl	%ecx, %ecx
	jle	.L25
	movslq	%ecx, %rdx
	movq	(%rsp), %rdi
	xorl	%esi, %esi
	salq	$2, %rdx
	call	memset@PLT
	movl	(%rbx), %ecx
.L25:
	movl	$0, (%r12)
	movl	$1, %edi
	xorl	%r9d, %r9d
	leaq	1(%r13), %r11
	.p2align 4,,10
	.p2align 3
.L30:
	movl	0(%rbp,%rdi,4), %edx
	movl	%edi, %r8d
	cmpl	%ecx, %edx
	jg	.L26
	movl	%edx, %eax
	.p2align 4,,10
	.p2align 3
.L27:
	movslq	%eax, %rsi
	addl	$1, (%rbx,%rsi,4)
	movl	%eax, %esi
	negl	%esi
	andl	%eax, %esi
	addl	%esi, %eax
	cmpl	%ecx, %eax
	jle	.L27
	movl	(%rbx), %ecx
.L26:
	testl	%edx, %edx
	jle	.L28
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L29:
	movslq	%edx, %rax
	addl	(%rbx,%rax,4), %esi
	leal	-1(%rdx), %eax
	andl	%eax, %edx
	jne	.L29
	subl	%esi, %r8d
.L28:
	addl	%r8d, %r9d
	leaq	1(%rdi), %rax
	movl	%r9d, (%r12)
	cmpq	%rdi, %r13
	je	.L59
	movq	%rax, %rdi
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L59:
	movl	0(%rbp,%r13,4), %r10d
	movl	$1, %esi
	.p2align 4,,10
	.p2align 3
.L38:
	movl	(%r15,%rsi,4), %edx
	movl	%edx, %eax
	cmpl	%ecx, %edx
	jg	.L34
	.p2align 4,,10
	.p2align 3
.L31:
	movslq	%eax, %rdi
	addl	$1, (%rbx,%rdi,4)
	movl	%eax, %edi
	negl	%edi
	andl	%eax, %edi
	addl	%edi, %eax
	cmpl	%ecx, %eax
	jle	.L31
.L34:
	leal	(%rsi,%r13), %edi
	movl	-4(%r12,%rsi,4), %r9d
	xorl	%ecx, %ecx
	movl	%edi, %eax
	testl	%edx, %edx
	jle	.L33
	.p2align 4,,10
	.p2align 3
.L32:
	movslq	%edx, %rax
	addl	(%rbx,%rax,4), %ecx
	leal	-1(%rdx), %eax
	andl	%eax, %edx
	jne	.L32
	movl	%edi, %eax
	subl	%ecx, %eax
.L33:
	movl	(%r12,%rsi,4), %r8d
	addl	%eax, %r9d
	testl	%r10d, %r10d
	jle	.L35
	movl	%r10d, %eax
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L36:
	movslq	%eax, %rdx
	addl	(%rbx,%rdx,4), %ecx
	leal	-1(%rax), %edx
	andl	%edx, %eax
	jne	.L36
	subl	%ecx, %edi
.L35:
	addl	%edi, %r8d
	cmpl	%r9d, %r8d
	cmovg	%r9d, %r8d
	movl	%r8d, (%r12,%rsi,4)
	addq	$1, %rsi
	cmpq	%r14, %rsi
	je	.L37
	movl	(%rbx), %ecx
	jmp	.L38
	.p2align 4,,10
	.p2align 3
.L37:
	cmpq	%r11, %r14
	je	.L19
	movl	(%rbx), %ecx
	movq	%r11, %r13
	jmp	.L39
.L58:
	movq	(%rsp), %rcx
	movl	%r14d, (%rcx,%rax,4)
	movl	24(%rsp), %eax
	addl	$1, %r14d
	leal	(%rax,%rax), %ebp
	cmpl	%r14d, %ebp
	jge	.L18
	movl	%eax, 12(%rsp)
	movq	%rcx, %r8
	jmp	.L17
.L19:
	movslq	12(%rsp), %rax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	movl	(%r12,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L60
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L60:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB43:
	.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
.LFE43:
	.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	add
	.type	add, @function
add:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %ecx
	cmpl	%esi, %ecx
	jl	.L1
	.p2align 4,,10
	.p2align 3
.L3:
	movslq	%esi, %rax
	addl	%edx, (%rdi,%rax,4)
	movl	%esi, %eax
	negl	%eax
	andl	%esi, %eax
	addl	%eax, %esi
	cmpl	%esi, %ecx
	jge	.L3
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	add, .-add
	.p2align 4
	.globl	get_sum
	.type	get_sum, @function
get_sum:
.LFB40:
	.cfi_startproc
	endbr64
	xorl	%r8d, %r8d
	testl	%esi, %esi
	jle	.L6
	.p2align 4,,10
	.p2align 3
.L8:
	movslq	%esi, %rax
	addl	(%rdi,%rax,4), %r8d
	leal	-1(%rsi), %eax
	andl	%eax, %esi
	jne	.L8
.L6:
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE40:
	.size	get_sum, .-get_sum
	.p2align 4
	.globl	init_bit
	.type	init_bit, @function
init_bit:
.LFB41:
	.cfi_startproc
	endbr64
	movslq	(%rdi), %rdx
	testl	%edx, %edx
	jle	.L11
	salq	$2, %rdx
	addq	$4, %rdi
	xorl	%esi, %esi
	jmp	memset@PLT
	.p2align 4,,10
	.p2align 3
.L11:
	ret
	.cfi_endproc
.LFE41:
	.size	init_bit, .-init_bit
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%i"
.LC1:
	.string	"%s%i"
.LC2:
	.string	"%i\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %ebx
	movl	$4, %esi
	leal	1(%rbx), %r14d
	movl	%ebx, 12(%rsp)
	leal	(%rbx,%rbx), %ebp
	movslq	%r14d, %r12
	movq	%r12, %rdi
	call	calloc@PLT
	movl	$4, %esi
	movq	%r12, %rdi
	movq	%rax, (%rsp)
	call	calloc@PLT
	testl	%ebp, %ebp
	movq	(%rsp), %r8
	movq	%rax, %r15
	jle	.L14
	movl	$1, %r14d
	leaq	28(%rsp), %r13
	leaq	35(%rsp), %r12
	leaq	.LC1(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L18:
	xorl	%eax, %eax
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpb	$87, 35(%rsp)
	movslq	28(%rsp), %rax
	je	.L58
	movl	%r14d, (%r15,%rax,4)
	movl	24(%rsp), %eax
	addl	$1, %r14d
	leal	(%rax,%rax), %ebp
	cmpl	%r14d, %ebp
	jge	.L18
	movl	%eax, 12(%rsp)
	movq	(%rsp), %r8
.L17:
	leal	1(%rax), %r14d
	movslq	%r14d, %r12
.L14:
	leal	1(%rbp), %edi
	movl	$4, %esi
	movq	%r8, (%rsp)
	movslq	%edi, %rdi
	call	calloc@PLT
	movq	%r12, %rdi
	movl	$4, %esi
	movl	%ebp, (%rax)
	movq	%rax, %rbx
	call	calloc@PLT
	movq	%rax, %r12
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L19
	movq	(%rsp), %r8
	movl	%r14d, %r14d
	movl	$1, %esi
	.p2align 4,,10
	.p2align 3
.L24:
	movl	(%r15,%rsi,4), %edx
	movl	%esi, %edi
	cmpl	%ebp, %edx
	jg	.L20
	movl	%edx, %eax
	.p2align 4,,10
	.p2align 3
.L21:
	movslq	%eax, %rcx
	addl	$1, (%rbx,%rcx,4)
	movl	%eax, %ecx
	negl	%ecx
	andl	%eax, %ecx
	addl	%ecx, %eax
	cmpl	%ebp, %eax
	jle	.L21
	movl	(%rbx), %ebp
.L20:
	movl	-4(%r12,%rsi,4), %r9d
	testl	%edx, %edx
	jle	.L22
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L23:
	movslq	%edx, %rax
	addl	(%rbx,%rax,4), %ecx
	leal	-1(%rdx), %eax
	andl	%eax, %edx
	jne	.L23
	subl	%ecx, %edi
.L22:
	leal	(%r9,%rdi), %eax
	movl	%eax, (%r12,%rsi,4)
	addq	$1, %rsi
	cmpq	%rsi, %r14
	jne	.L24
	leaq	4(%rbx), %rax
	movl	%ebp, %ecx
	movl	$1, %r13d
	movq	%r8, %rbp
	movq	%rax, (%rsp)
	.p2align 4,,10
	.p2align 3
.L39:
	testl	%ecx, %ecx
	jle	.L25
	movslq	%ecx, %rdx
	movq	(%rsp), %rdi
	xorl	%esi, %esi
	salq	$2, %rdx
	call	memset@PLT
	movl	(%rbx), %ecx
.L25:
	movl	$0, (%r12)
	movl	$1, %edi
	xorl	%r9d, %r9d
	leaq	1(%r13), %r11
	.p2align 4,,10
	.p2align 3
.L30:
	movl	0(%rbp,%rdi,4), %edx
	movl	%edi, %r8d
	cmpl	%ecx, %edx
	jg	.L26
	movl	%edx, %eax
	.p2align 4,,10
	.p2align 3
.L27:
	movslq	%eax, %rsi
	addl	$1, (%rbx,%rsi,4)
	movl	%eax, %esi
	negl	%esi
	andl	%eax, %esi
	addl	%esi, %eax
	cmpl	%ecx, %eax
	jle	.L27
	movl	(%rbx), %ecx
.L26:
	testl	%edx, %edx
	jle	.L28
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L29:
	movslq	%edx, %rax
	addl	(%rbx,%rax,4), %esi
	leal	-1(%rdx), %eax
	andl	%eax, %edx
	jne	.L29
	subl	%esi, %r8d
.L28:
	addl	%r8d, %r9d
	leaq	1(%rdi), %rax
	movl	%r9d, (%r12)
	cmpq	%rdi, %r13
	je	.L59
	movq	%rax, %rdi
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L59:
	movl	0(%rbp,%r13,4), %r10d
	movl	$1, %esi
	.p2align 4,,10
	.p2align 3
.L38:
	movl	(%r15,%rsi,4), %edx
	movl	%edx, %eax
	cmpl	%ecx, %edx
	jg	.L34
	.p2align 4,,10
	.p2align 3
.L31:
	movslq	%eax, %rdi
	addl	$1, (%rbx,%rdi,4)
	movl	%eax, %edi
	negl	%edi
	andl	%eax, %edi
	addl	%edi, %eax
	cmpl	%ecx, %eax
	jle	.L31
.L34:
	leal	(%rsi,%r13), %edi
	movl	-4(%r12,%rsi,4), %r9d
	xorl	%ecx, %ecx
	movl	%edi, %eax
	testl	%edx, %edx
	jle	.L33
	.p2align 4,,10
	.p2align 3
.L32:
	movslq	%edx, %rax
	addl	(%rbx,%rax,4), %ecx
	leal	-1(%rdx), %eax
	andl	%eax, %edx
	jne	.L32
	movl	%edi, %eax
	subl	%ecx, %eax
.L33:
	movl	(%r12,%rsi,4), %r8d
	addl	%eax, %r9d
	testl	%r10d, %r10d
	jle	.L35
	movl	%r10d, %eax
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L36:
	movslq	%eax, %rdx
	addl	(%rbx,%rdx,4), %ecx
	leal	-1(%rax), %edx
	andl	%edx, %eax
	jne	.L36
	subl	%ecx, %edi
.L35:
	addl	%edi, %r8d
	cmpl	%r9d, %r8d
	cmovg	%r9d, %r8d
	movl	%r8d, (%r12,%rsi,4)
	addq	$1, %rsi
	cmpq	%r14, %rsi
	je	.L37
	movl	(%rbx), %ecx
	jmp	.L38
	.p2align 4,,10
	.p2align 3
.L37:
	cmpq	%r11, %r14
	je	.L19
	movl	(%rbx), %ecx
	movq	%r11, %r13
	jmp	.L39
.L58:
	movq	(%rsp), %rcx
	movl	%r14d, (%rcx,%rax,4)
	movl	24(%rsp), %eax
	addl	$1, %r14d
	leal	(%rax,%rax), %ebp
	cmpl	%r14d, %ebp
	jge	.L18
	movl	%eax, 12(%rsp)
	movq	%rcx, %r8
	jmp	.L17
.L19:
	movslq	12(%rsp), %rax
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	movl	(%r12,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L60
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L60:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB43:
	.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
.LFE43:
	.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<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void add (i32 *bit, i32 x, i32 v) {
  i32 n = bit[0];
  for (i32 i = x; i <= n; i += i & -i) {
    bit[i] += v;
  }
}

i32 get_sum (i32 *bit, i32 x) {
  i32 sum = 0;
  for (i32 i = x; i > 0; i -= i & -i) {
    sum += bit[i];
  }
  return sum;
}

void init_bit (i32 *bit) {
  i32 n = bit[0];
  for (i32 i = 1; i <= n; ++i) {
    bit[i] = 0;
  }
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *w = ALLOC (n + 1, i32);
  i32 *b = ALLOC (n + 1, i32);
  for (i32 i = 1; i <= 2 * n; ++i) {
    char s[5];
    i32 a;
    scanf ("%s%" SCNi32, s, &a);
    if (s[0] == 'W') {
      w[a] = i;
    } else {
      b[a] = i;
    }
  }
  i32 *bit = ALLOC (2 * n + 1, i32);
  bit[0] = 2 * n;
  i32 *dp = ALLOC (n + 1, i32);
  for (i32 i = 1; i <= n; ++i) {
    add (bit, b[i], 1);
    dp[i] = dp[i - 1] + (i - get_sum (bit, b[i]));
  }
  for (i32 i = 1; i <= n; ++i) {
    init_bit (bit);
    dp[0] = 0;
    for (i32 j = 1; j <= i; ++j) {
      add (bit, w[j], 1);
      dp[0] += j - get_sum (bit, w[j]);
    }
    for (i32 j = 1; j <= n; ++j) {
      add (bit, b[j], 1);
      i32 x = dp[j - 1] + (i + j - get_sum (bit, b[j]));
      i32 y = dp[j] + (i + j - get_sum (bit, w[i]));
      dp[j] = x < y ? x : y;
    }
  }
  printf ("%" PRIi32 "\n", dp[n]);
}

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

3
B 1
W 1
B 3
W 2
W 3
B 2
 4
B 4
W 4
B 2
W 3
B 3
W 2
B 1
W 1
 4
B 2
W 4
B 3
W 3
B 4
W 2
B 1
W 1
 4
B 4
W 4
B 3
W 2
B 1
W 3
B 2
W 1
 3
B 1
W 1
B 2
W 2
W 3
B 3
 3
B 1
W 1
B 3
W 3
W 2
B 2
 3
B 1
W 2
B 2
W 1
W 3
B 3
 4
B 4
W 4
B 3
W 3
B 1
W 2
B 2
W 1
 3
B 1
W 1
B 3
W 2
W 3
B 2
 4
B 4
W 4
B 3
W 2
B 2
W 3
B 1
W 1

3
 17
 15
 16
 0
 4
 2
 17
 3
 17

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

typedef int32_t i32;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void add (i32 *bit, i32 x, i32 v) {
  i32 n = bit[0];
  for (i32 i = x; i <= n; i += i & -i) {
    bit[i] += v;
  }
}

i32 get_sum (i32 *bit, i32 x) {
  i32 sum = 0;
  for (i32 i = x; i > 0; i -= i & -i) {
    sum += bit[i];
  }
  return sum;
}

void init_bit (i32 *bit) {
  i32 n = bit[0];
  for (i32 i = 1; i <= n; ++i) {
    bit[i] = 0;
  }
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *w = ALLOC (n + 1, i32);
  i32 *b = ALLOC (n + 1, i32);
  for (i32 i = 1; i <= 2 * n; ++i) {
    char s[5];
    i32 a;
    scanf ("%s%" SCNi32, s, &a);
    if (s[0] == 'W') {
      w[a] = i;
    } else {
      b[a] = i;
    }
  }
  i32 *bit = ALLOC (2 * n + 1, i32);
  bit[0] = 2 * n;
  i32 *dp = ALLOC (n + 1, i32);
  for (i32 i = 1; i <= n; ++i) {
    add (bit, b[i], 1);
    dp[i] = dp[i - 1] + (i - get_sum (bit, b[i]));
  }
  for (i32 i = 1; i <= n; ++i) {
    init_bit (bit);
    dp[0] = 0;
    for (i32 j = 1; j <= i; ++j) {
      add (bit, w[j], 1);
      dp[0] += j - get_sum (bit, w[j]);
    }
    for (i32 j = 1; j <= n; ++j) {
      add (bit, b[j], 1);
      i32 x = dp[j - 1] + (i + j - get_sum (bit, b[j]));
      i32 y = dp[j] + (i + j - get_sum (bit, w[i]));
      dp[j] = x < y ? x : y;
    }
  }
  printf ("%" PRIi32 "\n", dp[n]);
}

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

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	add
	.type	add, @function
add:
.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)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L2
.L3:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-32(%rbp), %edx
	addl	%ecx, %edx
	movl	%edx, (%rax)
	movl	-8(%rbp), %eax
	negl	%eax
	andl	-8(%rbp), %eax
	addl	%eax, -8(%rbp)
.L2:
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L3
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	add, .-add
	.globl	get_sum
	.type	get_sum, @function
get_sum:
.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, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -8(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L5
.L6:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -8(%rbp)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	andl	%eax, -4(%rbp)
.L5:
	cmpl	$0, -4(%rbp)
	jg	.L6
	movl	-8(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	get_sum, .-get_sum
	.globl	init_bit
	.type	init_bit, @function
init_bit:
.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	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L9
.L10:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	addl	$1, -8(%rbp)
.L9:
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L10
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	init_bit, .-init_bit
	.section	.rodata
.LC0:
	.string	"%i"
.LC1:
	.string	"%s%i"
.LC2:
	.string	"%i\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r12
	pushq	%rbx
	subq	$96, %rsp
	.cfi_offset 12, -24
	.cfi_offset 3, -32
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-100(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-100(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -64(%rbp)
	movl	-100(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -56(%rbp)
	movl	$1, -92(%rbp)
	jmp	.L12
.L15:
	leaq	-96(%rbp), %rdx
	leaq	-29(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movzbl	-29(%rbp), %eax
	cmpb	$87, %al
	jne	.L13
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-92(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L14
.L13:
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rax, %rdx
	movl	-92(%rbp), %eax
	movl	%eax, (%rdx)
.L14:
	addl	$1, -92(%rbp)
.L12:
	movl	-100(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -92(%rbp)
	jle	.L15
	movl	-100(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -48(%rbp)
	movl	-100(%rbp), %eax
	leal	(%rax,%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movl	-100(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -40(%rbp)
	movl	$1, -88(%rbp)
	jmp	.L16
.L17:
	movl	-88(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movq	-48(%rbp), %rax
	movl	$1, %edx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	add
	movl	-88(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ebx
	movl	-88(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	get_sum
	movl	%eax, %edx
	movl	-88(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-88(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	leal	(%rbx,%rcx), %edx
	movl	%edx, (%rax)
	addl	$1, -88(%rbp)
.L16:
	movl	-100(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jle	.L17
	movl	$1, -84(%rbp)
	jmp	.L18
.L23:
	movq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	init_bit
	movq	-40(%rbp), %rax
	movl	$0, (%rax)
	movl	$1, -80(%rbp)
	jmp	.L19
.L20:
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movq	-48(%rbp), %rax
	movl	$1, %edx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	add
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	get_sum
	movl	%eax, %edx
	movl	-80(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movq	-40(%rbp), %rax
	movl	(%rax), %eax
	leal	(%rcx,%rax), %edx
	movq	-40(%rbp), %rax
	movl	%edx, (%rax)
	addl	$1, -80(%rbp)
.L19:
	movl	-80(%rbp), %eax
	cmpl	-84(%rbp), %eax
	jle	.L20
	movl	$1, -76(%rbp)
	jmp	.L21
.L22:
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movq	-48(%rbp), %rax
	movl	$1, %edx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	add
	movl	-76(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %r12d
	movl	-84(%rbp), %edx
	movl	-76(%rbp), %eax
	leal	(%rdx,%rax), %ebx
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	get_sum
	subl	%eax, %ebx
	movl	%ebx, %edx
	leal	(%r12,%rdx), %eax
	movl	%eax, -72(%rbp)
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %r12d
	movl	-84(%rbp), %edx
	movl	-76(%rbp), %eax
	leal	(%rdx,%rax), %ebx
	movl	-84(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	get_sum
	subl	%eax, %ebx
	movl	%ebx, %edx
	leal	(%r12,%rdx), %eax
	movl	%eax, -68(%rbp)
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-68(%rbp), %edx
	movl	-72(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, (%rcx)
	addl	$1, -76(%rbp)
.L21:
	movl	-100(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jle	.L22
	addl	$1, -84(%rbp)
.L18:
	movl	-100(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jle	.L23
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-24(%rbp), %rax
	subq	%fs:40, %rax
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	addq	$96, %rsp
	popq	%rbx
	popq	%r12
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB10:
	.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
.LFE10:
	.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	add
	.type	add, @function
add:
.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)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L2
.L3:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-32(%rbp), %edx
	addl	%ecx, %edx
	movl	%edx, (%rax)
	movl	-8(%rbp), %eax
	negl	%eax
	andl	-8(%rbp), %eax
	addl	%eax, -8(%rbp)
.L2:
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L3
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	add, .-add
	.globl	get_sum
	.type	get_sum, @function
get_sum:
.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, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -8(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L5
.L6:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	addl	%eax, -8(%rbp)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	andl	%eax, -4(%rbp)
.L5:
	cmpl	$0, -4(%rbp)
	jg	.L6
	movl	-8(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	get_sum, .-get_sum
	.globl	init_bit
	.type	init_bit, @function
init_bit:
.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	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L9
.L10:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	addl	$1, -8(%rbp)
.L9:
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L10
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	init_bit, .-init_bit
	.section	.rodata
.LC0:
	.string	"%i"
.LC1:
	.string	"%s%i"
.LC2:
	.string	"%i\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r12
	pushq	%rbx
	subq	$96, %rsp
	.cfi_offset 12, -24
	.cfi_offset 3, -32
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-100(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-100(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -64(%rbp)
	movl	-100(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -56(%rbp)
	movl	$1, -92(%rbp)
	jmp	.L12
.L15:
	leaq	-96(%rbp), %rdx
	leaq	-29(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movzbl	-29(%rbp), %eax
	cmpb	$87, %al
	jne	.L13
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rax, %rdx
	movl	-92(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L14
.L13:
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rax, %rdx
	movl	-92(%rbp), %eax
	movl	%eax, (%rdx)
.L14:
	addl	$1, -92(%rbp)
.L12:
	movl	-100(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -92(%rbp)
	jle	.L15
	movl	-100(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -48(%rbp)
	movl	-100(%rbp), %eax
	leal	(%rax,%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movl	-100(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -40(%rbp)
	movl	$1, -88(%rbp)
	jmp	.L16
.L17:
	movl	-88(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movq	-48(%rbp), %rax
	movl	$1, %edx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	add
	movl	-88(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ebx
	movl	-88(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	get_sum
	movl	%eax, %edx
	movl	-88(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-88(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	leal	(%rbx,%rcx), %edx
	movl	%edx, (%rax)
	addl	$1, -88(%rbp)
.L16:
	movl	-100(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jle	.L17
	movl	$1, -84(%rbp)
	jmp	.L18
.L23:
	movq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	init_bit
	movq	-40(%rbp), %rax
	movl	$0, (%rax)
	movl	$1, -80(%rbp)
	jmp	.L19
.L20:
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movq	-48(%rbp), %rax
	movl	$1, %edx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	add
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	get_sum
	movl	%eax, %edx
	movl	-80(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movq	-40(%rbp), %rax
	movl	(%rax), %eax
	leal	(%rcx,%rax), %edx
	movq	-40(%rbp), %rax
	movl	%edx, (%rax)
	addl	$1, -80(%rbp)
.L19:
	movl	-80(%rbp), %eax
	cmpl	-84(%rbp), %eax
	jle	.L20
	movl	$1, -76(%rbp)
	jmp	.L21
.L22:
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movq	-48(%rbp), %rax
	movl	$1, %edx
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	add
	movl	-76(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %r12d
	movl	-84(%rbp), %edx
	movl	-76(%rbp), %eax
	leal	(%rdx,%rax), %ebx
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	get_sum
	subl	%eax, %ebx
	movl	%ebx, %edx
	leal	(%r12,%rdx), %eax
	movl	%eax, -72(%rbp)
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %r12d
	movl	-84(%rbp), %edx
	movl	-76(%rbp), %eax
	leal	(%rdx,%rax), %ebx
	movl	-84(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	get_sum
	subl	%eax, %ebx
	movl	%ebx, %edx
	leal	(%r12,%rdx), %eax
	movl	%eax, -68(%rbp)
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-68(%rbp), %edx
	movl	-72(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, (%rcx)
	addl	$1, -76(%rbp)
.L21:
	movl	-100(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jle	.L22
	addl	$1, -84(%rbp)
.L18:
	movl	-100(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jle	.L23
	movl	-100(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-24(%rbp), %rax
	subq	%fs:40, %rax
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	addq	$96, %rsp
	popq	%rbx
	popq	%r12
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB10:
	.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
.LFE10:
	.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:
