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

```c
// Aizu Vol-1 0137: Middle-Square Method
// 2017.8.1

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);
char buf[50];

int main()
{
	int i, n, s, k;

	gets(buf); n = atoi(buf);
	for (i = 1; i <= n; i++) {
		gets(buf); s = atoi(buf);
		printf("Case %d:\n", i);
		for (k = 0; k < 10; k++) {
			s = (s * s / 100) % 10000;
			printf("%d\n", s);
		}
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	buf
	.bss
	.align 32
	.type	buf, @object
	.size	buf, 50
buf:
	.zero	50
	.section	.rodata
.LC0:
	.string	"Case %d:\n"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	buf(%rip), %rax
	movq	%rax, %rdi
	call	gets@PLT
	leaq	buf(%rip), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -4(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L2
.L5:
	leaq	buf(%rip), %rax
	movq	%rax, %rdi
	call	gets@PLT
	leaq	buf(%rip), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -12(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -8(%rbp)
	jmp	.L3
.L4:
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	movslq	%eax, %rdx
	imulq	$1374389535, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$5, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movslq	%eax, %rdx
	imulq	$1759218605, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$12, %edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -12(%rbp)
	movl	-12(%rbp), %edx
	imull	$10000, %edx, %edx
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -8(%rbp)
.L3:
	cmpl	$9, -8(%rbp)
	jle	.L4
	addl	$1, -16(%rbp)
.L2:
	movl	-16(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L5
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	"Case %d:\n"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.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
	leaq	buf(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r14, %rdi
	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
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	gets@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%r14, %rdi
	call	strtol@PLT
	movl	%eax, 12(%rsp)
	testl	%eax, %eax
	jle	.L2
	movl	$1, %r13d
	leaq	.LC1(%rip), %r12
	movl	$3518437209, %ebp
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r14, %rdi
	movl	$10, %ebx
	call	gets@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%r14, %rdi
	call	strtol@PLT
	movl	%r13d, %edx
	movl	$1, %edi
	leaq	.LC0(%rip), %rsi
	movl	%eax, %r15d
	xorl	%eax, %eax
	call	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%r15d, %ecx
	movq	%r12, %rsi
	movl	$1, %edi
	imull	%r15d, %ecx
	imulq	$1374389535, %rcx, %rax
	shrq	$37, %rax
	movl	%eax, %ecx
	imulq	%rbp, %rcx
	shrq	$45, %rcx
	imull	$10000, %ecx, %edx
	subl	%edx, %eax
	movl	%eax, %r15d
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	subl	$1, %ebx
	jne	.L3
	addl	$1, %r13d
	cmpl	12(%rsp), %r13d
	jle	.L4
.L2:
	addq	$24, %rsp
	.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
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.globl	buf
	.bss
	.align 32
	.type	buf, @object
	.size	buf, 50
buf:
	.zero	50
	.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	"Case %d:\n"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.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
	leaq	buf(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r14, %rdi
	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
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	gets@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%r14, %rdi
	call	strtol@PLT
	movl	%eax, 12(%rsp)
	testl	%eax, %eax
	jle	.L2
	movl	$1, %r13d
	leaq	.LC1(%rip), %r12
	movl	$3518437209, %ebp
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r14, %rdi
	movl	$10, %ebx
	call	gets@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%r14, %rdi
	call	strtol@PLT
	movl	%r13d, %edx
	movl	$1, %edi
	leaq	.LC0(%rip), %rsi
	movl	%eax, %r15d
	xorl	%eax, %eax
	call	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L3:
	movl	%r15d, %ecx
	movq	%r12, %rsi
	movl	$1, %edi
	imull	%r15d, %ecx
	imulq	$1374389535, %rcx, %rax
	shrq	$37, %rax
	movl	%eax, %ecx
	imulq	%rbp, %rcx
	shrq	$45, %rcx
	imull	$10000, %ecx, %edx
	subl	%edx, %eax
	movl	%eax, %r15d
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	subl	$1, %ebx
	jne	.L3
	addl	$1, %r13d
	cmpl	12(%rsp), %r13d
	jle	.L4
.L2:
	addq	$24, %rsp
	.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
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.globl	buf
	.bss
	.align 32
	.type	buf, @object
	.size	buf, 50
buf:
	.zero	50
	.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:

// Aizu Vol-1 0137: Middle-Square Method
// 2017.8.1

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);
char buf[50];

int main()
{
	int i, n, s, k;

	gets(buf); n = atoi(buf);
	for (i = 1; i <= n; i++) {
		gets(buf); s = atoi(buf);
		printf("Case %d:\n", i);
		for (k = 0; k < 10; k++) {
			s = (s * s / 100) % 10000;
			printf("%d\n", s);
		}
	}
	return 0;
}
2
210
567
 2
210
225
 2
272
225
 2
272
153
 2
499
153
 2
711
153
 2
390
153
 2
390
297
 2
191
297
 2
191
461

Case 1:
441
1944
7791
6996
9440
1136
2904
4332
7662
7062
Case 2:
3214
3297
8702
7248
5335
4622
3628
1623
6341
2082
 Case 1:
441
1944
7791
6996
9440
1136
2904
4332
7662
7062
Case 2:
506
2560
5536
6472
8867
6236
8876
7833
3558
6593
 Case 1:
739
5461
8225
6506
3280
7584
5170
7289
1295
6770
Case 2:
506
2560
5536
6472
8867
6236
8876
7833
3558
6593
 Case 1:
739
5461
8225
6506
3280
7584
5170
7289
1295
6770
Case 2:
234
547
2992
9520
6304
7404
8192
1088
1837
3745
 Case 1:
2490
2001
40
16
2
0
0
0
0
0
Case 2:
234
547
2992
9520
6304
7404
8192
1088
1837
3745
 Case 1:
5055
5530
5809
7444
4131
651
4238
9606
2752
5735
Case 2:
234
547
2992
9520
6304
7404
8192
1088
1837
3745
 Case 1:
1521
3134
8219
5519
4593
956
9139
5213
1753
730
Case 2:
234
547
2992
9520
6304
7404
8192
1088
1837
3745
 Case 1:
1521
3134
8219
5519
4593
956
9139
5213
1753
730
Case 2:
882
7779
5128
2963
7793
7308
4068
5486
961
9235
 Case 1:
364
1324
7529
6858
321
1030
609
3708
7492
1300
Case 2:
882
7779
5128
2963
7793
7308
4068
5486
961
9235
 Case 1:
364
1324
7529
6858
321
1030
609
3708
7492
1300
Case 2:
2125
5156
5843
1406
9768
4138
1230
5129
3066
4003

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

```c
// Aizu Vol-1 0137: Middle-Square Method
// 2017.8.1

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);
char buf[50];

int main()
{
	int i, n, s, k;

	gets(buf); n = atoi(buf);
	for (i = 1; i <= n; i++) {
		gets(buf); s = atoi(buf);
		printf("Case %d:\n", i);
		for (k = 0; k < 10; k++) {
			s = (s * s / 100) % 10000;
			printf("%d\n", s);
		}
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	buf
	.bss
	.align 32
	.type	buf, @object
	.size	buf, 50
buf:
	.zero	50
	.section	.rodata
.LC0:
	.string	"Case %d:\n"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	buf(%rip), %rax
	movq	%rax, %rdi
	call	gets@PLT
	leaq	buf(%rip), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -4(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L2
.L5:
	leaq	buf(%rip), %rax
	movq	%rax, %rdi
	call	gets@PLT
	leaq	buf(%rip), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -12(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -8(%rbp)
	jmp	.L3
.L4:
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	movslq	%eax, %rdx
	imulq	$1374389535, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$5, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movslq	%eax, %rdx
	imulq	$1759218605, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$12, %edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -12(%rbp)
	movl	-12(%rbp), %edx
	imull	$10000, %edx, %edx
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -8(%rbp)
.L3:
	cmpl	$9, -8(%rbp)
	jle	.L4
	addl	$1, -16(%rbp)
.L2:
	movl	-16(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L5
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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
	.globl	buf
	.bss
	.align 32
	.type	buf, @object
	.size	buf, 50
buf:
	.zero	50
	.section	.rodata
.LC0:
	.string	"Case %d:\n"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	buf(%rip), %rax
	movq	%rax, %rdi
	call	gets@PLT
	leaq	buf(%rip), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -4(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L2
.L5:
	leaq	buf(%rip), %rax
	movq	%rax, %rdi
	call	gets@PLT
	leaq	buf(%rip), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -12(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -8(%rbp)
	jmp	.L3
.L4:
	movl	-12(%rbp), %eax
	imull	%eax, %eax
	movslq	%eax, %rdx
	imulq	$1374389535, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$5, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movslq	%eax, %rdx
	imulq	$1759218605, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$12, %edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -12(%rbp)
	movl	-12(%rbp), %edx
	imull	$10000, %edx, %edx
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -8(%rbp)
.L3:
	cmpl	$9, -8(%rbp)
	jle	.L4
	addl	$1, -16(%rbp)
.L2:
	movl	-16(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L5
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
