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 max(int a, int b)
{
   if(a>b) return a;
   else return b;
}
int min(int a, int b)
{
   if(a<b) return a;
   else return b;
}

int main(void)
{
   int q1, b, c1, c2, q2;
   int qa;
   int hi, lo, ce;

   while(scanf("%d", &q1)){
      if(q1==0) break;
      scanf("%d %d %d %d", &b, &c1, &c2, &q2);

      qa=0;
      hi=q2;
      lo=1;
      while(hi>=lo){
         ce=(hi+lo)/2;
	 if(c1*ce+c2*max(q1-ce, 0)<=b){
	    lo=ce+1;
	    qa=ce;
	 }
	 else {
	    if(c1>=c2 || c1*ce>b) hi=ce-1;
	    else {
	       qa=min(b/c1, q2);
	       if(c1*qa+c2*max(q1-qa, 0)>b){
	          qa=0; break;
               }
	    }
	 }
      }
      if(qa==0) printf("NA\n");
      else printf("%d %d\n", qa, (b-c1*qa)/c2);
   }
   return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	max
	.type	max, @function
max:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jle	.L2
	movl	-4(%rbp), %eax
	jmp	.L3
.L2:
	movl	-8(%rbp), %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	max, .-max
	.globl	min
	.type	min, @function
min:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L5
	movl	-4(%rbp), %eax
	jmp	.L6
.L5:
	movl	-8(%rbp), %eax
.L6:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"%d %d %d %d"
.LC1:
	.string	"NA"
.LC2:
	.string	"%d %d\n"
.LC3:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	jmp	.L8
.L18:
	movl	-60(%rbp), %eax
	testl	%eax, %eax
	je	.L21
	leaq	-44(%rbp), %rsi
	leaq	-48(%rbp), %rcx
	leaq	-52(%rbp), %rdx
	leaq	-56(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40(%rbp)
	movl	-44(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	$1, -32(%rbp)
	jmp	.L11
.L16:
	movl	-36(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -28(%rbp)
	movl	-52(%rbp), %eax
	imull	-28(%rbp), %eax
	movl	%eax, %ebx
	movl	-60(%rbp), %eax
	subl	-28(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	max
	movl	-48(%rbp), %edx
	imull	%edx, %eax
	leal	(%rbx,%rax), %edx
	movl	-56(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L12
	movl	-28(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -40(%rbp)
	jmp	.L11
.L12:
	movl	-52(%rbp), %edx
	movl	-48(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L13
	movl	-52(%rbp), %eax
	imull	-28(%rbp), %eax
	movl	%eax, %edx
	movl	-56(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L14
.L13:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
	jmp	.L11
.L14:
	movl	-44(%rbp), %ecx
	movl	-56(%rbp), %eax
	movl	-52(%rbp), %ebx
	cltd
	idivl	%ebx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	min
	movl	%eax, -40(%rbp)
	movl	-52(%rbp), %eax
	imull	-40(%rbp), %eax
	movl	%eax, %ebx
	movl	-60(%rbp), %eax
	subl	-40(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	max
	movl	-48(%rbp), %edx
	imull	%edx, %eax
	leal	(%rbx,%rax), %edx
	movl	-56(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L11
	movl	$0, -40(%rbp)
	jmp	.L15
.L11:
	movl	-36(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jge	.L16
.L15:
	cmpl	$0, -40(%rbp)
	jne	.L17
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L8
.L17:
	movl	-56(%rbp), %edx
	movl	-52(%rbp), %eax
	imull	-40(%rbp), %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	-48(%rbp), %ebx
	cltd
	idivl	%ebx
	movl	%eax, %edx
	movl	-40(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L8:
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	jne	.L18
	jmp	.L10
.L21:
	nop
.L10:
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB23:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovge	%edi, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	max, .-max
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB24:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovle	%edi, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	min, .-min
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d %d"
.LC1:
	.string	"NA"
.LC2:
	.string	"%d %d\n"
.LC3:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.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
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC3(%rip), %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rax
	leaq	20(%rsp), %rbp
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L5:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L6
	movl	20(%rsp), %eax
	testl	%eax, %eax
	je	.L6
	movq	8(%rsp), %r8
	leaq	32(%rsp), %rcx
	xorl	%eax, %eax
	leaq	28(%rsp), %rdx
	leaq	24(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %r13d
	testl	%r13d, %r13d
	jle	.L7
	movl	28(%rsp), %r9d
	movl	24(%rsp), %ecx
	movl	%r13d, %r8d
	movl	$1, %edi
	movl	32(%rsp), %r11d
	movl	20(%rsp), %r12d
	cmpl	%r11d, %r9d
	setge	%r14b
	xorl	%r10d, %r10d
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L26:
	leal	1(%rsi), %edi
	movl	%esi, %r10d
.L9:
	cmpl	%r8d, %edi
	jg	.L25
.L12:
	leal	(%r8,%rdi), %esi
	movl	%r9d, %r15d
	movl	%r12d, %edx
	movl	$0, %eax
	sarl	%esi
	imull	%esi, %r15d
	subl	%esi, %edx
	cmovs	%eax, %edx
	imull	%r11d, %edx
	addl	%r15d, %edx
	cmpl	%ecx, %edx
	jle	.L26
	cmpl	%ecx, %r15d
	jg	.L17
	testb	%r14b, %r14b
	je	.L10
.L17:
	leal	-1(%rsi), %r8d
	cmpl	%r8d, %edi
	jle	.L12
.L25:
	testl	%r10d, %r10d
	je	.L7
	imull	%r10d, %r9d
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	subl	%r9d, %ecx
	movl	%ecx, %eax
	cltd
	idivl	%r11d
	movl	%r10d, %edx
	movl	%eax, %ecx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L10:
	movl	%ecx, %eax
	cltd
	idivl	%r9d
	movl	$0, %edx
	cmpl	%r13d, %eax
	cmovg	%r13d, %eax
	movl	%eax, %r10d
	movl	%r12d, %eax
	subl	%r10d, %eax
	cmovs	%edx, %eax
	movl	%r9d, %edx
	imull	%r10d, %edx
	imull	%r11d, %eax
	addl	%edx, %eax
	cmpl	%eax, %ecx
	jge	.L9
.L7:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L5
.L6:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	addq	$56, %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
.L27:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.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
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB23:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovge	%edi, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	max, .-max
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB24:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovle	%edi, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	min, .-min
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d %d"
.LC1:
	.string	"NA"
.LC2:
	.string	"%d %d\n"
.LC3:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.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
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC3(%rip), %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rax
	leaq	20(%rsp), %rbp
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L5:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L6
	movl	20(%rsp), %eax
	testl	%eax, %eax
	je	.L6
	movq	8(%rsp), %r8
	leaq	32(%rsp), %rcx
	xorl	%eax, %eax
	leaq	28(%rsp), %rdx
	leaq	24(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %r13d
	testl	%r13d, %r13d
	jle	.L7
	movl	28(%rsp), %r9d
	movl	24(%rsp), %ecx
	movl	%r13d, %r8d
	movl	$1, %edi
	movl	32(%rsp), %r11d
	movl	20(%rsp), %r12d
	cmpl	%r11d, %r9d
	setge	%r14b
	xorl	%r10d, %r10d
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L26:
	leal	1(%rsi), %edi
	movl	%esi, %r10d
.L9:
	cmpl	%r8d, %edi
	jg	.L25
.L12:
	leal	(%r8,%rdi), %esi
	movl	%r9d, %r15d
	movl	%r12d, %edx
	movl	$0, %eax
	sarl	%esi
	imull	%esi, %r15d
	subl	%esi, %edx
	cmovs	%eax, %edx
	imull	%r11d, %edx
	addl	%r15d, %edx
	cmpl	%ecx, %edx
	jle	.L26
	cmpl	%ecx, %r15d
	jg	.L17
	testb	%r14b, %r14b
	je	.L10
.L17:
	leal	-1(%rsi), %r8d
	cmpl	%r8d, %edi
	jle	.L12
.L25:
	testl	%r10d, %r10d
	je	.L7
	imull	%r10d, %r9d
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	subl	%r9d, %ecx
	movl	%ecx, %eax
	cltd
	idivl	%r11d
	movl	%r10d, %edx
	movl	%eax, %ecx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L10:
	movl	%ecx, %eax
	cltd
	idivl	%r9d
	movl	$0, %edx
	cmpl	%r13d, %eax
	cmovg	%r13d, %eax
	movl	%eax, %r10d
	movl	%r12d, %eax
	subl	%r10d, %eax
	cmovs	%edx, %eax
	movl	%r9d, %edx
	imull	%r10d, %edx
	imull	%r11d, %eax
	addl	%edx, %eax
	cmpl	%eax, %ecx
	jge	.L9
.L7:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L5
.L6:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	addq	$56, %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
.L27:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.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 max(int a, int b)
{
   if(a>b) return a;
   else return b;
}
int min(int a, int b)
{
   if(a<b) return a;
   else return b;
}

int main(void)
{
   int q1, b, c1, c2, q2;
   int qa;
   int hi, lo, ce;

   while(scanf("%d", &q1)){
      if(q1==0) break;
      scanf("%d %d %d %d", &b, &c1, &c2, &q2);

      qa=0;
      hi=q2;
      lo=1;
      while(hi>=lo){
         ce=(hi+lo)/2;
	 if(c1*ce+c2*max(q1-ce, 0)<=b){
	    lo=ce+1;
	    qa=ce;
	 }
	 else {
	    if(c1>=c2 || c1*ce>b) hi=ce-1;
	    else {
	       qa=min(b/c1, q2);
	       if(c1*qa+c2*max(q1-qa, 0)>b){
	          qa=0; break;
               }
	    }
	 }
      }
      if(qa==0) printf("NA\n");
      else printf("%d %d\n", qa, (b-c1*qa)/c2);
   }
   return 0;
}
48 9297 240 126 32
20 3010 157 141 7
30 117002 5680 962 15
8 1673 1712 190 22
64 8478 87 54 307
23 5477 117 92 12
50 7558 1396 187 17
279 88677 2825 514 14
0
 48 9297 240 126 32
20 3010 157 141 7
30 117002 5843 962 15
8 1673 1712 190 22
64 8478 87 54 307
23 5477 117 92 12
50 7558 1396 187 17
279 88677 2825 514 14
0
 48 9297 240 126 32
20 3010 157 141 7
30 117002 5843 962 15
7 1673 1712 190 22
64 8478 160 54 307
23 5477 117 92 12
50 7558 1396 187 17
279 88677 2825 514 14
0
 48 9297 240 126 32
20 3010 157 141 7
30 117002 5843 962 15
7 1673 1712 190 22
64 8478 160 54 307
23 9941 117 92 12
50 7558 2714 187 17
279 88677 2825 514 14
0
 48 9297 240 126 32
20 3389 157 141 7
30 117002 5843 962 15
3 1673 1712 190 22
64 8478 160 54 307
23 9941 117 92 12
50 7558 2714 187 17
279 88677 2825 514 14
0
 48 9297 240 126 32
20 3389 157 141 7
30 65446 5843 962 15
3 1673 1492 190 22
64 8478 160 54 307
23 9941 117 92 12
50 7558 2714 187 17
173 88677 2825 514 14
0
 48 9297 240 126 32
20 3389 157 141 7
30 65446 6697 962 15
3 1673 1492 190 22
64 8478 160 54 307
23 9941 117 92 12
50 7558 2714 187 17
173 88677 2825 514 14
0
 48 9297 240 126 32
20 3389 177 141 7
30 65446 6697 962 15
3 1673 1779 190 22
64 8478 160 54 307
23 9941 117 92 12
50 7558 2714 187 17
173 88677 2825 514 14
0
 48 9297 240 126 32
20 3389 303 141 7
30 65446 6697 962 15
3 1673 1779 190 22
64 8478 160 54 307
23 9941 117 92 12
50 7558 2714 187 17
173 88677 2825 514 14
0
 48 5128 240 126 32
20 3389 303 141 7
30 65446 6697 962 15
3 1673 1779 111 22
64 8478 160 54 307
23 9941 118 92 12
50 7558 2714 187 17
173 88677 2825 514 14
0

28 20
7 13
15 33
NA
97 0
12 44
NA
NA
 28 20
7 13
15 30
NA
97 0
12 44
NA
NA
 28 20
7 13
15 30
NA
47 17
12 44
NA
NA
 28 20
7 13
15 30
NA
47 17
12 92
NA
NA
 28 20
7 16
15 30
NA
47 17
12 92
NA
NA
 28 20
7 16
7 25
NA
47 17
12 92
NA
NA
 28 20
7 16
6 26
NA
47 17
12 92
NA
NA
 28 20
7 15
6 26
NA
47 17
12 92
NA
NA
 28 20
3 17
6 26
NA
47 17
12 92
NA
NA
 NA
3 17
6 26
NA
47 17
12 92
NA
NA

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 max(int a, int b)
{
   if(a>b) return a;
   else return b;
}
int min(int a, int b)
{
   if(a<b) return a;
   else return b;
}

int main(void)
{
   int q1, b, c1, c2, q2;
   int qa;
   int hi, lo, ce;

   while(scanf("%d", &q1)){
      if(q1==0) break;
      scanf("%d %d %d %d", &b, &c1, &c2, &q2);

      qa=0;
      hi=q2;
      lo=1;
      while(hi>=lo){
         ce=(hi+lo)/2;
	 if(c1*ce+c2*max(q1-ce, 0)<=b){
	    lo=ce+1;
	    qa=ce;
	 }
	 else {
	    if(c1>=c2 || c1*ce>b) hi=ce-1;
	    else {
	       qa=min(b/c1, q2);
	       if(c1*qa+c2*max(q1-qa, 0)>b){
	          qa=0; break;
               }
	    }
	 }
      }
      if(qa==0) printf("NA\n");
      else printf("%d %d\n", qa, (b-c1*qa)/c2);
   }
   return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	max
	.type	max, @function
max:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jle	.L2
	movl	-4(%rbp), %eax
	jmp	.L3
.L2:
	movl	-8(%rbp), %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	max, .-max
	.globl	min
	.type	min, @function
min:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L5
	movl	-4(%rbp), %eax
	jmp	.L6
.L5:
	movl	-8(%rbp), %eax
.L6:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"%d %d %d %d"
.LC1:
	.string	"NA"
.LC2:
	.string	"%d %d\n"
.LC3:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	jmp	.L8
.L18:
	movl	-60(%rbp), %eax
	testl	%eax, %eax
	je	.L21
	leaq	-44(%rbp), %rsi
	leaq	-48(%rbp), %rcx
	leaq	-52(%rbp), %rdx
	leaq	-56(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40(%rbp)
	movl	-44(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	$1, -32(%rbp)
	jmp	.L11
.L16:
	movl	-36(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -28(%rbp)
	movl	-52(%rbp), %eax
	imull	-28(%rbp), %eax
	movl	%eax, %ebx
	movl	-60(%rbp), %eax
	subl	-28(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	max
	movl	-48(%rbp), %edx
	imull	%edx, %eax
	leal	(%rbx,%rax), %edx
	movl	-56(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L12
	movl	-28(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -40(%rbp)
	jmp	.L11
.L12:
	movl	-52(%rbp), %edx
	movl	-48(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L13
	movl	-52(%rbp), %eax
	imull	-28(%rbp), %eax
	movl	%eax, %edx
	movl	-56(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L14
.L13:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
	jmp	.L11
.L14:
	movl	-44(%rbp), %ecx
	movl	-56(%rbp), %eax
	movl	-52(%rbp), %ebx
	cltd
	idivl	%ebx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	min
	movl	%eax, -40(%rbp)
	movl	-52(%rbp), %eax
	imull	-40(%rbp), %eax
	movl	%eax, %ebx
	movl	-60(%rbp), %eax
	subl	-40(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	max
	movl	-48(%rbp), %edx
	imull	%edx, %eax
	leal	(%rbx,%rax), %edx
	movl	-56(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L11
	movl	$0, -40(%rbp)
	jmp	.L15
.L11:
	movl	-36(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jge	.L16
.L15:
	cmpl	$0, -40(%rbp)
	jne	.L17
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L8
.L17:
	movl	-56(%rbp), %edx
	movl	-52(%rbp), %eax
	imull	-40(%rbp), %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	-48(%rbp), %ebx
	cltd
	idivl	%ebx
	movl	%eax, %edx
	movl	-40(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L8:
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	jne	.L18
	jmp	.L10
.L21:
	nop
.L10:
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	max
	.type	max, @function
max:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jle	.L2
	movl	-4(%rbp), %eax
	jmp	.L3
.L2:
	movl	-8(%rbp), %eax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	max, .-max
	.globl	min
	.type	min, @function
min:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L5
	movl	-4(%rbp), %eax
	jmp	.L6
.L5:
	movl	-8(%rbp), %eax
.L6:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"%d %d %d %d"
.LC1:
	.string	"NA"
.LC2:
	.string	"%d %d\n"
.LC3:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	jmp	.L8
.L18:
	movl	-60(%rbp), %eax
	testl	%eax, %eax
	je	.L21
	leaq	-44(%rbp), %rsi
	leaq	-48(%rbp), %rcx
	leaq	-52(%rbp), %rdx
	leaq	-56(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40(%rbp)
	movl	-44(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	$1, -32(%rbp)
	jmp	.L11
.L16:
	movl	-36(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -28(%rbp)
	movl	-52(%rbp), %eax
	imull	-28(%rbp), %eax
	movl	%eax, %ebx
	movl	-60(%rbp), %eax
	subl	-28(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	max
	movl	-48(%rbp), %edx
	imull	%edx, %eax
	leal	(%rbx,%rax), %edx
	movl	-56(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L12
	movl	-28(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -40(%rbp)
	jmp	.L11
.L12:
	movl	-52(%rbp), %edx
	movl	-48(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L13
	movl	-52(%rbp), %eax
	imull	-28(%rbp), %eax
	movl	%eax, %edx
	movl	-56(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L14
.L13:
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
	jmp	.L11
.L14:
	movl	-44(%rbp), %ecx
	movl	-56(%rbp), %eax
	movl	-52(%rbp), %ebx
	cltd
	idivl	%ebx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	min
	movl	%eax, -40(%rbp)
	movl	-52(%rbp), %eax
	imull	-40(%rbp), %eax
	movl	%eax, %ebx
	movl	-60(%rbp), %eax
	subl	-40(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	max
	movl	-48(%rbp), %edx
	imull	%edx, %eax
	leal	(%rbx,%rax), %edx
	movl	-56(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L11
	movl	$0, -40(%rbp)
	jmp	.L15
.L11:
	movl	-36(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jge	.L16
.L15:
	cmpl	$0, -40(%rbp)
	jne	.L17
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L8
.L17:
	movl	-56(%rbp), %edx
	movl	-52(%rbp), %eax
	imull	-40(%rbp), %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	-48(%rbp), %ebx
	cltd
	idivl	%ebx
	movl	%eax, %edx
	movl	-40(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L8:
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	jne	.L18
	jmp	.L10
.L21:
	nop
.L10:
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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:
