Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
// AtCoder ABC054 D - Mixing Experiment
// 2020.1.24 bal4u

#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0; int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

#define MAX 230000
#define SFT 9
#define MSK 511
#define INF 0x5ffffff
int dp[MAX+5];
int N;

int main()
{
	int i, Ma, Mb;
	int ma, ans;
	
	N = in(), Ma = in(), Mb = in();
	ans = INF, ma = 0;
	for (i = 0; i < MAX; ++i) dp[i] = INF;
	dp[0] = 0;
	while (N--) {
		int a = in(), b = in(), c = in();
		for (i = ma; i >= 0; --i) if (dp[i] < INF) {
			int x = dp[i] + c;
			int aa = (i >> SFT) + a, bb = (i & MSK) + b;
			if (aa*Mb == bb*Ma && ans > x) ans = x;
			int k = (aa << SFT) | bb;
			if (k > ma) ma = k;
			if (dp[k] > x) dp[k] = x;
		}
	}
	if (ans < INF) printf("%d\n", ans);
	else puts("-1");
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	in
	.type	in, @function
in:
.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L2:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	in, .-in
	.globl	dp
	.bss
	.align 32
	.type	dp, @object
	.size	dp, 920020
dp:
	.zero	920020
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"-1"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	movl	$0, %eax
	call	in
	movl	%eax, N(%rip)
	movl	$0, %eax
	call	in
	movl	%eax, -36(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -32(%rbp)
	movl	$100663295, -40(%rbp)
	movl	$0, -44(%rbp)
	movl	$0, -48(%rbp)
	jmp	.L5
.L6:
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	$100663295, (%rdx,%rax)
	addl	$1, -48(%rbp)
.L5:
	cmpl	$229999, -48(%rbp)
	jle	.L6
	movl	$0, dp(%rip)
	jmp	.L7
.L13:
	movl	$0, %eax
	call	in
	movl	%eax, -28(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -24(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -20(%rbp)
	movl	-44(%rbp), %eax
	movl	%eax, -48(%rbp)
	jmp	.L8
.L12:
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$100663294, %eax
	jg	.L9
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	-48(%rbp), %eax
	sarl	$9, %eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-48(%rbp), %eax
	andl	$511, %eax
	movl	%eax, %edx
	movl	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-12(%rbp), %eax
	imull	-32(%rbp), %eax
	movl	%eax, %edx
	movl	-8(%rbp), %eax
	imull	-36(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L10
	movl	-40(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jle	.L10
	movl	-16(%rbp), %eax
	movl	%eax, -40(%rbp)
.L10:
	movl	-12(%rbp), %eax
	sall	$9, %eax
	orl	-8(%rbp), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-44(%rbp), %eax
	jle	.L11
	movl	-4(%rbp), %eax
	movl	%eax, -44(%rbp)
.L11:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rdx
	movl	-16(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L9:
	subl	$1, -48(%rbp)
.L8:
	cmpl	$0, -48(%rbp)
	jns	.L12
.L7:
	movl	N(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	jne	.L13
	cmpl	$100663294, -40(%rbp)
	jg	.L14
	movl	-40(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L15
.L14:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L15:
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	in
	.type	in, @function
in:
.LFB35:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L11
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L3:
	xorl	%r12d, %r12d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L1
.L5:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L7:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L4
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L1
	movq	stdin(%rip), %rdi
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L1:
	movl	%r12d, %eax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L3
	.cfi_endproc
.LFE35:
	.size	in, .-in
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d\n"
.LC2:
	.string	"-1"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	dp(%rip), %r14
	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
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	in
	movl	%eax, N(%rip)
	xorl	%eax, %eax
	call	in
	movl	%eax, 8(%rsp)
	xorl	%eax, %eax
	call	in
	movdqa	.LC0(%rip), %xmm0
	leaq	920000(%r14), %rdx
	movl	%eax, %ebp
	movq	%r14, %rax
	.p2align 4,,10
	.p2align 3
.L13:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L13
	movl	$0, dp(%rip)
	movl	N(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	je	.L14
	movl	$100663295, %r13d
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L36:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L49
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L16:
	xorl	%r12d, %r12d
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L17:
	leaq	1(%rdx), %r8
	movq	%r8, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L19
.L18:
	movq	%r8, %rdx
.L20:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L17
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %r8
	movq	16(%rdi), %rcx
	cmpl	$47, %eax
	jg	.L18
	.p2align 4,,10
	.p2align 3
.L19:
	cmpq	%r8, %rcx
	jbe	.L50
	leaq	1(%r8), %rsi
	movq	%rsi, 8(%rdi)
	movzbl	(%r8), %eax
.L22:
	xorl	%ebx, %ebx
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L23:
	leaq	1(%rsi), %r8
	movq	%r8, 8(%rdi)
	movzbl	(%rsi), %eax
	cmpl	$47, %eax
	jle	.L25
.L24:
	movq	%r8, %rsi
.L26:
	leal	(%rbx,%rbx,4), %edx
	andl	$15, %eax
	leal	(%rax,%rdx,2), %ebx
	cmpq	%rcx, %rsi
	jb	.L23
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %r8
	movq	16(%rdi), %rcx
	cmpl	$47, %eax
	jg	.L24
	.p2align 4,,10
	.p2align 3
.L25:
	cmpq	%r8, %rcx
	jbe	.L51
	leaq	1(%r8), %r9
	movq	%r9, 8(%rdi)
	movzbl	(%r8), %eax
.L28:
	xorl	%esi, %esi
	jmp	.L32
	.p2align 4,,10
	.p2align 3
.L29:
	leaq	1(%r9), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%r9), %eax
	cmpl	$47, %eax
	jle	.L31
.L30:
	movq	8(%rdi), %r9
	movq	16(%rdi), %rcx
.L32:
	leal	(%rsi,%rsi,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %esi
	cmpq	%rcx, %r9
	jb	.L29
	movl	%esi, 12(%rsp)
	call	__uflow@PLT
	movl	12(%rsp), %esi
	cmpl	$47, %eax
	jle	.L31
	movq	stdin(%rip), %rdi
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L31:
	movslq	%r15d, %rcx
	.p2align 4,,10
	.p2align 3
.L35:
	movl	(%r14,%rcx,4), %eax
	cmpl	$100663294, %eax
	jg	.L33
	leal	(%rax,%rsi), %r8d
	movl	%ecx, %edi
	movl	%ecx, %eax
	movl	8(%rsp), %r10d
	sarl	$9, %eax
	andl	$511, %edi
	movl	%ebp, %r11d
	movl	%r8d, %r9d
	addl	%r12d, %eax
	addl	%ebx, %edi
	imull	%eax, %r11d
	imull	%edi, %r10d
	cmpl	%r8d, %r13d
	cmovle	%r13d, %r9d
	cmpl	%r10d, %r11d
	cmove	%r9d, %r13d
	sall	$9, %eax
	orl	%edi, %eax
	cmpl	%eax, %r15d
	cmovl	%eax, %r15d
	cltq
	cmpl	%r8d, (%r14,%rax,4)
	jle	.L33
	movl	%r8d, (%r14,%rax,4)
.L33:
	subq	$1, %rcx
	cmpl	$-1, %ecx
	jne	.L35
	movl	N(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	jne	.L36
	cmpl	$100663295, %r13d
	je	.L14
	movl	%r13d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
.L37:
	addq	$24, %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
.L51:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %r9
	movq	16(%rdi), %rcx
	jmp	.L28
.L50:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rsi
	movq	16(%rdi), %rcx
	jmp	.L22
.L49:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L16
.L14:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L37
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 920020
dp:
	.zero	920020
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	100663295
	.long	100663295
	.long	100663295
	.long	100663295
	.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	in
	.type	in, @function
in:
.LFB35:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L11
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L3:
	xorl	%r12d, %r12d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L1
.L5:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L7:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L4
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L1
	movq	stdin(%rip), %rdi
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L1:
	movl	%r12d, %eax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L3
	.cfi_endproc
.LFE35:
	.size	in, .-in
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d\n"
.LC2:
	.string	"-1"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	dp(%rip), %r14
	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
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	in
	movl	%eax, N(%rip)
	xorl	%eax, %eax
	call	in
	movl	%eax, 8(%rsp)
	xorl	%eax, %eax
	call	in
	movdqa	.LC0(%rip), %xmm0
	leaq	920000(%r14), %rdx
	movl	%eax, %ebp
	movq	%r14, %rax
	.p2align 4,,10
	.p2align 3
.L13:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L13
	movl	$0, dp(%rip)
	movl	N(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	je	.L14
	movl	$100663295, %r13d
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L36:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L49
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L16:
	xorl	%r12d, %r12d
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L17:
	leaq	1(%rdx), %r8
	movq	%r8, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L19
.L18:
	movq	%r8, %rdx
.L20:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L17
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %r8
	movq	16(%rdi), %rcx
	cmpl	$47, %eax
	jg	.L18
	.p2align 4,,10
	.p2align 3
.L19:
	cmpq	%r8, %rcx
	jbe	.L50
	leaq	1(%r8), %rsi
	movq	%rsi, 8(%rdi)
	movzbl	(%r8), %eax
.L22:
	xorl	%ebx, %ebx
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L23:
	leaq	1(%rsi), %r8
	movq	%r8, 8(%rdi)
	movzbl	(%rsi), %eax
	cmpl	$47, %eax
	jle	.L25
.L24:
	movq	%r8, %rsi
.L26:
	leal	(%rbx,%rbx,4), %edx
	andl	$15, %eax
	leal	(%rax,%rdx,2), %ebx
	cmpq	%rcx, %rsi
	jb	.L23
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %r8
	movq	16(%rdi), %rcx
	cmpl	$47, %eax
	jg	.L24
	.p2align 4,,10
	.p2align 3
.L25:
	cmpq	%r8, %rcx
	jbe	.L51
	leaq	1(%r8), %r9
	movq	%r9, 8(%rdi)
	movzbl	(%r8), %eax
.L28:
	xorl	%esi, %esi
	jmp	.L32
	.p2align 4,,10
	.p2align 3
.L29:
	leaq	1(%r9), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%r9), %eax
	cmpl	$47, %eax
	jle	.L31
.L30:
	movq	8(%rdi), %r9
	movq	16(%rdi), %rcx
.L32:
	leal	(%rsi,%rsi,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %esi
	cmpq	%rcx, %r9
	jb	.L29
	movl	%esi, 12(%rsp)
	call	__uflow@PLT
	movl	12(%rsp), %esi
	cmpl	$47, %eax
	jle	.L31
	movq	stdin(%rip), %rdi
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L31:
	movslq	%r15d, %rcx
	.p2align 4,,10
	.p2align 3
.L35:
	movl	(%r14,%rcx,4), %eax
	cmpl	$100663294, %eax
	jg	.L33
	leal	(%rax,%rsi), %r8d
	movl	%ecx, %edi
	movl	%ecx, %eax
	movl	8(%rsp), %r10d
	sarl	$9, %eax
	andl	$511, %edi
	movl	%ebp, %r11d
	movl	%r8d, %r9d
	addl	%r12d, %eax
	addl	%ebx, %edi
	imull	%eax, %r11d
	imull	%edi, %r10d
	cmpl	%r8d, %r13d
	cmovle	%r13d, %r9d
	cmpl	%r10d, %r11d
	cmove	%r9d, %r13d
	sall	$9, %eax
	orl	%edi, %eax
	cmpl	%eax, %r15d
	cmovl	%eax, %r15d
	cltq
	cmpl	%r8d, (%r14,%rax,4)
	jle	.L33
	movl	%r8d, (%r14,%rax,4)
.L33:
	subq	$1, %rcx
	cmpl	$-1, %ecx
	jne	.L35
	movl	N(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	jne	.L36
	cmpl	$100663295, %r13d
	je	.L14
	movl	%r13d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
.L37:
	addq	$24, %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
.L51:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %r9
	movq	16(%rdi), %rcx
	jmp	.L28
.L50:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rsi
	movq	16(%rdi), %rcx
	jmp	.L22
.L49:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L16
.L14:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L37
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 920020
dp:
	.zero	920020
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	100663295
	.long	100663295
	.long	100663295
	.long	100663295
	.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:

// AtCoder ABC054 D - Mixing Experiment
// 2020.1.24 bal4u

#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0; int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

#define MAX 230000
#define SFT 9
#define MSK 511
#define INF 0x5ffffff
int dp[MAX+5];
int N;

int main()
{
	int i, Ma, Mb;
	int ma, ans;
	
	N = in(), Ma = in(), Mb = in();
	ans = INF, ma = 0;
	for (i = 0; i < MAX; ++i) dp[i] = INF;
	dp[0] = 0;
	while (N--) {
		int a = in(), b = in(), c = in();
		for (i = ma; i >= 0; --i) if (dp[i] < INF) {
			int x = dp[i] + c;
			int aa = (i >> SFT) + a, bb = (i & MSK) + b;
			if (aa*Mb == bb*Ma && ans > x) ans = x;
			int k = (aa << SFT) | bb;
			if (k > ma) ma = k;
			if (dp[k] > x) dp[k] = x;
		}
	}
	if (ans < INF) printf("%d\n", ans);
	else puts("-1");
	return 0;
}

1 0 10
10 10 10
 3 1 1
1 2 2
2 1 2
3 3 10
 3 1 1
1 2 2
2 1 4
0 3 16
 3 1 1
1 2 1
2 0 2
3 3 10
 3 1 2
0 2 2
2 1 2
0 3 16
 3 1 1
1 2 2
2 1 5
0 3 16
 3 1 1
1 2 1
2 0 2
3 5 10
 3 2 1
1 2 4
2 1 2
3 3 10
 3 1 1
2 0 2
2 1 2
0 3 10
 3 1 1
1 2 1
3 0 2
3 5 10

-1
 4
 6
 10
 18
 7
 12
 2
 14
 13

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
// AtCoder ABC054 D - Mixing Experiment
// 2020.1.24 bal4u

#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0; int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

#define MAX 230000
#define SFT 9
#define MSK 511
#define INF 0x5ffffff
int dp[MAX+5];
int N;

int main()
{
	int i, Ma, Mb;
	int ma, ans;
	
	N = in(), Ma = in(), Mb = in();
	ans = INF, ma = 0;
	for (i = 0; i < MAX; ++i) dp[i] = INF;
	dp[0] = 0;
	while (N--) {
		int a = in(), b = in(), c = in();
		for (i = ma; i >= 0; --i) if (dp[i] < INF) {
			int x = dp[i] + c;
			int aa = (i >> SFT) + a, bb = (i & MSK) + b;
			if (aa*Mb == bb*Ma && ans > x) ans = x;
			int k = (aa << SFT) | bb;
			if (k > ma) ma = k;
			if (dp[k] > x) dp[k] = x;
		}
	}
	if (ans < INF) printf("%d\n", ans);
	else puts("-1");
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	in
	.type	in, @function
in:
.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L2:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	in, .-in
	.globl	dp
	.bss
	.align 32
	.type	dp, @object
	.size	dp, 920020
dp:
	.zero	920020
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"-1"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	movl	$0, %eax
	call	in
	movl	%eax, N(%rip)
	movl	$0, %eax
	call	in
	movl	%eax, -36(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -32(%rbp)
	movl	$100663295, -40(%rbp)
	movl	$0, -44(%rbp)
	movl	$0, -48(%rbp)
	jmp	.L5
.L6:
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	$100663295, (%rdx,%rax)
	addl	$1, -48(%rbp)
.L5:
	cmpl	$229999, -48(%rbp)
	jle	.L6
	movl	$0, dp(%rip)
	jmp	.L7
.L13:
	movl	$0, %eax
	call	in
	movl	%eax, -28(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -24(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -20(%rbp)
	movl	-44(%rbp), %eax
	movl	%eax, -48(%rbp)
	jmp	.L8
.L12:
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$100663294, %eax
	jg	.L9
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	-48(%rbp), %eax
	sarl	$9, %eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-48(%rbp), %eax
	andl	$511, %eax
	movl	%eax, %edx
	movl	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-12(%rbp), %eax
	imull	-32(%rbp), %eax
	movl	%eax, %edx
	movl	-8(%rbp), %eax
	imull	-36(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L10
	movl	-40(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jle	.L10
	movl	-16(%rbp), %eax
	movl	%eax, -40(%rbp)
.L10:
	movl	-12(%rbp), %eax
	sall	$9, %eax
	orl	-8(%rbp), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-44(%rbp), %eax
	jle	.L11
	movl	-4(%rbp), %eax
	movl	%eax, -44(%rbp)
.L11:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rdx
	movl	-16(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L9:
	subl	$1, -48(%rbp)
.L8:
	cmpl	$0, -48(%rbp)
	jns	.L12
.L7:
	movl	N(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	jne	.L13
	cmpl	$100663294, -40(%rbp)
	jg	.L14
	movl	-40(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L15
.L14:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L15:
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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.
val
	.file	"temp.c"
	.text
	.globl	in
	.type	in, @function
in:
.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L2:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	in, .-in
	.globl	dp
	.bss
	.align 32
	.type	dp, @object
	.size	dp, 920020
dp:
	.zero	920020
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"-1"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	movl	$0, %eax
	call	in
	movl	%eax, N(%rip)
	movl	$0, %eax
	call	in
	movl	%eax, -36(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -32(%rbp)
	movl	$100663295, -40(%rbp)
	movl	$0, -44(%rbp)
	movl	$0, -48(%rbp)
	jmp	.L5
.L6:
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	$100663295, (%rdx,%rax)
	addl	$1, -48(%rbp)
.L5:
	cmpl	$229999, -48(%rbp)
	jle	.L6
	movl	$0, dp(%rip)
	jmp	.L7
.L13:
	movl	$0, %eax
	call	in
	movl	%eax, -28(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -24(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -20(%rbp)
	movl	-44(%rbp), %eax
	movl	%eax, -48(%rbp)
	jmp	.L8
.L12:
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$100663294, %eax
	jg	.L9
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	-48(%rbp), %eax
	sarl	$9, %eax
	movl	%eax, %edx
	movl	-28(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-48(%rbp), %eax
	andl	$511, %eax
	movl	%eax, %edx
	movl	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-12(%rbp), %eax
	imull	-32(%rbp), %eax
	movl	%eax, %edx
	movl	-8(%rbp), %eax
	imull	-36(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L10
	movl	-40(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jle	.L10
	movl	-16(%rbp), %eax
	movl	%eax, -40(%rbp)
.L10:
	movl	-12(%rbp), %eax
	sall	$9, %eax
	orl	-8(%rbp), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-44(%rbp), %eax
	jle	.L11
	movl	-4(%rbp), %eax
	movl	%eax, -44(%rbp)
.L11:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rdx
	movl	-16(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L9:
	subl	$1, -48(%rbp)
.L8:
	cmpl	$0, -48(%rbp)
	jns	.L12
.L7:
	movl	N(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	jne	.L13
	cmpl	$100663294, -40(%rbp)
	jg	.L14
	movl	-40(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L15
.L14:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L15:
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
