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

```c
#include <stdio.h>
#include <string.h>


int main(void) {
    int n, i, c;
    int stk[100001], si, last_color, total;

    while (scanf("%d", &n) == 1 && n) {
        memset(stk + 1, 0, n * sizeof(int));
        scanf("%d", &c);
        si = 1;
        stk[si] = 1;
        last_color = c;
        for (i = 2; i <= n; i++) {
            scanf("%d", &c);
            if (i&1) {
                stk[si += last_color != c]++;
            }
            else {
                if (last_color != c && si > 1) {
                    stk[si-1] += stk[si];
                    stk[si] = 0;
                    si--;
                }
                stk[si]++;
            }
            last_color = c;
        }
        for (i = si - (last_color != 0), total = 0;
             i > 0; i -= 2) {
            total += stk[i];
        }
        printf("%d\n", total);
    }

    return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397368
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2728, %rsp
	.cfi_def_cfa_offset 400096
	leaq	.LC0(%rip), %r12
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, %ebx
	cmpl	$1, %eax
	jne	.L10
	movslq	8(%rsp), %rdx
	testl	%edx, %edx
	je	.L10
	salq	$2, %rdx
	xorl	%esi, %esi
	leaq	20(%rsp), %rdi
	movl	$400000, %ecx
	call	__memset_chk@PLT
	leaq	12(%rsp), %r15
	xorl	%eax, %eax
	movq	%r12, %rdi
	movq	%r15, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$1, 8(%rsp)
	movl	12(%rsp), %r14d
	movl	$1, 20(%rsp)
	jle	.L3
	movl	$2, %ebp
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L23:
	xorl	%edx, %edx
	cmpl	%r14d, %eax
	movl	%eax, %r14d
	setne	%dl
	addl	$1, %ebp
	addl	%edx, %ebx
	movslq	%ebx, %rdx
	addl	$1, 16(%rsp,%rdx,4)
	cmpl	%ebp, 8(%rsp)
	jl	.L3
.L7:
	movq	%r15, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testb	$1, %bpl
	jne	.L23
	cmpl	%r14d, %eax
	je	.L6
	cmpl	$1, %ebx
	je	.L6
	leal	-1(%rbx), %edx
	movslq	%ebx, %rbx
	movslq	%edx, %rcx
	movl	16(%rsp,%rbx,4), %esi
	addl	%esi, 16(%rsp,%rcx,4)
	movl	$0, 16(%rsp,%rbx,4)
	movl	%edx, %ebx
.L6:
	movslq	%ebx, %rdx
	movl	%eax, %r14d
	addl	$1, %ebp
	addl	$1, 16(%rsp,%rdx,4)
	cmpl	%ebp, 8(%rsp)
	jge	.L7
.L3:
	cmpl	$1, %r14d
	adcl	$-1, %ebx
	movl	%ebx, %edx
	testl	%ebx, %ebx
	je	.L8
	movslq	%ebx, %rcx
	subl	$1, %edx
	salq	$2, %rcx
	shrl	%edx
	salq	$3, %rdx
	leaq	16(%rsp,%rcx), %rax
	addq	%r13, %rcx
	subq	%rdx, %rcx
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L9:
	addl	(%rax), %edx
	subq	$8, %rax
	cmpq	%rcx, %rax
	jne	.L9
.L8:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L10:
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L24
	addq	$400040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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
.L24:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397368
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2728, %rsp
	.cfi_def_cfa_offset 400096
	leaq	.LC0(%rip), %r12
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, %ebx
	cmpl	$1, %eax
	jne	.L10
	movslq	8(%rsp), %rdx
	testl	%edx, %edx
	je	.L10
	salq	$2, %rdx
	xorl	%esi, %esi
	leaq	20(%rsp), %rdi
	movl	$400000, %ecx
	call	__memset_chk@PLT
	leaq	12(%rsp), %r15
	xorl	%eax, %eax
	movq	%r12, %rdi
	movq	%r15, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$1, 8(%rsp)
	movl	12(%rsp), %r14d
	movl	$1, 20(%rsp)
	jle	.L3
	movl	$2, %ebp
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L23:
	xorl	%edx, %edx
	cmpl	%r14d, %eax
	movl	%eax, %r14d
	setne	%dl
	addl	$1, %ebp
	addl	%edx, %ebx
	movslq	%ebx, %rdx
	addl	$1, 16(%rsp,%rdx,4)
	cmpl	%ebp, 8(%rsp)
	jl	.L3
.L7:
	movq	%r15, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testb	$1, %bpl
	jne	.L23
	cmpl	%r14d, %eax
	je	.L6
	cmpl	$1, %ebx
	je	.L6
	leal	-1(%rbx), %edx
	movslq	%ebx, %rbx
	movslq	%edx, %rcx
	movl	16(%rsp,%rbx,4), %esi
	addl	%esi, 16(%rsp,%rcx,4)
	movl	$0, 16(%rsp,%rbx,4)
	movl	%edx, %ebx
.L6:
	movslq	%ebx, %rdx
	movl	%eax, %r14d
	addl	$1, %ebp
	addl	$1, 16(%rsp,%rdx,4)
	cmpl	%ebp, 8(%rsp)
	jge	.L7
.L3:
	cmpl	$1, %r14d
	adcl	$-1, %ebx
	movl	%ebx, %edx
	testl	%ebx, %ebx
	je	.L8
	movslq	%ebx, %rcx
	subl	$1, %edx
	salq	$2, %rcx
	shrl	%edx
	salq	$3, %rdx
	leaq	16(%rsp,%rcx), %rax
	addq	%r13, %rcx
	subq	%rdx, %rcx
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L9:
	addl	(%rax), %edx
	subq	$8, %rax
	cmpq	%rcx, %rax
	jne	.L9
.L8:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L10:
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L24
	addq	$400040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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
.L24:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397368
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2728, %rsp
	.cfi_def_cfa_offset 400096
	leaq	.LC0(%rip), %r12
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, %ebx
	cmpl	$1, %eax
	jne	.L10
	movslq	8(%rsp), %rdx
	testl	%edx, %edx
	je	.L10
	salq	$2, %rdx
	xorl	%esi, %esi
	leaq	20(%rsp), %rdi
	movl	$400000, %ecx
	call	__memset_chk@PLT
	leaq	12(%rsp), %r15
	xorl	%eax, %eax
	movq	%r12, %rdi
	movq	%r15, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$1, 8(%rsp)
	movl	12(%rsp), %r14d
	movl	$1, 20(%rsp)
	jle	.L3
	movl	$2, %ebp
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L23:
	xorl	%edx, %edx
	cmpl	%r14d, %eax
	movl	%eax, %r14d
	setne	%dl
	addl	$1, %ebp
	addl	%edx, %ebx
	movslq	%ebx, %rdx
	addl	$1, 16(%rsp,%rdx,4)
	cmpl	%ebp, 8(%rsp)
	jl	.L3
.L7:
	movq	%r15, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testb	$1, %bpl
	jne	.L23
	cmpl	%r14d, %eax
	je	.L6
	cmpl	$1, %ebx
	je	.L6
	leal	-1(%rbx), %edx
	movslq	%ebx, %rbx
	movslq	%edx, %rcx
	movl	16(%rsp,%rbx,4), %esi
	addl	%esi, 16(%rsp,%rcx,4)
	movl	$0, 16(%rsp,%rbx,4)
	movl	%edx, %ebx
.L6:
	movslq	%ebx, %rdx
	movl	%eax, %r14d
	addl	$1, %ebp
	addl	$1, 16(%rsp,%rdx,4)
	cmpl	%ebp, 8(%rsp)
	jge	.L7
.L3:
	cmpl	$1, %r14d
	adcl	$-1, %ebx
	movl	%ebx, %edx
	testl	%ebx, %ebx
	je	.L8
	movslq	%ebx, %rcx
	subl	$1, %edx
	salq	$2, %rcx
	shrl	%edx
	salq	$3, %rdx
	leaq	16(%rsp,%rcx), %rax
	addq	%r13, %rcx
	subq	%rdx, %rcx
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L9:
	addl	(%rax), %edx
	subq	$8, %rax
	cmpq	%rcx, %rax
	jne	.L9
.L8:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L10:
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L24
	addq	$400040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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
.L24:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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:
```
```c
#include <stdio.h>
#include <string.h>


int main(void) {
    int n, i, c;
    int stk[100001], si, last_color, total;

    while (scanf("%d", &n) == 1 && n) {
        memset(stk + 1, 0, n * sizeof(int));
        scanf("%d", &c);
        si = 1;
        stk[si] = 1;
        last_color = c;
        for (i = 2; i <= n; i++) {
            scanf("%d", &c);
            if (i&1) {
                stk[si += last_color != c]++;
            }
            else {
                if (last_color != c && si > 1) {
                    stk[si-1] += stk[si];
                    stk[si] = 0;
                    si--;
                }
                stk[si]++;
            }
            last_color = c;
        }
        for (i = si - (last_color != 0), total = 0;
             i > 0; i -= 2) {
            total += stk[i];
        }
        printf("%d\n", total);
    }

    return 0;
}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <string.h>


int main(void) {
    int n, i, c;
    int stk[100001], si, last_color, total;

    while (scanf("%d", &n) == 1 && n) {
        memset(stk + 1, 0, n * sizeof(int));
        scanf("%d", &c);
        si = 1;
        stk[si] = 1;
        last_color = c;
        for (i = 2; i <= n; i++) {
            scanf("%d", &c);
            if (i&1) {
                stk[si += last_color != c]++;
            }
            else {
                if (last_color != c && si > 1) {
                    stk[si-1] += stk[si];
                    stk[si] = 0;
                    si--;
                }
                stk[si]++;
            }
            last_color = c;
        }
        for (i = si - (last_color != 0), total = 0;
             i > 0; i -= 2) {
            total += stk[i];
        }
        printf("%d\n", total);
    }

    return 0;
}```

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.
Optimized Assembly Code:

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
 6
2
2
 4
4
 6
0
 4
1
 6
2
1
 8
4

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

```c
#include <stdio.h>
#include <string.h>


int main(void) {
    int n, i, c;
    int stk[100001], si, last_color, total;

    while (scanf("%d", &n) == 1 && n) {
        memset(stk + 1, 0, n * sizeof(int));
        scanf("%d", &c);
        si = 1;
        stk[si] = 1;
        last_color = c;
        for (i = 2; i <= n; i++) {
            scanf("%d", &c);
            if (i&1) {
                stk[si += last_color != c]++;
            }
            else {
                if (last_color != c && si > 1) {
                    stk[si-1] += stk[si];
                    stk[si] = 0;
                    si--;
                }
                stk[si]++;
            }
            last_color = c;
        }
        for (i = si - (last_color != 0), total = 0;
             i > 0; i -= 2) {
            total += stk[i];
        }
        printf("%d\n", total);
    }

    return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397368
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2728, %rsp
	.cfi_def_cfa_offset 400096
	leaq	.LC0(%rip), %r12
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, %ebx
	cmpl	$1, %eax
	jne	.L10
	movslq	8(%rsp), %rdx
	testl	%edx, %edx
	je	.L10
	salq	$2, %rdx
	xorl	%esi, %esi
	leaq	20(%rsp), %rdi
	movl	$400000, %ecx
	call	__memset_chk@PLT
	leaq	12(%rsp), %r15
	xorl	%eax, %eax
	movq	%r12, %rdi
	movq	%r15, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$1, 8(%rsp)
	movl	12(%rsp), %r14d
	movl	$1, 20(%rsp)
	jle	.L3
	movl	$2, %ebp
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L23:
	xorl	%edx, %edx
	cmpl	%r14d, %eax
	movl	%eax, %r14d
	setne	%dl
	addl	$1, %ebp
	addl	%edx, %ebx
	movslq	%ebx, %rdx
	addl	$1, 16(%rsp,%rdx,4)
	cmpl	%ebp, 8(%rsp)
	jl	.L3
.L7:
	movq	%r15, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testb	$1, %bpl
	jne	.L23
	cmpl	%r14d, %eax
	je	.L6
	cmpl	$1, %ebx
	je	.L6
	leal	-1(%rbx), %edx
	movslq	%ebx, %rbx
	movslq	%edx, %rcx
	movl	16(%rsp,%rbx,4), %esi
	addl	%esi, 16(%rsp,%rcx,4)
	movl	$0, 16(%rsp,%rbx,4)
	movl	%edx, %ebx
.L6:
	movslq	%ebx, %rdx
	movl	%eax, %r14d
	addl	$1, %ebp
	addl	$1, 16(%rsp,%rdx,4)
	cmpl	%ebp, 8(%rsp)
	jge	.L7
.L3:
	cmpl	$1, %r14d
	adcl	$-1, %ebx
	movl	%ebx, %edx
	testl	%ebx, %ebx
	je	.L8
	movslq	%ebx, %rcx
	subl	$1, %edx
	salq	$2, %rcx
	shrl	%edx
	salq	$3, %rdx
	leaq	16(%rsp,%rcx), %rax
	addq	%r13, %rcx
	subq	%rdx, %rcx
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L9:
	addl	(%rax), %edx
	subq	$8, %rax
	cmpq	%rcx, %rax
	jne	.L9
.L8:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L10:
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L24
	addq	$400040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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
.L24:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397368
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2728, %rsp
	.cfi_def_cfa_offset 400096
	leaq	.LC0(%rip), %r12
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, %ebx
	cmpl	$1, %eax
	jne	.L10
	movslq	8(%rsp), %rdx
	testl	%edx, %edx
	je	.L10
	salq	$2, %rdx
	xorl	%esi, %esi
	leaq	20(%rsp), %rdi
	movl	$400000, %ecx
	call	__memset_chk@PLT
	leaq	12(%rsp), %r15
	xorl	%eax, %eax
	movq	%r12, %rdi
	movq	%r15, %rsi
	call	__isoc99_scanf@PLT
	cmpl	$1, 8(%rsp)
	movl	12(%rsp), %r14d
	movl	$1, 20(%rsp)
	jle	.L3
	movl	$2, %ebp
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L23:
	xorl	%edx, %edx
	cmpl	%r14d, %eax
	movl	%eax, %r14d
	setne	%dl
	addl	$1, %ebp
	addl	%edx, %ebx
	movslq	%ebx, %rdx
	addl	$1, 16(%rsp,%rdx,4)
	cmpl	%ebp, 8(%rsp)
	jl	.L3
.L7:
	movq	%r15, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testb	$1, %bpl
	jne	.L23
	cmpl	%r14d, %eax
	je	.L6
	cmpl	$1, %ebx
	je	.L6
	leal	-1(%rbx), %edx
	movslq	%ebx, %rbx
	movslq	%edx, %rcx
	movl	16(%rsp,%rbx,4), %esi
	addl	%esi, 16(%rsp,%rcx,4)
	movl	$0, 16(%rsp,%rbx,4)
	movl	%edx, %ebx
.L6:
	movslq	%ebx, %rdx
	movl	%eax, %r14d
	addl	$1, %ebp
	addl	$1, 16(%rsp,%rdx,4)
	cmpl	%ebp, 8(%rsp)
	jge	.L7
.L3:
	cmpl	$1, %r14d
	adcl	$-1, %ebx
	movl	%ebx, %edx
	testl	%ebx, %ebx
	je	.L8
	movslq	%ebx, %rcx
	subl	$1, %edx
	salq	$2, %rcx
	shrl	%edx
	salq	$3, %rdx
	leaq	16(%rsp,%rcx), %rax
	addq	%r13, %rcx
	subq	%rdx, %rcx
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L9:
	addl	(%rax), %edx
	subq	$8, %rax
	cmpq	%rcx, %rax
	jne	.L9
.L8:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L10:
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L24
	addq	$400040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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
.L24:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.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:
```