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>

int main(void){
    int N;
    scanf("%d", &N);
    char S[N+1];
    scanf("%s", S);

    int max = N;
    int ans = max;

    int idx;
    int i;
    int flag = 1;

    for(i = 0; i < N-1; i++){
        if(S[i] != S[i+1]){flag = 0; break;}
    }
    

    //これだと(2*10^5)^2で10^10以上で間に合わなさそうなので
    //累積和を使ってO(n)チックにしたい
    /*for(idx = 1; idx <= N-1; idx++){
        for(i = 0; i < idx; i++){if(S[i] == '#')left++;}
        for(i = idx; i < N; i++){if(S[i] == '.')right++;}
        if(ans > (left+right)){ans = left+right;}
        left = 0;
        right = 0;
    }*/

    int lc[N+1];
    lc[0] = 0;
    for(idx = 0; idx < N; idx++){
        if(S[idx] == '#'){lc[idx+1] = lc[idx] + 1;}
        //これ（真下）がないと、何も代入されてない要素ができてしまう
        else{lc[idx+1] = lc[idx];}
        //printf("idx+1:%d, lc[%d]:%d\n", idx+1, idx+1, lc[idx+1]);
    }
    int rc[N+1];
    rc[N] = 0;
    for(idx = N-1; idx >= 0; idx--){
        if(S[idx] == '.'){rc[idx] = rc[idx+1] + 1;}
        else{rc[idx] = rc[idx+1];}
        //printf("idx1:%d, rc[%d]:%d\n", idx, idx, rc[idx]);
    }

    for(i = 0; i < N+1; i++){
        if(ans > lc[i] + rc[i]){ans = lc[i] + rc[i];}
    }
    
    if(flag == 1){printf("0\n");}
    else{printf("%d\n", ans);}
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"0"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$152, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-128(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-128(%rbp), %eax
	leal	1(%rax), %edx
	movslq	%edx, %rax
	subq	$1, %rax
	movq	%rax, -104(%rbp)
	movslq	%edx, %rax
	movq	%rax, -144(%rbp)
	movq	$0, -136(%rbp)
	movslq	%edx, %rax
	movq	%rax, -160(%rbp)
	movq	$0, -152(%rbp)
	movslq	%edx, %rax
	movl	$16, %edx
	subq	$1, %rdx
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$0, %rax
	movq	%rax, -96(%rbp)
	movq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-128(%rbp), %eax
	movl	%eax, -108(%rbp)
	movl	-108(%rbp), %eax
	movl	%eax, -124(%rbp)
	movl	$1, -112(%rbp)
	movl	$0, -116(%rbp)
	jmp	.L5
.L8:
	movq	-96(%rbp), %rdx
	movl	-116(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movl	-116(%rbp), %eax
	addl	$1, %eax
	movq	-96(%rbp), %rdx
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	je	.L6
	movl	$0, -112(%rbp)
	jmp	.L7
.L6:
	addl	$1, -116(%rbp)
.L5:
	movl	-128(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -116(%rbp)
	jl	.L8
.L7:
	movl	-128(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -88(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -176(%rbp)
	movq	$0, -168(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -192(%rbp)
	movq	$0, -184(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L9:
	cmpq	%rdx, %rsp
	je	.L10
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L9
.L10:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L11
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L11:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -80(%rbp)
	movq	-80(%rbp), %rax
	movl	$0, (%rax)
	movl	$0, -120(%rbp)
	jmp	.L12
.L15:
	movq	-96(%rbp), %rdx
	movl	-120(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$35, %al
	jne	.L13
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	movl	-120(%rbp), %edx
	addl	$1, %edx
	leal	1(%rax), %ecx
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	jmp	.L14
.L13:
	movl	-120(%rbp), %eax
	leal	1(%rax), %esi
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-80(%rbp), %rax
	movslq	%esi, %rdx
	movl	%ecx, (%rax,%rdx,4)
.L14:
	addl	$1, -120(%rbp)
.L12:
	movl	-128(%rbp), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L15
	movl	-128(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L16:
	cmpq	%rdx, %rsp
	je	.L17
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L16
.L17:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L18
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L18:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	-128(%rbp), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	$0, (%rax,%rdx,4)
	movl	-128(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -120(%rbp)
	jmp	.L19
.L22:
	movq	-96(%rbp), %rdx
	movl	-120(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$46, %al
	jne	.L20
	movl	-120(%rbp), %eax
	leal	1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	leal	1(%rax), %ecx
	movq	-64(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	jmp	.L21
.L20:
	movl	-120(%rbp), %eax
	leal	1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
.L21:
	subl	$1, -120(%rbp)
.L19:
	cmpl	$0, -120(%rbp)
	jns	.L22
	movl	$0, -116(%rbp)
	jmp	.L23
.L25:
	movq	-80(%rbp), %rax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%ecx, %eax
	cmpl	%eax, -124(%rbp)
	jle	.L24
	movq	-80(%rbp), %rax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%ecx, %eax
	movl	%eax, -124(%rbp)
.L24:
	addl	$1, -116(%rbp)
.L23:
	movl	-128(%rbp), %eax
	cmpl	%eax, -116(%rbp)
	jle	.L25
	cmpl	$1, -112(%rbp)
	jne	.L26
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L27
.L26:
	movl	-124(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L27:
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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"
.LC1:
	.string	"%s"
.LC2:
	.string	"0"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	leaq	-28(%rbp), %rsi
	subq	$24, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	movq	%rsp, %rcx
	addl	$1, %eax
	cltq
	addq	$15, %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L74:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L74
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L75
.L4:
	movq	%rsp, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movq	%rsp, %rbx
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %r8d
	xorl	%edx, %edx
	leal	-1(%r8), %eax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L7:
	movzbl	(%rbx,%rdx), %ecx
	addq	$1, %rdx
	cmpb	(%rbx,%rdx), %cl
	jne	.L6
.L5:
	cmpl	%edx, %eax
	jg	.L7
	leal	1(%r8), %edx
	movq	%rsp, %rcx
	movslq	%edx, %rdx
	leaq	15(,%rdx,4), %r9
	movq	%r9, %rsi
	movq	%r9, %rdx
	andq	$-4096, %rsi
	andq	$-16, %rdx
	subq	%rsi, %rcx
.L8:
	cmpq	%rcx, %rsp
	je	.L9
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L8
.L6:
	leal	1(%r8), %edx
	movq	%rsp, %rcx
	movslq	%edx, %rdx
	leaq	15(,%rdx,4), %r9
	movq	%r9, %rsi
	movq	%r9, %rdx
	andq	$-4096, %rsi
	andq	$-16, %rdx
	subq	%rsi, %rcx
.L39:
	cmpq	%rcx, %rsp
	je	.L40
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L39
.L75:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L9:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L10
	orq	$0, -8(%rsp,%rdx)
.L10:
	leaq	3(%rsp), %rsi
	movq	%rsi, %rdx
	andq	$-4, %rsi
	shrq	$2, %rdx
	movl	$0, 0(,%rdx,4)
	testl	%r8d, %r8d
	jle	.L11
	movl	$1, %r10d
.L42:
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L13:
	xorl	%edi, %edi
	cmpb	$35, (%rbx,%rdx)
	sete	%dil
	addl	%edi, %ecx
	movl	%ecx, 4(%rsi,%rdx,4)
	addq	$1, %rdx
	cmpl	%edx, %r8d
	jg	.L13
	movq	%r9, %rdx
	movq	%rsp, %rcx
	andq	$-4096, %r9
	andq	$-16, %rdx
	subq	%r9, %rcx
.L30:
	cmpq	%rcx, %rsp
	je	.L31
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L30
.L31:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L32
	orq	$0, -8(%rsp,%rdx)
.L32:
	movq	%rsp, %rdx
	movslq	%r8d, %rcx
	movl	$0, (%rdx,%rcx,4)
	testl	%eax, %eax
	js	.L34
.L38:
	cltq
	.p2align 4,,10
	.p2align 3
.L22:
	cmpb	$46, (%rbx,%rax)
	je	.L76
	movl	4(%rdx,%rax,4), %ecx
	movl	%ecx, (%rdx,%rax,4)
	subq	$1, %rax
	testl	%eax, %eax
	jns	.L22
.L21:
	testl	%r8d, %r8d
	js	.L46
.L34:
	xorl	%edi, %edi
	testl	%r8d, %r8d
	cmovns	%r8d, %edi
	addl	$1, %edi
	cmpl	$2, %r8d
	jle	.L47
	movl	%edi, %ecx
	movd	%r8d, %xmm4
	xorl	%eax, %eax
	shrl	$2, %ecx
	pshufd	$0, %xmm4, %xmm0
	salq	$4, %rcx
	.p2align 4,,10
	.p2align 3
.L26:
	movdqu	(%rsi,%rax), %xmm2
	movdqu	(%rdx,%rax), %xmm3
	addq	$16, %rax
	paddd	%xmm3, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm1, %xmm0
	cmpq	%rcx, %rax
	jne	.L26
	movdqa	%xmm0, %xmm2
	movl	%edi, %r11d
	psrldq	$8, %xmm2
	andl	$-4, %r11d
	andl	$3, %edi
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm1, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm0, %xmm1
	movd	%xmm1, %r9d
	je	.L25
.L23:
	movslq	%r11d, %rax
	salq	$2, %rax
	addq	%rax, %rsi
	addq	%rdx, %rax
	leal	1(%r11), %edx
	movl	(%rax), %ecx
	addl	(%rsi), %ecx
	cmpl	%ecx, %r9d
	cmovg	%ecx, %r9d
	cmpl	%r8d, %edx
	jg	.L25
	movl	4(%rax), %ecx
	addl	4(%rsi), %ecx
	leal	2(%r11), %edx
	cmpl	%ecx, %r9d
	cmovg	%ecx, %r9d
	cmpl	%edx, %r8d
	jl	.L25
	movl	8(%rax), %eax
	addl	8(%rsi), %eax
	cmpl	%eax, %r9d
	cmovg	%eax, %r9d
.L25:
	cmpl	$1, %r10d
	je	.L24
	movl	%r9d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L29:
	movq	-24(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L77
	movq	-8(%rbp), %rbx
	xorl	%eax, %eax
	leave
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L76:
	.cfi_restore_state
	movl	4(%rdx,%rax,4), %edi
	leal	1(%rdi), %ecx
	movl	%ecx, (%rdx,%rax,4)
	subq	$1, %rax
	testl	%eax, %eax
	jns	.L22
	jmp	.L21
.L24:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L29
.L40:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L41
	orq	$0, -8(%rsp,%rdx)
.L41:
	leaq	3(%rsp), %rsi
	xorl	%r10d, %r10d
	movq	%rsi, %rdx
	andq	$-4, %rsi
	shrq	$2, %rdx
	movl	$0, 0(,%rdx,4)
	testl	%r8d, %r8d
	jg	.L42
	movq	%r9, %rdx
	movq	%rsp, %rcx
	andq	$-4096, %r9
	andq	$-16, %rdx
	subq	%r9, %rcx
.L35:
	cmpq	%rcx, %rsp
	je	.L36
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L35
.L46:
	movl	%r8d, %r9d
	jmp	.L25
.L47:
	movl	%r8d, %r9d
	xorl	%r11d, %r11d
	jmp	.L23
.L11:
	movq	%r9, %rcx
	movq	%rsp, %rdx
	andq	$-4096, %r9
	andq	$-16, %rcx
	subq	%r9, %rdx
.L15:
	cmpq	%rdx, %rsp
	je	.L16
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L15
.L16:
	andl	$4095, %ecx
	subq	%rcx, %rsp
	testq	%rcx, %rcx
	je	.L17
	orq	$0, -8(%rsp,%rcx)
.L17:
	movq	%rsp, %rdx
	movslq	%r8d, %rcx
	movl	$0, (%rdx,%rcx,4)
	testl	%eax, %eax
	js	.L18
	movl	$1, %r10d
	jmp	.L38
.L36:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L37
	orq	$0, -8(%rsp,%rdx)
.L37:
	movq	%rsp, %rdx
	movslq	%r8d, %rcx
	xorl	%r10d, %r10d
	movl	$0, (%rdx,%rcx,4)
	jmp	.L38
.L18:
	testl	%r8d, %r8d
	jne	.L24
	xorl	%r11d, %r11d
	xorl	%r9d, %r9d
	movl	$1, %r10d
	jmp	.L23
.L77:
	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
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"0"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	leaq	-28(%rbp), %rsi
	subq	$24, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	movq	%rsp, %rcx
	addl	$1, %eax
	cltq
	addq	$15, %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L74:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L74
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L75
.L4:
	movq	%rsp, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movq	%rsp, %rbx
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %r8d
	xorl	%edx, %edx
	leal	-1(%r8), %eax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L7:
	movzbl	(%rbx,%rdx), %ecx
	addq	$1, %rdx
	cmpb	(%rbx,%rdx), %cl
	jne	.L6
.L5:
	cmpl	%edx, %eax
	jg	.L7
	leal	1(%r8), %edx
	movq	%rsp, %rcx
	movslq	%edx, %rdx
	leaq	15(,%rdx,4), %r9
	movq	%r9, %rsi
	movq	%r9, %rdx
	andq	$-4096, %rsi
	andq	$-16, %rdx
	subq	%rsi, %rcx
.L8:
	cmpq	%rcx, %rsp
	je	.L9
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L8
.L6:
	leal	1(%r8), %edx
	movq	%rsp, %rcx
	movslq	%edx, %rdx
	leaq	15(,%rdx,4), %r9
	movq	%r9, %rsi
	movq	%r9, %rdx
	andq	$-4096, %rsi
	andq	$-16, %rdx
	subq	%rsi, %rcx
.L39:
	cmpq	%rcx, %rsp
	je	.L40
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L39
.L75:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L9:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L10
	orq	$0, -8(%rsp,%rdx)
.L10:
	leaq	3(%rsp), %rsi
	movq	%rsi, %rdx
	andq	$-4, %rsi
	shrq	$2, %rdx
	movl	$0, 0(,%rdx,4)
	testl	%r8d, %r8d
	jle	.L11
	movl	$1, %r10d
.L42:
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L13:
	xorl	%edi, %edi
	cmpb	$35, (%rbx,%rdx)
	sete	%dil
	addl	%edi, %ecx
	movl	%ecx, 4(%rsi,%rdx,4)
	addq	$1, %rdx
	cmpl	%edx, %r8d
	jg	.L13
	movq	%r9, %rdx
	movq	%rsp, %rcx
	andq	$-4096, %r9
	andq	$-16, %rdx
	subq	%r9, %rcx
.L30:
	cmpq	%rcx, %rsp
	je	.L31
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L30
.L31:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L32
	orq	$0, -8(%rsp,%rdx)
.L32:
	movq	%rsp, %rdx
	movslq	%r8d, %rcx
	movl	$0, (%rdx,%rcx,4)
	testl	%eax, %eax
	js	.L34
.L38:
	cltq
	.p2align 4,,10
	.p2align 3
.L22:
	cmpb	$46, (%rbx,%rax)
	je	.L76
	movl	4(%rdx,%rax,4), %ecx
	movl	%ecx, (%rdx,%rax,4)
	subq	$1, %rax
	testl	%eax, %eax
	jns	.L22
.L21:
	testl	%r8d, %r8d
	js	.L46
.L34:
	xorl	%edi, %edi
	testl	%r8d, %r8d
	cmovns	%r8d, %edi
	addl	$1, %edi
	cmpl	$2, %r8d
	jle	.L47
	movl	%edi, %ecx
	movd	%r8d, %xmm4
	xorl	%eax, %eax
	shrl	$2, %ecx
	pshufd	$0, %xmm4, %xmm0
	salq	$4, %rcx
	.p2align 4,,10
	.p2align 3
.L26:
	movdqu	(%rsi,%rax), %xmm2
	movdqu	(%rdx,%rax), %xmm3
	addq	$16, %rax
	paddd	%xmm3, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm1, %xmm0
	cmpq	%rcx, %rax
	jne	.L26
	movdqa	%xmm0, %xmm2
	movl	%edi, %r11d
	psrldq	$8, %xmm2
	andl	$-4, %r11d
	andl	$3, %edi
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm1, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm0, %xmm1
	movd	%xmm1, %r9d
	je	.L25
.L23:
	movslq	%r11d, %rax
	salq	$2, %rax
	addq	%rax, %rsi
	addq	%rdx, %rax
	leal	1(%r11), %edx
	movl	(%rax), %ecx
	addl	(%rsi), %ecx
	cmpl	%ecx, %r9d
	cmovg	%ecx, %r9d
	cmpl	%r8d, %edx
	jg	.L25
	movl	4(%rax), %ecx
	addl	4(%rsi), %ecx
	leal	2(%r11), %edx
	cmpl	%ecx, %r9d
	cmovg	%ecx, %r9d
	cmpl	%edx, %r8d
	jl	.L25
	movl	8(%rax), %eax
	addl	8(%rsi), %eax
	cmpl	%eax, %r9d
	cmovg	%eax, %r9d
.L25:
	cmpl	$1, %r10d
	je	.L24
	movl	%r9d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L29:
	movq	-24(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L77
	movq	-8(%rbp), %rbx
	xorl	%eax, %eax
	leave
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L76:
	.cfi_restore_state
	movl	4(%rdx,%rax,4), %edi
	leal	1(%rdi), %ecx
	movl	%ecx, (%rdx,%rax,4)
	subq	$1, %rax
	testl	%eax, %eax
	jns	.L22
	jmp	.L21
.L24:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L29
.L40:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L41
	orq	$0, -8(%rsp,%rdx)
.L41:
	leaq	3(%rsp), %rsi
	xorl	%r10d, %r10d
	movq	%rsi, %rdx
	andq	$-4, %rsi
	shrq	$2, %rdx
	movl	$0, 0(,%rdx,4)
	testl	%r8d, %r8d
	jg	.L42
	movq	%r9, %rdx
	movq	%rsp, %rcx
	andq	$-4096, %r9
	andq	$-16, %rdx
	subq	%r9, %rcx
.L35:
	cmpq	%rcx, %rsp
	je	.L36
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L35
.L46:
	movl	%r8d, %r9d
	jmp	.L25
.L47:
	movl	%r8d, %r9d
	xorl	%r11d, %r11d
	jmp	.L23
.L11:
	movq	%r9, %rcx
	movq	%rsp, %rdx
	andq	$-4096, %r9
	andq	$-16, %rcx
	subq	%r9, %rdx
.L15:
	cmpq	%rdx, %rsp
	je	.L16
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L15
.L16:
	andl	$4095, %ecx
	subq	%rcx, %rsp
	testq	%rcx, %rcx
	je	.L17
	orq	$0, -8(%rsp,%rcx)
.L17:
	movq	%rsp, %rdx
	movslq	%r8d, %rcx
	movl	$0, (%rdx,%rcx,4)
	testl	%eax, %eax
	js	.L18
	movl	$1, %r10d
	jmp	.L38
.L36:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	je	.L37
	orq	$0, -8(%rsp,%rdx)
.L37:
	movq	%rsp, %rdx
	movslq	%r8d, %rcx
	xorl	%r10d, %r10d
	movl	$0, (%rdx,%rcx,4)
	jmp	.L38
.L18:
	testl	%r8d, %r8d
	jne	.L24
	xorl	%r11d, %r11d
	xorl	%r9d, %r9d
	movl	$1, %r10d
	jmp	.L23
.L77:
	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:

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

int main(void){
    int N;
    scanf("%d", &N);
    char S[N+1];
    scanf("%s", S);

    int max = N;
    int ans = max;

    int idx;
    int i;
    int flag = 1;

    for(i = 0; i < N-1; i++){
        if(S[i] != S[i+1]){flag = 0; break;}
    }
    

    //これだと(2*10^5)^2で10^10以上で間に合わなさそうなので
    //累積和を使ってO(n)チックにしたい
    /*for(idx = 1; idx <= N-1; idx++){
        for(i = 0; i < idx; i++){if(S[i] == '#')left++;}
        for(i = idx; i < N; i++){if(S[i] == '.')right++;}
        if(ans > (left+right)){ans = left+right;}
        left = 0;
        right = 0;
    }*/

    int lc[N+1];
    lc[0] = 0;
    for(idx = 0; idx < N; idx++){
        if(S[idx] == '#'){lc[idx+1] = lc[idx] + 1;}
        //これ（真下）がないと、何も代入されてない要素ができてしまう
        else{lc[idx+1] = lc[idx];}
        //printf("idx+1:%d, lc[%d]:%d\n", idx+1, idx+1, lc[idx+1]);
    }
    int rc[N+1];
    rc[N] = 0;
    for(idx = N-1; idx >= 0; idx--){
        if(S[idx] == '.'){rc[idx] = rc[idx+1] + 1;}
        else{rc[idx] = rc[idx+1];}
        //printf("idx1:%d, rc[%d]:%d\n", idx, idx, rc[idx]);
    }

    for(i = 0; i < N+1; i++){
        if(ans > lc[i] + rc[i]){ans = lc[i] + rc[i];}
    }
    
    if(flag == 1){printf("0\n");}
    else{printf("%d\n", ans);}
    return 0;
}
5
.#.#
 3
.##
 3
##.
 5
..##
 5
#..#
 3
.# 
 3
##.
 3
.##
 5
.#.#
 5
..##

1
 0
 1
 0
 1
 0
 1
 0
 1
 0

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>

int main(void){
    int N;
    scanf("%d", &N);
    char S[N+1];
    scanf("%s", S);

    int max = N;
    int ans = max;

    int idx;
    int i;
    int flag = 1;

    for(i = 0; i < N-1; i++){
        if(S[i] != S[i+1]){flag = 0; break;}
    }
    

    //これだと(2*10^5)^2で10^10以上で間に合わなさそうなので
    //累積和を使ってO(n)チックにしたい
    /*for(idx = 1; idx <= N-1; idx++){
        for(i = 0; i < idx; i++){if(S[i] == '#')left++;}
        for(i = idx; i < N; i++){if(S[i] == '.')right++;}
        if(ans > (left+right)){ans = left+right;}
        left = 0;
        right = 0;
    }*/

    int lc[N+1];
    lc[0] = 0;
    for(idx = 0; idx < N; idx++){
        if(S[idx] == '#'){lc[idx+1] = lc[idx] + 1;}
        //これ（真下）がないと、何も代入されてない要素ができてしまう
        else{lc[idx+1] = lc[idx];}
        //printf("idx+1:%d, lc[%d]:%d\n", idx+1, idx+1, lc[idx+1]);
    }
    int rc[N+1];
    rc[N] = 0;
    for(idx = N-1; idx >= 0; idx--){
        if(S[idx] == '.'){rc[idx] = rc[idx+1] + 1;}
        else{rc[idx] = rc[idx+1];}
        //printf("idx1:%d, rc[%d]:%d\n", idx, idx, rc[idx]);
    }

    for(i = 0; i < N+1; i++){
        if(ans > lc[i] + rc[i]){ans = lc[i] + rc[i];}
    }
    
    if(flag == 1){printf("0\n");}
    else{printf("%d\n", ans);}
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"0"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$152, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-128(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-128(%rbp), %eax
	leal	1(%rax), %edx
	movslq	%edx, %rax
	subq	$1, %rax
	movq	%rax, -104(%rbp)
	movslq	%edx, %rax
	movq	%rax, -144(%rbp)
	movq	$0, -136(%rbp)
	movslq	%edx, %rax
	movq	%rax, -160(%rbp)
	movq	$0, -152(%rbp)
	movslq	%edx, %rax
	movl	$16, %edx
	subq	$1, %rdx
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$0, %rax
	movq	%rax, -96(%rbp)
	movq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-128(%rbp), %eax
	movl	%eax, -108(%rbp)
	movl	-108(%rbp), %eax
	movl	%eax, -124(%rbp)
	movl	$1, -112(%rbp)
	movl	$0, -116(%rbp)
	jmp	.L5
.L8:
	movq	-96(%rbp), %rdx
	movl	-116(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movl	-116(%rbp), %eax
	addl	$1, %eax
	movq	-96(%rbp), %rdx
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	je	.L6
	movl	$0, -112(%rbp)
	jmp	.L7
.L6:
	addl	$1, -116(%rbp)
.L5:
	movl	-128(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -116(%rbp)
	jl	.L8
.L7:
	movl	-128(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -88(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -176(%rbp)
	movq	$0, -168(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -192(%rbp)
	movq	$0, -184(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L9:
	cmpq	%rdx, %rsp
	je	.L10
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L9
.L10:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L11
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L11:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -80(%rbp)
	movq	-80(%rbp), %rax
	movl	$0, (%rax)
	movl	$0, -120(%rbp)
	jmp	.L12
.L15:
	movq	-96(%rbp), %rdx
	movl	-120(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$35, %al
	jne	.L13
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	movl	-120(%rbp), %edx
	addl	$1, %edx
	leal	1(%rax), %ecx
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	jmp	.L14
.L13:
	movl	-120(%rbp), %eax
	leal	1(%rax), %esi
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-80(%rbp), %rax
	movslq	%esi, %rdx
	movl	%ecx, (%rax,%rdx,4)
.L14:
	addl	$1, -120(%rbp)
.L12:
	movl	-128(%rbp), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L15
	movl	-128(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L16:
	cmpq	%rdx, %rsp
	je	.L17
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L16
.L17:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L18
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L18:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	-128(%rbp), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	$0, (%rax,%rdx,4)
	movl	-128(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -120(%rbp)
	jmp	.L19
.L22:
	movq	-96(%rbp), %rdx
	movl	-120(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$46, %al
	jne	.L20
	movl	-120(%rbp), %eax
	leal	1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	leal	1(%rax), %ecx
	movq	-64(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	jmp	.L21
.L20:
	movl	-120(%rbp), %eax
	leal	1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
.L21:
	subl	$1, -120(%rbp)
.L19:
	cmpl	$0, -120(%rbp)
	jns	.L22
	movl	$0, -116(%rbp)
	jmp	.L23
.L25:
	movq	-80(%rbp), %rax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%ecx, %eax
	cmpl	%eax, -124(%rbp)
	jle	.L24
	movq	-80(%rbp), %rax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%ecx, %eax
	movl	%eax, -124(%rbp)
.L24:
	addl	$1, -116(%rbp)
.L23:
	movl	-128(%rbp), %eax
	cmpl	%eax, -116(%rbp)
	jle	.L25
	cmpl	$1, -112(%rbp)
	jne	.L26
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L27
.L26:
	movl	-124(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L27:
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"0"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$152, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-128(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-128(%rbp), %eax
	leal	1(%rax), %edx
	movslq	%edx, %rax
	subq	$1, %rax
	movq	%rax, -104(%rbp)
	movslq	%edx, %rax
	movq	%rax, -144(%rbp)
	movq	$0, -136(%rbp)
	movslq	%edx, %rax
	movq	%rax, -160(%rbp)
	movq	$0, -152(%rbp)
	movslq	%edx, %rax
	movl	$16, %edx
	subq	$1, %rdx
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$0, %rax
	movq	%rax, -96(%rbp)
	movq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-128(%rbp), %eax
	movl	%eax, -108(%rbp)
	movl	-108(%rbp), %eax
	movl	%eax, -124(%rbp)
	movl	$1, -112(%rbp)
	movl	$0, -116(%rbp)
	jmp	.L5
.L8:
	movq	-96(%rbp), %rdx
	movl	-116(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %ecx
	movl	-116(%rbp), %eax
	addl	$1, %eax
	movq	-96(%rbp), %rdx
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	%al, %cl
	je	.L6
	movl	$0, -112(%rbp)
	jmp	.L7
.L6:
	addl	$1, -116(%rbp)
.L5:
	movl	-128(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -116(%rbp)
	jl	.L8
.L7:
	movl	-128(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -88(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -176(%rbp)
	movq	$0, -168(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, -192(%rbp)
	movq	$0, -184(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L9:
	cmpq	%rdx, %rsp
	je	.L10
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L9
.L10:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L11
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L11:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -80(%rbp)
	movq	-80(%rbp), %rax
	movl	$0, (%rax)
	movl	$0, -120(%rbp)
	jmp	.L12
.L15:
	movq	-96(%rbp), %rdx
	movl	-120(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$35, %al
	jne	.L13
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	movl	-120(%rbp), %edx
	addl	$1, %edx
	leal	1(%rax), %ecx
	movq	-80(%rbp), %rax
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	jmp	.L14
.L13:
	movl	-120(%rbp), %eax
	leal	1(%rax), %esi
	movq	-80(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-80(%rbp), %rax
	movslq	%esi, %rdx
	movl	%ecx, (%rax,%rdx,4)
.L14:
	addl	$1, -120(%rbp)
.L12:
	movl	-128(%rbp), %eax
	cmpl	%eax, -120(%rbp)
	jl	.L15
	movl	-128(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L16:
	cmpq	%rdx, %rsp
	je	.L17
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L16
.L17:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L18
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L18:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	-128(%rbp), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	$0, (%rax,%rdx,4)
	movl	-128(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -120(%rbp)
	jmp	.L19
.L22:
	movq	-96(%rbp), %rdx
	movl	-120(%rbp), %eax
	cltq
	movzbl	(%rdx,%rax), %eax
	cmpb	$46, %al
	jne	.L20
	movl	-120(%rbp), %eax
	leal	1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	leal	1(%rax), %ecx
	movq	-64(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
	jmp	.L21
.L20:
	movl	-120(%rbp), %eax
	leal	1(%rax), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-120(%rbp), %edx
	movslq	%edx, %rdx
	movl	%ecx, (%rax,%rdx,4)
.L21:
	subl	$1, -120(%rbp)
.L19:
	cmpl	$0, -120(%rbp)
	jns	.L22
	movl	$0, -116(%rbp)
	jmp	.L23
.L25:
	movq	-80(%rbp), %rax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%ecx, %eax
	cmpl	%eax, -124(%rbp)
	jle	.L24
	movq	-80(%rbp), %rax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %ecx
	movq	-64(%rbp), %rax
	movl	-116(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	addl	%ecx, %eax
	movl	%eax, -124(%rbp)
.L24:
	addl	$1, -116(%rbp)
.L23:
	movl	-128(%rbp), %eax
	cmpl	%eax, -116(%rbp)
	jle	.L25
	cmpl	$1, -112(%rbp)
	jne	.L26
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L27
.L26:
	movl	-124(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L27:
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
