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

```c
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct{
    int l;
    int r;
}data;

int main(void){
    int Q;
    scanf("%d",&Q);

    //A[0]~A[N-1]に格納する
    data* A;
    NEW(A,Q);
    for(int i=0;i<Q;i++){
        scanf("%d%d",&A[i].l,&A[i].r);
    }

    //iが素数のとき、prime[i]は1、そうでないなら0
    int* prime;
    int N=1e5;
    NEW(prime,N+1);
    prime[1]=0;
    for(int i=2;i<=N;i++) prime[i]=1;
    for(int i=2;i<=N;i++){
        if(prime[i]==1){
            int j=2;
            while(i*j<=N){
                prime[i*j]=0;
                j++;
            }
        }
    }

    int* ans;
    NEW(ans,N+1);
    ans[0]=0;
    for(int i=1;i<=N;i++){
        if(prime[i]){
            if(prime[(i+1)/2]) ans[i]=1;
        }
    }
    for(int i=1;i<=N;i++) ans[i]+=ans[i-1];

    for(int i=0;i<Q;i++){
        printf("%d\n",ans[A[i].r]-ans[A[i].l-1]);
    }

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"not enough memory"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-68(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-68(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -32(%rbp)
	cmpq	$0, -32(%rbp)
	jne	.L2
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %edi
	call	exit@PLT
.L2:
	movl	$0, -64(%rbp)
	jmp	.L3
.L4:
	movl	-64(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	addq	$4, %rax
	movl	-64(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-32(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rdx, %rcx
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -64(%rbp)
.L3:
	movl	-68(%rbp), %eax
	cmpl	%eax, -64(%rbp)
	jl	.L4
	movl	$100000, -36(%rbp)
	movl	-36(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	cmpq	$0, -24(%rbp)
	jne	.L5
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %edi
	call	exit@PLT
.L5:
	movq	-24(%rbp), %rax
	addq	$4, %rax
	movl	$0, (%rax)
	movl	$2, -60(%rbp)
	jmp	.L6
.L7:
	movl	-60(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	$1, (%rax)
	addl	$1, -60(%rbp)
.L6:
	movl	-60(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L7
	movl	$2, -56(%rbp)
	jmp	.L8
.L12:
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	$2, -52(%rbp)
	jmp	.L10
.L11:
	movl	-56(%rbp), %eax
	imull	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	addl	$1, -52(%rbp)
.L10:
	movl	-56(%rbp), %eax
	imull	-52(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jge	.L11
.L9:
	addl	$1, -56(%rbp)
.L8:
	movl	-56(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L12
	movl	-36(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	cmpq	$0, -16(%rbp)
	jne	.L13
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %edi
	call	exit@PLT
.L13:
	movq	-16(%rbp), %rax
	movl	$0, (%rax)
	movl	$1, -48(%rbp)
	jmp	.L14
.L16:
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L15
	movl	-48(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L15
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	$1, (%rax)
.L15:
	addl	$1, -48(%rbp)
.L14:
	movl	-48(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L16
	movl	$1, -44(%rbp)
	jmp	.L17
.L18:
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movl	-44(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rsi
	movq	-16(%rbp), %rax
	addq	%rsi, %rax
	addl	%ecx, %edx
	movl	%edx, (%rax)
	addl	$1, -44(%rbp)
.L17:
	movl	-44(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L18
	movl	$0, -40(%rbp)
	jmp	.L19
.L20:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-32(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -40(%rbp)
.L19:
	movl	-68(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L20
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"not enough memory"
.LC2:
	.string	"%d%d"
.LC5:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %rdi
	movq	%rdi, %r12
	salq	$3, %rdi
	call	malloc@PLT
	testq	%rax, %rax
	je	.L2
	movq	%rax, %rbp
	movq	%rax, %rbx
	leaq	.LC2(%rip), %r14
	xorl	%r13d, %r13d
	testl	%r12d, %r12d
	jle	.L4
	.p2align 4,,10
	.p2align 3
.L5:
	leaq	4(%rbx), %rdx
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %r12d
	addl	$1, %r13d
	addq	$8, %rbx
	cmpl	%r13d, %r12d
	jg	.L5
.L4:
	movl	$400004, %edi
	call	malloc@PLT
	movq	%rax, %rbx
	testq	%rax, %rax
	je	.L2
	movdqa	.LC3(%rip), %xmm0
	movl	$0, 4(%rax)
	leaq	399992(%rbx), %rdx
	leaq	8(%rax), %rax
	.p2align 4,,10
	.p2align 3
.L6:
	movups	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rax, %rdx
	jne	.L6
	movq	.LC4(%rip), %rax
	movl	$4, %ecx
	movl	$1, 400000(%rbx)
	movq	%rax, 399992(%rbx)
	movl	$2, %eax
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L10:
	addq	$1, %rax
	addq	$2, %rcx
	cmpq	$100001, %rax
	je	.L41
.L8:
	cmpl	$1, (%rbx,%rax,4)
	jne	.L10
	cmpq	$100000, %rcx
	ja	.L10
	movq	%rcx, %rdx
	.p2align 4,,10
	.p2align 3
.L11:
	movl	$0, (%rbx,%rdx,4)
	addq	%rax, %rdx
	cmpl	$100000, %edx
	jle	.L11
	addq	$1, %rax
	addq	$2, %rcx
	cmpq	$100001, %rax
	jne	.L8
.L41:
	movl	$400004, %edi
	call	malloc@PLT
	movq	%rax, %r13
	testq	%rax, %rax
	je	.L2
	movl	$0, (%rax)
	movl	$2, %eax
	.p2align 4,,10
	.p2align 3
.L13:
	movl	-4(%rbx,%rax,4), %ecx
	testl	%ecx, %ecx
	je	.L12
	movl	%eax, %edx
	sarl	%edx
	movslq	%edx, %rdx
	movl	(%rbx,%rdx,4), %edx
	testl	%edx, %edx
	je	.L12
	movl	$1, -4(%r13,%rax,4)
.L12:
	addq	$1, %rax
	cmpq	$100002, %rax
	jne	.L13
	movl	0(%r13), %edx
	leaq	4(%r13), %rax
	leaq	400004(%r13), %rcx
	.p2align 4,,10
	.p2align 3
.L14:
	addl	(%rax), %edx
	addq	$4, %rax
	movl	%edx, -4(%rax)
	cmpq	%rcx, %rax
	jne	.L14
	xorl	%ebx, %ebx
	leaq	.LC5(%rip), %r14
	testl	%r12d, %r12d
	jle	.L16
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	0(%rbp,%rbx,8), %rax
	movslq	4(%rbp,%rbx,8), %rdx
	movq	%r14, %rsi
	movl	$1, %edi
	addq	$1, %rbx
	movl	0(%r13,%rdx,4), %edx
	subl	-4(%r13,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	%ebx, 4(%rsp)
	jg	.L15
.L16:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L42
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L2:
	.cfi_restore_state
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	movl	$1, %edi
	call	exit@PLT
.L42:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC3:
	.long	1
	.long	1
	.long	1
	.long	1
	.set	.LC4,.LC3
	.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"
.LC1:
	.string	"not enough memory"
.LC2:
	.string	"%d%d"
.LC5:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %rdi
	movq	%rdi, %r12
	salq	$3, %rdi
	call	malloc@PLT
	testq	%rax, %rax
	je	.L2
	movq	%rax, %rbp
	movq	%rax, %rbx
	leaq	.LC2(%rip), %r14
	xorl	%r13d, %r13d
	testl	%r12d, %r12d
	jle	.L4
	.p2align 4,,10
	.p2align 3
.L5:
	leaq	4(%rbx), %rdx
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %r12d
	addl	$1, %r13d
	addq	$8, %rbx
	cmpl	%r13d, %r12d
	jg	.L5
.L4:
	movl	$400004, %edi
	call	malloc@PLT
	movq	%rax, %rbx
	testq	%rax, %rax
	je	.L2
	movdqa	.LC3(%rip), %xmm0
	movl	$0, 4(%rax)
	leaq	399992(%rbx), %rdx
	leaq	8(%rax), %rax
	.p2align 4,,10
	.p2align 3
.L6:
	movups	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rax, %rdx
	jne	.L6
	movq	.LC4(%rip), %rax
	movl	$4, %ecx
	movl	$1, 400000(%rbx)
	movq	%rax, 399992(%rbx)
	movl	$2, %eax
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L10:
	addq	$1, %rax
	addq	$2, %rcx
	cmpq	$100001, %rax
	je	.L41
.L8:
	cmpl	$1, (%rbx,%rax,4)
	jne	.L10
	cmpq	$100000, %rcx
	ja	.L10
	movq	%rcx, %rdx
	.p2align 4,,10
	.p2align 3
.L11:
	movl	$0, (%rbx,%rdx,4)
	addq	%rax, %rdx
	cmpl	$100000, %edx
	jle	.L11
	addq	$1, %rax
	addq	$2, %rcx
	cmpq	$100001, %rax
	jne	.L8
.L41:
	movl	$400004, %edi
	call	malloc@PLT
	movq	%rax, %r13
	testq	%rax, %rax
	je	.L2
	movl	$0, (%rax)
	movl	$2, %eax
	.p2align 4,,10
	.p2align 3
.L13:
	movl	-4(%rbx,%rax,4), %ecx
	testl	%ecx, %ecx
	je	.L12
	movl	%eax, %edx
	sarl	%edx
	movslq	%edx, %rdx
	movl	(%rbx,%rdx,4), %edx
	testl	%edx, %edx
	je	.L12
	movl	$1, -4(%r13,%rax,4)
.L12:
	addq	$1, %rax
	cmpq	$100002, %rax
	jne	.L13
	movl	0(%r13), %edx
	leaq	4(%r13), %rax
	leaq	400004(%r13), %rcx
	.p2align 4,,10
	.p2align 3
.L14:
	addl	(%rax), %edx
	addq	$4, %rax
	movl	%edx, -4(%rax)
	cmpq	%rcx, %rax
	jne	.L14
	xorl	%ebx, %ebx
	leaq	.LC5(%rip), %r14
	testl	%r12d, %r12d
	jle	.L16
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	0(%rbp,%rbx,8), %rax
	movslq	4(%rbp,%rbx,8), %rdx
	movq	%r14, %rsi
	movl	$1, %edi
	addq	$1, %rbx
	movl	0(%r13,%rdx,4), %edx
	subl	-4(%r13,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	%ebx, 4(%rsp)
	jg	.L15
.L16:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L42
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L2:
	.cfi_restore_state
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	movl	$1, %edi
	call	exit@PLT
.L42:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC3:
	.long	1
	.long	1
	.long	1
	.long	1
	.set	.LC4,.LC3
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct{
    int l;
    int r;
}data;

int main(void){
    int Q;
    scanf("%d",&Q);

    //A[0]~A[N-1]に格納する
    data* A;
    NEW(A,Q);
    for(int i=0;i<Q;i++){
        scanf("%d%d",&A[i].l,&A[i].r);
    }

    //iが素数のとき、prime[i]は1、そうでないなら0
    int* prime;
    int N=1e5;
    NEW(prime,N+1);
    prime[1]=0;
    for(int i=2;i<=N;i++) prime[i]=1;
    for(int i=2;i<=N;i++){
        if(prime[i]==1){
            int j=2;
            while(i*j<=N){
                prime[i*j]=0;
                j++;
            }
        }
    }

    int* ans;
    NEW(ans,N+1);
    ans[0]=0;
    for(int i=1;i<=N;i++){
        if(prime[i]){
            if(prime[(i+1)/2]) ans[i]=1;
        }
    }
    for(int i=1;i<=N;i++) ans[i]+=ans[i-1];

    for(int i=0;i<Q;i++){
        printf("%d\n",ans[A[i].r]-ans[A[i].l-1]);
    }

    return 0;
}
1
3 9
 1
5 9
 1
9 9
 4
13 13
7 0
7 11
2017 2017
 6
1 53
7 91
37 55
19 51
73 91
13 49
 4
11 13
7 1
7 13
2017 2017
 6
1 53
7 91
37 55
19 51
73 169
13 49
 4
11 13
7 0
7 13
1181 2017
 6
1 53
13 91
37 55
19 51
11 91
13 49
 1
3 13

2
 1
 0
 1
-2
0
1
 4
4
1
1
1
2
 1
-2
1
1
 4
4
1
1
2
2
 1
-2
1
13
 4
4
1
1
4
2
 3

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

```c
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct{
    int l;
    int r;
}data;

int main(void){
    int Q;
    scanf("%d",&Q);

    //A[0]~A[N-1]に格納する
    data* A;
    NEW(A,Q);
    for(int i=0;i<Q;i++){
        scanf("%d%d",&A[i].l,&A[i].r);
    }

    //iが素数のとき、prime[i]は1、そうでないなら0
    int* prime;
    int N=1e5;
    NEW(prime,N+1);
    prime[1]=0;
    for(int i=2;i<=N;i++) prime[i]=1;
    for(int i=2;i<=N;i++){
        if(prime[i]==1){
            int j=2;
            while(i*j<=N){
                prime[i*j]=0;
                j++;
            }
        }
    }

    int* ans;
    NEW(ans,N+1);
    ans[0]=0;
    for(int i=1;i<=N;i++){
        if(prime[i]){
            if(prime[(i+1)/2]) ans[i]=1;
        }
    }
    for(int i=1;i<=N;i++) ans[i]+=ans[i-1];

    for(int i=0;i<Q;i++){
        printf("%d\n",ans[A[i].r]-ans[A[i].l-1]);
    }

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"not enough memory"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-68(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-68(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -32(%rbp)
	cmpq	$0, -32(%rbp)
	jne	.L2
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %edi
	call	exit@PLT
.L2:
	movl	$0, -64(%rbp)
	jmp	.L3
.L4:
	movl	-64(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	addq	$4, %rax
	movl	-64(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-32(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rdx, %rcx
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -64(%rbp)
.L3:
	movl	-68(%rbp), %eax
	cmpl	%eax, -64(%rbp)
	jl	.L4
	movl	$100000, -36(%rbp)
	movl	-36(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	cmpq	$0, -24(%rbp)
	jne	.L5
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %edi
	call	exit@PLT
.L5:
	movq	-24(%rbp), %rax
	addq	$4, %rax
	movl	$0, (%rax)
	movl	$2, -60(%rbp)
	jmp	.L6
.L7:
	movl	-60(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	$1, (%rax)
	addl	$1, -60(%rbp)
.L6:
	movl	-60(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L7
	movl	$2, -56(%rbp)
	jmp	.L8
.L12:
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	$2, -52(%rbp)
	jmp	.L10
.L11:
	movl	-56(%rbp), %eax
	imull	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	addl	$1, -52(%rbp)
.L10:
	movl	-56(%rbp), %eax
	imull	-52(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jge	.L11
.L9:
	addl	$1, -56(%rbp)
.L8:
	movl	-56(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L12
	movl	-36(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	cmpq	$0, -16(%rbp)
	jne	.L13
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %edi
	call	exit@PLT
.L13:
	movq	-16(%rbp), %rax
	movl	$0, (%rax)
	movl	$1, -48(%rbp)
	jmp	.L14
.L16:
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L15
	movl	-48(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L15
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	$1, (%rax)
.L15:
	addl	$1, -48(%rbp)
.L14:
	movl	-48(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L16
	movl	$1, -44(%rbp)
	jmp	.L17
.L18:
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movl	-44(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rsi
	movq	-16(%rbp), %rax
	addq	%rsi, %rax
	addl	%ecx, %edx
	movl	%edx, (%rax)
	addl	$1, -44(%rbp)
.L17:
	movl	-44(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L18
	movl	$0, -40(%rbp)
	jmp	.L19
.L20:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-32(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -40(%rbp)
.L19:
	movl	-68(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L20
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"not enough memory"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-68(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-68(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -32(%rbp)
	cmpq	$0, -32(%rbp)
	jne	.L2
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %edi
	call	exit@PLT
.L2:
	movl	$0, -64(%rbp)
	jmp	.L3
.L4:
	movl	-64(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	addq	$4, %rax
	movl	-64(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-32(%rbp), %rdx
	addq	%rcx, %rdx
	movq	%rdx, %rcx
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -64(%rbp)
.L3:
	movl	-68(%rbp), %eax
	cmpl	%eax, -64(%rbp)
	jl	.L4
	movl	$100000, -36(%rbp)
	movl	-36(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	cmpq	$0, -24(%rbp)
	jne	.L5
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %edi
	call	exit@PLT
.L5:
	movq	-24(%rbp), %rax
	addq	$4, %rax
	movl	$0, (%rax)
	movl	$2, -60(%rbp)
	jmp	.L6
.L7:
	movl	-60(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	$1, (%rax)
	addl	$1, -60(%rbp)
.L6:
	movl	-60(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L7
	movl	$2, -56(%rbp)
	jmp	.L8
.L12:
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	$1, %eax
	jne	.L9
	movl	$2, -52(%rbp)
	jmp	.L10
.L11:
	movl	-56(%rbp), %eax
	imull	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	addl	$1, -52(%rbp)
.L10:
	movl	-56(%rbp), %eax
	imull	-52(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jge	.L11
.L9:
	addl	$1, -56(%rbp)
.L8:
	movl	-56(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L12
	movl	-36(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	cmpq	$0, -16(%rbp)
	jne	.L13
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %edi
	call	exit@PLT
.L13:
	movq	-16(%rbp), %rax
	movl	$0, (%rax)
	movl	$1, -48(%rbp)
	jmp	.L14
.L16:
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L15
	movl	-48(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L15
	movl	-48(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	$1, (%rax)
.L15:
	addl	$1, -48(%rbp)
.L14:
	movl	-48(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L16
	movl	$1, -44(%rbp)
	jmp	.L17
.L18:
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movl	-44(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rsi
	movq	-16(%rbp), %rax
	addq	%rsi, %rax
	addl	%ecx, %edx
	movl	%edx, (%rax)
	addl	$1, -44(%rbp)
.L17:
	movl	-44(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L18
	movl	$0, -40(%rbp)
	jmp	.L19
.L20:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-32(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	leaq	-4(%rdx), %rcx
	movq	-16(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -40(%rbp)
.L19:
	movl	-68(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L20
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
