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

```c
S[9999];main(F,I,s,f){for(;scanf("%d,%d",&I,&s)*I;S[I]=s)F|=1<<s;for(;~scanf("%d",&I);printf("%d\n",s))for(f=F&-1<<S[I],s=1;f&=f-1;)s++;}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	S
	.bss
	.align 32
	.type	S, @object
	.size	S, 39996
S:
	.zero	39996
	.section	.rodata
.LC0:
	.string	"%d,%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d"
	.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	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	jmp	.L2
.L3:
	movl	-12(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	orl	%eax, -4(%rbp)
	movl	-8(%rbp), %edx
	movl	-12(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	S(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L2:
	leaq	-12(%rbp), %rdx
	leaq	-8(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-8(%rbp), %edx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L3
	jmp	.L4
.L7:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	$-1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	andl	-4(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	$1, -12(%rbp)
	jmp	.L5
.L6:
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -12(%rbp)
.L5:
	movl	-16(%rbp), %eax
	subl	$1, %eax
	andl	%eax, -16(%rbp)
	cmpl	$0, -16(%rbp)
	jne	.L6
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L4:
	leaq	-8(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L7
	movl	$0, %eax
	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"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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	S(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	%esi, 12(%rsp)
	leaq	8(%rsp), %r13
	leaq	12(%rsp), %rbp
	movl	%edx, 8(%rsp)
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	movl	8(%rsp), %ecx
	movl	$1, %eax
	movl	%ecx, (%r14,%rdx,4)
	sall	%cl, %eax
	orl	%eax, %ebx
.L2:
	movq	%r13, %rdx
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	12(%rsp), %rdx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L3
	leaq	.LC2(%rip), %r12
	leaq	S(%rip), %r15
	movl	$-1, %r14d
	leaq	.LC1(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r12, %rdi
	call	scanf@PLT
	cmpl	$-1, %eax
	je	.L12
	movslq	12(%rsp), %rax
	movl	$1, 8(%rsp)
	movl	(%r15,%rax,4), %ecx
	movl	%r14d, %eax
	sall	%cl, %eax
	andl	%ebx, %eax
	leal	-1(%rax), %edx
	andl	%edx, %eax
	je	.L8
	movl	$2, %ecx
	.p2align 4,,10
	.p2align 3
.L6:
	leal	-1(%rax), %edx
	movl	%ecx, %esi
	leal	1(%rcx), %ecx
	andl	%edx, %eax
	jne	.L6
	movl	%esi, 8(%rsp)
.L5:
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	printf@PLT
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L12:
	addq	$24, %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
.L8:
	.cfi_restore_state
	movl	$1, %esi
	jmp	.L5
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	S
	.bss
	.align 32
	.type	S, @object
	.size	S, 39996
S:
	.zero	39996
	.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"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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	S(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	%esi, 12(%rsp)
	leaq	8(%rsp), %r13
	leaq	12(%rsp), %rbp
	movl	%edx, 8(%rsp)
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	movl	8(%rsp), %ecx
	movl	$1, %eax
	movl	%ecx, (%r14,%rdx,4)
	sall	%cl, %eax
	orl	%eax, %ebx
.L2:
	movq	%r13, %rdx
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	12(%rsp), %rdx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L3
	leaq	.LC2(%rip), %r12
	leaq	S(%rip), %r15
	movl	$-1, %r14d
	leaq	.LC1(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r12, %rdi
	call	scanf@PLT
	cmpl	$-1, %eax
	je	.L12
	movslq	12(%rsp), %rax
	movl	$1, 8(%rsp)
	movl	(%r15,%rax,4), %ecx
	movl	%r14d, %eax
	sall	%cl, %eax
	andl	%ebx, %eax
	leal	-1(%rax), %edx
	andl	%edx, %eax
	je	.L8
	movl	$2, %ecx
	.p2align 4,,10
	.p2align 3
.L6:
	leal	-1(%rax), %edx
	movl	%ecx, %esi
	leal	1(%rcx), %ecx
	andl	%edx, %eax
	jne	.L6
	movl	%esi, 8(%rsp)
.L5:
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	printf@PLT
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L12:
	addq	$24, %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
.L8:
	.cfi_restore_state
	movl	$1, %esi
	jmp	.L5
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	S
	.bss
	.align 32
	.type	S, @object
	.size	S, 39996
S:
	.zero	39996
	.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:

S[9999];main(F,I,s,f){for(;scanf("%d,%d",&I,&s)*I;S[I]=s)F|=1<<s;for(;~scanf("%d",&I);printf("%d\n",s))for(f=F&-1<<S[I],s=1;f&=f-1;)s++;}
1,20
2,20
3,30
4,10
5,10
6,20
0,0
1
2
4
1

2
2
3
2

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

```c
S[9999];main(F,I,s,f){for(;scanf("%d,%d",&I,&s)*I;S[I]=s)F|=1<<s;for(;~scanf("%d",&I);printf("%d\n",s))for(f=F&-1<<S[I],s=1;f&=f-1;)s++;}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	S
	.bss
	.align 32
	.type	S, @object
	.size	S, 39996
S:
	.zero	39996
	.section	.rodata
.LC0:
	.string	"%d,%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d"
	.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	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	jmp	.L2
.L3:
	movl	-12(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	orl	%eax, -4(%rbp)
	movl	-8(%rbp), %edx
	movl	-12(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	S(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L2:
	leaq	-12(%rbp), %rdx
	leaq	-8(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-8(%rbp), %edx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L3
	jmp	.L4
.L7:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	$-1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	andl	-4(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	$1, -12(%rbp)
	jmp	.L5
.L6:
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -12(%rbp)
.L5:
	movl	-16(%rbp), %eax
	subl	$1, %eax
	andl	%eax, -16(%rbp)
	cmpl	$0, -16(%rbp)
	jne	.L6
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L4:
	leaq	-8(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L7
	movl	$0, %eax
	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
	.globl	S
	.bss
	.align 32
	.type	S, @object
	.size	S, 39996
S:
	.zero	39996
	.section	.rodata
.LC0:
	.string	"%d,%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d"
	.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	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	%ecx, -16(%rbp)
	jmp	.L2
.L3:
	movl	-12(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	orl	%eax, -4(%rbp)
	movl	-8(%rbp), %edx
	movl	-12(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	S(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L2:
	leaq	-12(%rbp), %rdx
	leaq	-8(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-8(%rbp), %edx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L3
	jmp	.L4
.L7:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	$-1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	andl	-4(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	$1, -12(%rbp)
	jmp	.L5
.L6:
	movl	-12(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -12(%rbp)
.L5:
	movl	-16(%rbp), %eax
	subl	$1, %eax
	andl	%eax, -16(%rbp)
	cmpl	$0, -16(%rbp)
	jne	.L6
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L4:
	leaq	-8(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L7
	movl	$0, %eax
	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:
