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>

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

int a[1000];

int main(void)
{
	int n, q, i, com, b, c, ans;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d%d", &com, &b, &c);
		if (com == 0) {
			ans = INF;
			for (i = b; i < c; i++) {
				ans = min(ans, a[i]);
			}
		}
		else {
			ans = -INF;
			for (i = b; i < c; i++) {
				ans = max(ans, a[i]);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 4000
a:
	.zero	4000
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L2
.L3:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -16(%rbp)
.L2:
	movl	-36(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L3
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L4
.L11:
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	movl	$1000000001, -12(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L6
.L7:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %edx
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -12(%rbp)
	addl	$1, -16(%rbp)
.L6:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L7
	jmp	.L8
.L5:
	movl	$-1000000001, -12(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L9
.L10:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -12(%rbp)
	addl	$1, -16(%rbp)
.L9:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L10
.L8:
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L4:
	movl	-32(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -32(%rbp)
	testl	%eax, %eax
	jne	.L11
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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
.LC2:
	.string	"%d"
.LC3:
	.string	"%d%d%d"
.LC4:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC2(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %edx
	testl	%edx, %edx
	jle	.L2
	leaq	a(%rip), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %rbp
	cmpl	%ebx, 4(%rsp)
	jg	.L3
.L2:
	leaq	8(%rsp), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 8(%rsp)
	testl	%eax, %eax
	je	.L4
	leaq	20(%rsp), %r15
	leaq	16(%rsp), %r14
	leaq	12(%rsp), %r13
	leaq	.LC3(%rip), %r12
	leaq	.LC4(%rip), %rbp
	leaq	a(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L14:
	movq	%r15, %rcx
	movq	%r12, %rdi
	movq	%r14, %rdx
	movq	%r13, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	movl	16(%rsp), %ecx
	movl	20(%rsp), %edi
	testl	%eax, %eax
	jne	.L5
	cmpl	%edi, %ecx
	jge	.L16
	movl	%edi, %r8d
	subl	%ecx, %r8d
	leal	-1(%r8), %eax
	cmpl	$2, %eax
	jbe	.L17
	movslq	%ecx, %rax
	movdqa	.LC0(%rip), %xmm0
	leaq	(%rbx,%rax,4), %rdx
	movl	%r8d, %eax
	shrl	$2, %eax
	leal	-1(%rax), %esi
	leaq	16(%rdx), %rax
	salq	$4, %rsi
	addq	%rax, %rsi
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L31:
	addq	$16, %rax
.L8:
	movdqu	(%rdx), %xmm2
	movq	%rax, %rdx
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm1, %xmm0
	cmpq	%rax, %rsi
	jne	.L31
	movdqa	%xmm0, %xmm2
	movl	%r8d, %eax
	psrldq	$8, %xmm2
	andl	$-4, %eax
	movdqa	%xmm2, %xmm1
	addl	%eax, %ecx
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm1, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm0, %xmm1
	movd	%xmm1, %edx
	cmpl	%eax, %r8d
	je	.L6
.L7:
	movslq	%ecx, %rax
	movl	(%rbx,%rax,4), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	leal	1(%rcx), %eax
	cmpl	%edi, %eax
	jge	.L6
	cltq
	movl	(%rbx,%rax,4), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	addl	$2, %ecx
	cmpl	%edi, %ecx
	jge	.L6
	movslq	%ecx, %rcx
	movl	(%rbx,%rcx,4), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
.L6:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	8(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 8(%rsp)
	testl	%eax, %eax
	jne	.L14
.L4:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	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
.L5:
	.cfi_restore_state
	cmpl	%edi, %ecx
	jge	.L18
	movl	%edi, %r8d
	subl	%ecx, %r8d
	leal	-1(%r8), %eax
	cmpl	$2, %eax
	jbe	.L19
	movslq	%ecx, %rax
	movdqa	.LC1(%rip), %xmm2
	leaq	(%rbx,%rax,4), %rdx
	movl	%r8d, %eax
	shrl	$2, %eax
	leal	-1(%rax), %esi
	leaq	16(%rdx), %rax
	salq	$4, %rsi
	addq	%rax, %rsi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L33:
	addq	$16, %rax
.L11:
	movdqu	(%rdx), %xmm0
	movq	%rax, %rdx
	movdqa	%xmm0, %xmm1
	pcmpgtd	%xmm2, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	por	%xmm0, %xmm2
	cmpq	%rsi, %rax
	jne	.L33
	movdqa	%xmm2, %xmm1
	movl	%r8d, %eax
	psrldq	$8, %xmm1
	andl	$-4, %eax
	movdqa	%xmm1, %xmm0
	addl	%eax, %ecx
	pcmpgtd	%xmm2, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movd	%xmm1, %edx
	cmpl	%eax, %r8d
	je	.L6
.L10:
	movslq	%ecx, %rax
	movl	(%rbx,%rax,4), %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	leal	1(%rcx), %eax
	cmpl	%eax, %edi
	jle	.L6
	cltq
	movl	(%rbx,%rax,4), %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	addl	$2, %ecx
	cmpl	%ecx, %edi
	jle	.L6
	movslq	%ecx, %rcx
	movl	(%rbx,%rcx,4), %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	jmp	.L6
.L16:
	movl	$1000000001, %edx
	jmp	.L6
.L18:
	movl	$-1000000001, %edx
	jmp	.L6
.L19:
	movl	$-1000000001, %edx
	jmp	.L10
.L17:
	movl	$1000000001, %edx
	jmp	.L7
.L32:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 4000
a:
	.zero	4000
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	1000000001
	.long	1000000001
	.long	1000000001
	.long	1000000001
	.align 16
.LC1:
	.long	-1000000001
	.long	-1000000001
	.long	-1000000001
	.long	-1000000001
	.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
.LC2:
	.string	"%d"
.LC3:
	.string	"%d%d%d"
.LC4:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC2(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %edx
	testl	%edx, %edx
	jle	.L2
	leaq	a(%rip), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %rbp
	cmpl	%ebx, 4(%rsp)
	jg	.L3
.L2:
	leaq	8(%rsp), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 8(%rsp)
	testl	%eax, %eax
	je	.L4
	leaq	20(%rsp), %r15
	leaq	16(%rsp), %r14
	leaq	12(%rsp), %r13
	leaq	.LC3(%rip), %r12
	leaq	.LC4(%rip), %rbp
	leaq	a(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L14:
	movq	%r15, %rcx
	movq	%r12, %rdi
	movq	%r14, %rdx
	movq	%r13, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	movl	16(%rsp), %ecx
	movl	20(%rsp), %edi
	testl	%eax, %eax
	jne	.L5
	cmpl	%edi, %ecx
	jge	.L16
	movl	%edi, %r8d
	subl	%ecx, %r8d
	leal	-1(%r8), %eax
	cmpl	$2, %eax
	jbe	.L17
	movslq	%ecx, %rax
	movdqa	.LC0(%rip), %xmm0
	leaq	(%rbx,%rax,4), %rdx
	movl	%r8d, %eax
	shrl	$2, %eax
	leal	-1(%rax), %esi
	leaq	16(%rdx), %rax
	salq	$4, %rsi
	addq	%rax, %rsi
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L31:
	addq	$16, %rax
.L8:
	movdqu	(%rdx), %xmm2
	movq	%rax, %rdx
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm1, %xmm0
	cmpq	%rax, %rsi
	jne	.L31
	movdqa	%xmm0, %xmm2
	movl	%r8d, %eax
	psrldq	$8, %xmm2
	andl	$-4, %eax
	movdqa	%xmm2, %xmm1
	addl	%eax, %ecx
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm1, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	por	%xmm0, %xmm1
	movd	%xmm1, %edx
	cmpl	%eax, %r8d
	je	.L6
.L7:
	movslq	%ecx, %rax
	movl	(%rbx,%rax,4), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	leal	1(%rcx), %eax
	cmpl	%edi, %eax
	jge	.L6
	cltq
	movl	(%rbx,%rax,4), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	addl	$2, %ecx
	cmpl	%edi, %ecx
	jge	.L6
	movslq	%ecx, %rcx
	movl	(%rbx,%rcx,4), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
.L6:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	8(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 8(%rsp)
	testl	%eax, %eax
	jne	.L14
.L4:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	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
.L5:
	.cfi_restore_state
	cmpl	%edi, %ecx
	jge	.L18
	movl	%edi, %r8d
	subl	%ecx, %r8d
	leal	-1(%r8), %eax
	cmpl	$2, %eax
	jbe	.L19
	movslq	%ecx, %rax
	movdqa	.LC1(%rip), %xmm2
	leaq	(%rbx,%rax,4), %rdx
	movl	%r8d, %eax
	shrl	$2, %eax
	leal	-1(%rax), %esi
	leaq	16(%rdx), %rax
	salq	$4, %rsi
	addq	%rax, %rsi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L33:
	addq	$16, %rax
.L11:
	movdqu	(%rdx), %xmm0
	movq	%rax, %rdx
	movdqa	%xmm0, %xmm1
	pcmpgtd	%xmm2, %xmm1
	pand	%xmm1, %xmm0
	pandn	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	por	%xmm0, %xmm2
	cmpq	%rsi, %rax
	jne	.L33
	movdqa	%xmm2, %xmm1
	movl	%r8d, %eax
	psrldq	$8, %xmm1
	andl	$-4, %eax
	movdqa	%xmm1, %xmm0
	addl	%eax, %ecx
	pcmpgtd	%xmm2, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	movdqa	%xmm0, %xmm2
	psrldq	$4, %xmm2
	movdqa	%xmm2, %xmm1
	pcmpgtd	%xmm0, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movd	%xmm1, %edx
	cmpl	%eax, %r8d
	je	.L6
.L10:
	movslq	%ecx, %rax
	movl	(%rbx,%rax,4), %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	leal	1(%rcx), %eax
	cmpl	%eax, %edi
	jle	.L6
	cltq
	movl	(%rbx,%rax,4), %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	addl	$2, %ecx
	cmpl	%ecx, %edi
	jle	.L6
	movslq	%ecx, %rcx
	movl	(%rbx,%rcx,4), %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	jmp	.L6
.L16:
	movl	$1000000001, %edx
	jmp	.L6
.L18:
	movl	$-1000000001, %edx
	jmp	.L6
.L19:
	movl	$-1000000001, %edx
	jmp	.L10
.L17:
	movl	$1000000001, %edx
	jmp	.L7
.L32:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 4000
a:
	.zero	4000
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	1000000001
	.long	1000000001
	.long	1000000001
	.long	1000000001
	.align 16
.LC1:
	.long	-1000000001
	.long	-1000000001
	.long	-1000000001
	.long	-1000000001
	.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>

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

int a[1000];

int main(void)
{
	int n, q, i, com, b, c, ans;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d%d", &com, &b, &c);
		if (com == 0) {
			ans = INF;
			for (i = b; i < c; i++) {
				ans = min(ans, a[i]);
			}
		}
		else {
			ans = -INF;
			for (i = b; i < c; i++) {
				ans = max(ans, a[i]);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


7
8 3 0 1 9 1 4
3
0 0 3
0 1 5
1 0 7
 7
8 3 0 0 9 1 4
3
0 0 3
1 1 5
1 0 7
 7
8 3 0 0 9 1 4
6
0 0 3
1 1 5
1 0 7
 7
8 3 0 1 14 1 4
3
0 1 3
0 1 5
1 0 7
 7
2 2 -1 2 9 1 0
3
0 0 3
0 1 5
1 0 7
 7
8 3 7 1 9 1 4
3
1 0 3
0 1 5
1 0 7
 7
8 3 0 -1 9 1 4
3
0 0 3
0 1 5
1 0 7
 7
8 3 0 1 6 1 4
3
0 0 3
1 1 5
1 0 7
 7
8 3 0 1 9 1 4
5
0 1 3
1 1 5
1 0 7
 7
2 2 0 1 9 1 0
3
1 0 4
0 1 5
1 0 7

0
0
9
 0
9
9
 0
9
9
9
9
9
 0
0
14
 -1
-1
9
 8
1
9
 0
-1
9
 0
6
8
 0
9
9
9
9
 2
0
9

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>

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

int a[1000];

int main(void)
{
	int n, q, i, com, b, c, ans;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d%d", &com, &b, &c);
		if (com == 0) {
			ans = INF;
			for (i = b; i < c; i++) {
				ans = min(ans, a[i]);
			}
		}
		else {
			ans = -INF;
			for (i = b; i < c; i++) {
				ans = max(ans, a[i]);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 4000
a:
	.zero	4000
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L2
.L3:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -16(%rbp)
.L2:
	movl	-36(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L3
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L4
.L11:
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	movl	$1000000001, -12(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L6
.L7:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %edx
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -12(%rbp)
	addl	$1, -16(%rbp)
.L6:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L7
	jmp	.L8
.L5:
	movl	$-1000000001, -12(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L9
.L10:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -12(%rbp)
	addl	$1, -16(%rbp)
.L9:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L10
.L8:
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L4:
	movl	-32(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -32(%rbp)
	testl	%eax, %eax
	jne	.L11
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 4000
a:
	.zero	4000
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.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
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L2
.L3:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -16(%rbp)
.L2:
	movl	-36(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L3
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L4
.L11:
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	movl	$1000000001, -12(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L6
.L7:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %edx
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -12(%rbp)
	addl	$1, -16(%rbp)
.L6:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L7
	jmp	.L8
.L5:
	movl	$-1000000001, -12(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L9
.L10:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-12(%rbp), %edx
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	movl	%eax, -12(%rbp)
	addl	$1, -16(%rbp)
.L9:
	movl	-20(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L10
.L8:
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L4:
	movl	-32(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -32(%rbp)
	testl	%eax, %eax
	jne	.L11
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
