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>
#define max(a,b) a>b?a:b
int check(int x){
    int i;
    if(x==2)return 1;
    for(i=3; i<=sqrt(x); i+=2)if(x%i==0)return 0;
    return 1;
}
int main(){
    int i, j, n, a[10], num[10][1001]={0}, amax=0, nmax=0, ans=1;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a[i]);
        amax=max(amax, a[i]);
    }
    for(i=2; i<=amax; i+=2){
        if(check(i)){
            for(j=0; j<n; j++){
                while(!(a[j]%i)){
                    a[j]/=i;
                    num[j][i]+=1;
                }
                nmax=max(nmax, num[j][i]);
            }
            for(j=0; j<nmax; j++)ans*=i;
            nmax=0;
        }
        if(i==2)i-=1;
    }
    printf("%d\n", ans);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	check
	.type	check, @function
check:
.LFB0:
	.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)
	cmpl	$2, -20(%rbp)
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movl	$3, -4(%rbp)
	jmp	.L4
.L6:
	movl	-20(%rbp), %eax
	cltd
	idivl	-4(%rbp)
	movl	%edx, %eax
	testl	%eax, %eax
	jne	.L5
	movl	$0, %eax
	jmp	.L3
.L5:
	addl	$2, -4(%rbp)
.L4:
	pxor	%xmm1, %xmm1
	cvtsi2sdl	-4(%rbp), %xmm1
	movsd	%xmm1, -32(%rbp)
	pxor	%xmm2, %xmm2
	cvtsi2sdl	-20(%rbp), %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	movq	%xmm0, %rax
	movq	%rax, %xmm3
	comisd	-32(%rbp), %xmm3
	jnb	.L6
	movl	$1, %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	check, .-check
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.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
	leaq	-36864(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3264, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40048(%rbp), %rax
	movl	$40040, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -40108(%rbp)
	movl	$0, -40104(%rbp)
	movl	$1, -40100(%rbp)
	leaq	-40120(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40116(%rbp)
	jmp	.L8
.L9:
	leaq	-40096(%rbp), %rdx
	movl	-40116(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40116(%rbp), %eax
	cltq
	movl	-40096(%rbp,%rax,4), %eax
	movl	-40108(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -40108(%rbp)
	addl	$1, -40116(%rbp)
.L8:
	movl	-40120(%rbp), %eax
	cmpl	%eax, -40116(%rbp)
	jl	.L9
	movl	$2, -40116(%rbp)
	jmp	.L10
.L19:
	movl	-40116(%rbp), %eax
	movl	%eax, %edi
	call	check
	testl	%eax, %eax
	je	.L11
	movl	$0, -40112(%rbp)
	jmp	.L12
.L14:
	movl	-40112(%rbp), %eax
	cltq
	movl	-40096(%rbp,%rax,4), %eax
	cltd
	idivl	-40116(%rbp)
	movl	%eax, %edx
	movl	-40112(%rbp), %eax
	cltq
	movl	%edx, -40096(%rbp,%rax,4)
	movl	-40116(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40112(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	-40048(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-40116(%rbp), %eax
	movslq	%eax, %rcx
	movl	-40112(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rcx, %rax
	movl	%edx, -40048(%rbp,%rax,4)
.L13:
	movl	-40112(%rbp), %eax
	cltq
	movl	-40096(%rbp,%rax,4), %eax
	cltd
	idivl	-40116(%rbp)
	movl	%edx, %eax
	testl	%eax, %eax
	je	.L14
	movl	-40116(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40112(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	-40048(%rbp,%rax,4), %eax
	movl	-40104(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -40104(%rbp)
	addl	$1, -40112(%rbp)
.L12:
	movl	-40120(%rbp), %eax
	cmpl	%eax, -40112(%rbp)
	jl	.L13
	movl	$0, -40112(%rbp)
	jmp	.L16
.L17:
	movl	-40100(%rbp), %eax
	imull	-40116(%rbp), %eax
	movl	%eax, -40100(%rbp)
	addl	$1, -40112(%rbp)
.L16:
	movl	-40112(%rbp), %eax
	cmpl	-40104(%rbp), %eax
	jl	.L17
	movl	$0, -40104(%rbp)
.L11:
	cmpl	$2, -40116(%rbp)
	jne	.L18
	subl	$1, -40116(%rbp)
.L18:
	addl	$2, -40116(%rbp)
.L10:
	movl	-40116(%rbp), %eax
	cmpl	-40108(%rbp), %eax
	jle	.L19
	movl	-40100(%rbp), %eax
	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	.L21
	call	__stack_chk_fail@PLT
.L21:
	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	check
	.type	check, @function
check:
.LFB23:
	.cfi_startproc
	endbr64
	cmpl	$2, %edi
	je	.L21
	pxor	%xmm1, %xmm1
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%edi, %xmm1
	ucomisd	%xmm1, %xmm0
	ja	.L19
	sqrtsd	%xmm1, %xmm1
	movl	$3, %ecx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%edi, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L26
	addl	$2, %ecx
.L6:
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%ecx, %xmm0
	comisd	%xmm0, %xmm1
	jnb	.L11
.L21:
	movl	$1, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L26:
	xorl	%eax, %eax
	ret
.L19:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movl	$3, %ebx
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	jmp	.L4
.L27:
	movl	12(%rsp), %edi
	movl	%edi, %eax
	cltd
	idivl	%ebx
	testl	%edx, %edx
	je	.L9
	movsd	(%rsp), %xmm1
	addl	$2, %ebx
.L4:
	movapd	%xmm1, %xmm0
	movl	%edi, 12(%rsp)
	movsd	%xmm1, (%rsp)
	call	sqrt@PLT
	movapd	%xmm0, %xmm2
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%ebx, %xmm0
	comisd	%xmm0, %xmm2
	jnb	.L27
	movl	$1, %eax
.L1:
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore_state
	xorl	%eax, %eax
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	check, .-check
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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
	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	-36864(%rsp), %r11
	.cfi_def_cfa 11, 36920
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3272, %rsp
	.cfi_def_cfa_offset 40192
	movl	$40040, %edx
	xorl	%esi, %esi
	leaq	.LC2(%rip), %r12
	xorl	%ebx, %ebx
	xorl	%ebp, %ebp
	movq	%fs:40, %rax
	movq	%rax, 40120(%rsp)
	xorl	%eax, %eax
	leaq	80(%rsp), %rax
	leaq	32(%rsp), %r13
	movq	%rax, %rdi
	movq	%rax, (%rsp)
	call	memset@PLT
	leaq	28(%rsp), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L31
	.p2align 4,,10
	.p2align 3
.L29:
	leaq	0(%r13,%rbx,4), %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	movl	0(%r13,%rbx,4), %eax
	movl	28(%rsp), %r15d
	cmpl	%eax, %ebp
	cmovl	%eax, %ebp
	addq	$1, %rbx
	cmpl	%ebx, %r15d
	jg	.L29
	cmpl	$1, %ebp
	jle	.L31
	movl	$1, %r12d
	movl	$2, %ebx
	pxor	%xmm2, %xmm2
	.p2align 4,,10
	.p2align 3
.L52:
	cmpl	$2, %ebx
	je	.L32
	pxor	%xmm1, %xmm1
	cvtsi2sdl	%ebx, %xmm1
	ucomisd	%xmm1, %xmm2
	ja	.L72
.L53:
	sqrtsd	%xmm1, %xmm1
	movl	$3, %ecx
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L45:
	movl	%ebx, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L51
	addl	$2, %ecx
.L35:
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%ecx, %xmm0
	comisd	%xmm0, %xmm1
	jnb	.L45
.L36:
	testl	%r15d, %r15d
	jle	.L42
.L39:
	movq	(%rsp), %rdi
	movslq	%ebx, %rax
	movl	28(%rsp), %r14d
	movq	%r13, %r9
	xorl	%r8d, %r8d
	xorl	%r11d, %r11d
	leaq	(%rdi,%rax,4), %r10
	.p2align 4,,10
	.p2align 3
.L41:
	movl	(%r9), %ecx
	movl	(%r10), %esi
	movl	%ecx, %eax
	leal	1(%rsi), %edi
	cltd
	idivl	%ebx
	testl	%edx, %edx
	jne	.L49
	.p2align 4,,10
	.p2align 3
.L46:
	movl	%ecx, %eax
	movl	%edi, %esi
	leal	1(%rdi), %edi
	cltd
	idivl	%ebx
	cltd
	movl	%eax, %ecx
	idivl	%ebx
	testl	%edx, %edx
	je	.L46
	movl	%ecx, (%r9)
	movl	%esi, (%r10)
.L49:
	cmpl	%esi, %r8d
	cmovl	%esi, %r8d
	addl	$1, %r11d
	addq	$4, %r9
	addq	$4004, %r10
	cmpl	%r11d, %r14d
	jg	.L41
	testl	%r8d, %r8d
	je	.L42
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L50:
	addl	$1, %eax
	imull	%ebx, %r12d
	cmpl	%r8d, %eax
	jne	.L50
.L42:
	cmpl	$2, %ebx
	jne	.L51
.L81:
	cmpl	$2, %ebp
	je	.L30
	movq	.LC1(%rip), %rax
	movl	$3, %ebx
	movq	%rax, %xmm1
	jmp	.L53
	.p2align 4,,10
	.p2align 3
.L51:
	addl	$2, %ebx
	cmpl	%ebx, %ebp
	jge	.L52
.L30:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movl	$1, %edi
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	movq	40120(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L82
	addq	$40136, %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
.L32:
	.cfi_restore_state
	testl	%r15d, %r15d
	jg	.L39
	jmp	.L81
.L31:
	movl	$1, %r12d
	jmp	.L30
.L72:
	movl	$3, %r14d
	jmp	.L33
.L83:
	movl	%ebx, %eax
	cltd
	idivl	%r14d
	testl	%edx, %edx
	je	.L51
	movsd	8(%rsp), %xmm1
	addl	$2, %r14d
.L33:
	movapd	%xmm1, %xmm0
	movsd	%xmm1, 8(%rsp)
	call	sqrt@PLT
	pxor	%xmm2, %xmm2
	movapd	%xmm0, %xmm3
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%r14d, %xmm0
	comisd	%xmm0, %xmm3
	jnb	.L83
	jmp	.L36
.L82:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1074266112
	.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	check
	.type	check, @function
check:
.LFB23:
	.cfi_startproc
	endbr64
	cmpl	$2, %edi
	je	.L21
	pxor	%xmm1, %xmm1
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%edi, %xmm1
	ucomisd	%xmm1, %xmm0
	ja	.L19
	sqrtsd	%xmm1, %xmm1
	movl	$3, %ecx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%edi, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L26
	addl	$2, %ecx
.L6:
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%ecx, %xmm0
	comisd	%xmm0, %xmm1
	jnb	.L11
.L21:
	movl	$1, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L26:
	xorl	%eax, %eax
	ret
.L19:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movl	$3, %ebx
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	jmp	.L4
.L27:
	movl	12(%rsp), %edi
	movl	%edi, %eax
	cltd
	idivl	%ebx
	testl	%edx, %edx
	je	.L9
	movsd	(%rsp), %xmm1
	addl	$2, %ebx
.L4:
	movapd	%xmm1, %xmm0
	movl	%edi, 12(%rsp)
	movsd	%xmm1, (%rsp)
	call	sqrt@PLT
	movapd	%xmm0, %xmm2
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%ebx, %xmm0
	comisd	%xmm0, %xmm2
	jnb	.L27
	movl	$1, %eax
.L1:
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore_state
	xorl	%eax, %eax
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	check, .-check
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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
	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	-36864(%rsp), %r11
	.cfi_def_cfa 11, 36920
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3272, %rsp
	.cfi_def_cfa_offset 40192
	movl	$40040, %edx
	xorl	%esi, %esi
	leaq	.LC2(%rip), %r12
	xorl	%ebx, %ebx
	xorl	%ebp, %ebp
	movq	%fs:40, %rax
	movq	%rax, 40120(%rsp)
	xorl	%eax, %eax
	leaq	80(%rsp), %rax
	leaq	32(%rsp), %r13
	movq	%rax, %rdi
	movq	%rax, (%rsp)
	call	memset@PLT
	leaq	28(%rsp), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jle	.L31
	.p2align 4,,10
	.p2align 3
.L29:
	leaq	0(%r13,%rbx,4), %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	movl	0(%r13,%rbx,4), %eax
	movl	28(%rsp), %r15d
	cmpl	%eax, %ebp
	cmovl	%eax, %ebp
	addq	$1, %rbx
	cmpl	%ebx, %r15d
	jg	.L29
	cmpl	$1, %ebp
	jle	.L31
	movl	$1, %r12d
	movl	$2, %ebx
	pxor	%xmm2, %xmm2
	.p2align 4,,10
	.p2align 3
.L52:
	cmpl	$2, %ebx
	je	.L32
	pxor	%xmm1, %xmm1
	cvtsi2sdl	%ebx, %xmm1
	ucomisd	%xmm1, %xmm2
	ja	.L72
.L53:
	sqrtsd	%xmm1, %xmm1
	movl	$3, %ecx
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L45:
	movl	%ebx, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L51
	addl	$2, %ecx
.L35:
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%ecx, %xmm0
	comisd	%xmm0, %xmm1
	jnb	.L45
.L36:
	testl	%r15d, %r15d
	jle	.L42
.L39:
	movq	(%rsp), %rdi
	movslq	%ebx, %rax
	movl	28(%rsp), %r14d
	movq	%r13, %r9
	xorl	%r8d, %r8d
	xorl	%r11d, %r11d
	leaq	(%rdi,%rax,4), %r10
	.p2align 4,,10
	.p2align 3
.L41:
	movl	(%r9), %ecx
	movl	(%r10), %esi
	movl	%ecx, %eax
	leal	1(%rsi), %edi
	cltd
	idivl	%ebx
	testl	%edx, %edx
	jne	.L49
	.p2align 4,,10
	.p2align 3
.L46:
	movl	%ecx, %eax
	movl	%edi, %esi
	leal	1(%rdi), %edi
	cltd
	idivl	%ebx
	cltd
	movl	%eax, %ecx
	idivl	%ebx
	testl	%edx, %edx
	je	.L46
	movl	%ecx, (%r9)
	movl	%esi, (%r10)
.L49:
	cmpl	%esi, %r8d
	cmovl	%esi, %r8d
	addl	$1, %r11d
	addq	$4, %r9
	addq	$4004, %r10
	cmpl	%r11d, %r14d
	jg	.L41
	testl	%r8d, %r8d
	je	.L42
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L50:
	addl	$1, %eax
	imull	%ebx, %r12d
	cmpl	%r8d, %eax
	jne	.L50
.L42:
	cmpl	$2, %ebx
	jne	.L51
.L81:
	cmpl	$2, %ebp
	je	.L30
	movq	.LC1(%rip), %rax
	movl	$3, %ebx
	movq	%rax, %xmm1
	jmp	.L53
	.p2align 4,,10
	.p2align 3
.L51:
	addl	$2, %ebx
	cmpl	%ebx, %ebp
	jge	.L52
.L30:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movl	$1, %edi
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	movq	40120(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L82
	addq	$40136, %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
.L32:
	.cfi_restore_state
	testl	%r15d, %r15d
	jg	.L39
	jmp	.L81
.L31:
	movl	$1, %r12d
	jmp	.L30
.L72:
	movl	$3, %r14d
	jmp	.L33
.L83:
	movl	%ebx, %eax
	cltd
	idivl	%r14d
	testl	%edx, %edx
	je	.L51
	movsd	8(%rsp), %xmm1
	addl	$2, %r14d
.L33:
	movapd	%xmm1, %xmm0
	movsd	%xmm1, 8(%rsp)
	call	sqrt@PLT
	pxor	%xmm2, %xmm2
	movapd	%xmm0, %xmm3
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%r14d, %xmm0
	comisd	%xmm0, %xmm3
	jnb	.L83
	jmp	.L36
.L82:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1074266112
	.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>
#define max(a,b) a>b?a:b
int check(int x){
    int i;
    if(x==2)return 1;
    for(i=3; i<=sqrt(x); i+=2)if(x%i==0)return 0;
    return 1;
}
int main(){
    int i, j, n, a[10], num[10][1001]={0}, amax=0, nmax=0, ans=1;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a[i]);
        amax=max(amax, a[i]);
    }
    for(i=2; i<=amax; i+=2){
        if(check(i)){
            for(j=0; j<n; j++){
                while(!(a[j]%i)){
                    a[j]/=i;
                    num[j][i]+=1;
                }
                nmax=max(nmax, num[j][i]);
            }
            for(j=0; j<nmax; j++)ans*=i;
            nmax=0;
        }
        if(i==2)i-=1;
    }
    printf("%d\n", ans);
    return 0;
}
4
1 2 5 5
 3
3 4 3
 4
1 2 5 7
 3
3 7 3
 4
1 2 1 7
 3
3 10 3
 3
3 13 3
 4
1 2 2 11
 3
6 13 3
 3
4 13 3

10
 12
 70
 21
 14
 30
 39
 22
 78
 156

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>
#define max(a,b) a>b?a:b
int check(int x){
    int i;
    if(x==2)return 1;
    for(i=3; i<=sqrt(x); i+=2)if(x%i==0)return 0;
    return 1;
}
int main(){
    int i, j, n, a[10], num[10][1001]={0}, amax=0, nmax=0, ans=1;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a[i]);
        amax=max(amax, a[i]);
    }
    for(i=2; i<=amax; i+=2){
        if(check(i)){
            for(j=0; j<n; j++){
                while(!(a[j]%i)){
                    a[j]/=i;
                    num[j][i]+=1;
                }
                nmax=max(nmax, num[j][i]);
            }
            for(j=0; j<nmax; j++)ans*=i;
            nmax=0;
        }
        if(i==2)i-=1;
    }
    printf("%d\n", ans);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	check
	.type	check, @function
check:
.LFB0:
	.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)
	cmpl	$2, -20(%rbp)
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movl	$3, -4(%rbp)
	jmp	.L4
.L6:
	movl	-20(%rbp), %eax
	cltd
	idivl	-4(%rbp)
	movl	%edx, %eax
	testl	%eax, %eax
	jne	.L5
	movl	$0, %eax
	jmp	.L3
.L5:
	addl	$2, -4(%rbp)
.L4:
	pxor	%xmm1, %xmm1
	cvtsi2sdl	-4(%rbp), %xmm1
	movsd	%xmm1, -32(%rbp)
	pxor	%xmm2, %xmm2
	cvtsi2sdl	-20(%rbp), %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	movq	%xmm0, %rax
	movq	%rax, %xmm3
	comisd	-32(%rbp), %xmm3
	jnb	.L6
	movl	$1, %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	check, .-check
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.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
	leaq	-36864(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3264, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40048(%rbp), %rax
	movl	$40040, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -40108(%rbp)
	movl	$0, -40104(%rbp)
	movl	$1, -40100(%rbp)
	leaq	-40120(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40116(%rbp)
	jmp	.L8
.L9:
	leaq	-40096(%rbp), %rdx
	movl	-40116(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40116(%rbp), %eax
	cltq
	movl	-40096(%rbp,%rax,4), %eax
	movl	-40108(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -40108(%rbp)
	addl	$1, -40116(%rbp)
.L8:
	movl	-40120(%rbp), %eax
	cmpl	%eax, -40116(%rbp)
	jl	.L9
	movl	$2, -40116(%rbp)
	jmp	.L10
.L19:
	movl	-40116(%rbp), %eax
	movl	%eax, %edi
	call	check
	testl	%eax, %eax
	je	.L11
	movl	$0, -40112(%rbp)
	jmp	.L12
.L14:
	movl	-40112(%rbp), %eax
	cltq
	movl	-40096(%rbp,%rax,4), %eax
	cltd
	idivl	-40116(%rbp)
	movl	%eax, %edx
	movl	-40112(%rbp), %eax
	cltq
	movl	%edx, -40096(%rbp,%rax,4)
	movl	-40116(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40112(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	-40048(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-40116(%rbp), %eax
	movslq	%eax, %rcx
	movl	-40112(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rcx, %rax
	movl	%edx, -40048(%rbp,%rax,4)
.L13:
	movl	-40112(%rbp), %eax
	cltq
	movl	-40096(%rbp,%rax,4), %eax
	cltd
	idivl	-40116(%rbp)
	movl	%edx, %eax
	testl	%eax, %eax
	je	.L14
	movl	-40116(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40112(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	-40048(%rbp,%rax,4), %eax
	movl	-40104(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -40104(%rbp)
	addl	$1, -40112(%rbp)
.L12:
	movl	-40120(%rbp), %eax
	cmpl	%eax, -40112(%rbp)
	jl	.L13
	movl	$0, -40112(%rbp)
	jmp	.L16
.L17:
	movl	-40100(%rbp), %eax
	imull	-40116(%rbp), %eax
	movl	%eax, -40100(%rbp)
	addl	$1, -40112(%rbp)
.L16:
	movl	-40112(%rbp), %eax
	cmpl	-40104(%rbp), %eax
	jl	.L17
	movl	$0, -40104(%rbp)
.L11:
	cmpl	$2, -40116(%rbp)
	jne	.L18
	subl	$1, -40116(%rbp)
.L18:
	addl	$2, -40116(%rbp)
.L10:
	movl	-40116(%rbp), %eax
	cmpl	-40108(%rbp), %eax
	jle	.L19
	movl	-40100(%rbp), %eax
	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	.L21
	call	__stack_chk_fail@PLT
.L21:
	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	check
	.type	check, @function
check:
.LFB0:
	.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)
	cmpl	$2, -20(%rbp)
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movl	$3, -4(%rbp)
	jmp	.L4
.L6:
	movl	-20(%rbp), %eax
	cltd
	idivl	-4(%rbp)
	movl	%edx, %eax
	testl	%eax, %eax
	jne	.L5
	movl	$0, %eax
	jmp	.L3
.L5:
	addl	$2, -4(%rbp)
.L4:
	pxor	%xmm1, %xmm1
	cvtsi2sdl	-4(%rbp), %xmm1
	movsd	%xmm1, -32(%rbp)
	pxor	%xmm2, %xmm2
	cvtsi2sdl	-20(%rbp), %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	movq	%xmm0, %rax
	movq	%rax, %xmm3
	comisd	-32(%rbp), %xmm3
	jnb	.L6
	movl	$1, %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	check, .-check
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.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
	leaq	-36864(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3264, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40048(%rbp), %rax
	movl	$40040, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -40108(%rbp)
	movl	$0, -40104(%rbp)
	movl	$1, -40100(%rbp)
	leaq	-40120(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40116(%rbp)
	jmp	.L8
.L9:
	leaq	-40096(%rbp), %rdx
	movl	-40116(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40116(%rbp), %eax
	cltq
	movl	-40096(%rbp,%rax,4), %eax
	movl	-40108(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -40108(%rbp)
	addl	$1, -40116(%rbp)
.L8:
	movl	-40120(%rbp), %eax
	cmpl	%eax, -40116(%rbp)
	jl	.L9
	movl	$2, -40116(%rbp)
	jmp	.L10
.L19:
	movl	-40116(%rbp), %eax
	movl	%eax, %edi
	call	check
	testl	%eax, %eax
	je	.L11
	movl	$0, -40112(%rbp)
	jmp	.L12
.L14:
	movl	-40112(%rbp), %eax
	cltq
	movl	-40096(%rbp,%rax,4), %eax
	cltd
	idivl	-40116(%rbp)
	movl	%eax, %edx
	movl	-40112(%rbp), %eax
	cltq
	movl	%edx, -40096(%rbp,%rax,4)
	movl	-40116(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40112(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	-40048(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-40116(%rbp), %eax
	movslq	%eax, %rcx
	movl	-40112(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rcx, %rax
	movl	%edx, -40048(%rbp,%rax,4)
.L13:
	movl	-40112(%rbp), %eax
	cltq
	movl	-40096(%rbp,%rax,4), %eax
	cltd
	idivl	-40116(%rbp)
	movl	%edx, %eax
	testl	%eax, %eax
	je	.L14
	movl	-40116(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40112(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	-40048(%rbp,%rax,4), %eax
	movl	-40104(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -40104(%rbp)
	addl	$1, -40112(%rbp)
.L12:
	movl	-40120(%rbp), %eax
	cmpl	%eax, -40112(%rbp)
	jl	.L13
	movl	$0, -40112(%rbp)
	jmp	.L16
.L17:
	movl	-40100(%rbp), %eax
	imull	-40116(%rbp), %eax
	movl	%eax, -40100(%rbp)
	addl	$1, -40112(%rbp)
.L16:
	movl	-40112(%rbp), %eax
	cmpl	-40104(%rbp), %eax
	jl	.L17
	movl	$0, -40104(%rbp)
.L11:
	cmpl	$2, -40116(%rbp)
	jne	.L18
	subl	$1, -40116(%rbp)
.L18:
	addl	$2, -40116(%rbp)
.L10:
	movl	-40116(%rbp), %eax
	cmpl	-40108(%rbp), %eax
	jle	.L19
	movl	-40100(%rbp), %eax
	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	.L21
	call	__stack_chk_fail@PLT
.L21:
	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:
