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() {
    int N, M, i, lock;
    char U[300][11];
    char s[11];

    scanf("%d", &N);

    for (i = 0; i < N; i++) { scanf("%s", U[i]); }

    scanf("%d", &M);

    lock = 1;

    while (M--) {
        scanf("%s", s);
        for (i = 0; i < N; i++) {
            if (strcmp(s, U[i]) == 0 && lock) {
                printf("Opened by %s\n", s);
                lock = 0;
                break;
            }
            else if (strcmp(s, U[i]) == 0 && !lock) {
                printf("Closed by %s\n", s);
                lock = 1;
                break;
            }
            if (i == N-1) { printf("Unknown %s\n", s); }
        }
    }
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"Opened by %s\n"
.LC3:
	.string	"Closed by %s\n"
.LC4:
	.string	"Unknown %s\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	$3344, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-3344(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3336(%rbp)
	jmp	.L2
.L3:
	leaq	-3328(%rbp), %rcx
	movl	-3336(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -3336(%rbp)
.L2:
	movl	-3344(%rbp), %eax
	cmpl	%eax, -3336(%rbp)
	jl	.L3
	leaq	-3340(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -3332(%rbp)
	jmp	.L4
.L10:
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3336(%rbp)
	jmp	.L5
.L9:
	leaq	-3328(%rbp), %rcx
	movl	-3336(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-19(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L6
	cmpl	$0, -3332(%rbp)
	je	.L6
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -3332(%rbp)
	jmp	.L4
.L6:
	leaq	-3328(%rbp), %rcx
	movl	-3336(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-19(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L7
	cmpl	$0, -3332(%rbp)
	jne	.L7
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$1, -3332(%rbp)
	jmp	.L4
.L7:
	movl	-3344(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -3336(%rbp)
	jne	.L8
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L8:
	addl	$1, -3336(%rbp)
.L5:
	movl	-3344(%rbp), %eax
	cmpl	%eax, -3336(%rbp)
	jl	.L9
.L4:
	movl	-3340(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -3340(%rbp)
	testl	%eax, %eax
	jne	.L10
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	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	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"Opened by %s\n"
.LC3:
	.string	"Unknown %s\n"
.LC4:
	.string	"Closed by %s\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
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	leaq	.LC1(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$3352, %rsp
	.cfi_def_cfa_offset 3408
	movq	%fs:40, %rax
	movq	%rax, 3336(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rsi
	leaq	16(%rsp), %rbp
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %eax
	testl	%eax, %eax
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$11, %rbp
	cmpl	%ebx, 8(%rsp)
	jg	.L4
.L5:
	movq	%r13, %rdi
	leaq	12(%rsp), %rsi
	xorl	%eax, %eax
	movl	$1, %r12d
	call	__isoc99_scanf@PLT
	leaq	.LC3(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L3:
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	je	.L8
.L29:
	leaq	3325(%rsp), %r15
.L7:
	movq	%r15, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	xorl	%ebx, %ebx
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %r14d
	leaq	16(%rsp), %rbp
	testl	%r14d, %r14d
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L14:
	movq	%rbp, %rsi
	movq	%r15, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L9
	movq	%r15, %rdx
	testl	%r12d, %r12d
	jne	.L28
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	$1, %r12d
	call	__printf_chk@PLT
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	jne	.L29
.L8:
	movq	3336(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$3352, %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
	.p2align 4,,10
	.p2align 3
.L9:
	.cfi_restore_state
	leal	-1(%r14), %eax
	cmpl	%ebx, %eax
	je	.L31
	addl	$1, %ebx
	addq	$11, %rbp
	cmpl	%r14d, %ebx
	jl	.L14
.L13:
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	jne	.L7
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L31:
	movq	%r15, %rdx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	8(%rsp), %r14d
	addl	$1, %ebx
	addq	$11, %rbp
	cmpl	%r14d, %ebx
	jl	.L14
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	jne	.L7
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L28:
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%r12d, %r12d
	call	__printf_chk@PLT
	jmp	.L3
.L30:
	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	"Opened by %s\n"
.LC3:
	.string	"Unknown %s\n"
.LC4:
	.string	"Closed by %s\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
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	leaq	.LC1(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$3352, %rsp
	.cfi_def_cfa_offset 3408
	movq	%fs:40, %rax
	movq	%rax, 3336(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rsi
	leaq	16(%rsp), %rbp
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %eax
	testl	%eax, %eax
	jle	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$11, %rbp
	cmpl	%ebx, 8(%rsp)
	jg	.L4
.L5:
	movq	%r13, %rdi
	leaq	12(%rsp), %rsi
	xorl	%eax, %eax
	movl	$1, %r12d
	call	__isoc99_scanf@PLT
	leaq	.LC3(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L3:
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	je	.L8
.L29:
	leaq	3325(%rsp), %r15
.L7:
	movq	%r15, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	xorl	%ebx, %ebx
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %r14d
	leaq	16(%rsp), %rbp
	testl	%r14d, %r14d
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L14:
	movq	%rbp, %rsi
	movq	%r15, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L9
	movq	%r15, %rdx
	testl	%r12d, %r12d
	jne	.L28
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	$1, %r12d
	call	__printf_chk@PLT
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	jne	.L29
.L8:
	movq	3336(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$3352, %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
	.p2align 4,,10
	.p2align 3
.L9:
	.cfi_restore_state
	leal	-1(%r14), %eax
	cmpl	%ebx, %eax
	je	.L31
	addl	$1, %ebx
	addq	$11, %rbp
	cmpl	%r14d, %ebx
	jl	.L14
.L13:
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	jne	.L7
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L31:
	movq	%r15, %rdx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	8(%rsp), %r14d
	addl	$1, %ebx
	addq	$11, %rbp
	cmpl	%r14d, %ebx
	jl	.L14
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	jne	.L7
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L28:
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%r12d, %r12d
	call	__printf_chk@PLT
	jmp	.L3
.L30:
	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() {
    int N, M, i, lock;
    char U[300][11];
    char s[11];

    scanf("%d", &N);

    for (i = 0; i < N; i++) { scanf("%s", U[i]); }

    scanf("%d", &M);

    lock = 1;

    while (M--) {
        scanf("%s", s);
        for (i = 0; i < N; i++) {
            if (strcmp(s, U[i]) == 0 && lock) {
                printf("Opened by %s\n", s);
                lock = 0;
                break;
            }
            else if (strcmp(s, U[i]) == 0 && !lock) {
                printf("Closed by %s\n", s);
                lock = 1;
                break;
            }
            if (i == N-1) { printf("Unknown %s\n", s); }
        }
    }
    return 0;
}

4
abcd
efgh
ijkl
mnop
5
abcd
abcc
efgh
abcd
mnop

Opened by abcd
Unknown abcc
Closed by efgh
Opened by abcd
Closed by mnop

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() {
    int N, M, i, lock;
    char U[300][11];
    char s[11];

    scanf("%d", &N);

    for (i = 0; i < N; i++) { scanf("%s", U[i]); }

    scanf("%d", &M);

    lock = 1;

    while (M--) {
        scanf("%s", s);
        for (i = 0; i < N; i++) {
            if (strcmp(s, U[i]) == 0 && lock) {
                printf("Opened by %s\n", s);
                lock = 0;
                break;
            }
            else if (strcmp(s, U[i]) == 0 && !lock) {
                printf("Closed by %s\n", s);
                lock = 1;
                break;
            }
            if (i == N-1) { printf("Unknown %s\n", s); }
        }
    }
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"Opened by %s\n"
.LC3:
	.string	"Closed by %s\n"
.LC4:
	.string	"Unknown %s\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	$3344, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-3344(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3336(%rbp)
	jmp	.L2
.L3:
	leaq	-3328(%rbp), %rcx
	movl	-3336(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -3336(%rbp)
.L2:
	movl	-3344(%rbp), %eax
	cmpl	%eax, -3336(%rbp)
	jl	.L3
	leaq	-3340(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -3332(%rbp)
	jmp	.L4
.L10:
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3336(%rbp)
	jmp	.L5
.L9:
	leaq	-3328(%rbp), %rcx
	movl	-3336(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-19(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L6
	cmpl	$0, -3332(%rbp)
	je	.L6
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -3332(%rbp)
	jmp	.L4
.L6:
	leaq	-3328(%rbp), %rcx
	movl	-3336(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-19(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L7
	cmpl	$0, -3332(%rbp)
	jne	.L7
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$1, -3332(%rbp)
	jmp	.L4
.L7:
	movl	-3344(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -3336(%rbp)
	jne	.L8
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L8:
	addl	$1, -3336(%rbp)
.L5:
	movl	-3344(%rbp), %eax
	cmpl	%eax, -3336(%rbp)
	jl	.L9
.L4:
	movl	-3340(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -3340(%rbp)
	testl	%eax, %eax
	jne	.L10
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	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	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"Opened by %s\n"
.LC3:
	.string	"Closed by %s\n"
.LC4:
	.string	"Unknown %s\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	$3344, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-3344(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3336(%rbp)
	jmp	.L2
.L3:
	leaq	-3328(%rbp), %rcx
	movl	-3336(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -3336(%rbp)
.L2:
	movl	-3344(%rbp), %eax
	cmpl	%eax, -3336(%rbp)
	jl	.L3
	leaq	-3340(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -3332(%rbp)
	jmp	.L4
.L10:
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3336(%rbp)
	jmp	.L5
.L9:
	leaq	-3328(%rbp), %rcx
	movl	-3336(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-19(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L6
	cmpl	$0, -3332(%rbp)
	je	.L6
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -3332(%rbp)
	jmp	.L4
.L6:
	leaq	-3328(%rbp), %rcx
	movl	-3336(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-19(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L7
	cmpl	$0, -3332(%rbp)
	jne	.L7
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$1, -3332(%rbp)
	jmp	.L4
.L7:
	movl	-3344(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -3336(%rbp)
	jne	.L8
	leaq	-19(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L8:
	addl	$1, -3336(%rbp)
.L5:
	movl	-3344(%rbp), %eax
	cmpl	%eax, -3336(%rbp)
	jl	.L9
.L4:
	movl	-3340(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -3340(%rbp)
	testl	%eax, %eax
	jne	.L10
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	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:
