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<stdlib.h>

int main(){

int s;
scanf("%d",&s);
int a[200];
a[0] = s;

for (int i = 1; i <= 200; i++)
{
  if (a[i-1]%2==0)
  {
    a[i] = a[i-1]/2;
  }else
  {
    a[i] = a[i-1]*3+1;
  }
  
  if (i%100==0)
  {
    for (int j = i-100; j < i-1; j++)
    {
      for (int k = j+1; k <= j+100; k++)
      {
        if(a[k] == a[j]){
          printf("%d",k+1);
          exit(0);
        }
      }
    }
  }
}

return 0;

}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
	.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	$832, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-832(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-832(%rbp), %eax
	movl	%eax, -816(%rbp)
	movl	$1, -828(%rbp)
	jmp	.L2
.L11:
	movl	-828(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L3
	movl	-828(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %edx
	movl	-828(%rbp), %eax
	cltq
	movl	%edx, -816(%rbp,%rax,4)
	jmp	.L4
.L3:
	movl	-828(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-816(%rbp,%rax,4), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	leal	1(%rax), %edx
	movl	-828(%rbp), %eax
	cltq
	movl	%edx, -816(%rbp,%rax,4)
.L4:
	movl	-828(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1374389535, %rax, %rax
	shrq	$32, %rax
	sarl	$5, %eax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	imull	$100, %eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	testl	%eax, %eax
	jne	.L5
	movl	-828(%rbp), %eax
	subl	$100, %eax
	movl	%eax, -824(%rbp)
	jmp	.L6
.L10:
	movl	-824(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -820(%rbp)
	jmp	.L7
.L9:
	movl	-820(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %edx
	movl	-824(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L8
	movl	-820(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %edi
	call	exit@PLT
.L8:
	addl	$1, -820(%rbp)
.L7:
	movl	-824(%rbp), %eax
	addl	$100, %eax
	cmpl	%eax, -820(%rbp)
	jle	.L9
	addl	$1, -824(%rbp)
.L6:
	movl	-828(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -824(%rbp)
	jl	.L10
.L5:
	addl	$1, -828(%rbp)
.L2:
	cmpl	$200, -828(%rbp)
	jle	.L11
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	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	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rbp
	movq	%rbp, %rdi
	subq	$832, %rsp
	.cfi_def_cfa_offset 848
	movq	%fs:40, %rax
	movq	%rax, 824(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	leaq	-380(%rsp), %rdi
	movl	$1, %r9d
	movl	%eax, 16(%rsp)
	movl	396(%rdi), %eax
	testb	$1, %al
	jne	.L16
.L8:
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
.L3:
	movl	%eax, 400(%rdi)
	imull	$-1030792151, %r9d, %eax
	rorl	$2, %eax
	cmpl	$42949672, %eax
	ja	.L4
	movl	%r9d, %ecx
	movq	%rdi, %r8
	leal	99(%r9), %r10d
.L7:
	movl	(%r8), %esi
	leal	-99(%rcx), %edx
	movq	%r8, %rax
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L5:
	addq	$4, %rax
	cmpl	%ecx, %edx
	jg	.L17
.L6:
	addl	$1, %edx
	cmpl	%esi, 4(%rax)
	jne	.L5
	movl	$1, %edi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	exit@PLT
	.p2align 4,,10
	.p2align 3
.L17:
	addl	$1, %ecx
	addq	$4, %r8
	cmpl	%r10d, %ecx
	jne	.L7
	.p2align 4,,10
	.p2align 3
.L4:
	movl	400(%rdi), %eax
	addq	$4, %rdi
	addl	$1, %r9d
	testb	$1, %al
	je	.L8
.L16:
	leal	1(%rax,%rax,2), %eax
	jmp	.L3
	.cfi_endproc
.LFE39:
	.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"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rbp
	movq	%rbp, %rdi
	subq	$832, %rsp
	.cfi_def_cfa_offset 848
	movq	%fs:40, %rax
	movq	%rax, 824(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	leaq	-380(%rsp), %rdi
	movl	$1, %r9d
	movl	%eax, 16(%rsp)
	movl	396(%rdi), %eax
	testb	$1, %al
	jne	.L16
.L8:
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
.L3:
	movl	%eax, 400(%rdi)
	imull	$-1030792151, %r9d, %eax
	rorl	$2, %eax
	cmpl	$42949672, %eax
	ja	.L4
	movl	%r9d, %ecx
	movq	%rdi, %r8
	leal	99(%r9), %r10d
.L7:
	movl	(%r8), %esi
	leal	-99(%rcx), %edx
	movq	%r8, %rax
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L5:
	addq	$4, %rax
	cmpl	%ecx, %edx
	jg	.L17
.L6:
	addl	$1, %edx
	cmpl	%esi, 4(%rax)
	jne	.L5
	movl	$1, %edi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	exit@PLT
	.p2align 4,,10
	.p2align 3
.L17:
	addl	$1, %ecx
	addq	$4, %r8
	cmpl	%r10d, %ecx
	jne	.L7
	.p2align 4,,10
	.p2align 3
.L4:
	movl	400(%rdi), %eax
	addq	$4, %rdi
	addl	$1, %r9d
	testb	$1, %al
	je	.L8
.L16:
	leal	1(%rax,%rax,2), %eax
	jmp	.L3
	.cfi_endproc
.LFE39:
	.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<stdlib.h>

int main(){

int s;
scanf("%d",&s);
int a[200];
a[0] = s;

for (int i = 1; i <= 200; i++)
{
  if (a[i-1]%2==0)
  {
    a[i] = a[i-1]/2;
  }else
  {
    a[i] = a[i-1]*3+1;
  }
  
  if (i%100==0)
  {
    for (int j = i-100; j < i-1; j++)
    {
      for (int k = j+1; k <= j+100; k++)
      {
        if(a[k] == a[j]){
          printf("%d",k+1);
          exit(0);
        }
      }
    }
  }
}

return 0;

}

87
 11
 10
 82
 17
 20
 65
 2
 22
 43

32 16 8 112 14 9 29 4 17 31
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<stdlib.h>

int main(){

int s;
scanf("%d",&s);
int a[200];
a[0] = s;

for (int i = 1; i <= 200; i++)
{
  if (a[i-1]%2==0)
  {
    a[i] = a[i-1]/2;
  }else
  {
    a[i] = a[i-1]*3+1;
  }
  
  if (i%100==0)
  {
    for (int j = i-100; j < i-1; j++)
    {
      for (int k = j+1; k <= j+100; k++)
      {
        if(a[k] == a[j]){
          printf("%d",k+1);
          exit(0);
        }
      }
    }
  }
}

return 0;

}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
	.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	$832, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-832(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-832(%rbp), %eax
	movl	%eax, -816(%rbp)
	movl	$1, -828(%rbp)
	jmp	.L2
.L11:
	movl	-828(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L3
	movl	-828(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %edx
	movl	-828(%rbp), %eax
	cltq
	movl	%edx, -816(%rbp,%rax,4)
	jmp	.L4
.L3:
	movl	-828(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-816(%rbp,%rax,4), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	leal	1(%rax), %edx
	movl	-828(%rbp), %eax
	cltq
	movl	%edx, -816(%rbp,%rax,4)
.L4:
	movl	-828(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1374389535, %rax, %rax
	shrq	$32, %rax
	sarl	$5, %eax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	imull	$100, %eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	testl	%eax, %eax
	jne	.L5
	movl	-828(%rbp), %eax
	subl	$100, %eax
	movl	%eax, -824(%rbp)
	jmp	.L6
.L10:
	movl	-824(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -820(%rbp)
	jmp	.L7
.L9:
	movl	-820(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %edx
	movl	-824(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L8
	movl	-820(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %edi
	call	exit@PLT
.L8:
	addl	$1, -820(%rbp)
.L7:
	movl	-824(%rbp), %eax
	addl	$100, %eax
	cmpl	%eax, -820(%rbp)
	jle	.L9
	addl	$1, -824(%rbp)
.L6:
	movl	-828(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -824(%rbp)
	jl	.L10
.L5:
	addl	$1, -828(%rbp)
.L2:
	cmpl	$200, -828(%rbp)
	jle	.L11
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	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.
val
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
	.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	$832, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-832(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-832(%rbp), %eax
	movl	%eax, -816(%rbp)
	movl	$1, -828(%rbp)
	jmp	.L2
.L11:
	movl	-828(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L3
	movl	-828(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %edx
	movl	-828(%rbp), %eax
	cltq
	movl	%edx, -816(%rbp,%rax,4)
	jmp	.L4
.L3:
	movl	-828(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-816(%rbp,%rax,4), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	leal	1(%rax), %edx
	movl	-828(%rbp), %eax
	cltq
	movl	%edx, -816(%rbp,%rax,4)
.L4:
	movl	-828(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1374389535, %rax, %rax
	shrq	$32, %rax
	sarl	$5, %eax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	imull	$100, %eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	testl	%eax, %eax
	jne	.L5
	movl	-828(%rbp), %eax
	subl	$100, %eax
	movl	%eax, -824(%rbp)
	jmp	.L6
.L10:
	movl	-824(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -820(%rbp)
	jmp	.L7
.L9:
	movl	-820(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %edx
	movl	-824(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L8
	movl	-820(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %edi
	call	exit@PLT
.L8:
	addl	$1, -820(%rbp)
.L7:
	movl	-824(%rbp), %eax
	addl	$100, %eax
	cmpl	%eax, -820(%rbp)
	jle	.L9
	addl	$1, -824(%rbp)
.L6:
	movl	-828(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -824(%rbp)
	jl	.L10
.L5:
	addl	$1, -828(%rbp)
.L2:
	cmpl	$200, -828(%rbp)
	jle	.L11
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	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:
