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

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"-1 -1 -1"
	.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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -28(%rbp)
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -36(%rbp)
	jmp	.L2
.L7:
	movl	$0, -32(%rbp)
	jmp	.L3
.L6:
	movl	-44(%rbp), %eax
	movl	-36(%rbp), %ecx
	movl	-32(%rbp), %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	js	.L4
	movl	-36(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%eax, %edx
	movl	-44(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L4
	movl	-12(%rbp), %eax
	imull	$10000, %eax, %edx
	movl	-32(%rbp), %eax
	imull	$5000, %eax, %eax
	addl	%eax, %edx
	movl	-36(%rbp), %eax
	imull	$1000, %eax, %eax
	addl	%eax, %edx
	movl	-40(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L4
	movl	-12(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	-36(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	$1, -28(%rbp)
	jmp	.L5
.L4:
	addl	$1, -32(%rbp)
.L3:
	movl	-44(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L6
.L5:
	addl	$1, -36(%rbp)
.L2:
	movl	-44(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jle	.L7
	cmpl	$1, -28(%rbp)
	jne	.L8
	movl	-16(%rbp), %ecx
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L8:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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 %d %d"
.LC2:
	.string	"-1 -1 -1"
	.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	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	leaq	4(%rsp), %rdx
	call	__isoc99_scanf@PLT
	movl	(%rsp), %esi
	testl	%esi, %esi
	js	.L2
	movl	4(%rsp), %edi
	leal	1(%rsi), %r11d
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	imull	$10000, %esi, %r10d
	.p2align 4,,10
	.p2align 3
.L6:
	movl	%esi, %eax
	movl	%r10d, %ecx
	xorl	%edx, %edx
	subl	%r9d, %eax
	.p2align 4,,10
	.p2align 3
.L5:
	testl	%eax, %eax
	js	.L3
	cmpl	%ecx, %edi
	je	.L9
.L3:
	addl	$1, %edx
	subl	$1, %eax
	subl	$5000, %ecx
	cmpl	%edx, %esi
	jge	.L5
	addl	$1, %r9d
	subl	$9000, %r10d
	cmpl	%r11d, %r9d
	jne	.L6
.L16:
	cmpl	$1, %r8d
	je	.L14
.L2:
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L7:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$16, %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
	.p2align 4,,10
	.p2align 3
.L9:
	.cfi_restore_state
	movl	%r9d, %ebx
	addl	$1, %r9d
	movl	%edx, %r13d
	movl	%eax, %r12d
	movl	$1, %r8d
	subl	$9000, %r10d
	cmpl	%r11d, %r9d
	jne	.L6
	jmp	.L16
.L14:
	movl	%ebx, %r8d
	movl	%r13d, %ecx
	movl	%r12d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L7
.L15:
	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	"%d %d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"-1 -1 -1"
	.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	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	leaq	4(%rsp), %rdx
	call	__isoc99_scanf@PLT
	movl	(%rsp), %esi
	testl	%esi, %esi
	js	.L2
	movl	4(%rsp), %edi
	leal	1(%rsi), %r11d
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	imull	$10000, %esi, %r10d
	.p2align 4,,10
	.p2align 3
.L6:
	movl	%esi, %eax
	movl	%r10d, %ecx
	xorl	%edx, %edx
	subl	%r9d, %eax
	.p2align 4,,10
	.p2align 3
.L5:
	testl	%eax, %eax
	js	.L3
	cmpl	%ecx, %edi
	je	.L9
.L3:
	addl	$1, %edx
	subl	$1, %eax
	subl	$5000, %ecx
	cmpl	%edx, %esi
	jge	.L5
	addl	$1, %r9d
	subl	$9000, %r10d
	cmpl	%r11d, %r9d
	jne	.L6
.L16:
	cmpl	$1, %r8d
	je	.L14
.L2:
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L7:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$16, %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
	.p2align 4,,10
	.p2align 3
.L9:
	.cfi_restore_state
	movl	%r9d, %ebx
	addl	$1, %r9d
	movl	%edx, %r13d
	movl	%eax, %r12d
	movl	$1, %r8d
	subl	$9000, %r10d
	cmpl	%r11d, %r9d
	jne	.L6
	jmp	.L16
.L14:
	movl	%ebx, %r8d
	movl	%r13d, %ecx
	movl	%r12d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L7
.L15:
	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(){
  int N,Y,i,k,p,t=0,a,b,c;
  scanf("%d %d",&N,&Y);
  for(i=0;i<=N;i++){
      for(k=0;k<=N;k++){
        p=N-(i+k);
     if(p>=0&&i+k+p==N&&10000*p+5000*k+1000*i==Y){
       a=p;
         b=k;
         c=i;
          t=1;
          break;
        }
      }
  }
    if(t==1){printf("%d %d %d",a,b,c);}
    else printf("-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(){
  int N,Y,i,k,p,t=0,a,b,c;
  scanf("%d %d",&N,&Y);
  for(i=0;i<=N;i++){
      for(k=0;k<=N;k++){
        p=N-(i+k);
     if(p>=0&&i+k+p==N&&10000*p+5000*k+1000*i==Y){
       a=p;
         b=k;
         c=i;
          t=1;
          break;
        }
      }
  }
    if(t==1){printf("%d %d %d",a,b,c);}
    else printf("-1 -1 -1");
  return 0;
  }```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"-1 -1 -1"
	.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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -28(%rbp)
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -36(%rbp)
	jmp	.L2
.L7:
	movl	$0, -32(%rbp)
	jmp	.L3
.L6:
	movl	-44(%rbp), %eax
	movl	-36(%rbp), %ecx
	movl	-32(%rbp), %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	js	.L4
	movl	-36(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%eax, %edx
	movl	-44(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L4
	movl	-12(%rbp), %eax
	imull	$10000, %eax, %edx
	movl	-32(%rbp), %eax
	imull	$5000, %eax, %eax
	addl	%eax, %edx
	movl	-36(%rbp), %eax
	imull	$1000, %eax, %eax
	addl	%eax, %edx
	movl	-40(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L4
	movl	-12(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	-36(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	$1, -28(%rbp)
	jmp	.L5
.L4:
	addl	$1, -32(%rbp)
.L3:
	movl	-44(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L6
.L5:
	addl	$1, -36(%rbp)
.L2:
	movl	-44(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jle	.L7
	cmpl	$1, -28(%rbp)
	jne	.L8
	movl	-16(%rbp), %ecx
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L8:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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 %d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.string	"-1 -1 -1"
	.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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -28(%rbp)
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -36(%rbp)
	jmp	.L2
.L7:
	movl	$0, -32(%rbp)
	jmp	.L3
.L6:
	movl	-44(%rbp), %eax
	movl	-36(%rbp), %ecx
	movl	-32(%rbp), %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	js	.L4
	movl	-36(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%eax, %edx
	movl	-44(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L4
	movl	-12(%rbp), %eax
	imull	$10000, %eax, %edx
	movl	-32(%rbp), %eax
	imull	$5000, %eax, %eax
	addl	%eax, %edx
	movl	-36(%rbp), %eax
	imull	$1000, %eax, %eax
	addl	%eax, %edx
	movl	-40(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L4
	movl	-12(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	-36(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	$1, -28(%rbp)
	jmp	.L5
.L4:
	addl	$1, -32(%rbp)
.L3:
	movl	-44(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L6
.L5:
	addl	$1, -36(%rbp)
.L2:
	movl	-44(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jle	.L7
	cmpl	$1, -28(%rbp)
	jne	.L8
	movl	-16(%rbp), %ecx
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L8:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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:
