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()
{
    unsigned long long int q, h, s, d;
    scanf("%lld %lld %lld %lld", &q, &h, &s, &d);
    unsigned long long int n;
    scanf("%lld", &n);
    unsigned long long int ans = 0;
    unsigned long long int min = d;
    if (2 * s < min)min = 2 * s;
    if (4 * h < min)min = 4 * h;
    if (8 * q < min)min = 8 * q;
    ans += min * (n / 2);
    n %= 2;
    min = s;
    if (2 * h < min)min = 2 * h;
    if (4 * q < min)min = 4 * q;
    ans += min * n;
    printf("%lld\n", ans);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%lld %lld %lld %lld"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.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	-40(%rbp), %rsi
	leaq	-48(%rbp), %rcx
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -16(%rbp)
	movq	-40(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-48(%rbp), %rax
	addq	%rax, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L2
	movq	-48(%rbp), %rax
	addq	%rax, %rax
	movq	%rax, -24(%rbp)
.L2:
	movq	-56(%rbp), %rax
	salq	$2, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L3
	movq	-56(%rbp), %rax
	salq	$2, %rax
	movq	%rax, -24(%rbp)
.L3:
	movq	-64(%rbp), %rax
	salq	$3, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L4
	movq	-64(%rbp), %rax
	salq	$3, %rax
	movq	%rax, -24(%rbp)
.L4:
	movq	-32(%rbp), %rax
	shrq	%rax
	imulq	-24(%rbp), %rax
	addq	%rax, -16(%rbp)
	movq	-32(%rbp), %rax
	andl	$1, %eax
	movq	%rax, -32(%rbp)
	movq	-48(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-56(%rbp), %rax
	addq	%rax, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L5
	movq	-56(%rbp), %rax
	addq	%rax, %rax
	movq	%rax, -24(%rbp)
.L5:
	movq	-64(%rbp), %rax
	salq	$2, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L6
	movq	-64(%rbp), %rax
	salq	$2, %rax
	movq	%rax, -24(%rbp)
.L6:
	movq	-32(%rbp), %rax
	imulq	-24(%rbp), %rax
	addq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	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 %lld %lld"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	subq	$56, %rsp
	.cfi_def_cfa_offset 64
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rcx
	leaq	8(%rsp), %rdx
	movq	%rsp, %rsi
	leaq	24(%rsp), %r8
	call	__isoc99_scanf@PLT
	leaq	32(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	16(%rsp), %r8
	movq	8(%rsp), %rax
	movq	(%rsp), %rdi
	movq	32(%rsp), %rsi
	leaq	0(,%rax,4), %rcx
	leaq	(%r8,%r8), %rdx
	cmpq	%rcx, %rdx
	cmova	%rcx, %rdx
	movq	24(%rsp), %rcx
	cmpq	%rcx, %rdx
	cmova	%rcx, %rdx
	leaq	0(,%rdi,8), %rcx
	cmpq	%rcx, %rdx
	cmovbe	%rdx, %rcx
	movq	%rsi, %rdx
	addq	%rax, %rax
	andl	$1, %esi
	shrq	%rdx
	movq	%rsi, 32(%rsp)
	imulq	%rdx, %rcx
	leaq	0(,%rdi,4), %rdx
	movl	$1, %edi
	cmpq	%rdx, %rax
	cmova	%rdx, %rax
	movq	%r8, %rdx
	cmpq	%r8, %rax
	cmovbe	%rax, %rdx
	movq	%rdx, %rax
	imulq	%rsi, %rax
	leaq	.LC2(%rip), %rsi
	leaq	(%rax,%rcx), %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L5
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L5:
	.cfi_restore_state
	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 %lld %lld"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	subq	$56, %rsp
	.cfi_def_cfa_offset 64
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rcx
	leaq	8(%rsp), %rdx
	movq	%rsp, %rsi
	leaq	24(%rsp), %r8
	call	__isoc99_scanf@PLT
	leaq	32(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	16(%rsp), %r8
	movq	8(%rsp), %rax
	movq	(%rsp), %rdi
	movq	32(%rsp), %rsi
	leaq	0(,%rax,4), %rcx
	leaq	(%r8,%r8), %rdx
	cmpq	%rcx, %rdx
	cmova	%rcx, %rdx
	movq	24(%rsp), %rcx
	cmpq	%rcx, %rdx
	cmova	%rcx, %rdx
	leaq	0(,%rdi,8), %rcx
	cmpq	%rcx, %rdx
	cmovbe	%rdx, %rcx
	movq	%rsi, %rdx
	addq	%rax, %rax
	andl	$1, %esi
	shrq	%rdx
	movq	%rsi, 32(%rsp)
	imulq	%rdx, %rcx
	leaq	0(,%rdi,4), %rdx
	movl	$1, %edi
	cmpq	%rdx, %rax
	cmova	%rdx, %rax
	movq	%r8, %rdx
	cmpq	%r8, %rax
	cmovbe	%rax, %rdx
	movq	%rdx, %rax
	imulq	%rsi, %rax
	leaq	.LC2(%rip), %rsi
	leaq	(%rax,%rcx), %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L5
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L5:
	.cfi_restore_state
	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()
{
    unsigned long long int q, h, s, d;
    scanf("%lld %lld %lld %lld", &q, &h, &s, &d);
    unsigned long long int n;
    scanf("%lld", &n);
    unsigned long long int ans = 0;
    unsigned long long int min = d;
    if (2 * s < min)min = 2 * s;
    if (4 * h < min)min = 4 * h;
    if (8 * q < min)min = 8 * q;
    ans += min * (n / 2);
    n %= 2;
    min = s;
    if (2 * h < min)min = 2 * h;
    if (4 * q < min)min = 4 * q;
    ans += min * n;
    printf("%lld\n", ans);
    return 0;
}
10 100 1010 10000
1
 20 30 70 129
3
 10000 1001 100 10
1
 12345678 87654321 12345678 87654321
226515686
 20 30 70 83
3
 10000 1001 100 10
0
 12345678 87654321 12873114 87654321
226515686
 20 30 70 63
3
 10000 1001 100 10
-1
 1103255 87654321 12873114 87654321
226515686

40
 180
 100
 2796489721305108
 143
 0
 2915962248666204
 123
 90
 999618252631720

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()
{
    unsigned long long int q, h, s, d;
    scanf("%lld %lld %lld %lld", &q, &h, &s, &d);
    unsigned long long int n;
    scanf("%lld", &n);
    unsigned long long int ans = 0;
    unsigned long long int min = d;
    if (2 * s < min)min = 2 * s;
    if (4 * h < min)min = 4 * h;
    if (8 * q < min)min = 8 * q;
    ans += min * (n / 2);
    n %= 2;
    min = s;
    if (2 * h < min)min = 2 * h;
    if (4 * q < min)min = 4 * q;
    ans += min * n;
    printf("%lld\n", ans);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%lld %lld %lld %lld"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.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	-40(%rbp), %rsi
	leaq	-48(%rbp), %rcx
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -16(%rbp)
	movq	-40(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-48(%rbp), %rax
	addq	%rax, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L2
	movq	-48(%rbp), %rax
	addq	%rax, %rax
	movq	%rax, -24(%rbp)
.L2:
	movq	-56(%rbp), %rax
	salq	$2, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L3
	movq	-56(%rbp), %rax
	salq	$2, %rax
	movq	%rax, -24(%rbp)
.L3:
	movq	-64(%rbp), %rax
	salq	$3, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L4
	movq	-64(%rbp), %rax
	salq	$3, %rax
	movq	%rax, -24(%rbp)
.L4:
	movq	-32(%rbp), %rax
	shrq	%rax
	imulq	-24(%rbp), %rax
	addq	%rax, -16(%rbp)
	movq	-32(%rbp), %rax
	andl	$1, %eax
	movq	%rax, -32(%rbp)
	movq	-48(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-56(%rbp), %rax
	addq	%rax, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L5
	movq	-56(%rbp), %rax
	addq	%rax, %rax
	movq	%rax, -24(%rbp)
.L5:
	movq	-64(%rbp), %rax
	salq	$2, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L6
	movq	-64(%rbp), %rax
	salq	$2, %rax
	movq	%rax, -24(%rbp)
.L6:
	movq	-32(%rbp), %rax
	imulq	-24(%rbp), %rax
	addq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	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 %lld %lld"
.LC1:
	.string	"%lld"
.LC2:
	.string	"%lld\n"
	.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	-40(%rbp), %rsi
	leaq	-48(%rbp), %rcx
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -16(%rbp)
	movq	-40(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-48(%rbp), %rax
	addq	%rax, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L2
	movq	-48(%rbp), %rax
	addq	%rax, %rax
	movq	%rax, -24(%rbp)
.L2:
	movq	-56(%rbp), %rax
	salq	$2, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L3
	movq	-56(%rbp), %rax
	salq	$2, %rax
	movq	%rax, -24(%rbp)
.L3:
	movq	-64(%rbp), %rax
	salq	$3, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L4
	movq	-64(%rbp), %rax
	salq	$3, %rax
	movq	%rax, -24(%rbp)
.L4:
	movq	-32(%rbp), %rax
	shrq	%rax
	imulq	-24(%rbp), %rax
	addq	%rax, -16(%rbp)
	movq	-32(%rbp), %rax
	andl	$1, %eax
	movq	%rax, -32(%rbp)
	movq	-48(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-56(%rbp), %rax
	addq	%rax, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L5
	movq	-56(%rbp), %rax
	addq	%rax, %rax
	movq	%rax, -24(%rbp)
.L5:
	movq	-64(%rbp), %rax
	salq	$2, %rax
	cmpq	%rax, -24(%rbp)
	jbe	.L6
	movq	-64(%rbp), %rax
	salq	$2, %rax
	movq	%rax, -24(%rbp)
.L6:
	movq	-32(%rbp), %rax
	imulq	-24(%rbp), %rax
	addq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	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:
