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

#define S_MAX 200000
#define N_MAX 100000
#define M_MAX 100000
#define INF 10000000
#define MOD 1000000007
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;
typedef   signed long long dll;

int n, m;
int h, w;
int i, j, k;

int a[N_MAX];
int b[N_MAX];

typedef struct {
	int in;
	int out;
} twoway;

void solve(){
	int lastindex = -1;
	int leftestcol;

	int result = 0;

	if (n == 1) printf("%d\n", a[0] ^ 1);
	for (i = 0; i < (n >> 1); i++) {
		if (lastindex == -1) {
			lastindex++;
			b[lastindex] = 1;
			leftestcol = a[1];
		} else if ((lastindex & 1) ^ leftestcol == a[(i << 1) + 1]) {

			b[lastindex]++;
		} else if (a[i << 1] == a[(i << 1) + 1]) {
			lastindex++;
			b[lastindex] = 1;
		} else if (lastindex) {
			b[lastindex - 1] += b[lastindex];
			b[lastindex - 1]++;
			lastindex--;
		} else {
			b[0]++;
			leftestcol ^= 1;
		}

		// for (j = 0; j <= lastindex; j++) printf("%dx%d, ", (lastindex & 1) ^ leftestcol, b[j]);
		// 	putchar('\n');
	}

	for (i = leftestcol; i <= lastindex; i += 2) {
		result += b[i];
	}

	result *= 2;
	if (n & 1) result += (a[n-1] ^ 1);

	printf("%d\n", result);

	return;
}

int main (void) {
	while (scanf("%d", &n), n) {
		for (i = 0; i < n; i++) scanf("%d", &a[i]);
		solve();
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400000
a:
	.zero	400000
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400000
b:
	.zero	400000
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB0:
	.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	$-1, -12(%rbp)
	movl	$0, -4(%rbp)
	movl	n(%rip), %eax
	cmpl	$1, %eax
	jne	.L2
	movl	a(%rip), %eax
	xorl	$1, %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	movl	$0, i(%rip)
	jmp	.L3
.L9:
	cmpl	$-1, -12(%rbp)
	jne	.L4
	addl	$1, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	4+a(%rip), %eax
	movl	%eax, -8(%rbp)
	jmp	.L5
.L4:
	movl	-12(%rbp), %eax
	andl	$1, %eax
	movl	i(%rip), %edx
	addl	%edx, %edx
	addl	$1, %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	cmpl	%edx, -8(%rbp)
	sete	%dl
	xorl	%edx, %eax
	testb	%al, %al
	je	.L6
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L5
.L6:
	movl	i(%rip), %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L7
	addl	$1, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	$1, (%rdx,%rax)
	jmp	.L5
.L7:
	cmpl	$0, -12(%rbp)
	je	.L8
	movl	-12(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-12(%rbp), %eax
	subl	$1, %eax
	addl	%edx, %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-12(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	b(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	subl	$1, -12(%rbp)
	jmp	.L5
.L8:
	movl	b(%rip), %eax
	addl	$1, %eax
	movl	%eax, b(%rip)
	xorl	$1, -8(%rbp)
.L5:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L3:
	movl	n(%rip), %eax
	sarl	%eax
	movl	%eax, %edx
	movl	i(%rip), %eax
	cmpl	%eax, %edx
	jg	.L9
	movl	-8(%rbp), %eax
	movl	%eax, i(%rip)
	jmp	.L10
.L11:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -4(%rbp)
	movl	i(%rip), %eax
	addl	$2, %eax
	movl	%eax, i(%rip)
.L10:
	movl	i(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L11
	sall	-4(%rbp)
	movl	n(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L12
	movl	n(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	xorl	$1, %eax
	addl	%eax, -4(%rbp)
.L12:
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	solve, .-solve
	.section	.rodata
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	jmp	.L15
.L18:
	movl	$0, i(%rip)
	jmp	.L16
.L17:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L16:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L17
	movl	$0, %eax
	call	solve
.L15:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L18
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	solve
	.type	solve, @function
solve:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movl	n(%rip), %r9d
	cmpl	$1, %r9d
	je	.L30
	movl	%r9d, %edx
	sarl	%edx
	testl	%edx, %edx
	jle	.L16
.L34:
	leaq	a(%rip), %rax
	leal	-1(%rdx), %ecx
	movl	4+a(%rip), %r11d
	leaq	8(%rax), %rdx
	leaq	b(%rip), %rsi
	leaq	(%rdx,%rcx,8), %r10
	movl	$-1, %ecx
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L31:
	movslq	%ecx, %rdx
	addl	$1, (%rsi,%rdx,4)
.L6:
	addq	$8, %rax
	cmpq	%r10, %rax
	je	.L3
.L10:
	cmpl	$-1, %ecx
	jne	.L4
	addq	$8, %rax
	movl	%r11d, %ebx
	xorl	%ecx, %ecx
	movl	$1, b(%rip)
	cmpq	%r10, %rax
	je	.L3
.L4:
	movl	%ecx, %r8d
	andl	$1, %r8d
.L9:
	movl	4(%rax), %edx
	cmpl	%ebx, %edx
	sete	%dil
	cmpb	%dil, %r8b
	jne	.L31
	cmpl	(%rax), %edx
	je	.L32
	testl	%ecx, %ecx
	je	.L8
	leal	-1(%rcx), %edi
	movslq	%ecx, %rcx
	addq	$8, %rax
	movslq	%edi, %r8
	movl	(%rsi,%rcx,4), %edx
	movl	%edi, %ecx
	addl	(%rsi,%r8,4), %edx
	addl	$1, %edx
	movl	%edx, (%rsi,%r8,4)
	cmpq	%r10, %rax
	jne	.L10
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%ebx, i(%rip)
	cmpl	%ebx, %ecx
	jl	.L18
.L35:
	movl	%ecx, %eax
	subl	%ebx, %eax
	movl	%eax, %r8d
	shrl	%r8d
	cmpl	$7, %eax
	jbe	.L19
	shrl	$3, %eax
	leaq	b(%rip), %rdi
	pxor	%xmm0, %xmm0
	movl	%eax, %r10d
	movslq	%ebx, %rax
	leaq	(%rdi,%rax,4), %rdx
	leal	-1(%r10), %esi
	salq	$5, %rsi
	leaq	32(%rdx), %rax
	addq	%rax, %rsi
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L33:
	addq	$32, %rax
.L13:
	movdqu	(%rdx), %xmm1
	movdqu	16(%rdx), %xmm2
	movq	%rax, %rdx
	shufps	$136, %xmm2, %xmm1
	paddd	%xmm1, %xmm0
	cmpq	%rsi, %rax
	jne	.L33
	movdqa	%xmm0, %xmm1
	leal	(%rbx,%r10,8), %eax
	psrldq	$8, %xmm1
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
.L12:
	movslq	%eax, %rsi
	addl	(%rdi,%rsi,4), %edx
	leal	2(%rax), %esi
	cmpl	%ecx, %esi
	jg	.L14
	movslq	%esi, %rsi
	addl	(%rdi,%rsi,4), %edx
	leal	4(%rax), %esi
	cmpl	%esi, %ecx
	jl	.L14
	movslq	%esi, %rsi
	addl	$6, %eax
	addl	(%rdi,%rsi,4), %edx
	cmpl	%eax, %ecx
	jl	.L14
	cltq
	addl	(%rdi,%rax,4), %edx
.L14:
	leal	2(%rbx,%r8,2), %eax
	addl	%edx, %edx
	movl	%eax, i(%rip)
.L11:
	testb	$1, %r9b
	je	.L15
	subl	$1, %r9d
	leaq	a(%rip), %rax
	movslq	%r9d, %r9
	movl	(%rax,%r9,4), %eax
	xorl	$1, %eax
	addl	%eax, %edx
.L15:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L32:
	.cfi_restore_state
	addl	$1, %ecx
	movslq	%ecx, %rdx
	movl	$1, (%rsi,%rdx,4)
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L8:
	addq	$8, %rax
	addl	$1, (%rsi)
	xorl	$1, %ebx
	cmpq	%r10, %rax
	jne	.L9
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L30:
	movl	a(%rip), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	xorl	$1, %edx
	call	__printf_chk@PLT
	movl	n(%rip), %r9d
	movl	%r9d, %edx
	sarl	%edx
	testl	%edx, %edx
	jg	.L34
.L16:
	movl	$-1, %ecx
	movl	%ebx, i(%rip)
	cmpl	%ebx, %ecx
	jge	.L35
	.p2align 4,,10
	.p2align 3
.L18:
	xorl	%edx, %edx
	jmp	.L11
.L19:
	movl	%ebx, %eax
	xorl	%edx, %edx
	leaq	b(%rip), %rdi
	jmp	.L12
	.cfi_endproc
.LFE35:
	.size	solve, .-solve
	.section	.rodata.str1.1
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	n(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	a(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	.LC1(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L37:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L43
	movl	$0, i(%rip)
	jle	.L38
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L39:
	cltq
	movq	%rbx, %rdi
	leaq	0(%rbp,%rax,4), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	addl	$1, %eax
	cmpl	n(%rip), %eax
	movl	%eax, i(%rip)
	jl	.L39
.L38:
	xorl	%eax, %eax
	call	solve
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L43:
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.globl	b
	.bss
	.align 32
	.type	b, @object
	.size	b, 400000
b:
	.zero	400000
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400000
a:
	.zero	400000
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	solve
	.type	solve, @function
solve:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movl	n(%rip), %r9d
	cmpl	$1, %r9d
	je	.L30
	movl	%r9d, %edx
	sarl	%edx
	testl	%edx, %edx
	jle	.L16
.L34:
	leaq	a(%rip), %rax
	leal	-1(%rdx), %ecx
	movl	4+a(%rip), %r11d
	leaq	8(%rax), %rdx
	leaq	b(%rip), %rsi
	leaq	(%rdx,%rcx,8), %r10
	movl	$-1, %ecx
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L31:
	movslq	%ecx, %rdx
	addl	$1, (%rsi,%rdx,4)
.L6:
	addq	$8, %rax
	cmpq	%r10, %rax
	je	.L3
.L10:
	cmpl	$-1, %ecx
	jne	.L4
	addq	$8, %rax
	movl	%r11d, %ebx
	xorl	%ecx, %ecx
	movl	$1, b(%rip)
	cmpq	%r10, %rax
	je	.L3
.L4:
	movl	%ecx, %r8d
	andl	$1, %r8d
.L9:
	movl	4(%rax), %edx
	cmpl	%ebx, %edx
	sete	%dil
	cmpb	%dil, %r8b
	jne	.L31
	cmpl	(%rax), %edx
	je	.L32
	testl	%ecx, %ecx
	je	.L8
	leal	-1(%rcx), %edi
	movslq	%ecx, %rcx
	addq	$8, %rax
	movslq	%edi, %r8
	movl	(%rsi,%rcx,4), %edx
	movl	%edi, %ecx
	addl	(%rsi,%r8,4), %edx
	addl	$1, %edx
	movl	%edx, (%rsi,%r8,4)
	cmpq	%r10, %rax
	jne	.L10
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%ebx, i(%rip)
	cmpl	%ebx, %ecx
	jl	.L18
.L35:
	movl	%ecx, %eax
	subl	%ebx, %eax
	movl	%eax, %r8d
	shrl	%r8d
	cmpl	$7, %eax
	jbe	.L19
	shrl	$3, %eax
	leaq	b(%rip), %rdi
	pxor	%xmm0, %xmm0
	movl	%eax, %r10d
	movslq	%ebx, %rax
	leaq	(%rdi,%rax,4), %rdx
	leal	-1(%r10), %esi
	salq	$5, %rsi
	leaq	32(%rdx), %rax
	addq	%rax, %rsi
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L33:
	addq	$32, %rax
.L13:
	movdqu	(%rdx), %xmm1
	movdqu	16(%rdx), %xmm2
	movq	%rax, %rdx
	shufps	$136, %xmm2, %xmm1
	paddd	%xmm1, %xmm0
	cmpq	%rsi, %rax
	jne	.L33
	movdqa	%xmm0, %xmm1
	leal	(%rbx,%r10,8), %eax
	psrldq	$8, %xmm1
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
.L12:
	movslq	%eax, %rsi
	addl	(%rdi,%rsi,4), %edx
	leal	2(%rax), %esi
	cmpl	%ecx, %esi
	jg	.L14
	movslq	%esi, %rsi
	addl	(%rdi,%rsi,4), %edx
	leal	4(%rax), %esi
	cmpl	%esi, %ecx
	jl	.L14
	movslq	%esi, %rsi
	addl	$6, %eax
	addl	(%rdi,%rsi,4), %edx
	cmpl	%eax, %ecx
	jl	.L14
	cltq
	addl	(%rdi,%rax,4), %edx
.L14:
	leal	2(%rbx,%r8,2), %eax
	addl	%edx, %edx
	movl	%eax, i(%rip)
.L11:
	testb	$1, %r9b
	je	.L15
	subl	$1, %r9d
	leaq	a(%rip), %rax
	movslq	%r9d, %r9
	movl	(%rax,%r9,4), %eax
	xorl	$1, %eax
	addl	%eax, %edx
.L15:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L32:
	.cfi_restore_state
	addl	$1, %ecx
	movslq	%ecx, %rdx
	movl	$1, (%rsi,%rdx,4)
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L8:
	addq	$8, %rax
	addl	$1, (%rsi)
	xorl	$1, %ebx
	cmpq	%r10, %rax
	jne	.L9
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L30:
	movl	a(%rip), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	xorl	$1, %edx
	call	__printf_chk@PLT
	movl	n(%rip), %r9d
	movl	%r9d, %edx
	sarl	%edx
	testl	%edx, %edx
	jg	.L34
.L16:
	movl	$-1, %ecx
	movl	%ebx, i(%rip)
	cmpl	%ebx, %ecx
	jge	.L35
	.p2align 4,,10
	.p2align 3
.L18:
	xorl	%edx, %edx
	jmp	.L11
.L19:
	movl	%ebx, %eax
	xorl	%edx, %edx
	leaq	b(%rip), %rdi
	jmp	.L12
	.cfi_endproc
.LFE35:
	.size	solve, .-solve
	.section	.rodata.str1.1
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	n(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	a(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	.LC1(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L37:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L43
	movl	$0, i(%rip)
	jle	.L38
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L39:
	cltq
	movq	%rbx, %rdi
	leaq	0(%rbp,%rax,4), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	addl	$1, %eax
	cmpl	n(%rip), %eax
	movl	%eax, i(%rip)
	jl	.L39
.L38:
	xorl	%eax, %eax
	call	solve
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L43:
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.globl	b
	.bss
	.align 32
	.type	b, @object
	.size	b, 400000
b:
	.zero	400000
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400000
a:
	.zero	400000
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.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:

#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define S_MAX 200000
#define N_MAX 100000
#define M_MAX 100000
#define INF 10000000
#define MOD 1000000007
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;
typedef   signed long long dll;

int n, m;
int h, w;
int i, j, k;

int a[N_MAX];
int b[N_MAX];

typedef struct {
	int in;
	int out;
} twoway;

void solve(){
	int lastindex = -1;
	int leftestcol;

	int result = 0;

	if (n == 1) printf("%d\n", a[0] ^ 1);
	for (i = 0; i < (n >> 1); i++) {
		if (lastindex == -1) {
			lastindex++;
			b[lastindex] = 1;
			leftestcol = a[1];
		} else if ((lastindex & 1) ^ leftestcol == a[(i << 1) + 1]) {

			b[lastindex]++;
		} else if (a[i << 1] == a[(i << 1) + 1]) {
			lastindex++;
			b[lastindex] = 1;
		} else if (lastindex) {
			b[lastindex - 1] += b[lastindex];
			b[lastindex - 1]++;
			lastindex--;
		} else {
			b[0]++;
			leftestcol ^= 1;
		}

		// for (j = 0; j <= lastindex; j++) printf("%dx%d, ", (lastindex & 1) ^ leftestcol, b[j]);
		// 	putchar('\n');
	}

	for (i = leftestcol; i <= lastindex; i += 2) {
		result += b[i];
	}

	result *= 2;
	if (n & 1) result += (a[n-1] ^ 1);

	printf("%d\n", result);

	return;
}

int main (void) {
	while (scanf("%d", &n), n) {
		for (i = 0; i < n; i++) scanf("%d", &a[i]);
		solve();
	}
	return 0;
}
8
1
1
1
1
0
0
0
0
8
1
0
1
1
0
0
0
1
0
 8
1
1
1
1
0
0
0
0
8
1
0
0
1
0
0
0
1
0
 8
1
0
1
1
0
0
0
0
4
1
0
1
1
0
0
0
1
0
 8
1
0
1
1
0
0
0
0
2
1
0
1
1
0
0
-1
1
0
 8
0
0
1
1
0
0
0
0
2
1
0
2
1
0
0
-1
1
0
 8
1
1
1
1
0
0
0
0
8
1
0
1
1
0
0
1
1
0
 8
1
0
1
1
0
0
-1
0
8
1
0
0
1
0
0
0
1
0
 8
1
1
2
1
0
0
0
0
1
0
0
1
1
0
0
0
1
0
 8
0
0
1
1
0
0
0
0
3
1
0
1
1
0
0
-1
1
0
 8
1
1
1
1
1
0
0
0
8
1
0
1
1
0
0
1
1
0

4
2
 4
0
 6
2
 6
2
0
0
 6
2
2
 4
4
 6
0
 4
1
1
 6
2
1
1
 8
4

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

#define S_MAX 200000
#define N_MAX 100000
#define M_MAX 100000
#define INF 10000000
#define MOD 1000000007
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;
typedef   signed long long dll;

int n, m;
int h, w;
int i, j, k;

int a[N_MAX];
int b[N_MAX];

typedef struct {
	int in;
	int out;
} twoway;

void solve(){
	int lastindex = -1;
	int leftestcol;

	int result = 0;

	if (n == 1) printf("%d\n", a[0] ^ 1);
	for (i = 0; i < (n >> 1); i++) {
		if (lastindex == -1) {
			lastindex++;
			b[lastindex] = 1;
			leftestcol = a[1];
		} else if ((lastindex & 1) ^ leftestcol == a[(i << 1) + 1]) {

			b[lastindex]++;
		} else if (a[i << 1] == a[(i << 1) + 1]) {
			lastindex++;
			b[lastindex] = 1;
		} else if (lastindex) {
			b[lastindex - 1] += b[lastindex];
			b[lastindex - 1]++;
			lastindex--;
		} else {
			b[0]++;
			leftestcol ^= 1;
		}

		// for (j = 0; j <= lastindex; j++) printf("%dx%d, ", (lastindex & 1) ^ leftestcol, b[j]);
		// 	putchar('\n');
	}

	for (i = leftestcol; i <= lastindex; i += 2) {
		result += b[i];
	}

	result *= 2;
	if (n & 1) result += (a[n-1] ^ 1);

	printf("%d\n", result);

	return;
}

int main (void) {
	while (scanf("%d", &n), n) {
		for (i = 0; i < n; i++) scanf("%d", &a[i]);
		solve();
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400000
a:
	.zero	400000
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400000
b:
	.zero	400000
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB0:
	.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	$-1, -12(%rbp)
	movl	$0, -4(%rbp)
	movl	n(%rip), %eax
	cmpl	$1, %eax
	jne	.L2
	movl	a(%rip), %eax
	xorl	$1, %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	movl	$0, i(%rip)
	jmp	.L3
.L9:
	cmpl	$-1, -12(%rbp)
	jne	.L4
	addl	$1, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	4+a(%rip), %eax
	movl	%eax, -8(%rbp)
	jmp	.L5
.L4:
	movl	-12(%rbp), %eax
	andl	$1, %eax
	movl	i(%rip), %edx
	addl	%edx, %edx
	addl	$1, %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	cmpl	%edx, -8(%rbp)
	sete	%dl
	xorl	%edx, %eax
	testb	%al, %al
	je	.L6
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L5
.L6:
	movl	i(%rip), %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L7
	addl	$1, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	$1, (%rdx,%rax)
	jmp	.L5
.L7:
	cmpl	$0, -12(%rbp)
	je	.L8
	movl	-12(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-12(%rbp), %eax
	subl	$1, %eax
	addl	%edx, %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-12(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	b(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	subl	$1, -12(%rbp)
	jmp	.L5
.L8:
	movl	b(%rip), %eax
	addl	$1, %eax
	movl	%eax, b(%rip)
	xorl	$1, -8(%rbp)
.L5:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L3:
	movl	n(%rip), %eax
	sarl	%eax
	movl	%eax, %edx
	movl	i(%rip), %eax
	cmpl	%eax, %edx
	jg	.L9
	movl	-8(%rbp), %eax
	movl	%eax, i(%rip)
	jmp	.L10
.L11:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -4(%rbp)
	movl	i(%rip), %eax
	addl	$2, %eax
	movl	%eax, i(%rip)
.L10:
	movl	i(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L11
	sall	-4(%rbp)
	movl	n(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L12
	movl	n(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	xorl	$1, %eax
	addl	%eax, -4(%rbp)
.L12:
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	solve, .-solve
	.section	.rodata
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	jmp	.L15
.L18:
	movl	$0, i(%rip)
	jmp	.L16
.L17:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L16:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L17
	movl	$0, %eax
	call	solve
.L15:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L18
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	h
	.align 4
	.type	h, @object
	.size	h, 4
h:
	.zero	4
	.globl	w
	.align 4
	.type	w, @object
	.size	w, 4
w:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400000
a:
	.zero	400000
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400000
b:
	.zero	400000
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB0:
	.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	$-1, -12(%rbp)
	movl	$0, -4(%rbp)
	movl	n(%rip), %eax
	cmpl	$1, %eax
	jne	.L2
	movl	a(%rip), %eax
	xorl	$1, %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	movl	$0, i(%rip)
	jmp	.L3
.L9:
	cmpl	$-1, -12(%rbp)
	jne	.L4
	addl	$1, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	4+a(%rip), %eax
	movl	%eax, -8(%rbp)
	jmp	.L5
.L4:
	movl	-12(%rbp), %eax
	andl	$1, %eax
	movl	i(%rip), %edx
	addl	%edx, %edx
	addl	$1, %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	cmpl	%edx, -8(%rbp)
	sete	%dl
	xorl	%edx, %eax
	testb	%al, %al
	je	.L6
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L5
.L6:
	movl	i(%rip), %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jne	.L7
	addl	$1, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	$1, (%rdx,%rax)
	jmp	.L5
.L7:
	cmpl	$0, -12(%rbp)
	je	.L8
	movl	-12(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-12(%rbp), %eax
	subl	$1, %eax
	addl	%edx, %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-12(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	b(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	subl	$1, -12(%rbp)
	jmp	.L5
.L8:
	movl	b(%rip), %eax
	addl	$1, %eax
	movl	%eax, b(%rip)
	xorl	$1, -8(%rbp)
.L5:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L3:
	movl	n(%rip), %eax
	sarl	%eax
	movl	%eax, %edx
	movl	i(%rip), %eax
	cmpl	%eax, %edx
	jg	.L9
	movl	-8(%rbp), %eax
	movl	%eax, i(%rip)
	jmp	.L10
.L11:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -4(%rbp)
	movl	i(%rip), %eax
	addl	$2, %eax
	movl	%eax, i(%rip)
.L10:
	movl	i(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L11
	sall	-4(%rbp)
	movl	n(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L12
	movl	n(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	xorl	$1, %eax
	addl	%eax, -4(%rbp)
.L12:
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	solve, .-solve
	.section	.rodata
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	jmp	.L15
.L18:
	movl	$0, i(%rip)
	jmp	.L16
.L17:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L16:
	movl	i(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jl	.L17
	movl	$0, %eax
	call	solve
.L15:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L18
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
