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 <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

#define HEIGHT_MAX 100
#define WIDTH_MAX 8
#define DIVISOR 1000000007
#define PATTERN_MAX (1<<(WIDTH_MAX-1))

void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

void get_next(int pat, int size, int *out) {
    int i, bit;
    for(i = 0; i < size; i++) out[i] = i;
    for(bit = 0; bit < size-1; bit++) {
        if(!(pat & (1<<bit))) continue;
        // swap
        swap(&out[bit], &out[bit+1]);
    }
}

int main(void) {
    int height, width, goal;
    get_int3(&height, &width, &goal);
    // 1-indexed -> 0-indexed
    goal--;
    static int64_t dp[HEIGHT_MAX+2][WIDTH_MAX];
    dp[0][0] = 1;
    int h, w, pat;
    static char pat_valid[PATTERN_MAX];
    static int next_idx[WIDTH_MAX];
    for(pat = 0; pat < (1<<(width-1)); pat++) {
        int bit;
        int prev = 0;
        int flag = 1;
        for(bit = 0; bit < width-1; bit++) {
            int cur = !!(pat & (1<<bit));
            if(prev == cur && cur == 1) { flag = 0; break; }
            prev = cur;
        }
        pat_valid[pat] = flag;
#ifdef DEBUG
        int i;
        printf("%d -> %d\n", pat, pat_valid[pat]);
        get_next(pat, width, next_idx);
        for(i = 0; i < width; i++) printf(" %d", next_idx[i]);
        putchar('\n');
#endif
    }

    for(h = 1; h <= height; h++) {
        for(pat = 0; pat < (1<<(width-1)); pat++) {
            if(!pat_valid[pat]) continue;
            get_next(pat, width, next_idx);
            for(w = 0; w < width; w++) {
                int nidx = next_idx[w];
                dp[h][nidx] = (dp[h][nidx] + dp[h-1][w])%DIVISOR;
#ifdef DEBUG
                printf("[%d] dp[%d][%d] = %lld\n", w, h, nidx, dp[h][nidx]);
#endif
            }
        }
    }
    printf("%d\n", (int)dp[height][goal]);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d %d"
	.text
	.globl	get_int3
	.type	get_int3, @function
get_int3:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	%rdx, -24(%rbp)
	movq	-24(%rbp), %rcx
	movq	-16(%rbp), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	get_int3, .-get_int3
	.globl	swap
	.type	swap, @function
swap:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	swap, .-swap
	.globl	get_next
	.type	get_next, @function
get_next:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movq	%rdx, -32(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L5
.L6:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rdx)
	addl	$1, -8(%rbp)
.L5:
	movl	-8(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L6
	movl	$0, -4(%rbp)
	jmp	.L7
.L10:
	movl	-4(%rbp), %eax
	movl	-20(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L11
	movl	-4(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-32(%rbp), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
	jmp	.L9
.L11:
	nop
.L9:
	addl	$1, -4(%rbp)
.L7:
	movl	-24(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -4(%rbp)
	jl	.L10
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	get_next, .-get_next
	.section	.rodata
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.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	-44(%rbp), %rdx
	leaq	-48(%rbp), %rcx
	leaq	-52(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	get_int3
	movl	-44(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -44(%rbp)
	movq	$1, dp.2(%rip)
	movl	$0, -32(%rbp)
	jmp	.L13
.L18:
	movl	$0, -24(%rbp)
	movl	$1, -20(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L14
.L17:
	movl	-28(%rbp), %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	setne	%al
	movzbl	%al, %eax
	movl	%eax, -12(%rbp)
	movl	-24(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jne	.L15
	cmpl	$1, -12(%rbp)
	jne	.L15
	movl	$0, -20(%rbp)
	jmp	.L16
.L15:
	movl	-12(%rbp), %eax
	movl	%eax, -24(%rbp)
	addl	$1, -28(%rbp)
.L14:
	movl	-48(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -28(%rbp)
	jl	.L17
.L16:
	movl	-20(%rbp), %eax
	movl	%eax, %ecx
	movl	-32(%rbp), %eax
	cltq
	leaq	pat_valid.1(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	addl	$1, -32(%rbp)
.L13:
	movl	-48(%rbp), %eax
	subl	$1, %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	cmpl	%eax, -32(%rbp)
	jl	.L18
	movl	$1, -40(%rbp)
	jmp	.L19
.L26:
	movl	$0, -32(%rbp)
	jmp	.L20
.L25:
	movl	-32(%rbp), %eax
	cltq
	leaq	pat_valid.1(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L29
	movl	-48(%rbp), %ecx
	movl	-32(%rbp), %eax
	leaq	next_idx.0(%rip), %rdx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	get_next
	movl	$0, -36(%rbp)
	jmp	.L23
.L24:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	next_idx.0(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp.2(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-36(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%edx, %rax
	salq	$3, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp.2(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movl	-16(%rbp), %edx
	movslq	%edx, %rcx
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	salq	$3, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	dp.2(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	addl	$1, -36(%rbp)
.L23:
	movl	-48(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L24
	jmp	.L22
.L29:
	nop
.L22:
	addl	$1, -32(%rbp)
.L20:
	movl	-48(%rbp), %eax
	subl	$1, %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	cmpl	%eax, -32(%rbp)
	jl	.L25
	addl	$1, -40(%rbp)
.L19:
	movl	-52(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jle	.L26
	movl	-52(%rbp), %eax
	movl	-44(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp.2(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	main, .-main
	.local	dp.2
	.comm	dp.2,6528,32
	.local	pat_valid.1
	.comm	pat_valid.1,128,32
	.local	next_idx.0
	.comm	next_idx.0,32,32
	.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 %d"
	.text
	.p2align 4
	.globl	get_int3
	.type	get_int3, @function
get_int3:
.LFB51:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movq	%rdx, %rcx
	xorl	%eax, %eax
	movq	%rsi, %rdx
	movq	%rdi, %rsi
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE51:
	.size	get_int3, .-get_int3
	.p2align 4
	.globl	swap
	.type	swap, @function
swap:
.LFB52:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	movl	(%rsi), %edx
	movl	%edx, (%rdi)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE52:
	.size	swap, .-swap
	.p2align 4
	.globl	get_next
	.type	get_next, @function
get_next:
.LFB53:
	.cfi_startproc
	endbr64
	movl	%esi, %ecx
	testl	%esi, %esi
	jle	.L5
	leal	-1(%rsi), %eax
	cmpl	$2, %eax
	jbe	.L14
	shrl	$2, %esi
	movdqa	.LC1(%rip), %xmm0
	movdqa	.LC2(%rip), %xmm2
	movq	%rdx, %rax
	subl	$1, %esi
	salq	$4, %rsi
	leaq	16(%rdx,%rsi), %rsi
	.p2align 4,,10
	.p2align 3
.L8:
	movdqa	%xmm0, %xmm1
	addq	$16, %rax
	paddd	%xmm2, %xmm0
	movups	%xmm1, -16(%rax)
	cmpq	%rsi, %rax
	jne	.L8
	movl	%ecx, %eax
	andl	$-4, %eax
	testb	$3, %cl
	je	.L13
.L7:
	movslq	%eax, %rsi
	movl	%eax, (%rdx,%rsi,4)
	leaq	0(,%rsi,4), %r8
	leal	1(%rax), %esi
	cmpl	%esi, %ecx
	jle	.L10
	addl	$2, %eax
	movl	%esi, 4(%rdx,%r8)
	cmpl	%eax, %ecx
	jle	.L13
	movl	%eax, 8(%rdx,%r8)
.L13:
	leal	-2(%rcx), %esi
	xorl	%eax, %eax
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rcx, %rax
.L12:
	btl	%eax, %edi
	jnc	.L11
	rolq	$32, (%rdx,%rax,4)
.L11:
	leaq	1(%rax), %rcx
	cmpq	%rax, %rsi
	jne	.L15
.L5:
	ret
.L14:
	xorl	%eax, %eax
	jmp	.L7
.L10:
	cmpl	$1, %ecx
	jg	.L13
	ret
	.cfi_endproc
.LFE53:
	.size	get_next, .-get_next
	.section	.rodata.str1.1
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB54:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	68(%rsp), %rcx
	leaq	60(%rsp), %rsi
	leaq	64(%rsp), %rdx
	call	__isoc99_scanf@PLT
	movl	68(%rsp), %eax
	movl	64(%rsp), %r8d
	movq	$1, dp.2(%rip)
	subl	$1, %eax
	leal	-1(%r8), %esi
	movl	%eax, 44(%rsp)
	movl	%esi, %ecx
	movl	%eax, 68(%rsp)
	movl	$1, %eax
	sall	%cl, %eax
	testl	%eax, %eax
	jle	.L22
	movslq	%eax, %r13
	xorl	%r9d, %r9d
	leaq	pat_valid.1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L23:
	movl	%r9d, %edi
	testl	%esi, %esi
	jle	.L50
	movl	%r9d, %edx
	andl	$1, %edx
	xorl	%ecx, %ecx
	addl	$1, %ecx
	cmpl	%esi, %ecx
	je	.L50
	.p2align 4,,10
	.p2align 3
.L26:
	movl	%edi, %eax
	sarl	%cl, %eax
	andl	$1, %eax
	cmpl	%edx, %eax
	jne	.L53
	testb	%al, %al
	jne	.L49
.L53:
	addl	$1, %ecx
	movl	%eax, %edx
	cmpl	%esi, %ecx
	jne	.L26
.L50:
	movl	$1, %eax
	movb	%al, 0(%rbp,%r9)
	addq	$1, %r9
	cmpq	%r13, %r9
	jne	.L23
.L27:
	movl	60(%rsp), %eax
	leaq	dp.2(%rip), %rdi
	movl	%eax, 40(%rsp)
	testl	%eax, %eax
	jle	.L42
	addl	$1, %eax
	leaq	next_idx.0(%rip), %r12
	movq	%rdi, %r10
	movl	$1, 12(%rsp)
	movl	%eax, 36(%rsp)
	movl	%r8d, %eax
	leaq	16(%r12), %rdx
	movdqa	.LC2(%rip), %xmm2
	movabsq	$-8543223828751151131, %r11
	shrl	$2, %eax
	subl	$1, %eax
	salq	$4, %rax
	leaq	(%rax,%rdx), %r15
	movl	%r8d, %eax
	andl	$-4, %eax
	movl	%eax, 32(%rsp)
	.p2align 4,,10
	.p2align 3
.L30:
	movslq	12(%rsp), %rax
	xorl	%ecx, %ecx
	movq	%rax, 24(%rsp)
	salq	$3, %rax
	movq	%rax, 16(%rsp)
	jmp	.L32
	.p2align 4,,10
	.p2align 3
.L41:
	addq	$1, %rcx
	cmpq	%r13, %rcx
	je	.L87
.L32:
	cmpb	$0, 0(%rbp,%rcx)
	movl	%ecx, %eax
	je	.L41
	testl	%r8d, %r8d
	jle	.L34
	cmpl	$2, %esi
	jbe	.L52
	movdqa	.LC1(%rip), %xmm0
	movq	%r12, %rdx
	.p2align 4,,10
	.p2align 3
.L36:
	movdqa	%xmm0, %xmm1
	addq	$16, %rdx
	paddd	%xmm2, %xmm0
	movaps	%xmm1, -16(%rdx)
	cmpq	%r15, %rdx
	jne	.L36
	movl	32(%rsp), %ebx
	movl	%ebx, %edx
	cmpl	%ebx, %r8d
	je	.L37
	movslq	%edx, %r9
	leal	1(%rdx), %ebx
	movl	%edx, (%r12,%r9,4)
	cmpl	%ebx, %r8d
	jle	.L38
.L90:
	leaq	4+next_idx.0(%rip), %r14
	addl	$2, %edx
	movl	%ebx, (%r14,%r9,4)
	cmpl	%edx, %r8d
	jle	.L37
	leaq	4(%r14), %rbx
	movl	%edx, (%rbx,%r9,4)
.L37:
	testl	%esi, %esi
	jle	.L88
.L43:
	movq	%r12, %r9
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L40:
	btl	%edx, %eax
	jnc	.L39
	rolq	$32, (%r9)
.L39:
	addl	$1, %edx
	addq	$4, %r9
	cmpl	%esi, %edx
	jl	.L40
	testl	%r8d, %r8d
	jle	.L41
.L44:
	movslq	(%r12), %rbx
	addq	16(%rsp), %rbx
	movq	(%r10), %r9
	addq	(%rdi,%rbx,8), %r9
	movq	%r9, %rax
	movq	%r9, %r14
	imulq	%r11
	sarq	$63, %r14
	leaq	(%rdx,%r9), %rax
	sarq	$29, %rax
	subq	%r14, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%rbx,8)
	cmpl	$1, %r8d
	jle	.L41
.L45:
	movq	24(%rsp), %rax
	movslq	4+next_idx.0(%rip), %r14
	leaq	0(,%rax,8), %rbx
	addq	%rbx, %r14
	movq	(%rdi,%r14,8), %r9
	addq	8(%r10), %r9
	movq	%r9, %rax
	imulq	%r11
	leaq	(%rdx,%r9), %rax
	movq	%r9, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%r14,8)
	cmpl	$2, %r8d
	jle	.L41
	movslq	8+next_idx.0(%rip), %r14
	addq	%rbx, %r14
	movq	(%rdi,%r14,8), %r9
	addq	16(%r10), %r9
	movq	%r9, %rax
	imulq	%r11
	leaq	(%rdx,%r9), %rax
	movq	%r9, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%r14,8)
	cmpl	$3, %r8d
	je	.L41
	movslq	12+next_idx.0(%rip), %r14
	addq	%rbx, %r14
	movq	(%rdi,%r14,8), %r9
	addq	24(%r10), %r9
	movq	%r9, %rax
	imulq	%r11
	leaq	(%rdx,%r9), %rax
	movq	%r9, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%r14,8)
	cmpl	$4, %r8d
	je	.L41
	movslq	16+next_idx.0(%rip), %r14
	movq	32(%r10), %r9
	addq	%rbx, %r14
	addq	(%rdi,%r14,8), %r9
	movq	%r9, %rax
	imulq	%r11
	leaq	(%rdx,%r9), %rax
	movq	%r9, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%r14,8)
	cmpl	$5, %r8d
	je	.L41
	movslq	20+next_idx.0(%rip), %r14
	movq	40(%r10), %r9
	addq	%rbx, %r14
	addq	(%rdi,%r14,8), %r9
	movq	%r9, %rax
	imulq	%r11
	leaq	(%rdx,%r9), %rax
	movq	%r9, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%r14,8)
	cmpl	$6, %r8d
	je	.L41
	movslq	24+next_idx.0(%rip), %r14
	movq	48(%r10), %r9
	addq	%rbx, %r14
	addq	(%rdi,%r14,8), %r9
	movq	%r9, %rax
	imulq	%r11
	leaq	(%rdx,%r9), %rax
	movq	%r9, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%r14,8)
	cmpl	$7, %r8d
	je	.L41
	movslq	28+next_idx.0(%rip), %rax
	movq	56(%r10), %r9
	addq	$1, %rcx
	addq	%rax, %rbx
	addq	(%rdi,%rbx,8), %r9
	movq	%r9, %rax
	movq	%r9, %r14
	imulq	%r11
	sarq	$63, %r14
	leaq	(%rdx,%r9), %rax
	sarq	$29, %rax
	subq	%r14, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%rbx,8)
	cmpq	%r13, %rcx
	jne	.L32
	.p2align 4,,10
	.p2align 3
.L87:
	addl	$1, 12(%rsp)
	addq	$64, %r10
	movl	12(%rsp), %eax
	cmpl	36(%rsp), %eax
	jne	.L30
.L42:
	movslq	40(%rsp), %rdx
	movslq	44(%rsp), %rax
	leaq	.LC3(%rip), %rsi
	leaq	(%rax,%rdx,8), %rax
	movl	(%rdi,%rax,8), %edx
	xorl	%eax, %eax
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L89
	addq	$88, %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
	.p2align 4,,10
	.p2align 3
.L49:
	.cfi_restore_state
	xorl	%eax, %eax
	movb	%al, 0(%rbp,%r9)
	addq	$1, %r9
	cmpq	%r13, %r9
	jne	.L23
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L34:
	testl	%esi, %esi
	jg	.L43
	jmp	.L41
.L88:
	movslq	(%r12), %rbx
	addq	16(%rsp), %rbx
	movq	(%rdi,%rbx,8), %r9
	addq	(%r10), %r9
	movq	%r9, %rax
	movq	%r9, %r14
	imulq	%r11
	sarq	$63, %r14
	leaq	(%rdx,%r9), %rax
	sarq	$29, %rax
	subq	%r14, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%rbx,8)
	jmp	.L45
.L52:
	xorl	%edx, %edx
	movslq	%edx, %r9
	leal	1(%rdx), %ebx
	movl	%edx, (%r12,%r9,4)
	cmpl	%ebx, %r8d
	jg	.L90
.L38:
	testl	%esi, %esi
	jg	.L43
	jmp	.L44
.L22:
	movl	60(%rsp), %eax
	leaq	dp.2(%rip), %rdi
	movl	%eax, 40(%rsp)
	jmp	.L42
.L89:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE54:
	.size	main, .-main
	.local	next_idx.0
	.comm	next_idx.0,32,32
	.local	pat_valid.1
	.comm	pat_valid.1,128,32
	.local	dp.2
	.comm	dp.2,6528,32
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC2:
	.long	4
	.long	4
	.long	4
	.long	4
	.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 %d"
	.text
	.p2align 4
	.globl	get_int3
	.type	get_int3, @function
get_int3:
.LFB51:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movq	%rdx, %rcx
	xorl	%eax, %eax
	movq	%rsi, %rdx
	movq	%rdi, %rsi
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE51:
	.size	get_int3, .-get_int3
	.p2align 4
	.globl	swap
	.type	swap, @function
swap:
.LFB52:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	movl	(%rsi), %edx
	movl	%edx, (%rdi)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE52:
	.size	swap, .-swap
	.p2align 4
	.globl	get_next
	.type	get_next, @function
get_next:
.LFB53:
	.cfi_startproc
	endbr64
	movl	%esi, %ecx
	testl	%esi, %esi
	jle	.L5
	leal	-1(%rsi), %eax
	cmpl	$2, %eax
	jbe	.L14
	shrl	$2, %esi
	movdqa	.LC1(%rip), %xmm0
	movdqa	.LC2(%rip), %xmm2
	movq	%rdx, %rax
	subl	$1, %esi
	salq	$4, %rsi
	leaq	16(%rdx,%rsi), %rsi
	.p2align 4,,10
	.p2align 3
.L8:
	movdqa	%xmm0, %xmm1
	addq	$16, %rax
	paddd	%xmm2, %xmm0
	movups	%xmm1, -16(%rax)
	cmpq	%rsi, %rax
	jne	.L8
	movl	%ecx, %eax
	andl	$-4, %eax
	testb	$3, %cl
	je	.L13
.L7:
	movslq	%eax, %rsi
	movl	%eax, (%rdx,%rsi,4)
	leaq	0(,%rsi,4), %r8
	leal	1(%rax), %esi
	cmpl	%esi, %ecx
	jle	.L10
	addl	$2, %eax
	movl	%esi, 4(%rdx,%r8)
	cmpl	%eax, %ecx
	jle	.L13
	movl	%eax, 8(%rdx,%r8)
.L13:
	leal	-2(%rcx), %esi
	xorl	%eax, %eax
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rcx, %rax
.L12:
	btl	%eax, %edi
	jnc	.L11
	rolq	$32, (%rdx,%rax,4)
.L11:
	leaq	1(%rax), %rcx
	cmpq	%rax, %rsi
	jne	.L15
.L5:
	ret
.L14:
	xorl	%eax, %eax
	jmp	.L7
.L10:
	cmpl	$1, %ecx
	jg	.L13
	ret
	.cfi_endproc
.LFE53:
	.size	get_next, .-get_next
	.section	.rodata.str1.1
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB54:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	68(%rsp), %rcx
	leaq	60(%rsp), %rsi
	leaq	64(%rsp), %rdx
	call	__isoc99_scanf@PLT
	movl	68(%rsp), %eax
	movl	64(%rsp), %r8d
	movq	$1, dp.2(%rip)
	subl	$1, %eax
	leal	-1(%r8), %esi
	movl	%eax, 44(%rsp)
	movl	%esi, %ecx
	movl	%eax, 68(%rsp)
	movl	$1, %eax
	sall	%cl, %eax
	testl	%eax, %eax
	jle	.L22
	movslq	%eax, %r13
	xorl	%r9d, %r9d
	leaq	pat_valid.1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L23:
	movl	%r9d, %edi
	testl	%esi, %esi
	jle	.L50
	movl	%r9d, %edx
	andl	$1, %edx
	xorl	%ecx, %ecx
	addl	$1, %ecx
	cmpl	%esi, %ecx
	je	.L50
	.p2align 4,,10
	.p2align 3
.L26:
	movl	%edi, %eax
	sarl	%cl, %eax
	andl	$1, %eax
	cmpl	%edx, %eax
	jne	.L53
	testb	%al, %al
	jne	.L49
.L53:
	addl	$1, %ecx
	movl	%eax, %edx
	cmpl	%esi, %ecx
	jne	.L26
.L50:
	movl	$1, %eax
	movb	%al, 0(%rbp,%r9)
	addq	$1, %r9
	cmpq	%r13, %r9
	jne	.L23
.L27:
	movl	60(%rsp), %eax
	leaq	dp.2(%rip), %rdi
	movl	%eax, 40(%rsp)
	testl	%eax, %eax
	jle	.L42
	addl	$1, %eax
	leaq	next_idx.0(%rip), %r12
	movq	%rdi, %r10
	movl	$1, 12(%rsp)
	movl	%eax, 36(%rsp)
	movl	%r8d, %eax
	leaq	16(%r12), %rdx
	movdqa	.LC2(%rip), %xmm2
	movabsq	$-8543223828751151131, %r11
	shrl	$2, %eax
	subl	$1, %eax
	salq	$4, %rax
	leaq	(%rax,%rdx), %r15
	movl	%r8d, %eax
	andl	$-4, %eax
	movl	%eax, 32(%rsp)
	.p2align 4,,10
	.p2align 3
.L30:
	movslq	12(%rsp), %rax
	xorl	%ecx, %ecx
	movq	%rax, 24(%rsp)
	salq	$3, %rax
	movq	%rax, 16(%rsp)
	jmp	.L32
	.p2align 4,,10
	.p2align 3
.L41:
	addq	$1, %rcx
	cmpq	%r13, %rcx
	je	.L87
.L32:
	cmpb	$0, 0(%rbp,%rcx)
	movl	%ecx, %eax
	je	.L41
	testl	%r8d, %r8d
	jle	.L34
	cmpl	$2, %esi
	jbe	.L52
	movdqa	.LC1(%rip), %xmm0
	movq	%r12, %rdx
	.p2align 4,,10
	.p2align 3
.L36:
	movdqa	%xmm0, %xmm1
	addq	$16, %rdx
	paddd	%xmm2, %xmm0
	movaps	%xmm1, -16(%rdx)
	cmpq	%r15, %rdx
	jne	.L36
	movl	32(%rsp), %ebx
	movl	%ebx, %edx
	cmpl	%ebx, %r8d
	je	.L37
	movslq	%edx, %r9
	leal	1(%rdx), %ebx
	movl	%edx, (%r12,%r9,4)
	cmpl	%ebx, %r8d
	jle	.L38
.L90:
	leaq	4+next_idx.0(%rip), %r14
	addl	$2, %edx
	movl	%ebx, (%r14,%r9,4)
	cmpl	%edx, %r8d
	jle	.L37
	leaq	4(%r14), %rbx
	movl	%edx, (%rbx,%r9,4)
.L37:
	testl	%esi, %esi
	jle	.L88
.L43:
	movq	%r12, %r9
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L40:
	btl	%edx, %eax
	jnc	.L39
	rolq	$32, (%r9)
.L39:
	addl	$1, %edx
	addq	$4, %r9
	cmpl	%esi, %edx
	jl	.L40
	testl	%r8d, %r8d
	jle	.L41
.L44:
	movslq	(%r12), %rbx
	addq	16(%rsp), %rbx
	movq	(%r10), %r9
	addq	(%rdi,%rbx,8), %r9
	movq	%r9, %rax
	movq	%r9, %r14
	imulq	%r11
	sarq	$63, %r14
	leaq	(%rdx,%r9), %rax
	sarq	$29, %rax
	subq	%r14, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%rbx,8)
	cmpl	$1, %r8d
	jle	.L41
.L45:
	movq	24(%rsp), %rax
	movslq	4+next_idx.0(%rip), %r14
	leaq	0(,%rax,8), %rbx
	addq	%rbx, %r14
	movq	(%rdi,%r14,8), %r9
	addq	8(%r10), %r9
	movq	%r9, %rax
	imulq	%r11
	leaq	(%rdx,%r9), %rax
	movq	%r9, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%r14,8)
	cmpl	$2, %r8d
	jle	.L41
	movslq	8+next_idx.0(%rip), %r14
	addq	%rbx, %r14
	movq	(%rdi,%r14,8), %r9
	addq	16(%r10), %r9
	movq	%r9, %rax
	imulq	%r11
	leaq	(%rdx,%r9), %rax
	movq	%r9, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%r14,8)
	cmpl	$3, %r8d
	je	.L41
	movslq	12+next_idx.0(%rip), %r14
	addq	%rbx, %r14
	movq	(%rdi,%r14,8), %r9
	addq	24(%r10), %r9
	movq	%r9, %rax
	imulq	%r11
	leaq	(%rdx,%r9), %rax
	movq	%r9, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%r14,8)
	cmpl	$4, %r8d
	je	.L41
	movslq	16+next_idx.0(%rip), %r14
	movq	32(%r10), %r9
	addq	%rbx, %r14
	addq	(%rdi,%r14,8), %r9
	movq	%r9, %rax
	imulq	%r11
	leaq	(%rdx,%r9), %rax
	movq	%r9, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%r14,8)
	cmpl	$5, %r8d
	je	.L41
	movslq	20+next_idx.0(%rip), %r14
	movq	40(%r10), %r9
	addq	%rbx, %r14
	addq	(%rdi,%r14,8), %r9
	movq	%r9, %rax
	imulq	%r11
	leaq	(%rdx,%r9), %rax
	movq	%r9, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%r14,8)
	cmpl	$6, %r8d
	je	.L41
	movslq	24+next_idx.0(%rip), %r14
	movq	48(%r10), %r9
	addq	%rbx, %r14
	addq	(%rdi,%r14,8), %r9
	movq	%r9, %rax
	imulq	%r11
	leaq	(%rdx,%r9), %rax
	movq	%r9, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%r14,8)
	cmpl	$7, %r8d
	je	.L41
	movslq	28+next_idx.0(%rip), %rax
	movq	56(%r10), %r9
	addq	$1, %rcx
	addq	%rax, %rbx
	addq	(%rdi,%rbx,8), %r9
	movq	%r9, %rax
	movq	%r9, %r14
	imulq	%r11
	sarq	$63, %r14
	leaq	(%rdx,%r9), %rax
	sarq	$29, %rax
	subq	%r14, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%rbx,8)
	cmpq	%r13, %rcx
	jne	.L32
	.p2align 4,,10
	.p2align 3
.L87:
	addl	$1, 12(%rsp)
	addq	$64, %r10
	movl	12(%rsp), %eax
	cmpl	36(%rsp), %eax
	jne	.L30
.L42:
	movslq	40(%rsp), %rdx
	movslq	44(%rsp), %rax
	leaq	.LC3(%rip), %rsi
	leaq	(%rax,%rdx,8), %rax
	movl	(%rdi,%rax,8), %edx
	xorl	%eax, %eax
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L89
	addq	$88, %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
	.p2align 4,,10
	.p2align 3
.L49:
	.cfi_restore_state
	xorl	%eax, %eax
	movb	%al, 0(%rbp,%r9)
	addq	$1, %r9
	cmpq	%r13, %r9
	jne	.L23
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L34:
	testl	%esi, %esi
	jg	.L43
	jmp	.L41
.L88:
	movslq	(%r12), %rbx
	addq	16(%rsp), %rbx
	movq	(%rdi,%rbx,8), %r9
	addq	(%r10), %r9
	movq	%r9, %rax
	movq	%r9, %r14
	imulq	%r11
	sarq	$63, %r14
	leaq	(%rdx,%r9), %rax
	sarq	$29, %rax
	subq	%r14, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r9
	movq	%r9, (%rdi,%rbx,8)
	jmp	.L45
.L52:
	xorl	%edx, %edx
	movslq	%edx, %r9
	leal	1(%rdx), %ebx
	movl	%edx, (%r12,%r9,4)
	cmpl	%ebx, %r8d
	jg	.L90
.L38:
	testl	%esi, %esi
	jg	.L43
	jmp	.L44
.L22:
	movl	60(%rsp), %eax
	leaq	dp.2(%rip), %rdi
	movl	%eax, 40(%rsp)
	jmp	.L42
.L89:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE54:
	.size	main, .-main
	.local	next_idx.0
	.comm	next_idx.0,32,32
	.local	pat_valid.1
	.comm	pat_valid.1,128,32
	.local	dp.2
	.comm	dp.2,6528,32
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC2:
	.long	4
	.long	4
	.long	4
	.long	4
	.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 <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

#define HEIGHT_MAX 100
#define WIDTH_MAX 8
#define DIVISOR 1000000007
#define PATTERN_MAX (1<<(WIDTH_MAX-1))

void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

void get_next(int pat, int size, int *out) {
    int i, bit;
    for(i = 0; i < size; i++) out[i] = i;
    for(bit = 0; bit < size-1; bit++) {
        if(!(pat & (1<<bit))) continue;
        // swap
        swap(&out[bit], &out[bit+1]);
    }
}

int main(void) {
    int height, width, goal;
    get_int3(&height, &width, &goal);
    // 1-indexed -> 0-indexed
    goal--;
    static int64_t dp[HEIGHT_MAX+2][WIDTH_MAX];
    dp[0][0] = 1;
    int h, w, pat;
    static char pat_valid[PATTERN_MAX];
    static int next_idx[WIDTH_MAX];
    for(pat = 0; pat < (1<<(width-1)); pat++) {
        int bit;
        int prev = 0;
        int flag = 1;
        for(bit = 0; bit < width-1; bit++) {
            int cur = !!(pat & (1<<bit));
            if(prev == cur && cur == 1) { flag = 0; break; }
            prev = cur;
        }
        pat_valid[pat] = flag;
#ifdef DEBUG
        int i;
        printf("%d -> %d\n", pat, pat_valid[pat]);
        get_next(pat, width, next_idx);
        for(i = 0; i < width; i++) printf(" %d", next_idx[i]);
        putchar('\n');
#endif
    }

    for(h = 1; h <= height; h++) {
        for(pat = 0; pat < (1<<(width-1)); pat++) {
            if(!pat_valid[pat]) continue;
            get_next(pat, width, next_idx);
            for(w = 0; w < width; w++) {
                int nidx = next_idx[w];
                dp[h][nidx] = (dp[h][nidx] + dp[h-1][w])%DIVISOR;
#ifdef DEBUG
                printf("[%d] dp[%d][%d] = %lld\n", w, h, nidx, dp[h][nidx]);
#endif
            }
        }
    }
    printf("%d\n", (int)dp[height][goal]);
    return 0;
}
4 3 1
 1 2 2
 1 5 1
 16 8 5
 4 6 1
 1 9 1
 16 8 3
 8 6 1
 1 9 2
 15 8 3

35
 1
 5
 698231265
 12371
 33
 59172019
 276953291
 15
 978283490

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 <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

#define HEIGHT_MAX 100
#define WIDTH_MAX 8
#define DIVISOR 1000000007
#define PATTERN_MAX (1<<(WIDTH_MAX-1))

void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

void get_next(int pat, int size, int *out) {
    int i, bit;
    for(i = 0; i < size; i++) out[i] = i;
    for(bit = 0; bit < size-1; bit++) {
        if(!(pat & (1<<bit))) continue;
        // swap
        swap(&out[bit], &out[bit+1]);
    }
}

int main(void) {
    int height, width, goal;
    get_int3(&height, &width, &goal);
    // 1-indexed -> 0-indexed
    goal--;
    static int64_t dp[HEIGHT_MAX+2][WIDTH_MAX];
    dp[0][0] = 1;
    int h, w, pat;
    static char pat_valid[PATTERN_MAX];
    static int next_idx[WIDTH_MAX];
    for(pat = 0; pat < (1<<(width-1)); pat++) {
        int bit;
        int prev = 0;
        int flag = 1;
        for(bit = 0; bit < width-1; bit++) {
            int cur = !!(pat & (1<<bit));
            if(prev == cur && cur == 1) { flag = 0; break; }
            prev = cur;
        }
        pat_valid[pat] = flag;
#ifdef DEBUG
        int i;
        printf("%d -> %d\n", pat, pat_valid[pat]);
        get_next(pat, width, next_idx);
        for(i = 0; i < width; i++) printf(" %d", next_idx[i]);
        putchar('\n');
#endif
    }

    for(h = 1; h <= height; h++) {
        for(pat = 0; pat < (1<<(width-1)); pat++) {
            if(!pat_valid[pat]) continue;
            get_next(pat, width, next_idx);
            for(w = 0; w < width; w++) {
                int nidx = next_idx[w];
                dp[h][nidx] = (dp[h][nidx] + dp[h-1][w])%DIVISOR;
#ifdef DEBUG
                printf("[%d] dp[%d][%d] = %lld\n", w, h, nidx, dp[h][nidx]);
#endif
            }
        }
    }
    printf("%d\n", (int)dp[height][goal]);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d %d"
	.text
	.globl	get_int3
	.type	get_int3, @function
get_int3:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	%rdx, -24(%rbp)
	movq	-24(%rbp), %rcx
	movq	-16(%rbp), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	get_int3, .-get_int3
	.globl	swap
	.type	swap, @function
swap:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	swap, .-swap
	.globl	get_next
	.type	get_next, @function
get_next:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movq	%rdx, -32(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L5
.L6:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rdx)
	addl	$1, -8(%rbp)
.L5:
	movl	-8(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L6
	movl	$0, -4(%rbp)
	jmp	.L7
.L10:
	movl	-4(%rbp), %eax
	movl	-20(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L11
	movl	-4(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-32(%rbp), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
	jmp	.L9
.L11:
	nop
.L9:
	addl	$1, -4(%rbp)
.L7:
	movl	-24(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -4(%rbp)
	jl	.L10
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	get_next, .-get_next
	.section	.rodata
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.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	-44(%rbp), %rdx
	leaq	-48(%rbp), %rcx
	leaq	-52(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	get_int3
	movl	-44(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -44(%rbp)
	movq	$1, dp.2(%rip)
	movl	$0, -32(%rbp)
	jmp	.L13
.L18:
	movl	$0, -24(%rbp)
	movl	$1, -20(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L14
.L17:
	movl	-28(%rbp), %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	setne	%al
	movzbl	%al, %eax
	movl	%eax, -12(%rbp)
	movl	-24(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jne	.L15
	cmpl	$1, -12(%rbp)
	jne	.L15
	movl	$0, -20(%rbp)
	jmp	.L16
.L15:
	movl	-12(%rbp), %eax
	movl	%eax, -24(%rbp)
	addl	$1, -28(%rbp)
.L14:
	movl	-48(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -28(%rbp)
	jl	.L17
.L16:
	movl	-20(%rbp), %eax
	movl	%eax, %ecx
	movl	-32(%rbp), %eax
	cltq
	leaq	pat_valid.1(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	addl	$1, -32(%rbp)
.L13:
	movl	-48(%rbp), %eax
	subl	$1, %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	cmpl	%eax, -32(%rbp)
	jl	.L18
	movl	$1, -40(%rbp)
	jmp	.L19
.L26:
	movl	$0, -32(%rbp)
	jmp	.L20
.L25:
	movl	-32(%rbp), %eax
	cltq
	leaq	pat_valid.1(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L29
	movl	-48(%rbp), %ecx
	movl	-32(%rbp), %eax
	leaq	next_idx.0(%rip), %rdx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	get_next
	movl	$0, -36(%rbp)
	jmp	.L23
.L24:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	next_idx.0(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp.2(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-36(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%edx, %rax
	salq	$3, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp.2(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movl	-16(%rbp), %edx
	movslq	%edx, %rcx
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	salq	$3, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	dp.2(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	addl	$1, -36(%rbp)
.L23:
	movl	-48(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L24
	jmp	.L22
.L29:
	nop
.L22:
	addl	$1, -32(%rbp)
.L20:
	movl	-48(%rbp), %eax
	subl	$1, %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	cmpl	%eax, -32(%rbp)
	jl	.L25
	addl	$1, -40(%rbp)
.L19:
	movl	-52(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jle	.L26
	movl	-52(%rbp), %eax
	movl	-44(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp.2(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	main, .-main
	.local	dp.2
	.comm	dp.2,6528,32
	.local	pat_valid.1
	.comm	pat_valid.1,128,32
	.local	next_idx.0
	.comm	next_idx.0,32,32
	.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 %d"
	.text
	.globl	get_int3
	.type	get_int3, @function
get_int3:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	%rdx, -24(%rbp)
	movq	-24(%rbp), %rcx
	movq	-16(%rbp), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	get_int3, .-get_int3
	.globl	swap
	.type	swap, @function
swap:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	swap, .-swap
	.globl	get_next
	.type	get_next, @function
get_next:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movq	%rdx, -32(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L5
.L6:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rdx)
	addl	$1, -8(%rbp)
.L5:
	movl	-8(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L6
	movl	$0, -4(%rbp)
	jmp	.L7
.L10:
	movl	-4(%rbp), %eax
	movl	-20(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L11
	movl	-4(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-32(%rbp), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
	jmp	.L9
.L11:
	nop
.L9:
	addl	$1, -4(%rbp)
.L7:
	movl	-24(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -4(%rbp)
	jl	.L10
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	get_next, .-get_next
	.section	.rodata
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.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	-44(%rbp), %rdx
	leaq	-48(%rbp), %rcx
	leaq	-52(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	get_int3
	movl	-44(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -44(%rbp)
	movq	$1, dp.2(%rip)
	movl	$0, -32(%rbp)
	jmp	.L13
.L18:
	movl	$0, -24(%rbp)
	movl	$1, -20(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L14
.L17:
	movl	-28(%rbp), %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	setne	%al
	movzbl	%al, %eax
	movl	%eax, -12(%rbp)
	movl	-24(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jne	.L15
	cmpl	$1, -12(%rbp)
	jne	.L15
	movl	$0, -20(%rbp)
	jmp	.L16
.L15:
	movl	-12(%rbp), %eax
	movl	%eax, -24(%rbp)
	addl	$1, -28(%rbp)
.L14:
	movl	-48(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -28(%rbp)
	jl	.L17
.L16:
	movl	-20(%rbp), %eax
	movl	%eax, %ecx
	movl	-32(%rbp), %eax
	cltq
	leaq	pat_valid.1(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	addl	$1, -32(%rbp)
.L13:
	movl	-48(%rbp), %eax
	subl	$1, %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	cmpl	%eax, -32(%rbp)
	jl	.L18
	movl	$1, -40(%rbp)
	jmp	.L19
.L26:
	movl	$0, -32(%rbp)
	jmp	.L20
.L25:
	movl	-32(%rbp), %eax
	cltq
	leaq	pat_valid.1(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L29
	movl	-48(%rbp), %ecx
	movl	-32(%rbp), %eax
	leaq	next_idx.0(%rip), %rdx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	get_next
	movl	$0, -36(%rbp)
	jmp	.L23
.L24:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	next_idx.0(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp.2(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-36(%rbp), %eax
	movslq	%eax, %rsi
	movslq	%edx, %rax
	salq	$3, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp.2(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movl	-16(%rbp), %edx
	movslq	%edx, %rcx
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	salq	$3, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	dp.2(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	addl	$1, -36(%rbp)
.L23:
	movl	-48(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L24
	jmp	.L22
.L29:
	nop
.L22:
	addl	$1, -32(%rbp)
.L20:
	movl	-48(%rbp), %eax
	subl	$1, %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	cmpl	%eax, -32(%rbp)
	jl	.L25
	addl	$1, -40(%rbp)
.L19:
	movl	-52(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jle	.L26
	movl	-52(%rbp), %eax
	movl	-44(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	dp.2(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	main, .-main
	.local	dp.2
	.comm	dp.2,6528,32
	.local	pat_valid.1
	.comm	pat_valid.1,128,32
	.local	next_idx.0
	.comm	next_idx.0,32,32
	.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:
