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>
#include <stdlib.h>

struct st_attack {
    int score;
    int cost;
};

int main(void) {
    int h,n;
    int max_score = 0;
    unsigned long long min_cost = __UINT64_MAX__;
    unsigned long long *costs;
    struct st_attack *attacks;
    scanf("%d %d", &h, &n);

    attacks = malloc( sizeof(struct st_attack)*n );
    for(int i=0; i<n; i++) {
        scanf("%d %d", &(attacks+i)->score, &(attacks+i)->cost);
        if( max_score < (attacks+i)->score ) {
            max_score = (attacks+i)->score;
        }
    }

    costs = malloc( sizeof(unsigned long long)*(h+max_score));
    
    for(int i=0; i<(h+max_score); i++) {
        costs[i] = __UINT64_MAX__;
    }
    costs[0] = 0;

    for(int i=0; i<h; i++) {
        if( costs[i]!=__UINT64_MAX__ ) {
            for(int j=0; j<n; j++) {
                if( costs[i+(attacks+j)->score] > costs[i] + (attacks+j)->cost ) { 
                    costs[i+(attacks+j)->score] = costs[i] + (attacks+j)->cost; 
                }
            }
        }
    }

    for(int i=0; i<max_score; i++) {
        if( costs[h+i]<min_cost ) {
            min_cost = costs[h+i];
        }
    }

    printf("%llu\n", min_cost);
    free(attacks);
    free(costs);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%llu\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.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
	movl	$0, -56(%rbp)
	movq	$-1, -32(%rbp)
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movl	$0, -52(%rbp)
	jmp	.L2
.L4:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	addq	$4, %rax
	movl	-52(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rdx, %rcx
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -56(%rbp)
	jge	.L3
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -56(%rbp)
.L3:
	addl	$1, -52(%rbp)
.L2:
	movl	-60(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jl	.L4
	movl	-64(%rbp), %edx
	movl	-56(%rbp), %eax
	addl	%edx, %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -48(%rbp)
	jmp	.L5
.L6:
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	$-1, (%rax)
	addl	$1, -48(%rbp)
.L5:
	movl	-64(%rbp), %edx
	movl	-56(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -48(%rbp)
	jl	.L6
	movq	-16(%rbp), %rax
	movq	$0, (%rax)
	movl	$0, -44(%rbp)
	jmp	.L7
.L12:
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	je	.L8
	movl	$0, -40(%rbp)
	jmp	.L9
.L11:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-44(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movl	-44(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rdx), %rcx
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rsi
	movq	-24(%rbp), %rdx
	addq	%rsi, %rdx
	movl	4(%rdx), %edx
	movslq	%edx, %rdx
	addq	%rcx, %rdx
	cmpq	%rdx, %rax
	jbe	.L10
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	movq	-24(%rbp), %rax
	addq	%rsi, %rax
	movl	(%rax), %esi
	movl	-44(%rbp), %eax
	addl	%esi, %eax
	cltq
	leaq	0(,%rax,8), %rsi
	movq	-16(%rbp), %rax
	addq	%rsi, %rax
	addq	%rcx, %rdx
	movq	%rdx, (%rax)
.L10:
	addl	$1, -40(%rbp)
.L9:
	movl	-60(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L11
.L8:
	addl	$1, -44(%rbp)
.L7:
	movl	-64(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jl	.L12
	movl	$0, -36(%rbp)
	jmp	.L13
.L15:
	movl	-64(%rbp), %edx
	movl	-36(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -32(%rbp)
	jbe	.L14
	movl	-64(%rbp), %edx
	movl	-36(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, -32(%rbp)
.L14:
	addl	$1, -36(%rbp)
.L13:
	movl	-36(%rbp), %eax
	cmpl	-56(%rbp), %eax
	jl	.L15
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	"%llu\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%r15, %rdi
	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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rdx
	leaq	16(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rdi
	movq	%rdi, %r13
	salq	$3, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testl	%r13d, %r13d
	jle	.L14
	movq	%rax, %r12
	xorl	%r14d, %r14d
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	4(%r12), %rdx
	movq	%r12, %rsi
	xorl	%eax, %eax
	movq	%r15, %rdi
	call	__isoc99_scanf@PLT
	movl	(%r12), %eax
	movl	20(%rsp), %r13d
	cmpl	%eax, %ebx
	cmovl	%eax, %ebx
	addl	$1, %r14d
	addq	$8, %r12
	cmpl	%r14d, %r13d
	jg	.L3
.L2:
	movslq	16(%rsp), %r14
	leal	(%r14,%rbx), %edx
	movslq	%edx, %r15
	movl	%edx, 12(%rsp)
	salq	$3, %r15
	movq	%r15, %rdi
	call	malloc@PLT
	movl	12(%rsp), %edx
	movq	%rax, %r12
	testl	%edx, %edx
	jle	.L7
	movq	%r15, %rdx
	movl	$255, %esi
	movq	%rax, %rdi
	call	memset@PLT
.L7:
	movq	$0, (%r12)
	testl	%r14d, %r14d
	jle	.L5
	leal	-1(%r13), %eax
	movslq	%r14d, %r9
	xorl	%esi, %esi
	xorl	%r10d, %r10d
	leaq	8(%rbp,%rax,8), %r8
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L8:
	addq	$1, %rsi
	cmpq	%rsi, %r9
	je	.L5
.L25:
	movq	(%r12,%rsi,8), %r10
.L6:
	movl	%esi, %edi
	cmpq	$-1, %r10
	je	.L8
	testl	%r13d, %r13d
	jle	.L8
	movq	%rbp, %rax
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L24:
	movq	(%r12,%rsi,8), %r10
.L10:
	movl	(%rax), %edx
	addl	%edi, %edx
	movslq	%edx, %rdx
	leaq	(%r12,%rdx,8), %rcx
	movslq	4(%rax), %rdx
	addq	%r10, %rdx
	cmpq	%rdx, (%rcx)
	jbe	.L9
	movq	%rdx, (%rcx)
.L9:
	addq	$8, %rax
	cmpq	%rax, %r8
	jne	.L24
	addq	$1, %rsi
	cmpq	%rsi, %r9
	jne	.L25
.L5:
	testl	%ebx, %ebx
	je	.L15
	leal	-1(%rbx), %edx
	leaq	(%r12,%r14,8), %rax
	addq	%r14, %rdx
	leaq	8(%r12,%rdx,8), %rsi
	movq	$-1, %rdx
	.p2align 4,,10
	.p2align 3
.L12:
	movq	(%rax), %rcx
	cmpq	%rcx, %rdx
	cmova	%rcx, %rdx
	addq	$8, %rax
	cmpq	%rsi, %rax
	jne	.L12
.L11:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	addq	$40, %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
.L14:
	.cfi_restore_state
	xorl	%ebx, %ebx
	jmp	.L2
.L15:
	orq	$-1, %rdx
	jmp	.L11
.L26:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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	"%llu\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%r15, %rdi
	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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rdx
	leaq	16(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rdi
	movq	%rdi, %r13
	salq	$3, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testl	%r13d, %r13d
	jle	.L14
	movq	%rax, %r12
	xorl	%r14d, %r14d
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	4(%r12), %rdx
	movq	%r12, %rsi
	xorl	%eax, %eax
	movq	%r15, %rdi
	call	__isoc99_scanf@PLT
	movl	(%r12), %eax
	movl	20(%rsp), %r13d
	cmpl	%eax, %ebx
	cmovl	%eax, %ebx
	addl	$1, %r14d
	addq	$8, %r12
	cmpl	%r14d, %r13d
	jg	.L3
.L2:
	movslq	16(%rsp), %r14
	leal	(%r14,%rbx), %edx
	movslq	%edx, %r15
	movl	%edx, 12(%rsp)
	salq	$3, %r15
	movq	%r15, %rdi
	call	malloc@PLT
	movl	12(%rsp), %edx
	movq	%rax, %r12
	testl	%edx, %edx
	jle	.L7
	movq	%r15, %rdx
	movl	$255, %esi
	movq	%rax, %rdi
	call	memset@PLT
.L7:
	movq	$0, (%r12)
	testl	%r14d, %r14d
	jle	.L5
	leal	-1(%r13), %eax
	movslq	%r14d, %r9
	xorl	%esi, %esi
	xorl	%r10d, %r10d
	leaq	8(%rbp,%rax,8), %r8
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L8:
	addq	$1, %rsi
	cmpq	%rsi, %r9
	je	.L5
.L25:
	movq	(%r12,%rsi,8), %r10
.L6:
	movl	%esi, %edi
	cmpq	$-1, %r10
	je	.L8
	testl	%r13d, %r13d
	jle	.L8
	movq	%rbp, %rax
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L24:
	movq	(%r12,%rsi,8), %r10
.L10:
	movl	(%rax), %edx
	addl	%edi, %edx
	movslq	%edx, %rdx
	leaq	(%r12,%rdx,8), %rcx
	movslq	4(%rax), %rdx
	addq	%r10, %rdx
	cmpq	%rdx, (%rcx)
	jbe	.L9
	movq	%rdx, (%rcx)
.L9:
	addq	$8, %rax
	cmpq	%rax, %r8
	jne	.L24
	addq	$1, %rsi
	cmpq	%rsi, %r9
	jne	.L25
.L5:
	testl	%ebx, %ebx
	je	.L15
	leal	-1(%rbx), %edx
	leaq	(%r12,%r14,8), %rax
	addq	%r14, %rdx
	leaq	8(%r12,%rdx,8), %rsi
	movq	$-1, %rdx
	.p2align 4,,10
	.p2align 3
.L12:
	movq	(%rax), %rcx
	cmpq	%rcx, %rdx
	cmova	%rcx, %rdx
	addq	$8, %rax
	cmpq	%rsi, %rax
	jne	.L12
.L11:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	addq	$40, %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
.L14:
	.cfi_restore_state
	xorl	%ebx, %ebx
	jmp	.L2
.L15:
	orq	$-1, %rdx
	jmp	.L11
.L26:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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>
#include <stdlib.h>

struct st_attack {
    int score;
    int cost;
};

int main(void) {
    int h,n;
    int max_score = 0;
    unsigned long long min_cost = __UINT64_MAX__;
    unsigned long long *costs;
    struct st_attack *attacks;
    scanf("%d %d", &h, &n);

    attacks = malloc( sizeof(struct st_attack)*n );
    for(int i=0; i<n; i++) {
        scanf("%d %d", &(attacks+i)->score, &(attacks+i)->cost);
        if( max_score < (attacks+i)->score ) {
            max_score = (attacks+i)->score;
        }
    }

    costs = malloc( sizeof(unsigned long long)*(h+max_score));
    
    for(int i=0; i<(h+max_score); i++) {
        costs[i] = __UINT64_MAX__;
    }
    costs[0] = 0;

    for(int i=0; i<h; i++) {
        if( costs[i]!=__UINT64_MAX__ ) {
            for(int j=0; j<n; j++) {
                if( costs[i+(attacks+j)->score] > costs[i] + (attacks+j)->cost ) { 
                    costs[i+(attacks+j)->score] = costs[i] + (attacks+j)->cost; 
                }
            }
        }
    }

    for(int i=0; i<max_score; i++) {
        if( costs[h+i]<min_cost ) {
            min_cost = costs[h+i];
        }
    }

    printf("%llu\n", min_cost);
    free(attacks);
    free(costs);
    return 0;
}
9999 10
540 7550
691 13640
700 9790
510 7150
415 5818
551 7712
587 8227
619 8671
588 8228
176 2461
 100 6
1 1
2 3
3 9
4 27
5 81
5 243
 110 6
1 1
2 3
3 9
4 27
5 81
5 243
 9999 10
540 7550
691 20670
700 9790
863 7150
415 5818
551 7712
587 8227
619 8671
588 8228
176 2461
 9999 10
540 7550
691 20670
700 9790
863 7150
415 1114
551 7712
587 8227
941 8671
588 10398
176 2461
 9999 5
540 4853
1222 7523
1778 16913
231 7150
415 769
118 7712
1118 8227
908 8671
94 4378
37 2120
 9999 5
289 4853
1222 12181
1778 16913
231 7150
415 1085
118 7712
1118 8227
1028 8975
94 5576
37 2120
 18187 7
197 2752
1222 10579
1778 16891
231 7150
415 1085
118 7083
813 10801
1028 8975
94 737
72 2120
 18187 7
228 2752
1939 10579
1778 16891
206 7150
415 1085
118 7083
560 878
3260 8600
12 1223
72 2120
 18187 7
379 2752
979 10579
1778 10271
187 7150
415 2513
130 13207
731 878
28 8600
6 2361
72 2120

139815
 100
 110
 85800
 27850
 19225
 27125
 47740
 28974
 21950

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>
#include <stdlib.h>

struct st_attack {
    int score;
    int cost;
};

int main(void) {
    int h,n;
    int max_score = 0;
    unsigned long long min_cost = __UINT64_MAX__;
    unsigned long long *costs;
    struct st_attack *attacks;
    scanf("%d %d", &h, &n);

    attacks = malloc( sizeof(struct st_attack)*n );
    for(int i=0; i<n; i++) {
        scanf("%d %d", &(attacks+i)->score, &(attacks+i)->cost);
        if( max_score < (attacks+i)->score ) {
            max_score = (attacks+i)->score;
        }
    }

    costs = malloc( sizeof(unsigned long long)*(h+max_score));
    
    for(int i=0; i<(h+max_score); i++) {
        costs[i] = __UINT64_MAX__;
    }
    costs[0] = 0;

    for(int i=0; i<h; i++) {
        if( costs[i]!=__UINT64_MAX__ ) {
            for(int j=0; j<n; j++) {
                if( costs[i+(attacks+j)->score] > costs[i] + (attacks+j)->cost ) { 
                    costs[i+(attacks+j)->score] = costs[i] + (attacks+j)->cost; 
                }
            }
        }
    }

    for(int i=0; i<max_score; i++) {
        if( costs[h+i]<min_cost ) {
            min_cost = costs[h+i];
        }
    }

    printf("%llu\n", min_cost);
    free(attacks);
    free(costs);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%llu\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.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
	movl	$0, -56(%rbp)
	movq	$-1, -32(%rbp)
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movl	$0, -52(%rbp)
	jmp	.L2
.L4:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	addq	$4, %rax
	movl	-52(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rdx, %rcx
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -56(%rbp)
	jge	.L3
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -56(%rbp)
.L3:
	addl	$1, -52(%rbp)
.L2:
	movl	-60(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jl	.L4
	movl	-64(%rbp), %edx
	movl	-56(%rbp), %eax
	addl	%edx, %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -48(%rbp)
	jmp	.L5
.L6:
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	$-1, (%rax)
	addl	$1, -48(%rbp)
.L5:
	movl	-64(%rbp), %edx
	movl	-56(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -48(%rbp)
	jl	.L6
	movq	-16(%rbp), %rax
	movq	$0, (%rax)
	movl	$0, -44(%rbp)
	jmp	.L7
.L12:
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	je	.L8
	movl	$0, -40(%rbp)
	jmp	.L9
.L11:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-44(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movl	-44(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rdx), %rcx
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rsi
	movq	-24(%rbp), %rdx
	addq	%rsi, %rdx
	movl	4(%rdx), %edx
	movslq	%edx, %rdx
	addq	%rcx, %rdx
	cmpq	%rdx, %rax
	jbe	.L10
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	movq	-24(%rbp), %rax
	addq	%rsi, %rax
	movl	(%rax), %esi
	movl	-44(%rbp), %eax
	addl	%esi, %eax
	cltq
	leaq	0(,%rax,8), %rsi
	movq	-16(%rbp), %rax
	addq	%rsi, %rax
	addq	%rcx, %rdx
	movq	%rdx, (%rax)
.L10:
	addl	$1, -40(%rbp)
.L9:
	movl	-60(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L11
.L8:
	addl	$1, -44(%rbp)
.L7:
	movl	-64(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jl	.L12
	movl	$0, -36(%rbp)
	jmp	.L13
.L15:
	movl	-64(%rbp), %edx
	movl	-36(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -32(%rbp)
	jbe	.L14
	movl	-64(%rbp), %edx
	movl	-36(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, -32(%rbp)
.L14:
	addl	$1, -36(%rbp)
.L13:
	movl	-36(%rbp), %eax
	cmpl	-56(%rbp), %eax
	jl	.L15
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	"%llu\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.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
	movl	$0, -56(%rbp)
	movq	$-1, -32(%rbp)
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movl	$0, -52(%rbp)
	jmp	.L2
.L4:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	addq	$4, %rax
	movl	-52(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rdx, %rcx
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -56(%rbp)
	jge	.L3
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -56(%rbp)
.L3:
	addl	$1, -52(%rbp)
.L2:
	movl	-60(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jl	.L4
	movl	-64(%rbp), %edx
	movl	-56(%rbp), %eax
	addl	%edx, %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -48(%rbp)
	jmp	.L5
.L6:
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	$-1, (%rax)
	addl	$1, -48(%rbp)
.L5:
	movl	-64(%rbp), %edx
	movl	-56(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -48(%rbp)
	jl	.L6
	movq	-16(%rbp), %rax
	movq	$0, (%rax)
	movl	$0, -44(%rbp)
	jmp	.L7
.L12:
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	$-1, %rax
	je	.L8
	movl	$0, -40(%rbp)
	jmp	.L9
.L11:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-44(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movl	-44(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movq	(%rdx), %rcx
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rsi
	movq	-24(%rbp), %rdx
	addq	%rsi, %rdx
	movl	4(%rdx), %edx
	movslq	%edx, %rdx
	addq	%rcx, %rdx
	cmpq	%rdx, %rax
	jbe	.L10
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	movq	-24(%rbp), %rax
	addq	%rsi, %rax
	movl	(%rax), %esi
	movl	-44(%rbp), %eax
	addl	%esi, %eax
	cltq
	leaq	0(,%rax,8), %rsi
	movq	-16(%rbp), %rax
	addq	%rsi, %rax
	addq	%rcx, %rdx
	movq	%rdx, (%rax)
.L10:
	addl	$1, -40(%rbp)
.L9:
	movl	-60(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L11
.L8:
	addl	$1, -44(%rbp)
.L7:
	movl	-64(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jl	.L12
	movl	$0, -36(%rbp)
	jmp	.L13
.L15:
	movl	-64(%rbp), %edx
	movl	-36(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -32(%rbp)
	jbe	.L14
	movl	-64(%rbp), %edx
	movl	-36(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, -32(%rbp)
.L14:
	addl	$1, -36(%rbp)
.L13:
	movl	-36(%rbp), %eax
	cmpl	-56(%rbp), %eax
	jl	.L15
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
