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>

int main(void) {
	int W, H;
	char c[4];
	int i, j;
	if (scanf("%d%d%1s", &W, &H, c) != 3) return 1;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			int pc = ' ';
			if ((i == 0 || i == H - 1) && (j == 0 || j == W - 1)) pc = '+';
			else if (i == 0 || i == H - 1) pc = '-';
			else if (j == 0 || j == W - 1) pc = '|';
			else if (i == H / 2 && j == W / 2) pc = c[0];
			else pc = '.';
			putchar(pc);
		}
		putchar('\n');
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d%1s"
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-12(%rbp), %rcx
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$3, %eax
	je	.L2
	movl	$1, %eax
	jmp	.L17
.L2:
	movl	$0, -24(%rbp)
	jmp	.L4
.L16:
	movl	$0, -20(%rbp)
	jmp	.L5
.L15:
	movl	$32, -16(%rbp)
	cmpl	$0, -24(%rbp)
	je	.L6
	movl	-28(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jne	.L7
.L6:
	cmpl	$0, -20(%rbp)
	je	.L8
	movl	-32(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jne	.L7
.L8:
	movl	$43, -16(%rbp)
	jmp	.L9
.L7:
	cmpl	$0, -24(%rbp)
	je	.L10
	movl	-28(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jne	.L11
.L10:
	movl	$45, -16(%rbp)
	jmp	.L9
.L11:
	cmpl	$0, -20(%rbp)
	je	.L12
	movl	-32(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jne	.L13
.L12:
	movl	$124, -16(%rbp)
	jmp	.L9
.L13:
	movl	-28(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -24(%rbp)
	jne	.L14
	movl	-32(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -20(%rbp)
	jne	.L14
	movzbl	-12(%rbp), %eax
	movsbl	%al, %eax
	movl	%eax, -16(%rbp)
	jmp	.L9
.L14:
	movl	$46, -16(%rbp)
.L9:
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -20(%rbp)
.L5:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L15
	movl	$10, %edi
	call	putchar@PLT
	addl	$1, -24(%rbp)
.L4:
	movl	-28(%rbp), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L16
	movl	$0, %eax
.L17:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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%d%1s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$40, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	%eax, %r8d
	movl	$1, %eax
	cmpl	$3, %r8d
	jne	.L1
	xorl	%ebp, %ebp
	cmpl	$0, 16(%rsp)
	jle	.L11
	.p2align 4,,10
	.p2align 3
.L3:
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L13
	xorl	%ebx, %ebx
	testl	%ebp, %ebp
	jne	.L7
	movl	$43, %edi
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L10:
	subl	$1, %eax
	xorl	%edi, %edi
	cmpl	%ebx, %eax
	setne	%dil
	leal	43(%rdi,%rdi), %edi
.L4:
	movq	stdout(%rip), %rsi
	addl	$1, %ebx
	call	putc@PLT
	movl	12(%rsp), %eax
	cmpl	%ebx, %eax
	jg	.L10
.L13:
	movq	stdout(%rip), %rsi
	movl	$10, %edi
	addl	$1, %ebp
	call	putc@PLT
	cmpl	%ebp, 16(%rsp)
	jg	.L3
.L11:
	xorl	%eax, %eax
.L1:
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L32
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L5:
	.cfi_restore_state
	movl	$124, %edi
	testl	%ebx, %ebx
	je	.L6
	leal	-1(%rax), %ecx
	cmpl	%ebx, %ecx
	je	.L6
	movl	%edx, %ecx
	movl	$46, %edi
	shrl	$31, %ecx
	addl	%ecx, %edx
	sarl	%edx
	cmpl	%ebp, %edx
	je	.L33
	.p2align 4,,10
	.p2align 3
.L6:
	movq	stdout(%rip), %rsi
	addl	$1, %ebx
	call	putc@PLT
	movl	12(%rsp), %eax
	cmpl	%eax, %ebx
	jge	.L13
.L7:
	movl	16(%rsp), %edx
	leal	-1(%rdx), %ecx
	cmpl	%ecx, %ebp
	jne	.L5
	movl	$43, %edi
	testl	%ebx, %ebx
	je	.L6
	subl	$1, %eax
	xorl	%edi, %edi
	cmpl	%ebx, %eax
	setne	%dil
	leal	43(%rdi,%rdi), %edi
	jmp	.L6
.L33:
	sarl	%eax
	cmpl	%ebx, %eax
	jne	.L6
	movsbl	20(%rsp), %edi
	jmp	.L6
.L32:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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%d%1s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$40, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	%eax, %r8d
	movl	$1, %eax
	cmpl	$3, %r8d
	jne	.L1
	xorl	%ebp, %ebp
	cmpl	$0, 16(%rsp)
	jle	.L11
	.p2align 4,,10
	.p2align 3
.L3:
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L13
	xorl	%ebx, %ebx
	testl	%ebp, %ebp
	jne	.L7
	movl	$43, %edi
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L10:
	subl	$1, %eax
	xorl	%edi, %edi
	cmpl	%ebx, %eax
	setne	%dil
	leal	43(%rdi,%rdi), %edi
.L4:
	movq	stdout(%rip), %rsi
	addl	$1, %ebx
	call	putc@PLT
	movl	12(%rsp), %eax
	cmpl	%ebx, %eax
	jg	.L10
.L13:
	movq	stdout(%rip), %rsi
	movl	$10, %edi
	addl	$1, %ebp
	call	putc@PLT
	cmpl	%ebp, 16(%rsp)
	jg	.L3
.L11:
	xorl	%eax, %eax
.L1:
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L32
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L5:
	.cfi_restore_state
	movl	$124, %edi
	testl	%ebx, %ebx
	je	.L6
	leal	-1(%rax), %ecx
	cmpl	%ebx, %ecx
	je	.L6
	movl	%edx, %ecx
	movl	$46, %edi
	shrl	$31, %ecx
	addl	%ecx, %edx
	sarl	%edx
	cmpl	%ebp, %edx
	je	.L33
	.p2align 4,,10
	.p2align 3
.L6:
	movq	stdout(%rip), %rsi
	addl	$1, %ebx
	call	putc@PLT
	movl	12(%rsp), %eax
	cmpl	%eax, %ebx
	jge	.L13
.L7:
	movl	16(%rsp), %edx
	leal	-1(%rdx), %ecx
	cmpl	%ecx, %ebp
	jne	.L5
	movl	$43, %edi
	testl	%ebx, %ebx
	je	.L6
	subl	$1, %eax
	xorl	%edi, %edi
	cmpl	%ebx, %eax
	setne	%dil
	leal	43(%rdi,%rdi), %edi
	jmp	.L6
.L33:
	sarl	%eax
	cmpl	%ebx, %eax
	jne	.L6
	movsbl	20(%rsp), %edi
	jmp	.L6
.L32:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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>

int main(void) {
	int W, H;
	char c[4];
	int i, j;
	if (scanf("%d%d%1s", &W, &H, c) != 3) return 1;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			int pc = ' ';
			if ((i == 0 || i == H - 1) && (j == 0 || j == W - 1)) pc = '+';
			else if (i == 0 || i == H - 1) pc = '-';
			else if (j == 0 || j == W - 1) pc = '|';
			else if (i == H / 2 && j == W / 2) pc = c[0];
			else pc = '.';
			putchar(pc);
		}
		putchar('\n');
	}
	return 0;
}


3 3 B

+-+
|B|
+-+

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>

int main(void) {
	int W, H;
	char c[4];
	int i, j;
	if (scanf("%d%d%1s", &W, &H, c) != 3) return 1;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			int pc = ' ';
			if ((i == 0 || i == H - 1) && (j == 0 || j == W - 1)) pc = '+';
			else if (i == 0 || i == H - 1) pc = '-';
			else if (j == 0 || j == W - 1) pc = '|';
			else if (i == H / 2 && j == W / 2) pc = c[0];
			else pc = '.';
			putchar(pc);
		}
		putchar('\n');
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d%1s"
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-12(%rbp), %rcx
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$3, %eax
	je	.L2
	movl	$1, %eax
	jmp	.L17
.L2:
	movl	$0, -24(%rbp)
	jmp	.L4
.L16:
	movl	$0, -20(%rbp)
	jmp	.L5
.L15:
	movl	$32, -16(%rbp)
	cmpl	$0, -24(%rbp)
	je	.L6
	movl	-28(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jne	.L7
.L6:
	cmpl	$0, -20(%rbp)
	je	.L8
	movl	-32(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jne	.L7
.L8:
	movl	$43, -16(%rbp)
	jmp	.L9
.L7:
	cmpl	$0, -24(%rbp)
	je	.L10
	movl	-28(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jne	.L11
.L10:
	movl	$45, -16(%rbp)
	jmp	.L9
.L11:
	cmpl	$0, -20(%rbp)
	je	.L12
	movl	-32(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jne	.L13
.L12:
	movl	$124, -16(%rbp)
	jmp	.L9
.L13:
	movl	-28(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -24(%rbp)
	jne	.L14
	movl	-32(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -20(%rbp)
	jne	.L14
	movzbl	-12(%rbp), %eax
	movsbl	%al, %eax
	movl	%eax, -16(%rbp)
	jmp	.L9
.L14:
	movl	$46, -16(%rbp)
.L9:
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -20(%rbp)
.L5:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L15
	movl	$10, %edi
	call	putchar@PLT
	addl	$1, -24(%rbp)
.L4:
	movl	-28(%rbp), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L16
	movl	$0, %eax
.L17:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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%d%1s"
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-12(%rbp), %rcx
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$3, %eax
	je	.L2
	movl	$1, %eax
	jmp	.L17
.L2:
	movl	$0, -24(%rbp)
	jmp	.L4
.L16:
	movl	$0, -20(%rbp)
	jmp	.L5
.L15:
	movl	$32, -16(%rbp)
	cmpl	$0, -24(%rbp)
	je	.L6
	movl	-28(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jne	.L7
.L6:
	cmpl	$0, -20(%rbp)
	je	.L8
	movl	-32(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jne	.L7
.L8:
	movl	$43, -16(%rbp)
	jmp	.L9
.L7:
	cmpl	$0, -24(%rbp)
	je	.L10
	movl	-28(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jne	.L11
.L10:
	movl	$45, -16(%rbp)
	jmp	.L9
.L11:
	cmpl	$0, -20(%rbp)
	je	.L12
	movl	-32(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -20(%rbp)
	jne	.L13
.L12:
	movl	$124, -16(%rbp)
	jmp	.L9
.L13:
	movl	-28(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -24(%rbp)
	jne	.L14
	movl	-32(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -20(%rbp)
	jne	.L14
	movzbl	-12(%rbp), %eax
	movsbl	%al, %eax
	movl	%eax, -16(%rbp)
	jmp	.L9
.L14:
	movl	$46, -16(%rbp)
.L9:
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -20(%rbp)
.L5:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L15
	movl	$10, %edi
	call	putchar@PLT
	addl	$1, -24(%rbp)
.L4:
	movl	-28(%rbp), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L16
	movl	$0, %eax
.L17:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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:
