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(){
  int n,s=0;
  scanf("%d",&n);
  while(n>=500){
    n-=500;
    s+=1000;  
  }
  while(n>=5){
    n-=5;
    s+=5;
  }
  printf("%d",s);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -12(%rbp)
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L3:
	movl	-16(%rbp), %eax
	subl	$500, %eax
	movl	%eax, -16(%rbp)
	addl	$1000, -12(%rbp)
.L2:
	movl	-16(%rbp), %eax
	cmpl	$499, %eax
	jg	.L3
	jmp	.L4
.L5:
	movl	-16(%rbp), %eax
	subl	$5, %eax
	movl	%eax, -16(%rbp)
	addl	$5, -12(%rbp)
.L4:
	movl	-16(%rbp), %eax
	cmpl	$4, %eax
	jg	.L5
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	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
.LC1:
	.string	"%d"
	.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	.LC1(%rip), %rbp
	movq	%rbp, %rdi
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ecx
	cmpl	$499, %ecx
	jle	.L11
	leal	-500(%rcx), %esi
	movq	%rsi, %rax
	imulq	$274877907, %rsi, %rsi
	shrq	$37, %rsi
	addl	$1, %esi
	cmpl	$1999, %eax
	jbe	.L12
	movd	%ecx, %xmm4
	movl	%esi, %edx
	movdqa	.LC0(%rip), %xmm3
	xorl	%eax, %eax
	pshufd	$0, %xmm4, %xmm2
	movdqa	.LC3(%rip), %xmm7
	paddd	.LC2(%rip), %xmm2
	shrl	$2, %edx
	movdqa	.LC4(%rip), %xmm6
	movdqa	.LC5(%rip), %xmm5
	movdqa	.LC6(%rip), %xmm4
	.p2align 4,,10
	.p2align 3
.L4:
	movdqa	%xmm3, %xmm1
	movdqa	%xmm2, %xmm0
	paddd	%xmm7, %xmm3
	addl	$1, %eax
	paddd	%xmm6, %xmm2
	paddd	%xmm5, %xmm0
	paddd	%xmm4, %xmm1
	cmpl	%edx, %eax
	jne	.L4
	movl	%esi, %r8d
	pshufd	$255, %xmm1, %xmm1
	pshufd	$255, %xmm0, %xmm0
	andl	$-4, %r8d
	movd	%xmm1, %edx
	imull	$-500, %r8d, %eax
	imull	$1000, %r8d, %edi
	addl	%ecx, %eax
	movd	%xmm0, %ecx
	cmpl	%r8d, %esi
	je	.L5
.L3:
	leal	-500(%rax), %ecx
	leal	1000(%rdi), %edx
	cmpl	$499, %ecx
	jle	.L5
	leal	-1000(%rax), %ecx
	leal	2000(%rdi), %edx
	cmpl	$499, %ecx
	jle	.L5
	leal	-1500(%rax), %ecx
	leal	3000(%rdi), %edx
	cmpl	$499, %ecx
	jle	.L5
	leal	-2000(%rax), %ecx
	leal	4000(%rdi), %edx
.L5:
	movl	%ecx, 4(%rsp)
.L2:
	cmpl	$4, %ecx
	jle	.L6
	leal	-5(%rcx), %esi
	movl	$3435973837, %edi
	movq	%rsi, %rax
	imulq	%rdi, %rsi
	shrq	$34, %rsi
	addl	$1, %esi
	cmpl	$19, %eax
	jbe	.L14
	movd	%ecx, %xmm5
	movd	%edx, %xmm6
	movl	%esi, %edi
	xorl	%eax, %eax
	pshufd	$0, %xmm5, %xmm3
	pshufd	$0, %xmm6, %xmm2
	paddd	.LC7(%rip), %xmm3
	movdqa	.LC9(%rip), %xmm7
	paddd	.LC8(%rip), %xmm2
	movdqa	.LC10(%rip), %xmm6
	shrl	$2, %edi
	movdqa	.LC11(%rip), %xmm5
	movdqa	.LC12(%rip), %xmm4
	.p2align 4,,10
	.p2align 3
.L8:
	movdqa	%xmm2, %xmm1
	movdqa	%xmm3, %xmm0
	paddd	%xmm7, %xmm2
	addl	$1, %eax
	paddd	%xmm6, %xmm3
	paddd	%xmm5, %xmm0
	paddd	%xmm4, %xmm1
	cmpl	%eax, %edi
	jne	.L8
	movl	%esi, %r8d
	pshufd	$255, %xmm1, %xmm1
	pshufd	$255, %xmm0, %xmm0
	andl	$-4, %r8d
	movd	%xmm0, %eax
	leal	(%r8,%r8,4), %edi
	subl	%edi, %ecx
	addl	%edx, %edi
	movd	%xmm1, %edx
	cmpl	%r8d, %esi
	je	.L9
	leal	-5(%rcx), %eax
.L7:
	leal	5(%rdi), %edx
	cmpl	$4, %eax
	jle	.L9
	leal	-10(%rcx), %eax
	leal	10(%rdi), %edx
	cmpl	$4, %eax
	jle	.L9
	leal	-15(%rcx), %eax
	leal	15(%rdi), %edx
	cmpl	$4, %eax
	jle	.L9
	leal	-20(%rcx), %eax
	leal	20(%rdi), %edx
.L9:
	movl	%eax, 4(%rsp)
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L11:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L2
.L12:
	movl	%ecx, %eax
	xorl	%edi, %edi
	jmp	.L3
.L14:
	movl	%edx, %edi
	jmp	.L7
.L20:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1000
	.long	2000
	.long	3000
	.align 16
.LC2:
	.long	0
	.long	-500
	.long	-1000
	.long	-1500
	.align 16
.LC3:
	.long	4000
	.long	4000
	.long	4000
	.long	4000
	.align 16
.LC4:
	.long	-2000
	.long	-2000
	.long	-2000
	.long	-2000
	.align 16
.LC5:
	.long	-500
	.long	-500
	.long	-500
	.long	-500
	.align 16
.LC6:
	.long	1000
	.long	1000
	.long	1000
	.long	1000
	.align 16
.LC7:
	.long	0
	.long	-5
	.long	-10
	.long	-15
	.align 16
.LC8:
	.long	0
	.long	5
	.long	10
	.long	15
	.align 16
.LC9:
	.long	20
	.long	20
	.long	20
	.long	20
	.align 16
.LC10:
	.long	-20
	.long	-20
	.long	-20
	.long	-20
	.align 16
.LC11:
	.long	-5
	.long	-5
	.long	-5
	.long	-5
	.align 16
.LC12:
	.long	5
	.long	5
	.long	5
	.long	5
	.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
.LC1:
	.string	"%d"
	.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	.LC1(%rip), %rbp
	movq	%rbp, %rdi
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ecx
	cmpl	$499, %ecx
	jle	.L11
	leal	-500(%rcx), %esi
	movq	%rsi, %rax
	imulq	$274877907, %rsi, %rsi
	shrq	$37, %rsi
	addl	$1, %esi
	cmpl	$1999, %eax
	jbe	.L12
	movd	%ecx, %xmm4
	movl	%esi, %edx
	movdqa	.LC0(%rip), %xmm3
	xorl	%eax, %eax
	pshufd	$0, %xmm4, %xmm2
	movdqa	.LC3(%rip), %xmm7
	paddd	.LC2(%rip), %xmm2
	shrl	$2, %edx
	movdqa	.LC4(%rip), %xmm6
	movdqa	.LC5(%rip), %xmm5
	movdqa	.LC6(%rip), %xmm4
	.p2align 4,,10
	.p2align 3
.L4:
	movdqa	%xmm3, %xmm1
	movdqa	%xmm2, %xmm0
	paddd	%xmm7, %xmm3
	addl	$1, %eax
	paddd	%xmm6, %xmm2
	paddd	%xmm5, %xmm0
	paddd	%xmm4, %xmm1
	cmpl	%edx, %eax
	jne	.L4
	movl	%esi, %r8d
	pshufd	$255, %xmm1, %xmm1
	pshufd	$255, %xmm0, %xmm0
	andl	$-4, %r8d
	movd	%xmm1, %edx
	imull	$-500, %r8d, %eax
	imull	$1000, %r8d, %edi
	addl	%ecx, %eax
	movd	%xmm0, %ecx
	cmpl	%r8d, %esi
	je	.L5
.L3:
	leal	-500(%rax), %ecx
	leal	1000(%rdi), %edx
	cmpl	$499, %ecx
	jle	.L5
	leal	-1000(%rax), %ecx
	leal	2000(%rdi), %edx
	cmpl	$499, %ecx
	jle	.L5
	leal	-1500(%rax), %ecx
	leal	3000(%rdi), %edx
	cmpl	$499, %ecx
	jle	.L5
	leal	-2000(%rax), %ecx
	leal	4000(%rdi), %edx
.L5:
	movl	%ecx, 4(%rsp)
.L2:
	cmpl	$4, %ecx
	jle	.L6
	leal	-5(%rcx), %esi
	movl	$3435973837, %edi
	movq	%rsi, %rax
	imulq	%rdi, %rsi
	shrq	$34, %rsi
	addl	$1, %esi
	cmpl	$19, %eax
	jbe	.L14
	movd	%ecx, %xmm5
	movd	%edx, %xmm6
	movl	%esi, %edi
	xorl	%eax, %eax
	pshufd	$0, %xmm5, %xmm3
	pshufd	$0, %xmm6, %xmm2
	paddd	.LC7(%rip), %xmm3
	movdqa	.LC9(%rip), %xmm7
	paddd	.LC8(%rip), %xmm2
	movdqa	.LC10(%rip), %xmm6
	shrl	$2, %edi
	movdqa	.LC11(%rip), %xmm5
	movdqa	.LC12(%rip), %xmm4
	.p2align 4,,10
	.p2align 3
.L8:
	movdqa	%xmm2, %xmm1
	movdqa	%xmm3, %xmm0
	paddd	%xmm7, %xmm2
	addl	$1, %eax
	paddd	%xmm6, %xmm3
	paddd	%xmm5, %xmm0
	paddd	%xmm4, %xmm1
	cmpl	%eax, %edi
	jne	.L8
	movl	%esi, %r8d
	pshufd	$255, %xmm1, %xmm1
	pshufd	$255, %xmm0, %xmm0
	andl	$-4, %r8d
	movd	%xmm0, %eax
	leal	(%r8,%r8,4), %edi
	subl	%edi, %ecx
	addl	%edx, %edi
	movd	%xmm1, %edx
	cmpl	%r8d, %esi
	je	.L9
	leal	-5(%rcx), %eax
.L7:
	leal	5(%rdi), %edx
	cmpl	$4, %eax
	jle	.L9
	leal	-10(%rcx), %eax
	leal	10(%rdi), %edx
	cmpl	$4, %eax
	jle	.L9
	leal	-15(%rcx), %eax
	leal	15(%rdi), %edx
	cmpl	$4, %eax
	jle	.L9
	leal	-20(%rcx), %eax
	leal	20(%rdi), %edx
.L9:
	movl	%eax, 4(%rsp)
.L6:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L11:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L2
.L12:
	movl	%ecx, %eax
	xorl	%edi, %edi
	jmp	.L3
.L14:
	movl	%edx, %edi
	jmp	.L7
.L20:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1000
	.long	2000
	.long	3000
	.align 16
.LC2:
	.long	0
	.long	-500
	.long	-1000
	.long	-1500
	.align 16
.LC3:
	.long	4000
	.long	4000
	.long	4000
	.long	4000
	.align 16
.LC4:
	.long	-2000
	.long	-2000
	.long	-2000
	.long	-2000
	.align 16
.LC5:
	.long	-500
	.long	-500
	.long	-500
	.long	-500
	.align 16
.LC6:
	.long	1000
	.long	1000
	.long	1000
	.long	1000
	.align 16
.LC7:
	.long	0
	.long	-5
	.long	-10
	.long	-15
	.align 16
.LC8:
	.long	0
	.long	5
	.long	10
	.long	15
	.align 16
.LC9:
	.long	20
	.long	20
	.long	20
	.long	20
	.align 16
.LC10:
	.long	-20
	.long	-20
	.long	-20
	.long	-20
	.align 16
.LC11:
	.long	-5
	.long	-5
	.long	-5
	.long	-5
	.align 16
.LC12:
	.long	5
	.long	5
	.long	5
	.long	5
	.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(){
  int n,s=0;
  scanf("%d",&n);
  while(n>=500){
    n-=500;
    s+=1000;  
  }
  while(n>=5){
    n-=5;
    s+=5;
  }
  printf("%d",s);
  return 0;
}

1
 1000000001
 656
 -1
 506
 685
 925
 -8
 989
 -11

0 2000000000 1155 0 1005 1185 1425 0 1485 0
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(){
  int n,s=0;
  scanf("%d",&n);
  while(n>=500){
    n-=500;
    s+=1000;  
  }
  while(n>=5){
    n-=5;
    s+=5;
  }
  printf("%d",s);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -12(%rbp)
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L3:
	movl	-16(%rbp), %eax
	subl	$500, %eax
	movl	%eax, -16(%rbp)
	addl	$1000, -12(%rbp)
.L2:
	movl	-16(%rbp), %eax
	cmpl	$499, %eax
	jg	.L3
	jmp	.L4
.L5:
	movl	-16(%rbp), %eax
	subl	$5, %eax
	movl	%eax, -16(%rbp)
	addl	$5, -12(%rbp)
.L4:
	movl	-16(%rbp), %eax
	cmpl	$4, %eax
	jg	.L5
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	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"
	.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -12(%rbp)
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L3:
	movl	-16(%rbp), %eax
	subl	$500, %eax
	movl	%eax, -16(%rbp)
	addl	$1000, -12(%rbp)
.L2:
	movl	-16(%rbp), %eax
	cmpl	$499, %eax
	jg	.L3
	jmp	.L4
.L5:
	movl	-16(%rbp), %eax
	subl	$5, %eax
	movl	%eax, -16(%rbp)
	addl	$5, -12(%rbp)
.L4:
	movl	-16(%rbp), %eax
	cmpl	$4, %eax
	jg	.L5
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	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:
