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

```c
/*
  AOJ 0145
  Title:Cards
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#include <limits.h>

#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))

int n,a[100],b[100],memo[100][100];
int solve(int start,int len)
{
  int i,min_,cost,cost1,cost2,ret;

#ifdef DEBUG
  for(i=0;i<len;i++)
    printf("%d %d|",a[start+i],b[start+i]);
  printf("[%d]\n",len);
#endif
  if(ret=memo[start][len])
    return(ret);
  if(len==1)
    return(0);
  if(len==2)
    {
      cost = a[start]*b[start]*a[start+1]*b[start+1];
#ifdef DEBUG
      printf("%d*%d*%d*%d=%d \n",a[start],b[start],
           a[start+1],b[start+1],cost);
#endif
      return(cost);
    }
  min_=INT_MAX;
  for(i=0;i<len-1;i++)
    {

      cost = a[start]*b[start+i]*a[start+i+1]*b[start+len-1];
#ifdef DEBUG
      printf("%d*%d*%d*%d=%d [%d]\n",a[start],b[start+i],
           a[start+i+1],b[start+len-1],cost,i);
#endif
      cost1=solve(start,i+1);
      cost2=solve(start+i+1,len-1-i);
#ifdef DEBUG
      printf("c12=%d %d\n",cost1,cost2);
#endif
      cost += (cost1+cost2);
      min_=min(min_,cost);
    }
  memo[start][len]=min_;
  return(min_);
}

main()
{
  int i,ret;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    scanf("%d %d",&a[i],&b[i]);
  
  ret=solve(0,n);
  printf("%d\n",ret);
  
  return(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400
a:
	.zero	400
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400
b:
	.zero	400
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 40000
memo:
	.zero	40000
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB0:
	.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)
	movl	%esi, -40(%rbp)
	movl	-40(%rbp), %eax
	movslq	%eax, %rcx
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	memo(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	cmpl	$0, -16(%rbp)
	je	.L2
	movl	-16(%rbp), %eax
	jmp	.L3
.L2:
	cmpl	$1, -40(%rbp)
	jne	.L4
	movl	$0, %eax
	jmp	.L3
.L4:
	cmpl	$2, -40(%rbp)
	jne	.L5
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	b(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%eax, %edx
	movl	-36(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%eax, %edx
	movl	-36(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	b(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	jmp	.L3
.L5:
	movl	$2147483647, -20(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L6
.L7:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-36(%rbp), %ecx
	movl	-24(%rbp), %eax
	addl	%ecx, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	b(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%eax, %edx
	movl	-36(%rbp), %ecx
	movl	-24(%rbp), %eax
	addl	%ecx, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%eax, %edx
	movl	-36(%rbp), %ecx
	movl	-40(%rbp), %eax
	addl	%ecx, %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	b(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-24(%rbp), %eax
	leal	1(%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	solve
	movl	%eax, -8(%rbp)
	movl	-40(%rbp), %eax
	subl	$1, %eax
	subl	-24(%rbp), %eax
	movl	-36(%rbp), %ecx
	movl	-24(%rbp), %edx
	addl	%ecx, %edx
	addl	$1, %edx
	movl	%eax, %esi
	movl	%edx, %edi
	call	solve
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, -12(%rbp)
	movl	-20(%rbp), %edx
	movl	-12(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -20(%rbp)
	addl	$1, -24(%rbp)
.L6:
	movl	-40(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jl	.L7
	movl	-40(%rbp), %eax
	movslq	%eax, %rcx
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	memo(%rip), %rdx
	movl	-20(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -8(%rbp)
	jmp	.L9
.L10:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L9:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L10
	movl	n(%rip), %eax
	movl	%eax, %esi
	movl	$0, %edi
	call	solve
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	solve
	.type	solve, @function
solve:
.LFB35:
	.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
	movslq	%edi, %r13
	movslq	%esi, %rdi
	leaq	0(,%r13,4), %rdx
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	(%rdx,%r13), %rax
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	(%rax,%rax,4), %rax
	leaq	memo(%rip), %rbx
	leaq	(%rdi,%rax,4), %rax
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movl	(%rbx,%rax,4), %r15d
	movl	%edi, 4(%rsp)
	movq	%rdi, 40(%rsp)
	testl	%r15d, %r15d
	jne	.L1
	cmpl	$1, %edi
	je	.L1
	movq	%r13, %r12
	cmpl	$2, %edi
	je	.L3
	movl	$2147483647, %r15d
	cmpl	$1, %edi
	jle	.L5
	leal	-2(%rdi), %esi
	leal	-1(%r13,%rdi), %eax
	movl	$1, %r14d
	movl	$2147483647, %r15d
	leaq	2(%rsi), %rbx
	leaq	a(%rip), %r10
	cltq
	movq	%r14, %r13
	movq	%rbx, 24(%rsp)
	leaq	b(%rip), %rbx
	movl	%r15d, %r14d
	movq	%r12, %r15
	leaq	(%rbx,%rdx), %rcx
	addq	%r10, %rdx
	movq	%rax, 32(%rsp)
	movq	%rcx, 16(%rsp)
	movq	%rdx, 8(%rsp)
.L6:
	movq	16(%rsp), %rax
	movl	(%r10,%r15,4), %ebp
	movl	%r13d, %esi
	movl	%r12d, %edi
	movq	32(%rsp), %rdx
	imull	-4(%rax,%r13,4), %ebp
	movq	8(%rsp), %rax
	imull	(%rax,%r13,4), %ebp
	leaq	b(%rip), %rax
	imull	(%rax,%rdx,4), %ebp
	call	solve
	movl	4(%rsp), %esi
	leal	(%r12,%r13), %edi
	movl	%eax, %ebx
	subl	%r13d, %esi
	call	solve
	leaq	a(%rip), %r10
	addl	%eax, %ebx
	addl	%ebp, %ebx
	cmpl	%ebx, %r14d
	cmovg	%ebx, %r14d
	addq	$1, %r13
	cmpq	24(%rsp), %r13
	jne	.L6
	movq	%r15, %r13
	movl	%r14d, %r15d
.L5:
	movq	40(%rsp), %rdx
	leaq	0(%r13,%r13,4), %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdx,%rax,4), %rax
	leaq	memo(%rip), %rdx
	movl	%r15d, (%rdx,%rax,4)
.L1:
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r15d, %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
.L3:
	.cfi_restore_state
	leal	1(%r13), %ecx
	leaq	a(%rip), %rdx
	leaq	b(%rip), %rax
	movslq	%ecx, %rcx
	movl	(%rdx,%r13,4), %r8d
	imull	(%rax,%r13,4), %r8d
	imull	(%rdx,%rcx,4), %r8d
	imull	(%rax,%rcx,4), %r8d
	movl	%r8d, %r15d
	jmp	.L1
	.cfi_endproc
.LFE35:
	.size	solve, .-solve
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	movl	n(%rip), %esi
	testl	%esi, %esi
	jle	.L14
	leaq	a(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	b(%rip), %r13
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rbp, %rsi
	leaq	0(%r13,%rbx,4), %rdx
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %esi
	addq	$1, %rbx
	addq	$4, %rbp
	cmpl	%ebx, %esi
	jg	.L15
.L14:
	xorl	%edi, %edi
	call	solve
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.globl	memo
	.bss
	.align 32
	.type	memo, @object
	.size	memo, 40000
memo:
	.zero	40000
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400
b:
	.zero	400
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400
a:
	.zero	400
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.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
	.globl	solve
	.type	solve, @function
solve:
.LFB35:
	.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
	movslq	%edi, %r13
	movslq	%esi, %rdi
	leaq	0(,%r13,4), %rdx
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	(%rdx,%r13), %rax
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	(%rax,%rax,4), %rax
	leaq	memo(%rip), %rbx
	leaq	(%rdi,%rax,4), %rax
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movl	(%rbx,%rax,4), %r15d
	movl	%edi, 4(%rsp)
	movq	%rdi, 40(%rsp)
	testl	%r15d, %r15d
	jne	.L1
	cmpl	$1, %edi
	je	.L1
	movq	%r13, %r12
	cmpl	$2, %edi
	je	.L3
	movl	$2147483647, %r15d
	cmpl	$1, %edi
	jle	.L5
	leal	-2(%rdi), %esi
	leal	-1(%r13,%rdi), %eax
	movl	$1, %r14d
	movl	$2147483647, %r15d
	leaq	2(%rsi), %rbx
	leaq	a(%rip), %r10
	cltq
	movq	%r14, %r13
	movq	%rbx, 24(%rsp)
	leaq	b(%rip), %rbx
	movl	%r15d, %r14d
	movq	%r12, %r15
	leaq	(%rbx,%rdx), %rcx
	addq	%r10, %rdx
	movq	%rax, 32(%rsp)
	movq	%rcx, 16(%rsp)
	movq	%rdx, 8(%rsp)
.L6:
	movq	16(%rsp), %rax
	movl	(%r10,%r15,4), %ebp
	movl	%r13d, %esi
	movl	%r12d, %edi
	movq	32(%rsp), %rdx
	imull	-4(%rax,%r13,4), %ebp
	movq	8(%rsp), %rax
	imull	(%rax,%r13,4), %ebp
	leaq	b(%rip), %rax
	imull	(%rax,%rdx,4), %ebp
	call	solve
	movl	4(%rsp), %esi
	leal	(%r12,%r13), %edi
	movl	%eax, %ebx
	subl	%r13d, %esi
	call	solve
	leaq	a(%rip), %r10
	addl	%eax, %ebx
	addl	%ebp, %ebx
	cmpl	%ebx, %r14d
	cmovg	%ebx, %r14d
	addq	$1, %r13
	cmpq	24(%rsp), %r13
	jne	.L6
	movq	%r15, %r13
	movl	%r14d, %r15d
.L5:
	movq	40(%rsp), %rdx
	leaq	0(%r13,%r13,4), %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdx,%rax,4), %rax
	leaq	memo(%rip), %rdx
	movl	%r15d, (%rdx,%rax,4)
.L1:
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r15d, %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
.L3:
	.cfi_restore_state
	leal	1(%r13), %ecx
	leaq	a(%rip), %rdx
	leaq	b(%rip), %rax
	movslq	%ecx, %rcx
	movl	(%rdx,%r13,4), %r8d
	imull	(%rax,%r13,4), %r8d
	imull	(%rdx,%rcx,4), %r8d
	imull	(%rax,%rcx,4), %r8d
	movl	%r8d, %r15d
	jmp	.L1
	.cfi_endproc
.LFE35:
	.size	solve, .-solve
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	movl	n(%rip), %esi
	testl	%esi, %esi
	jle	.L14
	leaq	a(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	b(%rip), %r13
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rbp, %rsi
	leaq	0(%r13,%rbx,4), %rdx
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %esi
	addq	$1, %rbx
	addq	$4, %rbp
	cmpl	%ebx, %esi
	jg	.L15
.L14:
	xorl	%edi, %edi
	call	solve
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.globl	memo
	.bss
	.align 32
	.type	memo, @object
	.size	memo, 40000
memo:
	.zero	40000
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400
b:
	.zero	400
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400
a:
	.zero	400
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.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:

/*
  AOJ 0145
  Title:Cards
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#include <limits.h>

#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))

int n,a[100],b[100],memo[100][100];
int solve(int start,int len)
{
  int i,min_,cost,cost1,cost2,ret;

#ifdef DEBUG
  for(i=0;i<len;i++)
    printf("%d %d|",a[start+i],b[start+i]);
  printf("[%d]\n",len);
#endif
  if(ret=memo[start][len])
    return(ret);
  if(len==1)
    return(0);
  if(len==2)
    {
      cost = a[start]*b[start]*a[start+1]*b[start+1];
#ifdef DEBUG
      printf("%d*%d*%d*%d=%d \n",a[start],b[start],
           a[start+1],b[start+1],cost);
#endif
      return(cost);
    }
  min_=INT_MAX;
  for(i=0;i<len-1;i++)
    {

      cost = a[start]*b[start+i]*a[start+i+1]*b[start+len-1];
#ifdef DEBUG
      printf("%d*%d*%d*%d=%d [%d]\n",a[start],b[start+i],
           a[start+i+1],b[start+len-1],cost,i);
#endif
      cost1=solve(start,i+1);
      cost2=solve(start+i+1,len-1-i);
#ifdef DEBUG
      printf("c12=%d %d\n",cost1,cost2);
#endif
      cost += (cost1+cost2);
      min_=min(min_,cost);
    }
  memo[start][len]=min_;
  return(min_);
}

main()
{
  int i,ret;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    scanf("%d %d",&a[i],&b[i]);
  
  ret=solve(0,n);
  printf("%d\n",ret);
  
  return(0);
}
3
3 5
2 16
5 4
 3
2 5
2 16
5 4
 3
2 5
4 16
5 4
 3
2 9
4 16
5 4
 3
2 9
6 16
5 4
 3
2 9
6 11
5 4
 3
2 9
6 18
5 4
 3
2 9
6 18
10 4
 3
0 9
6 18
10 4
 3
2 21
0 48
-1 9

760
 720
 1280
 1568
 2352
 1628
 2592
 3384
 0
 -864

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

```c
/*
  AOJ 0145
  Title:Cards
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#include <limits.h>

#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))

int n,a[100],b[100],memo[100][100];
int solve(int start,int len)
{
  int i,min_,cost,cost1,cost2,ret;

#ifdef DEBUG
  for(i=0;i<len;i++)
    printf("%d %d|",a[start+i],b[start+i]);
  printf("[%d]\n",len);
#endif
  if(ret=memo[start][len])
    return(ret);
  if(len==1)
    return(0);
  if(len==2)
    {
      cost = a[start]*b[start]*a[start+1]*b[start+1];
#ifdef DEBUG
      printf("%d*%d*%d*%d=%d \n",a[start],b[start],
           a[start+1],b[start+1],cost);
#endif
      return(cost);
    }
  min_=INT_MAX;
  for(i=0;i<len-1;i++)
    {

      cost = a[start]*b[start+i]*a[start+i+1]*b[start+len-1];
#ifdef DEBUG
      printf("%d*%d*%d*%d=%d [%d]\n",a[start],b[start+i],
           a[start+i+1],b[start+len-1],cost,i);
#endif
      cost1=solve(start,i+1);
      cost2=solve(start+i+1,len-1-i);
#ifdef DEBUG
      printf("c12=%d %d\n",cost1,cost2);
#endif
      cost += (cost1+cost2);
      min_=min(min_,cost);
    }
  memo[start][len]=min_;
  return(min_);
}

main()
{
  int i,ret;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    scanf("%d %d",&a[i],&b[i]);
  
  ret=solve(0,n);
  printf("%d\n",ret);
  
  return(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400
a:
	.zero	400
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400
b:
	.zero	400
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 40000
memo:
	.zero	40000
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB0:
	.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)
	movl	%esi, -40(%rbp)
	movl	-40(%rbp), %eax
	movslq	%eax, %rcx
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	memo(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	cmpl	$0, -16(%rbp)
	je	.L2
	movl	-16(%rbp), %eax
	jmp	.L3
.L2:
	cmpl	$1, -40(%rbp)
	jne	.L4
	movl	$0, %eax
	jmp	.L3
.L4:
	cmpl	$2, -40(%rbp)
	jne	.L5
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	b(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%eax, %edx
	movl	-36(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%eax, %edx
	movl	-36(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	b(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	jmp	.L3
.L5:
	movl	$2147483647, -20(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L6
.L7:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-36(%rbp), %ecx
	movl	-24(%rbp), %eax
	addl	%ecx, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	b(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%eax, %edx
	movl	-36(%rbp), %ecx
	movl	-24(%rbp), %eax
	addl	%ecx, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%eax, %edx
	movl	-36(%rbp), %ecx
	movl	-40(%rbp), %eax
	addl	%ecx, %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	b(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-24(%rbp), %eax
	leal	1(%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	solve
	movl	%eax, -8(%rbp)
	movl	-40(%rbp), %eax
	subl	$1, %eax
	subl	-24(%rbp), %eax
	movl	-36(%rbp), %ecx
	movl	-24(%rbp), %edx
	addl	%ecx, %edx
	addl	$1, %edx
	movl	%eax, %esi
	movl	%edx, %edi
	call	solve
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, -12(%rbp)
	movl	-20(%rbp), %edx
	movl	-12(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -20(%rbp)
	addl	$1, -24(%rbp)
.L6:
	movl	-40(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jl	.L7
	movl	-40(%rbp), %eax
	movslq	%eax, %rcx
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	memo(%rip), %rdx
	movl	-20(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -8(%rbp)
	jmp	.L9
.L10:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L9:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L10
	movl	n(%rip), %eax
	movl	%eax, %esi
	movl	$0, %edi
	call	solve
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400
a:
	.zero	400
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400
b:
	.zero	400
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 40000
memo:
	.zero	40000
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB0:
	.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)
	movl	%esi, -40(%rbp)
	movl	-40(%rbp), %eax
	movslq	%eax, %rcx
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	memo(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	cmpl	$0, -16(%rbp)
	je	.L2
	movl	-16(%rbp), %eax
	jmp	.L3
.L2:
	cmpl	$1, -40(%rbp)
	jne	.L4
	movl	$0, %eax
	jmp	.L3
.L4:
	cmpl	$2, -40(%rbp)
	jne	.L5
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	b(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%eax, %edx
	movl	-36(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%eax, %edx
	movl	-36(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	b(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	jmp	.L3
.L5:
	movl	$2147483647, -20(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L6
.L7:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-36(%rbp), %ecx
	movl	-24(%rbp), %eax
	addl	%ecx, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	b(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%eax, %edx
	movl	-36(%rbp), %ecx
	movl	-24(%rbp), %eax
	addl	%ecx, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%eax, %edx
	movl	-36(%rbp), %ecx
	movl	-40(%rbp), %eax
	addl	%ecx, %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	b(%rip), %rax
	movl	(%rcx,%rax), %eax
	imull	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-24(%rbp), %eax
	leal	1(%rax), %edx
	movl	-36(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	solve
	movl	%eax, -8(%rbp)
	movl	-40(%rbp), %eax
	subl	$1, %eax
	subl	-24(%rbp), %eax
	movl	-36(%rbp), %ecx
	movl	-24(%rbp), %edx
	addl	%ecx, %edx
	addl	$1, %edx
	movl	%eax, %esi
	movl	%edx, %edi
	call	solve
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, -12(%rbp)
	movl	-20(%rbp), %edx
	movl	-12(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -20(%rbp)
	addl	$1, -24(%rbp)
.L6:
	movl	-40(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -24(%rbp)
	jl	.L7
	movl	-40(%rbp), %eax
	movslq	%eax, %rcx
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	memo(%rip), %rdx
	movl	-20(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -8(%rbp)
	jmp	.L9
.L10:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L9:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L10
	movl	n(%rip), %eax
	movl	%eax, %esi
	movl	$0, %edi
	call	solve
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
