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){
  
  long long N;
  
  long long Y;
  
  scanf("%lld %lld", &N, &Y);
  
  long long i, j, k;
  long long p=0, a, b;
  
  for (i=0; i<= N; i++){
    for (j=0; j<= N-i; j++){
      if (10000*i + 5000*j + 1000*(N-i-j) == Y)
      {p=1; a=i; b=j;}
    }
  }
  
  if (p==1) {printf("%lld %lld %lld", a, b, N-a-b);}
  else {printf("%d %d %d", -1, -1, -1);}
  
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"%lld %lld %lld"
.LC2:
	.string	"%d %d %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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -32(%rbp)
	movq	$0, -48(%rbp)
	jmp	.L2
.L6:
	movq	$0, -40(%rbp)
	jmp	.L3
.L5:
	movq	-48(%rbp), %rax
	imulq	$10000, %rax, %rdx
	movq	-40(%rbp), %rax
	imulq	$5000, %rax, %rax
	addq	%rax, %rdx
	movq	-64(%rbp), %rax
	subq	-48(%rbp), %rax
	subq	-40(%rbp), %rax
	imulq	$1000, %rax, %rax
	addq	%rax, %rdx
	movq	-56(%rbp), %rax
	cmpq	%rax, %rdx
	jne	.L4
	movq	$1, -32(%rbp)
	movq	-48(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-40(%rbp), %rax
	movq	%rax, -16(%rbp)
.L4:
	addq	$1, -40(%rbp)
.L3:
	movq	-64(%rbp), %rax
	subq	-48(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jle	.L5
	addq	$1, -48(%rbp)
.L2:
	movq	-64(%rbp), %rax
	cmpq	%rax, -48(%rbp)
	jle	.L6
	cmpq	$1, -32(%rbp)
	jne	.L7
	movq	-64(%rbp), %rax
	subq	-24(%rbp), %rax
	subq	-16(%rbp), %rax
	movq	%rax, %rcx
	movq	-16(%rbp), %rdx
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L8
.L7:
	movl	$-1, %ecx
	movl	$-1, %edx
	movl	$-1, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L8:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	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	"%lld %lld"
.LC1:
	.string	"%lld %lld %lld"
.LC2:
	.string	"%d %d %d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rbx
	testq	%rbx, %rbx
	js	.L2
	imulq	$1000, %rbx, %r8
	leaq	1(%rbx), %rsi
	movq	%rbx, %r11
	xorl	%ecx, %ecx
	movq	16(%rsp), %r10
	movl	$1, %r9d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbx, %rdi
	movq	%r8, %rdx
	xorl	%eax, %eax
	subq	%r11, %rdi
	testq	%r11, %r11
	js	.L7
	.p2align 4,,10
	.p2align 3
.L5:
	cmpq	%r10, %rdx
	cmove	%rax, %r13
	cmove	%rdi, %r12
	cmove	%r9, %rcx
	addq	$1, %rax
	addq	$4000, %rdx
	cmpq	%rsi, %rax
	jne	.L5
.L7:
	subq	$1, %r11
	addq	$9000, %r8
	subq	$1, %rsi
	jne	.L3
	cmpq	$1, %rcx
	je	.L15
.L2:
	orl	$-1, %r8d
	orl	$-1, %ecx
	orl	$-1, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L8:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$32, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L15:
	.cfi_restore_state
	subq	%r12, %rbx
	movq	%r13, %rcx
	movq	%r12, %rdx
	movl	$1, %edi
	movq	%rbx, %r8
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	subq	%r13, %r8
	call	__printf_chk@PLT
	jmp	.L8
.L16:
	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	"%lld %lld"
.LC1:
	.string	"%lld %lld %lld"
.LC2:
	.string	"%d %d %d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rbx
	testq	%rbx, %rbx
	js	.L2
	imulq	$1000, %rbx, %r8
	leaq	1(%rbx), %rsi
	movq	%rbx, %r11
	xorl	%ecx, %ecx
	movq	16(%rsp), %r10
	movl	$1, %r9d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbx, %rdi
	movq	%r8, %rdx
	xorl	%eax, %eax
	subq	%r11, %rdi
	testq	%r11, %r11
	js	.L7
	.p2align 4,,10
	.p2align 3
.L5:
	cmpq	%r10, %rdx
	cmove	%rax, %r13
	cmove	%rdi, %r12
	cmove	%r9, %rcx
	addq	$1, %rax
	addq	$4000, %rdx
	cmpq	%rsi, %rax
	jne	.L5
.L7:
	subq	$1, %r11
	addq	$9000, %r8
	subq	$1, %rsi
	jne	.L3
	cmpq	$1, %rcx
	je	.L15
.L2:
	orl	$-1, %r8d
	orl	$-1, %ecx
	orl	$-1, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L8:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$32, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L15:
	.cfi_restore_state
	subq	%r12, %rbx
	movq	%r13, %rcx
	movq	%r12, %rdx
	movl	$1, %edi
	movq	%rbx, %r8
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	subq	%r13, %r8
	call	__printf_chk@PLT
	jmp	.L8
.L16:
	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){
  
  long long N;
  
  long long Y;
  
  scanf("%lld %lld", &N, &Y);
  
  long long i, j, k;
  long long p=0, a, b;
  
  for (i=0; i<= N; i++){
    for (j=0; j<= N-i; j++){
      if (10000*i + 5000*j + 1000*(N-i-j) == Y)
      {p=1; a=i; b=j;}
    }
  }
  
  if (p==1) {printf("%lld %lld %lld", a, b, N-a-b);}
  else {printf("%d %d %d", -1, -1, -1);}
  
  return 0;
}
0000 1234000
 6 45000
 0000 0
 20 318832
 2000 25743705
 0000 841858
 6 3463
 20 93731
 2000 40151179
 0000 383974

-1 -1 -1 3 3 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
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){
  
  long long N;
  
  long long Y;
  
  scanf("%lld %lld", &N, &Y);
  
  long long i, j, k;
  long long p=0, a, b;
  
  for (i=0; i<= N; i++){
    for (j=0; j<= N-i; j++){
      if (10000*i + 5000*j + 1000*(N-i-j) == Y)
      {p=1; a=i; b=j;}
    }
  }
  
  if (p==1) {printf("%lld %lld %lld", a, b, N-a-b);}
  else {printf("%d %d %d", -1, -1, -1);}
  
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"%lld %lld %lld"
.LC2:
	.string	"%d %d %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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -32(%rbp)
	movq	$0, -48(%rbp)
	jmp	.L2
.L6:
	movq	$0, -40(%rbp)
	jmp	.L3
.L5:
	movq	-48(%rbp), %rax
	imulq	$10000, %rax, %rdx
	movq	-40(%rbp), %rax
	imulq	$5000, %rax, %rax
	addq	%rax, %rdx
	movq	-64(%rbp), %rax
	subq	-48(%rbp), %rax
	subq	-40(%rbp), %rax
	imulq	$1000, %rax, %rax
	addq	%rax, %rdx
	movq	-56(%rbp), %rax
	cmpq	%rax, %rdx
	jne	.L4
	movq	$1, -32(%rbp)
	movq	-48(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-40(%rbp), %rax
	movq	%rax, -16(%rbp)
.L4:
	addq	$1, -40(%rbp)
.L3:
	movq	-64(%rbp), %rax
	subq	-48(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jle	.L5
	addq	$1, -48(%rbp)
.L2:
	movq	-64(%rbp), %rax
	cmpq	%rax, -48(%rbp)
	jle	.L6
	cmpq	$1, -32(%rbp)
	jne	.L7
	movq	-64(%rbp), %rax
	subq	-24(%rbp), %rax
	subq	-16(%rbp), %rax
	movq	%rax, %rcx
	movq	-16(%rbp), %rdx
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L8
.L7:
	movl	$-1, %ecx
	movl	$-1, %edx
	movl	$-1, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L8:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	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	"%lld %lld"
.LC1:
	.string	"%lld %lld %lld"
.LC2:
	.string	"%d %d %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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -32(%rbp)
	movq	$0, -48(%rbp)
	jmp	.L2
.L6:
	movq	$0, -40(%rbp)
	jmp	.L3
.L5:
	movq	-48(%rbp), %rax
	imulq	$10000, %rax, %rdx
	movq	-40(%rbp), %rax
	imulq	$5000, %rax, %rax
	addq	%rax, %rdx
	movq	-64(%rbp), %rax
	subq	-48(%rbp), %rax
	subq	-40(%rbp), %rax
	imulq	$1000, %rax, %rax
	addq	%rax, %rdx
	movq	-56(%rbp), %rax
	cmpq	%rax, %rdx
	jne	.L4
	movq	$1, -32(%rbp)
	movq	-48(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-40(%rbp), %rax
	movq	%rax, -16(%rbp)
.L4:
	addq	$1, -40(%rbp)
.L3:
	movq	-64(%rbp), %rax
	subq	-48(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jle	.L5
	addq	$1, -48(%rbp)
.L2:
	movq	-64(%rbp), %rax
	cmpq	%rax, -48(%rbp)
	jle	.L6
	cmpq	$1, -32(%rbp)
	jne	.L7
	movq	-64(%rbp), %rax
	subq	-24(%rbp), %rax
	subq	-16(%rbp), %rax
	movq	%rax, %rcx
	movq	-16(%rbp), %rdx
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L8
.L7:
	movl	$-1, %ecx
	movl	$-1, %edx
	movl	$-1, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L8:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	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:
