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

#define max_ans 13

int num;
int cache[max_ans + 1];

int dfs(int depth, int max_depth)
{
	if (cache[depth] == num) // correct ans
		return 1;
	if (depth == max_depth) // reach max depth,break;
		return 0;
	int max_value = cache[0];
	for (int i = 1; i <= depth; i++) // find current max power
	{
		max_value = (((max_value) > (cache[i])) ? (max_value) : (cache[i]));
	}
	if ((max_value << (max_depth - depth)) < num) //return false if max_value*2^(left depth) still can't reach num.
		return 0;                                 //which means impossible to reach target num
	for (int i = depth; i >= 0; i--)
	{
		cache[depth + 1] = cache[depth] + cache[i];
		if (dfs(depth + 1, max_depth) == 1)
			return 1;
		cache[depth + 1] = cache[depth] - cache[i];
		if (dfs(depth + 1, max_depth) == 1)
			return 1;
	}
	return 0;
}

int main(int argc, char const *argv[])
{
	for (int input, output; scanf("%d", &input) && input != 0; printf("%d\n", output))
	{
		num = input;
		output = -1;
		if (input == 1)
			output = 0;
		else
		{
			cache[0] = 1;
			for (int i = 0; i < max_ans; i++)
			{
				if (dfs(0, i) == 1)
				{
					output = i;
					goto b1;
				}
			}
			if (output == -1)
				output = max_ans;
		b1:
			output = output;
		}
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	num
	.bss
	.align 4
	.type	num, @object
	.size	num, 4
num:
	.zero	4
	.globl	cache
	.align 32
	.type	cache, @object
	.size	cache, 56
cache:
	.zero	56
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.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
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	num(%rip), %eax
	cmpl	%eax, %edx
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movl	-20(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jne	.L4
	movl	$0, %eax
	jmp	.L3
.L4:
	movl	cache(%rip), %eax
	movl	%eax, -12(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L5
.L6:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -12(%rbp)
	addl	$1, -8(%rbp)
.L5:
	movl	-8(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L6
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	movl	-12(%rbp), %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	num(%rip), %eax
	cmpl	%eax, %edx
	jge	.L7
	movl	$0, %eax
	jmp	.L3
.L7:
	movl	-20(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L8
.L11:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	addl	$1, %eax
	addl	%edx, %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-20(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	dfs
	cmpl	$1, %eax
	jne	.L9
	movl	$1, %eax
	jmp	.L3
.L9:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cache(%rip), %rdx
	movl	(%rcx,%rdx), %esi
	movl	-20(%rbp), %edx
	addl	$1, %edx
	subl	%esi, %eax
	movl	%eax, %ecx
	movslq	%edx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-20(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	dfs
	cmpl	$1, %eax
	jne	.L10
	movl	$1, %eax
	jmp	.L3
.L10:
	subl	$1, -4(%rbp)
.L8:
	cmpl	$0, -4(%rbp)
	jns	.L11
	movl	$0, %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.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	%edi, -36(%rbp)
	movq	%rsi, -48(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L13
.L21:
	movl	-20(%rbp), %eax
	movl	%eax, num(%rip)
	movl	$-1, -16(%rbp)
	movl	-20(%rbp), %eax
	cmpl	$1, %eax
	jne	.L14
	movl	$0, -16(%rbp)
	jmp	.L15
.L14:
	movl	$1, cache(%rip)
	movl	$0, -12(%rbp)
	jmp	.L16
.L19:
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	movl	$0, %edi
	call	dfs
	cmpl	$1, %eax
	jne	.L17
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L15
.L17:
	addl	$1, -12(%rbp)
.L16:
	cmpl	$12, -12(%rbp)
	jle	.L19
	cmpl	$-1, -16(%rbp)
	jne	.L24
	movl	$13, -16(%rbp)
	jmp	.L15
.L18:
.L24:
	nop
.L15:
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L13:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L20
	movl	-20(%rbp), %eax
	testl	%eax, %eax
	jne	.L21
.L20:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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
	.type	dfs.part.0, @function
dfs.part.0:
.LFB41:
	.cfi_startproc
	testl	%edi, %edi
	js	.L38
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leal	1(%rdi), %r15d
	movslq	%edi, %rdx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%r15d, %eax
	movl	%r15d, %r8d
	movl	%edi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	andl	$-4, %eax
	shrl	$2, %r8d
	movl	%esi, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movslq	%r15d, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %r9
	movl	%r8d, %r12d
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	cache(%rip), %rbx
	leaq	(%rbx,%rdx,4), %rbp
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movl	%eax, 8(%rsp)
	addl	$1, %eax
	movl	%eax, 12(%rsp)
	movl	%esi, %eax
	subl	%r15d, %eax
	movl	%eax, 4(%rsp)
.L7:
	movl	num(%rip), %edi
	movl	0(%rbp), %eax
	addl	(%rbx,%rdx,4), %eax
	movl	%eax, (%rbx,%r9,4)
	cmpl	%edi, %eax
	je	.L6
	cmpl	%r13d, %r15d
	je	.L39
	movl	(%rbx), %eax
	cmpl	$2, %r14d
	jle	.L18
	movdqu	4+cache(%rip), %xmm1
	movd	%eax, %xmm3
	pshufd	$0, %xmm3, %xmm2
	movdqa	%xmm1, %xmm0
	pcmpgtd	%xmm2, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	cmpl	$1, %r12d
	jbe	.L10
	movdqu	20+cache(%rip), %xmm1
	movdqa	%xmm1, %xmm2
	pcmpgtd	%xmm0, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	por	%xmm1, %xmm0
	cmpl	$2, %r12d
	je	.L10
	movdqu	36+cache(%rip), %xmm1
	movdqa	%xmm1, %xmm2
	pcmpgtd	%xmm0, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	por	%xmm1, %xmm0
.L10:
	movdqa	%xmm0, %xmm2
	psrldq	$8, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	por	%xmm2, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movd	%xmm1, %eax
	cmpl	8(%rsp), %r15d
	je	.L11
	movl	12(%rsp), %ecx
.L9:
	movslq	%ecx, %r10
	movl	(%rbx,%r10,4), %r10d
	cmpl	%r10d, %eax
	cmovl	%r10d, %eax
	leal	1(%rcx), %r10d
	cmpl	%ecx, %r14d
	jl	.L11
	movslq	%r10d, %r11
	movl	(%rbx,%r11,4), %r11d
	cmpl	%r11d, %eax
	cmovl	%r11d, %eax
	addl	$2, %ecx
	cmpl	%r10d, %r14d
	jl	.L11
	movslq	%ecx, %rcx
	movl	(%rbx,%rcx,4), %ecx
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
.L11:
	movzbl	4(%rsp), %ecx
	sall	%cl, %eax
	cmpl	%eax, %edi
	jg	.L12
	movl	%r13d, %esi
	movl	%r15d, %edi
	movq	%r9, 24(%rsp)
	movq	%rdx, 16(%rsp)
	call	dfs.part.0
	cmpl	$1, %eax
	je	.L6
	movl	num(%rip), %edi
	movq	16(%rsp), %rdx
	movq	24(%rsp), %r9
.L12:
	movl	(%rbx,%rdx,4), %eax
	subl	0(%rbp), %eax
	movl	%eax, (%rbx,%r9,4)
	cmpl	%eax, %edi
	je	.L6
	movl	(%rbx), %eax
	cmpl	$2, %r14d
	jle	.L19
	movdqu	4+cache(%rip), %xmm1
	movd	%eax, %xmm4
	pshufd	$0, %xmm4, %xmm2
	movdqa	%xmm1, %xmm0
	pcmpgtd	%xmm2, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	cmpl	$1, %r12d
	jbe	.L14
	movdqu	20+cache(%rip), %xmm1
	movdqa	%xmm1, %xmm2
	pcmpgtd	%xmm0, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	por	%xmm1, %xmm0
	cmpl	$2, %r12d
	je	.L14
	movdqu	36+cache(%rip), %xmm1
	movdqa	%xmm1, %xmm2
	pcmpgtd	%xmm0, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	por	%xmm1, %xmm0
.L14:
	movdqa	%xmm0, %xmm2
	psrldq	$8, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	por	%xmm2, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movd	%xmm1, %eax
	cmpl	8(%rsp), %r15d
	je	.L15
	movl	12(%rsp), %ecx
.L13:
	movslq	%ecx, %r10
	movl	(%rbx,%r10,4), %r10d
	cmpl	%r10d, %eax
	cmovl	%r10d, %eax
	leal	1(%rcx), %r10d
	cmpl	%ecx, %r14d
	jl	.L15
	movslq	%r10d, %r11
	movl	(%rbx,%r11,4), %r11d
	cmpl	%r11d, %eax
	cmovl	%r11d, %eax
	addl	$2, %ecx
	cmpl	%r10d, %r14d
	jl	.L15
	movslq	%ecx, %rcx
	movl	(%rbx,%rcx,4), %ecx
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
.L15:
	movzbl	4(%rsp), %ecx
	sall	%cl, %eax
	cmpl	%edi, %eax
	jl	.L16
	movl	%r13d, %esi
	movl	%r15d, %edi
	movq	%r9, 24(%rsp)
	movq	%rdx, 16(%rsp)
	call	dfs.part.0
	movq	16(%rsp), %rdx
	movq	24(%rsp), %r9
	cmpl	$1, %eax
	je	.L6
.L16:
	subq	$4, %rbp
	leaq	-4+cache(%rip), %rax
	cmpq	%rax, %rbp
	jne	.L7
	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
	.p2align 4,,10
	.p2align 3
.L39:
	.cfi_restore_state
	movl	(%rbx,%rdx,4), %eax
	subl	0(%rbp), %eax
	movl	%eax, (%rbx,%r9,4)
	cmpl	%eax, %edi
	jne	.L16
.L6:
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	$1, %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
.L18:
	.cfi_restore_state
	movl	$1, %ecx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L19:
	movl	$1, %ecx
	jmp	.L13
.L38:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE41:
	.size	dfs.part.0, .-dfs.part.0
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB39:
	.cfi_startproc
	endbr64
	leaq	cache(%rip), %rcx
	movslq	%edi, %rax
	movl	num(%rip), %r9d
	cmpl	%r9d, (%rcx,%rax,4)
	je	.L46
	cmpl	%esi, %edi
	je	.L49
	movl	cache(%rip), %eax
	testl	%edi, %edi
	jle	.L42
	leal	-1(%rdi), %edx
	cmpl	$2, %edx
	jbe	.L48
	movdqu	4+cache(%rip), %xmm1
	movd	%eax, %xmm3
	movl	%edi, %edx
	pshufd	$0, %xmm3, %xmm2
	shrl	$2, %edx
	movdqa	%xmm1, %xmm0
	pcmpgtd	%xmm2, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	cmpl	$1, %edx
	je	.L44
	movdqu	20+cache(%rip), %xmm1
	movdqa	%xmm1, %xmm2
	pcmpgtd	%xmm0, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	por	%xmm1, %xmm0
	cmpl	$2, %edx
	je	.L44
	movdqu	36+cache(%rip), %xmm1
	movdqa	%xmm1, %xmm2
	pcmpgtd	%xmm0, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	por	%xmm1, %xmm0
.L44:
	movdqa	%xmm0, %xmm2
	movl	%edi, %r8d
	psrldq	$8, %xmm2
	andl	$-4, %r8d
	movdqa	%xmm2, %xmm1
	leal	1(%r8), %edx
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	por	%xmm2, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movd	%xmm1, %eax
	cmpl	%r8d, %edi
	je	.L42
.L43:
	movslq	%edx, %r8
	movl	(%rcx,%r8,4), %r8d
	cmpl	%r8d, %eax
	cmovl	%r8d, %eax
	leal	1(%rdx), %r8d
	cmpl	%r8d, %edi
	jl	.L42
	movslq	%r8d, %r8
	movl	(%rcx,%r8,4), %r8d
	cmpl	%r8d, %eax
	cmovl	%r8d, %eax
	addl	$2, %edx
	cmpl	%edx, %edi
	jl	.L42
	movslq	%edx, %rdx
	movl	(%rcx,%rdx,4), %edx
	cmpl	%edx, %eax
	cmovl	%edx, %eax
.L42:
	movl	%esi, %ecx
	subl	%edi, %ecx
	sall	%cl, %eax
	cmpl	%eax, %r9d
	jg	.L49
	jmp	dfs.part.0
	.p2align 4,,10
	.p2align 3
.L49:
	xorl	%eax, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L46:
	movl	$1, %eax
	ret
.L48:
	movl	$1, %edx
	jmp	.L43
	.cfi_endproc
.LFE39:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	cache(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %r14
	jmp	.L57
	.p2align 4,,10
	.p2align 3
.L58:
	movl	%r12d, %edx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L57:
	xorl	%eax, %eax
	movq	%r14, %rsi
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L67
	movl	4(%rsp), %eax
	testl	%eax, %eax
	je	.L67
	movl	%eax, num(%rip)
	xorl	%r12d, %r12d
	cmpl	$1, %eax
	je	.L58
	movl	$1, cache(%rip)
	movl	$1, %edx
.L59:
	addl	$1, %r12d
.L69:
	cmpl	%eax, %edx
	je	.L58
	movl	%edx, %edi
	movl	%r12d, %ecx
	sall	%cl, %edi
	cmpl	%eax, %edi
	jl	.L60
	leal	(%rdx,%rdx), %esi
	movl	%esi, 4+cache(%rip)
	cmpl	%eax, %esi
	je	.L58
	cmpl	$1, %r12d
	je	.L61
	cmpl	%edx, %esi
	movl	%edx, %edi
	leal	-1(%r12), %ebp
	cmovge	%esi, %edi
	movl	%ebp, %ecx
	sall	%cl, %edi
	cmpl	%edi, %eax
	jg	.L62
	leaq	4+cache(%rip), %r15
.L64:
	addl	(%r15), %esi
	movl	$2, %edi
	movl	%esi, 8+cache(%rip)
	movl	%r12d, %esi
	call	dfs
	cmpl	$1, %eax
	je	.L58
	movl	4+cache(%rip), %eax
	movl	%r12d, %esi
	subl	(%r15), %eax
	movl	$2, %edi
	movl	%eax, 8+cache(%rip)
	call	dfs
	cmpl	$1, %eax
	je	.L58
	cmpq	%r15, %rbx
	je	.L101
	movl	4+cache(%rip), %esi
	subq	$4, %r15
	jmp	.L64
	.p2align 4,,10
	.p2align 3
.L60:
	addl	$1, %r12d
	cmpl	$13, %r12d
	je	.L58
	movl	(%rbx), %edx
	movl	num(%rip), %eax
	jmp	.L69
.L61:
	movl	$0, 4+cache(%rip)
	testl	%eax, %eax
	jne	.L59
	jmp	.L58
.L101:
	movl	(%rbx), %edx
	movl	num(%rip), %eax
.L62:
	movl	$0, 4+cache(%rip)
	testl	%eax, %eax
	je	.L58
	xorl	%ecx, %ecx
	testl	%edx, %edx
	cmovs	%ecx, %edx
	movl	%ebp, %ecx
	sall	%cl, %edx
	cmpl	%eax, %edx
	jl	.L60
	leaq	4+cache(%rip), %rbp
	xorl	%eax, %eax
.L65:
	addl	0(%rbp), %eax
	movl	%r12d, %esi
	movl	$2, %edi
	movl	%eax, 8+cache(%rip)
	call	dfs
	cmpl	$1, %eax
	je	.L58
	movl	4+cache(%rip), %eax
	movl	%r12d, %esi
	subl	0(%rbp), %eax
	movl	$2, %edi
	movl	%eax, 8+cache(%rip)
	call	dfs
	cmpl	$1, %eax
	je	.L58
	cmpq	%rbx, %rbp
	je	.L60
	movl	4+cache(%rip), %eax
	subq	$4, %rbp
	jmp	.L65
.L67:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L102
	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
.L102:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	cache
	.bss
	.align 32
	.type	cache, @object
	.size	cache, 56
cache:
	.zero	56
	.globl	num
	.align 4
	.type	num, @object
	.size	num, 4
num:
	.zero	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
	.p2align 4
	.type	dfs.part.0, @function
dfs.part.0:
.LFB41:
	.cfi_startproc
	testl	%edi, %edi
	js	.L38
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leal	1(%rdi), %r15d
	movslq	%edi, %rdx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%r15d, %eax
	movl	%r15d, %r8d
	movl	%edi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	andl	$-4, %eax
	shrl	$2, %r8d
	movl	%esi, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movslq	%r15d, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %r9
	movl	%r8d, %r12d
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	cache(%rip), %rbx
	leaq	(%rbx,%rdx,4), %rbp
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movl	%eax, 8(%rsp)
	addl	$1, %eax
	movl	%eax, 12(%rsp)
	movl	%esi, %eax
	subl	%r15d, %eax
	movl	%eax, 4(%rsp)
.L7:
	movl	num(%rip), %edi
	movl	0(%rbp), %eax
	addl	(%rbx,%rdx,4), %eax
	movl	%eax, (%rbx,%r9,4)
	cmpl	%edi, %eax
	je	.L6
	cmpl	%r13d, %r15d
	je	.L39
	movl	(%rbx), %eax
	cmpl	$2, %r14d
	jle	.L18
	movdqu	4+cache(%rip), %xmm1
	movd	%eax, %xmm3
	pshufd	$0, %xmm3, %xmm2
	movdqa	%xmm1, %xmm0
	pcmpgtd	%xmm2, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	cmpl	$1, %r12d
	jbe	.L10
	movdqu	20+cache(%rip), %xmm1
	movdqa	%xmm1, %xmm2
	pcmpgtd	%xmm0, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	por	%xmm1, %xmm0
	cmpl	$2, %r12d
	je	.L10
	movdqu	36+cache(%rip), %xmm1
	movdqa	%xmm1, %xmm2
	pcmpgtd	%xmm0, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	por	%xmm1, %xmm0
.L10:
	movdqa	%xmm0, %xmm2
	psrldq	$8, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	por	%xmm2, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movd	%xmm1, %eax
	cmpl	8(%rsp), %r15d
	je	.L11
	movl	12(%rsp), %ecx
.L9:
	movslq	%ecx, %r10
	movl	(%rbx,%r10,4), %r10d
	cmpl	%r10d, %eax
	cmovl	%r10d, %eax
	leal	1(%rcx), %r10d
	cmpl	%ecx, %r14d
	jl	.L11
	movslq	%r10d, %r11
	movl	(%rbx,%r11,4), %r11d
	cmpl	%r11d, %eax
	cmovl	%r11d, %eax
	addl	$2, %ecx
	cmpl	%r10d, %r14d
	jl	.L11
	movslq	%ecx, %rcx
	movl	(%rbx,%rcx,4), %ecx
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
.L11:
	movzbl	4(%rsp), %ecx
	sall	%cl, %eax
	cmpl	%eax, %edi
	jg	.L12
	movl	%r13d, %esi
	movl	%r15d, %edi
	movq	%r9, 24(%rsp)
	movq	%rdx, 16(%rsp)
	call	dfs.part.0
	cmpl	$1, %eax
	je	.L6
	movl	num(%rip), %edi
	movq	16(%rsp), %rdx
	movq	24(%rsp), %r9
.L12:
	movl	(%rbx,%rdx,4), %eax
	subl	0(%rbp), %eax
	movl	%eax, (%rbx,%r9,4)
	cmpl	%eax, %edi
	je	.L6
	movl	(%rbx), %eax
	cmpl	$2, %r14d
	jle	.L19
	movdqu	4+cache(%rip), %xmm1
	movd	%eax, %xmm4
	pshufd	$0, %xmm4, %xmm2
	movdqa	%xmm1, %xmm0
	pcmpgtd	%xmm2, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	cmpl	$1, %r12d
	jbe	.L14
	movdqu	20+cache(%rip), %xmm1
	movdqa	%xmm1, %xmm2
	pcmpgtd	%xmm0, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	por	%xmm1, %xmm0
	cmpl	$2, %r12d
	je	.L14
	movdqu	36+cache(%rip), %xmm1
	movdqa	%xmm1, %xmm2
	pcmpgtd	%xmm0, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	por	%xmm1, %xmm0
.L14:
	movdqa	%xmm0, %xmm2
	psrldq	$8, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	por	%xmm2, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movd	%xmm1, %eax
	cmpl	8(%rsp), %r15d
	je	.L15
	movl	12(%rsp), %ecx
.L13:
	movslq	%ecx, %r10
	movl	(%rbx,%r10,4), %r10d
	cmpl	%r10d, %eax
	cmovl	%r10d, %eax
	leal	1(%rcx), %r10d
	cmpl	%ecx, %r14d
	jl	.L15
	movslq	%r10d, %r11
	movl	(%rbx,%r11,4), %r11d
	cmpl	%r11d, %eax
	cmovl	%r11d, %eax
	addl	$2, %ecx
	cmpl	%r10d, %r14d
	jl	.L15
	movslq	%ecx, %rcx
	movl	(%rbx,%rcx,4), %ecx
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
.L15:
	movzbl	4(%rsp), %ecx
	sall	%cl, %eax
	cmpl	%edi, %eax
	jl	.L16
	movl	%r13d, %esi
	movl	%r15d, %edi
	movq	%r9, 24(%rsp)
	movq	%rdx, 16(%rsp)
	call	dfs.part.0
	movq	16(%rsp), %rdx
	movq	24(%rsp), %r9
	cmpl	$1, %eax
	je	.L6
.L16:
	subq	$4, %rbp
	leaq	-4+cache(%rip), %rax
	cmpq	%rax, %rbp
	jne	.L7
	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
	.p2align 4,,10
	.p2align 3
.L39:
	.cfi_restore_state
	movl	(%rbx,%rdx,4), %eax
	subl	0(%rbp), %eax
	movl	%eax, (%rbx,%r9,4)
	cmpl	%eax, %edi
	jne	.L16
.L6:
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	$1, %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
.L18:
	.cfi_restore_state
	movl	$1, %ecx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L19:
	movl	$1, %ecx
	jmp	.L13
.L38:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE41:
	.size	dfs.part.0, .-dfs.part.0
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB39:
	.cfi_startproc
	endbr64
	leaq	cache(%rip), %rcx
	movslq	%edi, %rax
	movl	num(%rip), %r9d
	cmpl	%r9d, (%rcx,%rax,4)
	je	.L46
	cmpl	%esi, %edi
	je	.L49
	movl	cache(%rip), %eax
	testl	%edi, %edi
	jle	.L42
	leal	-1(%rdi), %edx
	cmpl	$2, %edx
	jbe	.L48
	movdqu	4+cache(%rip), %xmm1
	movd	%eax, %xmm3
	movl	%edi, %edx
	pshufd	$0, %xmm3, %xmm2
	shrl	$2, %edx
	movdqa	%xmm1, %xmm0
	pcmpgtd	%xmm2, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	cmpl	$1, %edx
	je	.L44
	movdqu	20+cache(%rip), %xmm1
	movdqa	%xmm1, %xmm2
	pcmpgtd	%xmm0, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	por	%xmm1, %xmm0
	cmpl	$2, %edx
	je	.L44
	movdqu	36+cache(%rip), %xmm1
	movdqa	%xmm1, %xmm2
	pcmpgtd	%xmm0, %xmm2
	pand	%xmm2, %xmm1
	pandn	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	por	%xmm1, %xmm0
.L44:
	movdqa	%xmm0, %xmm2
	movl	%edi, %r8d
	psrldq	$8, %xmm2
	andl	$-4, %r8d
	movdqa	%xmm2, %xmm1
	leal	1(%r8), %edx
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	por	%xmm2, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movd	%xmm1, %eax
	cmpl	%r8d, %edi
	je	.L42
.L43:
	movslq	%edx, %r8
	movl	(%rcx,%r8,4), %r8d
	cmpl	%r8d, %eax
	cmovl	%r8d, %eax
	leal	1(%rdx), %r8d
	cmpl	%r8d, %edi
	jl	.L42
	movslq	%r8d, %r8
	movl	(%rcx,%r8,4), %r8d
	cmpl	%r8d, %eax
	cmovl	%r8d, %eax
	addl	$2, %edx
	cmpl	%edx, %edi
	jl	.L42
	movslq	%edx, %rdx
	movl	(%rcx,%rdx,4), %edx
	cmpl	%edx, %eax
	cmovl	%edx, %eax
.L42:
	movl	%esi, %ecx
	subl	%edi, %ecx
	sall	%cl, %eax
	cmpl	%eax, %r9d
	jg	.L49
	jmp	dfs.part.0
	.p2align 4,,10
	.p2align 3
.L49:
	xorl	%eax, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L46:
	movl	$1, %eax
	ret
.L48:
	movl	$1, %edx
	jmp	.L43
	.cfi_endproc
.LFE39:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	cache(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %r14
	jmp	.L57
	.p2align 4,,10
	.p2align 3
.L58:
	movl	%r12d, %edx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L57:
	xorl	%eax, %eax
	movq	%r14, %rsi
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L67
	movl	4(%rsp), %eax
	testl	%eax, %eax
	je	.L67
	movl	%eax, num(%rip)
	xorl	%r12d, %r12d
	cmpl	$1, %eax
	je	.L58
	movl	$1, cache(%rip)
	movl	$1, %edx
.L59:
	addl	$1, %r12d
.L69:
	cmpl	%eax, %edx
	je	.L58
	movl	%edx, %edi
	movl	%r12d, %ecx
	sall	%cl, %edi
	cmpl	%eax, %edi
	jl	.L60
	leal	(%rdx,%rdx), %esi
	movl	%esi, 4+cache(%rip)
	cmpl	%eax, %esi
	je	.L58
	cmpl	$1, %r12d
	je	.L61
	cmpl	%edx, %esi
	movl	%edx, %edi
	leal	-1(%r12), %ebp
	cmovge	%esi, %edi
	movl	%ebp, %ecx
	sall	%cl, %edi
	cmpl	%edi, %eax
	jg	.L62
	leaq	4+cache(%rip), %r15
.L64:
	addl	(%r15), %esi
	movl	$2, %edi
	movl	%esi, 8+cache(%rip)
	movl	%r12d, %esi
	call	dfs
	cmpl	$1, %eax
	je	.L58
	movl	4+cache(%rip), %eax
	movl	%r12d, %esi
	subl	(%r15), %eax
	movl	$2, %edi
	movl	%eax, 8+cache(%rip)
	call	dfs
	cmpl	$1, %eax
	je	.L58
	cmpq	%r15, %rbx
	je	.L101
	movl	4+cache(%rip), %esi
	subq	$4, %r15
	jmp	.L64
	.p2align 4,,10
	.p2align 3
.L60:
	addl	$1, %r12d
	cmpl	$13, %r12d
	je	.L58
	movl	(%rbx), %edx
	movl	num(%rip), %eax
	jmp	.L69
.L61:
	movl	$0, 4+cache(%rip)
	testl	%eax, %eax
	jne	.L59
	jmp	.L58
.L101:
	movl	(%rbx), %edx
	movl	num(%rip), %eax
.L62:
	movl	$0, 4+cache(%rip)
	testl	%eax, %eax
	je	.L58
	xorl	%ecx, %ecx
	testl	%edx, %edx
	cmovs	%ecx, %edx
	movl	%ebp, %ecx
	sall	%cl, %edx
	cmpl	%eax, %edx
	jl	.L60
	leaq	4+cache(%rip), %rbp
	xorl	%eax, %eax
.L65:
	addl	0(%rbp), %eax
	movl	%r12d, %esi
	movl	$2, %edi
	movl	%eax, 8+cache(%rip)
	call	dfs
	cmpl	$1, %eax
	je	.L58
	movl	4+cache(%rip), %eax
	movl	%r12d, %esi
	subl	0(%rbp), %eax
	movl	$2, %edi
	movl	%eax, 8+cache(%rip)
	call	dfs
	cmpl	$1, %eax
	je	.L58
	cmpq	%rbx, %rbp
	je	.L60
	movl	4+cache(%rip), %eax
	subq	$4, %rbp
	jmp	.L65
.L67:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L102
	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
.L102:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	cache
	.bss
	.align 32
	.type	cache, @object
	.size	cache, 56
cache:
	.zero	56
	.globl	num
	.align 4
	.type	num, @object
	.size	num, 4
num:
	.zero	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 <math.h>
#include <stdlib.h>

#define max_ans 13

int num;
int cache[max_ans + 1];

int dfs(int depth, int max_depth)
{
	if (cache[depth] == num) // correct ans
		return 1;
	if (depth == max_depth) // reach max depth,break;
		return 0;
	int max_value = cache[0];
	for (int i = 1; i <= depth; i++) // find current max power
	{
		max_value = (((max_value) > (cache[i])) ? (max_value) : (cache[i]));
	}
	if ((max_value << (max_depth - depth)) < num) //return false if max_value*2^(left depth) still can't reach num.
		return 0;                                 //which means impossible to reach target num
	for (int i = depth; i >= 0; i--)
	{
		cache[depth + 1] = cache[depth] + cache[i];
		if (dfs(depth + 1, max_depth) == 1)
			return 1;
		cache[depth + 1] = cache[depth] - cache[i];
		if (dfs(depth + 1, max_depth) == 1)
			return 1;
	}
	return 0;
}

int main(int argc, char const *argv[])
{
	for (int input, output; scanf("%d", &input) && input != 0; printf("%d\n", output))
	{
		num = input;
		output = -1;
		if (input == 1)
			output = 0;
		else
		{
			cache[0] = 1;
			for (int i = 0; i < max_ans; i++)
			{
				if (dfs(0, i) == 1)
				{
					output = i;
					goto b1;
				}
			}
			if (output == -1)
				output = max_ans;
		b1:
			output = output;
		}
	}
	return 0;
}


1
31
99
91
473
512
811
953
0
 1
31
134
91
473
512
811
953
0
 1
31
134
91
40
512
811
953
0
 1
31
134
86
40
512
811
953
0
 1
31
70
91
473
512
11
953
0
 1
31
99
91
473
512
326
953
0
 1
31
134
91
473
221
811
953
0
 1
31
134
86
40
512
654
953
0
 1
49
99
91
473
512
326
953
0
 1
14
134
91
473
221
811
953
0

0
6
8
9
11
9
13
12
 0
6
9
9
11
9
13
12
 0
6
9
9
6
9
13
12
 0
6
9
8
6
9
13
12
 0
6
8
9
11
9
5
12
 0
6
8
9
11
9
10
12
 0
6
9
9
11
10
13
12
 0
6
9
8
6
9
12
12
 0
7
8
9
11
9
10
12
 0
5
9
9
11
10
13
12

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

#define max_ans 13

int num;
int cache[max_ans + 1];

int dfs(int depth, int max_depth)
{
	if (cache[depth] == num) // correct ans
		return 1;
	if (depth == max_depth) // reach max depth,break;
		return 0;
	int max_value = cache[0];
	for (int i = 1; i <= depth; i++) // find current max power
	{
		max_value = (((max_value) > (cache[i])) ? (max_value) : (cache[i]));
	}
	if ((max_value << (max_depth - depth)) < num) //return false if max_value*2^(left depth) still can't reach num.
		return 0;                                 //which means impossible to reach target num
	for (int i = depth; i >= 0; i--)
	{
		cache[depth + 1] = cache[depth] + cache[i];
		if (dfs(depth + 1, max_depth) == 1)
			return 1;
		cache[depth + 1] = cache[depth] - cache[i];
		if (dfs(depth + 1, max_depth) == 1)
			return 1;
	}
	return 0;
}

int main(int argc, char const *argv[])
{
	for (int input, output; scanf("%d", &input) && input != 0; printf("%d\n", output))
	{
		num = input;
		output = -1;
		if (input == 1)
			output = 0;
		else
		{
			cache[0] = 1;
			for (int i = 0; i < max_ans; i++)
			{
				if (dfs(0, i) == 1)
				{
					output = i;
					goto b1;
				}
			}
			if (output == -1)
				output = max_ans;
		b1:
			output = output;
		}
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	num
	.bss
	.align 4
	.type	num, @object
	.size	num, 4
num:
	.zero	4
	.globl	cache
	.align 32
	.type	cache, @object
	.size	cache, 56
cache:
	.zero	56
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.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
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	num(%rip), %eax
	cmpl	%eax, %edx
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movl	-20(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jne	.L4
	movl	$0, %eax
	jmp	.L3
.L4:
	movl	cache(%rip), %eax
	movl	%eax, -12(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L5
.L6:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -12(%rbp)
	addl	$1, -8(%rbp)
.L5:
	movl	-8(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L6
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	movl	-12(%rbp), %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	num(%rip), %eax
	cmpl	%eax, %edx
	jge	.L7
	movl	$0, %eax
	jmp	.L3
.L7:
	movl	-20(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L8
.L11:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	addl	$1, %eax
	addl	%edx, %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-20(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	dfs
	cmpl	$1, %eax
	jne	.L9
	movl	$1, %eax
	jmp	.L3
.L9:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cache(%rip), %rdx
	movl	(%rcx,%rdx), %esi
	movl	-20(%rbp), %edx
	addl	$1, %edx
	subl	%esi, %eax
	movl	%eax, %ecx
	movslq	%edx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-20(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	dfs
	cmpl	$1, %eax
	jne	.L10
	movl	$1, %eax
	jmp	.L3
.L10:
	subl	$1, -4(%rbp)
.L8:
	cmpl	$0, -4(%rbp)
	jns	.L11
	movl	$0, %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.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	%edi, -36(%rbp)
	movq	%rsi, -48(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L13
.L21:
	movl	-20(%rbp), %eax
	movl	%eax, num(%rip)
	movl	$-1, -16(%rbp)
	movl	-20(%rbp), %eax
	cmpl	$1, %eax
	jne	.L14
	movl	$0, -16(%rbp)
	jmp	.L15
.L14:
	movl	$1, cache(%rip)
	movl	$0, -12(%rbp)
	jmp	.L16
.L19:
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	movl	$0, %edi
	call	dfs
	cmpl	$1, %eax
	jne	.L17
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L15
.L17:
	addl	$1, -12(%rbp)
.L16:
	cmpl	$12, -12(%rbp)
	jle	.L19
	cmpl	$-1, -16(%rbp)
	jne	.L24
	movl	$13, -16(%rbp)
	jmp	.L15
.L18:
.L24:
	nop
.L15:
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L13:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L20
	movl	-20(%rbp), %eax
	testl	%eax, %eax
	jne	.L21
.L20:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	num
	.bss
	.align 4
	.type	num, @object
	.size	num, 4
num:
	.zero	4
	.globl	cache
	.align 32
	.type	cache, @object
	.size	cache, 56
cache:
	.zero	56
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.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
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	num(%rip), %eax
	cmpl	%eax, %edx
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movl	-20(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jne	.L4
	movl	$0, %eax
	jmp	.L3
.L4:
	movl	cache(%rip), %eax
	movl	%eax, -12(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L5
.L6:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -12(%rbp)
	addl	$1, -8(%rbp)
.L5:
	movl	-8(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L6
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	movl	-12(%rbp), %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	num(%rip), %eax
	cmpl	%eax, %edx
	jge	.L7
	movl	$0, %eax
	jmp	.L3
.L7:
	movl	-20(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L8
.L11:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	addl	$1, %eax
	addl	%edx, %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-20(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	dfs
	cmpl	$1, %eax
	jne	.L9
	movl	$1, %eax
	jmp	.L3
.L9:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	cache(%rip), %rdx
	movl	(%rcx,%rdx), %esi
	movl	-20(%rbp), %edx
	addl	$1, %edx
	subl	%esi, %eax
	movl	%eax, %ecx
	movslq	%edx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cache(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-20(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	dfs
	cmpl	$1, %eax
	jne	.L10
	movl	$1, %eax
	jmp	.L3
.L10:
	subl	$1, -4(%rbp)
.L8:
	cmpl	$0, -4(%rbp)
	jns	.L11
	movl	$0, %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.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	%edi, -36(%rbp)
	movq	%rsi, -48(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L13
.L21:
	movl	-20(%rbp), %eax
	movl	%eax, num(%rip)
	movl	$-1, -16(%rbp)
	movl	-20(%rbp), %eax
	cmpl	$1, %eax
	jne	.L14
	movl	$0, -16(%rbp)
	jmp	.L15
.L14:
	movl	$1, cache(%rip)
	movl	$0, -12(%rbp)
	jmp	.L16
.L19:
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	movl	$0, %edi
	call	dfs
	cmpl	$1, %eax
	jne	.L17
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L15
.L17:
	addl	$1, -12(%rbp)
.L16:
	cmpl	$12, -12(%rbp)
	jle	.L19
	cmpl	$-1, -16(%rbp)
	jne	.L24
	movl	$13, -16(%rbp)
	jmp	.L15
.L18:
.L24:
	nop
.L15:
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L13:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L20
	movl	-20(%rbp), %eax
	testl	%eax, %eax
	jne	.L21
.L20:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
