Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
// AOJ 2900 Bumpy Array
// 2018.3.14 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()   // 整数の入力（負数に対応）
{
	int n = 0, c = gc();
	if (c == '-') {
		c = gc();
		do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int N;
int a[100005], b[100005];

int calc(int *a)
{
	int i, t, ans = 0;

	for (i = 2; i < N; i++) {
		if (a[i - 2] > a[i - 1]) {
			if (i == N - 1) {
				if (a[i - 1] > a[i]) ans++;
				break;
			}
		}
		else {
			if (a[i - 2] < a[i]) t = a[i - 2], a[i - 2] = a[i - 1], a[i - 1] = t;
			else t = a[i - 1], a[i - 1] = a[i], a[i] = t;
			ans++;
		}
		
		if (++i == N) break;
		if (a[i - 2] < a[i - 1]) {
			if (i == N - 1) {
				if (a[i - 1] < a[i]) ans++;
				break;
			}
		}
		else {
			if (a[i - 2] > a[i]) t = a[i - 2], a[i - 2] = a[i - 1], a[i - 1] = t;
			else t = a[i - 1], a[i - 1] = a[i], a[i] = t;
			ans++;
		}
	}
	return ans;
}

int main()
{
	int i, ans;

	N = in();
	if (N < 3) { puts("0"); return 0; }
	for (i = 0; i < N; i++) a[i] = in(), b[i] = -a[i];

	ans = calc(a);
	i = calc(b);
	if (i < ans) ans = i;
	printf("%d\n", ans);
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	in
	.type	in, @function
in:
.LFB6:
	.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$45, -4(%rbp)
	jne	.L2
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L3:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L3
	movl	-8(%rbp), %eax
	negl	%eax
	jmp	.L4
.L2:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	in, .-in
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400020
a:
	.zero	400020
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400020
b:
	.zero	400020
	.text
	.globl	calc
	.type	calc, @function
calc:
.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	$0, -8(%rbp)
	movl	$2, -12(%rbp)
	jmp	.L6
.L19:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L7
	movl	N(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jne	.L8
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L21
	addl	$1, -8(%rbp)
	jmp	.L21
.L7:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L11
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-8(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L12
.L11:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
.L12:
	addl	$1, -8(%rbp)
.L8:
	addl	$1, -12(%rbp)
	movl	N(%rip), %eax
	cmpl	%eax, -12(%rbp)
	je	.L22
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L14
	movl	N(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jne	.L15
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L23
	addl	$1, -8(%rbp)
	jmp	.L23
.L14:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L17
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-8(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L18
.L17:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
.L18:
	addl	$1, -8(%rbp)
.L15:
	addl	$1, -12(%rbp)
.L6:
	movl	N(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L19
	jmp	.L10
.L21:
	nop
	jmp	.L10
.L22:
	nop
	jmp	.L10
.L23:
	nop
.L10:
	movl	-8(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"0"
.LC1:
	.string	"%d\n"
	.text
	.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
	subq	$16, %rsp
	movl	$0, %eax
	call	in
	movl	%eax, N(%rip)
	movl	N(%rip), %eax
	cmpl	$2, %eax
	jg	.L25
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L26
.L25:
	movl	$0, -8(%rbp)
	jmp	.L27
.L28:
	movl	$0, %eax
	call	in
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	negl	%eax
	movl	%eax, %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -8(%rbp)
.L27:
	movl	N(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L28
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	calc
	movl	%eax, -4(%rbp)
	leaq	b(%rip), %rax
	movq	%rax, %rdi
	call	calc
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jge	.L29
	movl	-8(%rbp), %eax
	movl	%eax, -4(%rbp)
.L29:
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L26:
	leave
	.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
	.globl	in
	.type	in, @function
in:
.LFB39:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L20
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L3:
	xorl	%r12d, %r12d
	cmpl	$45, %eax
	jne	.L4
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L12:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L1
.L13:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L4:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L12
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L1
	movq	stdin(%rip), %rdi
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L9:
	negl	%r12d
.L1:
	movl	%r12d, %eax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L21:
	.cfi_restore_state
	cmpq	%rcx, %rdx
	jnb	.L22
	leaq	1(%rdx), %rsi
	movq	%rsi, 8(%rdi)
	movzbl	(%rdx), %eax
.L6:
	xorl	%r12d, %r12d
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L7:
	leaq	1(%rsi), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rsi), %eax
	cmpl	$47, %eax
	jle	.L9
.L8:
	movq	8(%rdi), %rsi
	movq	16(%rdi), %rcx
.L10:
	leal	(%r12,%r12,4), %edx
	andl	$15, %eax
	leal	(%rax,%rdx,2), %r12d
	cmpq	%rcx, %rsi
	jb	.L7
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L9
	movq	stdin(%rip), %rdi
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L20:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L3
.L22:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rsi
	movq	16(%rdi), %rcx
	jmp	.L6
	.cfi_endproc
.LFE39:
	.size	in, .-in
	.p2align 4
	.globl	calc
	.type	calc, @function
calc:
.LFB40:
	.cfi_startproc
	endbr64
	movl	N(%rip), %ecx
	cmpl	$2, %ecx
	jle	.L34
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$8, %r10d
	movq	%rdi, %rax
	movl	$3, %esi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	$12, %r11d
	movq	%rdi, %rbp
	xorl	%r9d, %r9d
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	$2, %edi
	subq	%rbp, %r10
	subq	%rbp, %r11
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L42:
	leal	-1(%rcx), %edx
	cmpl	%edx, %edi
	je	.L40
	cmpl	%esi, %ecx
	je	.L23
.L43:
	movq	4(%rax), %xmm0
	movl	8(%rax), %r12d
	leaq	(%r11,%rax), %rbx
	pshufd	$0xe5, %xmm0, %xmm3
	movd	%xmm0, %r8d
	movd	%xmm3, %edx
	pshufd	$225, %xmm0, %xmm1
	cmpl	%r8d, %edx
	jle	.L29
	leal	-1(%rcx), %edx
	cmpl	%esi, %edx
	je	.L41
.L30:
	addl	$2, %edi
	addq	$8, %rax
	addl	$2, %esi
	cmpl	%ecx, %edi
	jge	.L23
.L33:
	movq	(%rax), %xmm0
	movl	4(%rax), %r12d
	leaq	(%r10,%rax), %rbx
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %r8d
	movd	%xmm2, %edx
	pshufd	$225, %xmm0, %xmm1
	cmpl	%edx, %r8d
	jg	.L42
	movd	8(%rax), %xmm0
	punpckldq	%xmm2, %xmm0
	cmpl	%r8d, 8(%rax)
	jle	.L27
	movq	%xmm1, (%rax)
.L28:
	movl	N(%rip), %ecx
	addl	$1, %r9d
	cmpl	%esi, %ecx
	jne	.L43
.L23:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movl	%r9d, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L29:
	.cfi_restore_state
	movd	12(%rax), %xmm0
	punpckldq	%xmm3, %xmm0
	cmpl	%r8d, 12(%rax)
	jge	.L31
	movq	%xmm1, 4(%rax)
.L32:
	movl	N(%rip), %ecx
	addl	$1, %r9d
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L27:
	movq	%xmm0, 4(%rax)
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L31:
	movq	%xmm0, 8(%rax)
	jmp	.L32
	.p2align 4,,10
	.p2align 3
.L40:
	xorl	%eax, %eax
	cmpl	0(%rbp,%rbx), %r12d
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	setg	%al
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	addl	%eax, %r9d
	movl	%r9d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L41:
	.cfi_restore_state
	xorl	%eax, %eax
	cmpl	0(%rbp,%rbx), %r12d
	popq	%rbx
	.cfi_def_cfa_offset 24
	setl	%al
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	addl	%eax, %r9d
	movl	%r9d, %eax
	ret
.L34:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE40:
	.size	calc, .-calc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"0"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%eax, %eax
	leaq	a(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	b(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
	call	in
	movl	%eax, N(%rip)
	cmpl	$2, %eax
	jle	.L52
	.p2align 4,,10
	.p2align 3
.L45:
	xorl	%eax, %eax
	call	in
	movl	%eax, (%r12,%rbx,4)
	negl	%eax
	movl	%eax, 0(%rbp,%rbx,4)
	addq	$1, %rbx
	cmpl	%ebx, N(%rip)
	jg	.L45
	movq	%r12, %rdi
	call	calc
	movq	%rbp, %rdi
	movl	%eax, %ebx
	call	calc
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	cmpl	%eax, %ebx
	cmovle	%ebx, %eax
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L46:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L52:
	.cfi_restore_state
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L46
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.globl	b
	.bss
	.align 32
	.type	b, @object
	.size	b, 400020
b:
	.zero	400020
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400020
a:
	.zero	400020
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	in
	.type	in, @function
in:
.LFB39:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L20
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L3:
	xorl	%r12d, %r12d
	cmpl	$45, %eax
	jne	.L4
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L12:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L1
.L13:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L4:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L12
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L1
	movq	stdin(%rip), %rdi
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L9:
	negl	%r12d
.L1:
	movl	%r12d, %eax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L21:
	.cfi_restore_state
	cmpq	%rcx, %rdx
	jnb	.L22
	leaq	1(%rdx), %rsi
	movq	%rsi, 8(%rdi)
	movzbl	(%rdx), %eax
.L6:
	xorl	%r12d, %r12d
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L7:
	leaq	1(%rsi), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rsi), %eax
	cmpl	$47, %eax
	jle	.L9
.L8:
	movq	8(%rdi), %rsi
	movq	16(%rdi), %rcx
.L10:
	leal	(%r12,%r12,4), %edx
	andl	$15, %eax
	leal	(%rax,%rdx,2), %r12d
	cmpq	%rcx, %rsi
	jb	.L7
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L9
	movq	stdin(%rip), %rdi
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L20:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L3
.L22:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rsi
	movq	16(%rdi), %rcx
	jmp	.L6
	.cfi_endproc
.LFE39:
	.size	in, .-in
	.p2align 4
	.globl	calc
	.type	calc, @function
calc:
.LFB40:
	.cfi_startproc
	endbr64
	movl	N(%rip), %ecx
	cmpl	$2, %ecx
	jle	.L34
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$8, %r10d
	movq	%rdi, %rax
	movl	$3, %esi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	$12, %r11d
	movq	%rdi, %rbp
	xorl	%r9d, %r9d
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	$2, %edi
	subq	%rbp, %r10
	subq	%rbp, %r11
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L42:
	leal	-1(%rcx), %edx
	cmpl	%edx, %edi
	je	.L40
	cmpl	%esi, %ecx
	je	.L23
.L43:
	movq	4(%rax), %xmm0
	movl	8(%rax), %r12d
	leaq	(%r11,%rax), %rbx
	pshufd	$0xe5, %xmm0, %xmm3
	movd	%xmm0, %r8d
	movd	%xmm3, %edx
	pshufd	$225, %xmm0, %xmm1
	cmpl	%r8d, %edx
	jle	.L29
	leal	-1(%rcx), %edx
	cmpl	%esi, %edx
	je	.L41
.L30:
	addl	$2, %edi
	addq	$8, %rax
	addl	$2, %esi
	cmpl	%ecx, %edi
	jge	.L23
.L33:
	movq	(%rax), %xmm0
	movl	4(%rax), %r12d
	leaq	(%r10,%rax), %rbx
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %r8d
	movd	%xmm2, %edx
	pshufd	$225, %xmm0, %xmm1
	cmpl	%edx, %r8d
	jg	.L42
	movd	8(%rax), %xmm0
	punpckldq	%xmm2, %xmm0
	cmpl	%r8d, 8(%rax)
	jle	.L27
	movq	%xmm1, (%rax)
.L28:
	movl	N(%rip), %ecx
	addl	$1, %r9d
	cmpl	%esi, %ecx
	jne	.L43
.L23:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movl	%r9d, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L29:
	.cfi_restore_state
	movd	12(%rax), %xmm0
	punpckldq	%xmm3, %xmm0
	cmpl	%r8d, 12(%rax)
	jge	.L31
	movq	%xmm1, 4(%rax)
.L32:
	movl	N(%rip), %ecx
	addl	$1, %r9d
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L27:
	movq	%xmm0, 4(%rax)
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L31:
	movq	%xmm0, 8(%rax)
	jmp	.L32
	.p2align 4,,10
	.p2align 3
.L40:
	xorl	%eax, %eax
	cmpl	0(%rbp,%rbx), %r12d
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	setg	%al
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	addl	%eax, %r9d
	movl	%r9d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L41:
	.cfi_restore_state
	xorl	%eax, %eax
	cmpl	0(%rbp,%rbx), %r12d
	popq	%rbx
	.cfi_def_cfa_offset 24
	setl	%al
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	addl	%eax, %r9d
	movl	%r9d, %eax
	ret
.L34:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE40:
	.size	calc, .-calc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"0"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%eax, %eax
	leaq	a(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	b(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
	call	in
	movl	%eax, N(%rip)
	cmpl	$2, %eax
	jle	.L52
	.p2align 4,,10
	.p2align 3
.L45:
	xorl	%eax, %eax
	call	in
	movl	%eax, (%r12,%rbx,4)
	negl	%eax
	movl	%eax, 0(%rbp,%rbx,4)
	addq	$1, %rbx
	cmpl	%ebx, N(%rip)
	jg	.L45
	movq	%r12, %rdi
	call	calc
	movq	%rbp, %rdi
	movl	%eax, %ebx
	call	calc
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	cmpl	%eax, %ebx
	cmovle	%ebx, %eax
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L46:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L52:
	.cfi_restore_state
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L46
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.globl	b
	.bss
	.align 32
	.type	b, @object
	.size	b, 400020
b:
	.zero	400020
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400020
a:
	.zero	400020
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

// AOJ 2900 Bumpy Array
// 2018.3.14 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()   // 整数の入力（負数に対応）
{
	int n = 0, c = gc();
	if (c == '-') {
		c = gc();
		do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int N;
int a[100005], b[100005];

int calc(int *a)
{
	int i, t, ans = 0;

	for (i = 2; i < N; i++) {
		if (a[i - 2] > a[i - 1]) {
			if (i == N - 1) {
				if (a[i - 1] > a[i]) ans++;
				break;
			}
		}
		else {
			if (a[i - 2] < a[i]) t = a[i - 2], a[i - 2] = a[i - 1], a[i - 1] = t;
			else t = a[i - 1], a[i - 1] = a[i], a[i] = t;
			ans++;
		}
		
		if (++i == N) break;
		if (a[i - 2] < a[i - 1]) {
			if (i == N - 1) {
				if (a[i - 1] < a[i]) ans++;
				break;
			}
		}
		else {
			if (a[i - 2] > a[i]) t = a[i - 2], a[i - 2] = a[i - 1], a[i - 1] = t;
			else t = a[i - 1], a[i - 1] = a[i], a[i] = t;
			ans++;
		}
	}
	return ans;
}

int main()
{
	int i, ans;

	N = in();
	if (N < 3) { puts("0"); return 0; }
	for (i = 0; i < N; i++) a[i] = in(), b[i] = -a[i];

	ans = calc(a);
	i = calc(b);
	if (i < ans) ans = i;
	printf("%d\n", ans);
	return 0;
}

5
0 2 3 4 5
 5
1 2 1 4 5
 5
0 4 3 13 4
 5
0 2 3 4 8
 5
0 2 3 4 14
 5
0 1 3 4 5
 5
0 2 3 4 2
 5
0 2 3 8 2
 5
0 2 3 13 2
 5
0 2 3 13 4

2
 1
 0
 2
 2
 2
 1
 1
 1
 1

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
// AOJ 2900 Bumpy Array
// 2018.3.14 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()   // 整数の入力（負数に対応）
{
	int n = 0, c = gc();
	if (c == '-') {
		c = gc();
		do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int N;
int a[100005], b[100005];

int calc(int *a)
{
	int i, t, ans = 0;

	for (i = 2; i < N; i++) {
		if (a[i - 2] > a[i - 1]) {
			if (i == N - 1) {
				if (a[i - 1] > a[i]) ans++;
				break;
			}
		}
		else {
			if (a[i - 2] < a[i]) t = a[i - 2], a[i - 2] = a[i - 1], a[i - 1] = t;
			else t = a[i - 1], a[i - 1] = a[i], a[i] = t;
			ans++;
		}
		
		if (++i == N) break;
		if (a[i - 2] < a[i - 1]) {
			if (i == N - 1) {
				if (a[i - 1] < a[i]) ans++;
				break;
			}
		}
		else {
			if (a[i - 2] > a[i]) t = a[i - 2], a[i - 2] = a[i - 1], a[i - 1] = t;
			else t = a[i - 1], a[i - 1] = a[i], a[i] = t;
			ans++;
		}
	}
	return ans;
}

int main()
{
	int i, ans;

	N = in();
	if (N < 3) { puts("0"); return 0; }
	for (i = 0; i < N; i++) a[i] = in(), b[i] = -a[i];

	ans = calc(a);
	i = calc(b);
	if (i < ans) ans = i;
	printf("%d\n", ans);
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	in
	.type	in, @function
in:
.LFB6:
	.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$45, -4(%rbp)
	jne	.L2
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L3:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L3
	movl	-8(%rbp), %eax
	negl	%eax
	jmp	.L4
.L2:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	in, .-in
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400020
a:
	.zero	400020
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400020
b:
	.zero	400020
	.text
	.globl	calc
	.type	calc, @function
calc:
.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	$0, -8(%rbp)
	movl	$2, -12(%rbp)
	jmp	.L6
.L19:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L7
	movl	N(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jne	.L8
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L21
	addl	$1, -8(%rbp)
	jmp	.L21
.L7:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L11
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-8(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L12
.L11:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
.L12:
	addl	$1, -8(%rbp)
.L8:
	addl	$1, -12(%rbp)
	movl	N(%rip), %eax
	cmpl	%eax, -12(%rbp)
	je	.L22
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L14
	movl	N(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jne	.L15
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L23
	addl	$1, -8(%rbp)
	jmp	.L23
.L14:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L17
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-8(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L18
.L17:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
.L18:
	addl	$1, -8(%rbp)
.L15:
	addl	$1, -12(%rbp)
.L6:
	movl	N(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L19
	jmp	.L10
.L21:
	nop
	jmp	.L10
.L22:
	nop
	jmp	.L10
.L23:
	nop
.L10:
	movl	-8(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"0"
.LC1:
	.string	"%d\n"
	.text
	.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
	subq	$16, %rsp
	movl	$0, %eax
	call	in
	movl	%eax, N(%rip)
	movl	N(%rip), %eax
	cmpl	$2, %eax
	jg	.L25
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L26
.L25:
	movl	$0, -8(%rbp)
	jmp	.L27
.L28:
	movl	$0, %eax
	call	in
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	negl	%eax
	movl	%eax, %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -8(%rbp)
.L27:
	movl	N(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L28
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	calc
	movl	%eax, -4(%rbp)
	leaq	b(%rip), %rax
	movq	%rax, %rdi
	call	calc
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jge	.L29
	movl	-8(%rbp), %eax
	movl	%eax, -4(%rbp)
.L29:
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L26:
	leave
	.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	in
	.type	in, @function
in:
.LFB6:
	.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$45, -4(%rbp)
	jne	.L2
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L3:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L3
	movl	-8(%rbp), %eax
	negl	%eax
	jmp	.L4
.L2:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	in, .-in
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400020
a:
	.zero	400020
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400020
b:
	.zero	400020
	.text
	.globl	calc
	.type	calc, @function
calc:
.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	$0, -8(%rbp)
	movl	$2, -12(%rbp)
	jmp	.L6
.L19:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L7
	movl	N(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jne	.L8
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L21
	addl	$1, -8(%rbp)
	jmp	.L21
.L7:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L11
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-8(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L12
.L11:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
.L12:
	addl	$1, -8(%rbp)
.L8:
	addl	$1, -12(%rbp)
	movl	N(%rip), %eax
	cmpl	%eax, -12(%rbp)
	je	.L22
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L14
	movl	N(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jne	.L15
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L23
	addl	$1, -8(%rbp)
	jmp	.L23
.L14:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jle	.L17
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-8(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-8(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L18
.L17:
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
.L18:
	addl	$1, -8(%rbp)
.L15:
	addl	$1, -12(%rbp)
.L6:
	movl	N(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L19
	jmp	.L10
.L21:
	nop
	jmp	.L10
.L22:
	nop
	jmp	.L10
.L23:
	nop
.L10:
	movl	-8(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"0"
.LC1:
	.string	"%d\n"
	.text
	.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
	subq	$16, %rsp
	movl	$0, %eax
	call	in
	movl	%eax, N(%rip)
	movl	N(%rip), %eax
	cmpl	$2, %eax
	jg	.L25
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L26
.L25:
	movl	$0, -8(%rbp)
	jmp	.L27
.L28:
	movl	$0, %eax
	call	in
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	negl	%eax
	movl	%eax, %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -8(%rbp)
.L27:
	movl	N(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L28
	leaq	a(%rip), %rax
	movq	%rax, %rdi
	call	calc
	movl	%eax, -4(%rbp)
	leaq	b(%rip), %rax
	movq	%rax, %rdi
	call	calc
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jge	.L29
	movl	-8(%rbp), %eax
	movl	%eax, -4(%rbp)
.L29:
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L26:
	leave
	.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:
