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

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

#define S 100

int main(void) {
    long k;
    int n, count_forward = 0, count_backward = 0;
    char c, s[S+2]; // +2 for newline and null
    bool is_same_char;

    fgets(s, S+1, stdin);
    n = strlen(s);
    if (s[n-1] == '\n') {
        s[n-1] = '\0';
        n--;
    }

    scanf("%ld", &k);

    // Special case for s consits of a single character
    is_same_char = true;
    c = s[0];
    for (int i = 1; i < n; i++) {
        if (s[i] != c) {
            is_same_char = false;
            break;
        }
    }
    if (is_same_char) {
        printf("%ld\n", (long) k * (long) n / 2);
        return 0;
    }

    if (s[0] == s[n-1]) {
        char c = s[0];

        int i = 0;
        while (i < n && s[i] == c) {
            count_forward++;
            i++;
        }
        i = n-1;
        while (i >= 0 && s[i] == c) {
            count_backward++;
            i--;
        }
    }

    long count = 0, ch_count = 1;
    c = s[0];
    for (int i = 1; i < n; i++) {
        if (s[i] == c) {
            ch_count++;
            if (ch_count % 2 == 0) {
                count++;
            }
        } else {
            ch_count = 1;
            c = s[i];
        }
    }

    long result = count * k - \
        (k - 1) * (count_forward / 2 + count_backward / 2 - (count_forward + count_backward) / 2);

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

    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\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
	subq	$176, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -164(%rbp)
	movl	$0, -160(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-112(%rbp), %rax
	movl	$101, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-112(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -168(%rbp)
	movl	-168(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$10, %al
	jne	.L2
	movl	-168(%rbp), %eax
	subl	$1, %eax
	cltq
	movb	$0, -112(%rbp,%rax)
	subl	$1, -168(%rbp)
.L2:
	leaq	-144(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movb	$1, -170(%rbp)
	movzbl	-112(%rbp), %eax
	movb	%al, -171(%rbp)
	movl	$1, -156(%rbp)
	jmp	.L3
.L6:
	movl	-156(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, -171(%rbp)
	je	.L4
	movb	$0, -170(%rbp)
	jmp	.L5
.L4:
	addl	$1, -156(%rbp)
.L3:
	movl	-156(%rbp), %eax
	cmpl	-168(%rbp), %eax
	jl	.L6
.L5:
	cmpb	$0, -170(%rbp)
	je	.L7
	movl	-168(%rbp), %eax
	movslq	%eax, %rdx
	movq	-144(%rbp), %rax
	imulq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L19
.L7:
	movzbl	-112(%rbp), %edx
	movl	-168(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, %dl
	jne	.L9
	movzbl	-112(%rbp), %eax
	movb	%al, -169(%rbp)
	movl	$0, -152(%rbp)
	jmp	.L10
.L12:
	addl	$1, -164(%rbp)
	addl	$1, -152(%rbp)
.L10:
	movl	-152(%rbp), %eax
	cmpl	-168(%rbp), %eax
	jge	.L11
	movl	-152(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, -169(%rbp)
	je	.L12
.L11:
	movl	-168(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -152(%rbp)
	jmp	.L13
.L14:
	addl	$1, -160(%rbp)
	subl	$1, -152(%rbp)
.L13:
	cmpl	$0, -152(%rbp)
	js	.L9
	movl	-152(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, -169(%rbp)
	je	.L14
.L9:
	movq	$0, -136(%rbp)
	movq	$1, -128(%rbp)
	movzbl	-112(%rbp), %eax
	movb	%al, -171(%rbp)
	movl	$1, -148(%rbp)
	jmp	.L15
.L18:
	movl	-148(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, -171(%rbp)
	jne	.L16
	addq	$1, -128(%rbp)
	movq	-128(%rbp), %rax
	andl	$1, %eax
	testq	%rax, %rax
	jne	.L17
	addq	$1, -136(%rbp)
	jmp	.L17
.L16:
	movq	$1, -128(%rbp)
	movl	-148(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	movb	%al, -171(%rbp)
.L17:
	addl	$1, -148(%rbp)
.L15:
	movl	-148(%rbp), %eax
	cmpl	-168(%rbp), %eax
	jl	.L18
	movq	-144(%rbp), %rax
	imulq	-136(%rbp), %rax
	movq	%rax, %rdx
	movq	-144(%rbp), %rax
	leaq	-1(%rax), %rcx
	movl	-164(%rbp), %eax
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%esi, %eax
	sarl	%eax
	movl	%eax, %edi
	movl	-160(%rbp), %eax
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%esi, %eax
	sarl	%eax
	addl	%eax, %edi
	movl	-164(%rbp), %esi
	movl	-160(%rbp), %eax
	addl	%esi, %eax
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%esi, %eax
	sarl	%eax
	negl	%eax
	addl	%edi, %eax
	cltq
	imulq	%rax, %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	movq	%rax, -120(%rbp)
	movq	-120(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L19:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leave
	.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	"%ld"
.LC1:
	.string	"%ld\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
	movl	$101, %esi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$136, %rsp
	.cfi_def_cfa_offset 160
	movq	stdin(%rip), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rbx
	movq	%rbx, %rdi
	call	fgets@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	movl	%eax, %ebp
	subl	$1, %eax
	movslq	%eax, %rdx
	cmpb	$10, 16(%rsp,%rdx)
	jne	.L2
	movb	$0, 16(%rsp,%rdx)
	movl	%eax, %ebp
.L2:
	leaq	8(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	16(%rsp), %esi
	cmpl	$1, %ebp
	jle	.L3
	leal	-2(%rbp), %eax
	leaq	17(%rsp), %rcx
	leaq	18(%rsp,%rax), %rdi
	movq	%rcx, %rax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L24:
	addq	$1, %rax
	cmpq	%rdi, %rax
	je	.L3
.L5:
	cmpb	%sil, (%rax)
	je	.L24
	leal	-1(%rbp), %eax
	cltq
	cmpb	%sil, 16(%rsp,%rax)
	je	.L13
	xorl	%r9d, %r9d
	xorl	%r10d, %r10d
.L8:
	movl	$1, %r8d
	xorl	%edx, %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L16:
	addq	$1, %rcx
	movl	%eax, %esi
	movl	$1, %r8d
	cmpq	%rdi, %rcx
	je	.L25
.L11:
	movzbl	(%rcx), %eax
	cmpb	%sil, %al
	jne	.L16
	addq	$1, %r8
	movq	%r8, %rax
	andl	$1, %eax
	cmpq	$1, %rax
	adcq	$0, %rdx
	addq	$1, %rcx
	cmpq	%rdi, %rcx
	jne	.L11
.L25:
	movl	%r9d, %ecx
	movl	%r10d, %eax
	addl	%r10d, %r9d
	movq	8(%rsp), %rsi
	sarl	%ecx
	sarl	%eax
	movl	$1, %edi
	addl	%ecx, %eax
	imulq	%rsi, %rdx
	movl	%r9d, %ecx
	subq	$1, %rsi
	shrl	$31, %ecx
	addl	%r9d, %ecx
	sarl	%ecx
	subl	%ecx, %eax
	cltq
	imulq	%rsi, %rax
	leaq	.LC1(%rip), %rsi
	subq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L12:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	addq	$136, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L13:
	.cfi_restore_state
	movslq	%ebp, %rdx
	movl	$1, %eax
	leaq	15(%rsp), %r8
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%eax, %r10d
	cmpq	%rax, %rdx
	je	.L6
	addq	$1, %rax
	cmpb	%sil, (%r8,%rax)
	je	.L7
.L6:
	leaq	(%rbx,%rdx), %rax
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L9:
	addl	$1, %r9d
	cmpl	%r9d, %ebp
	je	.L8
	subq	$1, %rax
	cmpb	%sil, -1(%rax)
	je	.L9
	jmp	.L8
.L3:
	movslq	%ebp, %rax
	imulq	8(%rsp), %rax
	movl	$2, %ecx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rcx
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L12
.L26:
	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	"%ld"
.LC1:
	.string	"%ld\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
	movl	$101, %esi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$136, %rsp
	.cfi_def_cfa_offset 160
	movq	stdin(%rip), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rbx
	movq	%rbx, %rdi
	call	fgets@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	movl	%eax, %ebp
	subl	$1, %eax
	movslq	%eax, %rdx
	cmpb	$10, 16(%rsp,%rdx)
	jne	.L2
	movb	$0, 16(%rsp,%rdx)
	movl	%eax, %ebp
.L2:
	leaq	8(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	16(%rsp), %esi
	cmpl	$1, %ebp
	jle	.L3
	leal	-2(%rbp), %eax
	leaq	17(%rsp), %rcx
	leaq	18(%rsp,%rax), %rdi
	movq	%rcx, %rax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L24:
	addq	$1, %rax
	cmpq	%rdi, %rax
	je	.L3
.L5:
	cmpb	%sil, (%rax)
	je	.L24
	leal	-1(%rbp), %eax
	cltq
	cmpb	%sil, 16(%rsp,%rax)
	je	.L13
	xorl	%r9d, %r9d
	xorl	%r10d, %r10d
.L8:
	movl	$1, %r8d
	xorl	%edx, %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L16:
	addq	$1, %rcx
	movl	%eax, %esi
	movl	$1, %r8d
	cmpq	%rdi, %rcx
	je	.L25
.L11:
	movzbl	(%rcx), %eax
	cmpb	%sil, %al
	jne	.L16
	addq	$1, %r8
	movq	%r8, %rax
	andl	$1, %eax
	cmpq	$1, %rax
	adcq	$0, %rdx
	addq	$1, %rcx
	cmpq	%rdi, %rcx
	jne	.L11
.L25:
	movl	%r9d, %ecx
	movl	%r10d, %eax
	addl	%r10d, %r9d
	movq	8(%rsp), %rsi
	sarl	%ecx
	sarl	%eax
	movl	$1, %edi
	addl	%ecx, %eax
	imulq	%rsi, %rdx
	movl	%r9d, %ecx
	subq	$1, %rsi
	shrl	$31, %ecx
	addl	%r9d, %ecx
	sarl	%ecx
	subl	%ecx, %eax
	cltq
	imulq	%rsi, %rax
	leaq	.LC1(%rip), %rsi
	subq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L12:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	addq	$136, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L13:
	.cfi_restore_state
	movslq	%ebp, %rdx
	movl	$1, %eax
	leaq	15(%rsp), %r8
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%eax, %r10d
	cmpq	%rax, %rdx
	je	.L6
	addq	$1, %rax
	cmpb	%sil, (%r8,%rax)
	je	.L7
.L6:
	leaq	(%rbx,%rdx), %rax
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L9:
	addl	$1, %r9d
	cmpl	%r9d, %ebp
	je	.L8
	subq	$1, %rax
	cmpb	%sil, -1(%rax)
	je	.L9
	jmp	.L8
.L3:
	movslq	%ebp, %rax
	imulq	8(%rsp), %rax
	movl	$2, %ecx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rcx
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L12
.L26:
	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 <stdbool.h>
#include <stdio.h>
#include <string.h>

#define S 100

int main(void) {
    long k;
    int n, count_forward = 0, count_backward = 0;
    char c, s[S+2]; // +2 for newline and null
    bool is_same_char;

    fgets(s, S+1, stdin);
    n = strlen(s);
    if (s[n-1] == '\n') {
        s[n-1] = '\0';
        n--;
    }

    scanf("%ld", &k);

    // Special case for s consits of a single character
    is_same_char = true;
    c = s[0];
    for (int i = 1; i < n; i++) {
        if (s[i] != c) {
            is_same_char = false;
            break;
        }
    }
    if (is_same_char) {
        printf("%ld\n", (long) k * (long) n / 2);
        return 0;
    }

    if (s[0] == s[n-1]) {
        char c = s[0];

        int i = 0;
        while (i < n && s[i] == c) {
            count_forward++;
            i++;
        }
        i = n-1;
        while (i >= 0 && s[i] == c) {
            count_backward++;
            i--;
        }
    }

    long count = 0, ch_count = 1;
    c = s[0];
    for (int i = 1; i < n; i++) {
        if (s[i] == c) {
            ch_count++;
            if (ch_count % 2 == 0) {
                count++;
            }
        } else {
            ch_count = 1;
            c = s[i];
        }
    }

    long result = count * k - \
        (k - 1) * (count_forward / 2 + count_backward / 2 - (count_forward + count_backward) / 2);

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

    return 0;
}

cooooooooonteeeeeeeedest
999993333
 issih
2
 rq
81
 hssih
2
 cooooooooonteeeeeeeedest
1894324309
 hssih
3
 hssih
6
 tsedeeeeeeeetnoooooonooc
54816478
 tsedeeeeeeeetnoooooonooc
93364260
 rr
552

7999946664
 2
 0
 3
 15154594472
 5
 11
 438531824
 746914080
 552

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

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

#define S 100

int main(void) {
    long k;
    int n, count_forward = 0, count_backward = 0;
    char c, s[S+2]; // +2 for newline and null
    bool is_same_char;

    fgets(s, S+1, stdin);
    n = strlen(s);
    if (s[n-1] == '\n') {
        s[n-1] = '\0';
        n--;
    }

    scanf("%ld", &k);

    // Special case for s consits of a single character
    is_same_char = true;
    c = s[0];
    for (int i = 1; i < n; i++) {
        if (s[i] != c) {
            is_same_char = false;
            break;
        }
    }
    if (is_same_char) {
        printf("%ld\n", (long) k * (long) n / 2);
        return 0;
    }

    if (s[0] == s[n-1]) {
        char c = s[0];

        int i = 0;
        while (i < n && s[i] == c) {
            count_forward++;
            i++;
        }
        i = n-1;
        while (i >= 0 && s[i] == c) {
            count_backward++;
            i--;
        }
    }

    long count = 0, ch_count = 1;
    c = s[0];
    for (int i = 1; i < n; i++) {
        if (s[i] == c) {
            ch_count++;
            if (ch_count % 2 == 0) {
                count++;
            }
        } else {
            ch_count = 1;
            c = s[i];
        }
    }

    long result = count * k - \
        (k - 1) * (count_forward / 2 + count_backward / 2 - (count_forward + count_backward) / 2);

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

    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\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
	subq	$176, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -164(%rbp)
	movl	$0, -160(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-112(%rbp), %rax
	movl	$101, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-112(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -168(%rbp)
	movl	-168(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$10, %al
	jne	.L2
	movl	-168(%rbp), %eax
	subl	$1, %eax
	cltq
	movb	$0, -112(%rbp,%rax)
	subl	$1, -168(%rbp)
.L2:
	leaq	-144(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movb	$1, -170(%rbp)
	movzbl	-112(%rbp), %eax
	movb	%al, -171(%rbp)
	movl	$1, -156(%rbp)
	jmp	.L3
.L6:
	movl	-156(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, -171(%rbp)
	je	.L4
	movb	$0, -170(%rbp)
	jmp	.L5
.L4:
	addl	$1, -156(%rbp)
.L3:
	movl	-156(%rbp), %eax
	cmpl	-168(%rbp), %eax
	jl	.L6
.L5:
	cmpb	$0, -170(%rbp)
	je	.L7
	movl	-168(%rbp), %eax
	movslq	%eax, %rdx
	movq	-144(%rbp), %rax
	imulq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L19
.L7:
	movzbl	-112(%rbp), %edx
	movl	-168(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, %dl
	jne	.L9
	movzbl	-112(%rbp), %eax
	movb	%al, -169(%rbp)
	movl	$0, -152(%rbp)
	jmp	.L10
.L12:
	addl	$1, -164(%rbp)
	addl	$1, -152(%rbp)
.L10:
	movl	-152(%rbp), %eax
	cmpl	-168(%rbp), %eax
	jge	.L11
	movl	-152(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, -169(%rbp)
	je	.L12
.L11:
	movl	-168(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -152(%rbp)
	jmp	.L13
.L14:
	addl	$1, -160(%rbp)
	subl	$1, -152(%rbp)
.L13:
	cmpl	$0, -152(%rbp)
	js	.L9
	movl	-152(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, -169(%rbp)
	je	.L14
.L9:
	movq	$0, -136(%rbp)
	movq	$1, -128(%rbp)
	movzbl	-112(%rbp), %eax
	movb	%al, -171(%rbp)
	movl	$1, -148(%rbp)
	jmp	.L15
.L18:
	movl	-148(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, -171(%rbp)
	jne	.L16
	addq	$1, -128(%rbp)
	movq	-128(%rbp), %rax
	andl	$1, %eax
	testq	%rax, %rax
	jne	.L17
	addq	$1, -136(%rbp)
	jmp	.L17
.L16:
	movq	$1, -128(%rbp)
	movl	-148(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	movb	%al, -171(%rbp)
.L17:
	addl	$1, -148(%rbp)
.L15:
	movl	-148(%rbp), %eax
	cmpl	-168(%rbp), %eax
	jl	.L18
	movq	-144(%rbp), %rax
	imulq	-136(%rbp), %rax
	movq	%rax, %rdx
	movq	-144(%rbp), %rax
	leaq	-1(%rax), %rcx
	movl	-164(%rbp), %eax
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%esi, %eax
	sarl	%eax
	movl	%eax, %edi
	movl	-160(%rbp), %eax
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%esi, %eax
	sarl	%eax
	addl	%eax, %edi
	movl	-164(%rbp), %esi
	movl	-160(%rbp), %eax
	addl	%esi, %eax
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%esi, %eax
	sarl	%eax
	negl	%eax
	addl	%edi, %eax
	cltq
	imulq	%rax, %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	movq	%rax, -120(%rbp)
	movq	-120(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L19:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leave
	.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	"%ld"
.LC1:
	.string	"%ld\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
	subq	$176, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -164(%rbp)
	movl	$0, -160(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-112(%rbp), %rax
	movl	$101, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-112(%rbp), %rax
	movq	%rax, %rdi
	call	strlen@PLT
	movl	%eax, -168(%rbp)
	movl	-168(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	$10, %al
	jne	.L2
	movl	-168(%rbp), %eax
	subl	$1, %eax
	cltq
	movb	$0, -112(%rbp,%rax)
	subl	$1, -168(%rbp)
.L2:
	leaq	-144(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movb	$1, -170(%rbp)
	movzbl	-112(%rbp), %eax
	movb	%al, -171(%rbp)
	movl	$1, -156(%rbp)
	jmp	.L3
.L6:
	movl	-156(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, -171(%rbp)
	je	.L4
	movb	$0, -170(%rbp)
	jmp	.L5
.L4:
	addl	$1, -156(%rbp)
.L3:
	movl	-156(%rbp), %eax
	cmpl	-168(%rbp), %eax
	jl	.L6
.L5:
	cmpb	$0, -170(%rbp)
	je	.L7
	movl	-168(%rbp), %eax
	movslq	%eax, %rdx
	movq	-144(%rbp), %rax
	imulq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L19
.L7:
	movzbl	-112(%rbp), %edx
	movl	-168(%rbp), %eax
	subl	$1, %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, %dl
	jne	.L9
	movzbl	-112(%rbp), %eax
	movb	%al, -169(%rbp)
	movl	$0, -152(%rbp)
	jmp	.L10
.L12:
	addl	$1, -164(%rbp)
	addl	$1, -152(%rbp)
.L10:
	movl	-152(%rbp), %eax
	cmpl	-168(%rbp), %eax
	jge	.L11
	movl	-152(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, -169(%rbp)
	je	.L12
.L11:
	movl	-168(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -152(%rbp)
	jmp	.L13
.L14:
	addl	$1, -160(%rbp)
	subl	$1, -152(%rbp)
.L13:
	cmpl	$0, -152(%rbp)
	js	.L9
	movl	-152(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, -169(%rbp)
	je	.L14
.L9:
	movq	$0, -136(%rbp)
	movq	$1, -128(%rbp)
	movzbl	-112(%rbp), %eax
	movb	%al, -171(%rbp)
	movl	$1, -148(%rbp)
	jmp	.L15
.L18:
	movl	-148(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	cmpb	%al, -171(%rbp)
	jne	.L16
	addq	$1, -128(%rbp)
	movq	-128(%rbp), %rax
	andl	$1, %eax
	testq	%rax, %rax
	jne	.L17
	addq	$1, -136(%rbp)
	jmp	.L17
.L16:
	movq	$1, -128(%rbp)
	movl	-148(%rbp), %eax
	cltq
	movzbl	-112(%rbp,%rax), %eax
	movb	%al, -171(%rbp)
.L17:
	addl	$1, -148(%rbp)
.L15:
	movl	-148(%rbp), %eax
	cmpl	-168(%rbp), %eax
	jl	.L18
	movq	-144(%rbp), %rax
	imulq	-136(%rbp), %rax
	movq	%rax, %rdx
	movq	-144(%rbp), %rax
	leaq	-1(%rax), %rcx
	movl	-164(%rbp), %eax
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%esi, %eax
	sarl	%eax
	movl	%eax, %edi
	movl	-160(%rbp), %eax
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%esi, %eax
	sarl	%eax
	addl	%eax, %edi
	movl	-164(%rbp), %esi
	movl	-160(%rbp), %eax
	addl	%esi, %eax
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%esi, %eax
	sarl	%eax
	negl	%eax
	addl	%edi, %eax
	cltq
	imulq	%rax, %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	movq	%rax, -120(%rbp)
	movq	-120(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L19:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leave
	.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:
