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

```c
long B[3<<17],a,r,I;h[2<<17],i,j;s(i){for(r=0;i;i-=i&-i)r=fmax(r,B[i]);}main(n){for(scanf("%d",&n);i<n;)scanf("%d",h+i++);for(;~scanf("%d",&a);)for(s(I=h[j++]);I<3<<17;I+=I&-I)B[I]=fmax(B[I],a+r);printf("%ld",r,s(n));}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	B
	.bss
	.align 32
	.type	B, @object
	.size	B, 3145728
B:
	.zero	3145728
	.globl	a
	.align 8
	.type	a, @object
	.size	a, 8
a:
	.zero	8
	.globl	r
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.globl	I
	.align 8
	.type	I, @object
	.size	I, 8
I:
	.zero	8
	.globl	h
	.align 32
	.type	h, @object
	.size	h, 1048576
h:
	.zero	1048576
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.text
	.globl	s
	.type	s, @function
s:
.LFB0:
	.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
	movl	%edi, -4(%rbp)
	movq	$0, r(%rip)
	jmp	.L2
.L3:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	B(%rip), %rax
	movq	(%rdx,%rax), %rax
	pxor	%xmm0, %xmm0
	cvtsi2sdq	%rax, %xmm0
	movq	r(%rip), %rax
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rax, %xmm2
	movq	%xmm2, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmax@PLT
	cvttsd2siq	%xmm0, %rax
	movq	%rax, r(%rip)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	andl	%eax, -4(%rbp)
.L2:
	cmpl	$0, -4(%rbp)
	jne	.L3
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	s, .-s
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%ld"
	.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
	movl	%edi, -4(%rbp)
	leaq	-4(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L5
.L6:
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	h(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
.L5:
	movl	i(%rip), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L6
	jmp	.L7
.L10:
	movl	j(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, j(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	h(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movq	%rax, I(%rip)
	movq	I(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	s
	jmp	.L8
.L9:
	movq	a(%rip), %rdx
	movq	r(%rip), %rax
	addq	%rdx, %rax
	pxor	%xmm0, %xmm0
	cvtsi2sdq	%rax, %xmm0
	movq	I(%rip), %rax
	leaq	0(,%rax,8), %rdx
	leaq	B(%rip), %rax
	movq	(%rdx,%rax), %rax
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rax, %xmm2
	movq	%xmm2, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmax@PLT
	movq	I(%rip), %rdx
	cvttsd2siq	%xmm0, %rax
	leaq	0(,%rdx,8), %rcx
	leaq	B(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	I(%rip), %rax
	negq	%rax
	movq	%rax, %rdx
	movq	I(%rip), %rax
	andq	%rax, %rdx
	movq	I(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, I(%rip)
.L8:
	movq	I(%rip), %rax
	cmpq	$393215, %rax
	jle	.L9
.L7:
	leaq	a(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L10
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	movl	$0, %eax
	call	s
	movl	%eax, %edx
	movq	r(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%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	s
	.type	s, @function
s:
.LFB0:
	.cfi_startproc
	endbr64
	movq	$0, r(%rip)
	testl	%edi, %edi
	je	.L9
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	xorl	%edx, %edx
	leaq	B(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	.p2align 4,,10
	.p2align 3
.L3:
	movslq	%ebx, %rax
	pxor	%xmm0, %xmm0
	pxor	%xmm1, %xmm1
	cvtsi2sdq	%rdx, %xmm0
	cvtsi2sdq	0(%rbp,%rax,8), %xmm1
	call	fmax@PLT
	leal	-1(%rbx), %eax
	cvttsd2siq	%xmm0, %rdx
	andl	%eax, %ebx
	jne	.L3
	movq	%rdx, r(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L9:
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE0:
	.size	s, .-s
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%ld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	h(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	%edi, 12(%rsp)
	leaq	12(%rsp), %rsi
	movq	%r13, %rdi
	call	scanf@PLT
	movslq	i(%rip), %rax
	cmpl	12(%rsp), %eax
	jge	.L16
	.p2align 4,,10
	.p2align 3
.L14:
	leal	1(%rax), %edx
	leaq	(%rbx,%rax,4), %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	movl	%edx, i(%rip)
	call	scanf@PLT
	movslq	i(%rip), %rax
	cmpl	12(%rsp), %eax
	jl	.L14
.L16:
	leaq	a(%rip), %r14
	leaq	h(%rip), %r15
	leaq	B(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L15:
	xorl	%eax, %eax
	movq	%r14, %rsi
	movq	%r13, %rdi
	call	scanf@PLT
	cmpl	$-1, %eax
	je	.L31
	movslq	j(%rip), %rax
	movq	$0, r(%rip)
	movslq	(%r15,%rax,4), %rbx
	leal	1(%rax), %edx
	movl	%edx, j(%rip)
	xorl	%edx, %edx
	movq	%rbx, I(%rip)
	movq	%rbx, %rbp
	movq	%rbx, %rax
	testl	%ebx, %ebx
	jne	.L18
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L32:
	movslq	%ebp, %rax
.L18:
	pxor	%xmm0, %xmm0
	pxor	%xmm1, %xmm1
	cvtsi2sdq	%rdx, %xmm0
	cvtsi2sdq	(%r12,%rax,8), %xmm1
	call	fmax@PLT
	leal	-1(%rbp), %eax
	cvttsd2siq	%xmm0, %rdx
	andl	%eax, %ebp
	jne	.L32
	movq	%rdx, r(%rip)
	cmpq	$393215, %rbx
	jg	.L15
.L17:
	addq	a(%rip), %rdx
	pxor	%xmm1, %xmm1
	cvtsi2sdq	%rdx, %xmm1
	.p2align 4,,10
	.p2align 3
.L20:
	pxor	%xmm0, %xmm0
	movsd	%xmm1, (%rsp)
	cvtsi2sdq	(%r12,%rbx,8), %xmm0
	call	fmax@PLT
	movsd	(%rsp), %xmm1
	cvttsd2siq	%xmm0, %rax
	movq	%rax, (%r12,%rbx,8)
	movq	%rbx, %rax
	negq	%rax
	andq	%rbx, %rax
	addq	%rax, %rbx
	cmpq	$393215, %rbx
	jle	.L20
	movq	%rbx, I(%rip)
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L31:
	movl	12(%rsp), %edi
	xorl	%eax, %eax
	call	s
	movq	r(%rip), %rsi
	leaq	.LC1(%rip), %rdi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	printf@PLT
	addq	$24, %rsp
	.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
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.globl	j
	.bss
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	h
	.align 32
	.type	h, @object
	.size	h, 1048576
h:
	.zero	1048576
	.globl	I
	.align 8
	.type	I, @object
	.size	I, 8
I:
	.zero	8
	.globl	r
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.globl	a
	.align 8
	.type	a, @object
	.size	a, 8
a:
	.zero	8
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 3145728
B:
	.zero	3145728
	.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	s
	.type	s, @function
s:
.LFB0:
	.cfi_startproc
	endbr64
	movq	$0, r(%rip)
	testl	%edi, %edi
	je	.L9
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	xorl	%edx, %edx
	leaq	B(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	.p2align 4,,10
	.p2align 3
.L3:
	movslq	%ebx, %rax
	pxor	%xmm0, %xmm0
	pxor	%xmm1, %xmm1
	cvtsi2sdq	%rdx, %xmm0
	cvtsi2sdq	0(%rbp,%rax,8), %xmm1
	call	fmax@PLT
	leal	-1(%rbx), %eax
	cvttsd2siq	%xmm0, %rdx
	andl	%eax, %ebx
	jne	.L3
	movq	%rdx, r(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L9:
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE0:
	.size	s, .-s
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%ld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	h(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	%edi, 12(%rsp)
	leaq	12(%rsp), %rsi
	movq	%r13, %rdi
	call	scanf@PLT
	movslq	i(%rip), %rax
	cmpl	12(%rsp), %eax
	jge	.L16
	.p2align 4,,10
	.p2align 3
.L14:
	leal	1(%rax), %edx
	leaq	(%rbx,%rax,4), %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	movl	%edx, i(%rip)
	call	scanf@PLT
	movslq	i(%rip), %rax
	cmpl	12(%rsp), %eax
	jl	.L14
.L16:
	leaq	a(%rip), %r14
	leaq	h(%rip), %r15
	leaq	B(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L15:
	xorl	%eax, %eax
	movq	%r14, %rsi
	movq	%r13, %rdi
	call	scanf@PLT
	cmpl	$-1, %eax
	je	.L31
	movslq	j(%rip), %rax
	movq	$0, r(%rip)
	movslq	(%r15,%rax,4), %rbx
	leal	1(%rax), %edx
	movl	%edx, j(%rip)
	xorl	%edx, %edx
	movq	%rbx, I(%rip)
	movq	%rbx, %rbp
	movq	%rbx, %rax
	testl	%ebx, %ebx
	jne	.L18
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L32:
	movslq	%ebp, %rax
.L18:
	pxor	%xmm0, %xmm0
	pxor	%xmm1, %xmm1
	cvtsi2sdq	%rdx, %xmm0
	cvtsi2sdq	(%r12,%rax,8), %xmm1
	call	fmax@PLT
	leal	-1(%rbp), %eax
	cvttsd2siq	%xmm0, %rdx
	andl	%eax, %ebp
	jne	.L32
	movq	%rdx, r(%rip)
	cmpq	$393215, %rbx
	jg	.L15
.L17:
	addq	a(%rip), %rdx
	pxor	%xmm1, %xmm1
	cvtsi2sdq	%rdx, %xmm1
	.p2align 4,,10
	.p2align 3
.L20:
	pxor	%xmm0, %xmm0
	movsd	%xmm1, (%rsp)
	cvtsi2sdq	(%r12,%rbx,8), %xmm0
	call	fmax@PLT
	movsd	(%rsp), %xmm1
	cvttsd2siq	%xmm0, %rax
	movq	%rax, (%r12,%rbx,8)
	movq	%rbx, %rax
	negq	%rax
	andq	%rbx, %rax
	addq	%rax, %rbx
	cmpq	$393215, %rbx
	jle	.L20
	movq	%rbx, I(%rip)
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L31:
	movl	12(%rsp), %edi
	xorl	%eax, %eax
	call	s
	movq	r(%rip), %rsi
	leaq	.LC1(%rip), %rdi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	printf@PLT
	addq	$24, %rsp
	.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
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.globl	j
	.bss
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	h
	.align 32
	.type	h, @object
	.size	h, 1048576
h:
	.zero	1048576
	.globl	I
	.align 8
	.type	I, @object
	.size	I, 8
I:
	.zero	8
	.globl	r
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.globl	a
	.align 8
	.type	a, @object
	.size	a, 8
a:
	.zero	8
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 3145728
B:
	.zero	3145728
	.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:

long B[3<<17],a,r,I;h[2<<17],i,j;s(i){for(r=0;i;i-=i&-i)r=fmax(r,B[i]);}main(n){for(scanf("%d",&n);i<n;)scanf("%d",h+i++);for(;~scanf("%d",&a);)for(s(I=h[j++]);I<3<<17;I+=I&-I)B[I]=fmax(B[I],a+r);printf("%ld",r,s(n));}
5
1 2 3 4 5
1000000000 1000000010 1000000000 1000000000 1000000000
 4
3 1 4 2
10 20 2 40
 9
4 2 5 8 3 6 1 7 9
6 8 8 4 6 5 5 7 5
 5
1 2 3 4 5
1000000000 1000000010 1000000000 1010000000 1000000000
 9
4 2 5 8 3 6 1 7 9
6 8 8 4 6 4 5 7 5
 5
1 2 3 4 5
1000000000 1000000010 1000100000 1010000000 1000000000
 4
3 1 4 2
20 20 2 26
 4
3 1 4 2
15 25 2 40
 5
1 2 3 4 5
1010000000 1000000010 1000100000 1010000000 1000000000
 5
1 2 3 4 5
1010000000 0000000010 1000100000 1010000000 1000000000

5000000010 60 33 5010000010 32 5010100010 46 65 5020100010 4020100010
Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
long B[3<<17],a,r,I;h[2<<17],i,j;s(i){for(r=0;i;i-=i&-i)r=fmax(r,B[i]);}main(n){for(scanf("%d",&n);i<n;)scanf("%d",h+i++);for(;~scanf("%d",&a);)for(s(I=h[j++]);I<3<<17;I+=I&-I)B[I]=fmax(B[I],a+r);printf("%ld",r,s(n));}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	B
	.bss
	.align 32
	.type	B, @object
	.size	B, 3145728
B:
	.zero	3145728
	.globl	a
	.align 8
	.type	a, @object
	.size	a, 8
a:
	.zero	8
	.globl	r
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.globl	I
	.align 8
	.type	I, @object
	.size	I, 8
I:
	.zero	8
	.globl	h
	.align 32
	.type	h, @object
	.size	h, 1048576
h:
	.zero	1048576
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.text
	.globl	s
	.type	s, @function
s:
.LFB0:
	.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
	movl	%edi, -4(%rbp)
	movq	$0, r(%rip)
	jmp	.L2
.L3:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	B(%rip), %rax
	movq	(%rdx,%rax), %rax
	pxor	%xmm0, %xmm0
	cvtsi2sdq	%rax, %xmm0
	movq	r(%rip), %rax
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rax, %xmm2
	movq	%xmm2, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmax@PLT
	cvttsd2siq	%xmm0, %rax
	movq	%rax, r(%rip)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	andl	%eax, -4(%rbp)
.L2:
	cmpl	$0, -4(%rbp)
	jne	.L3
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	s, .-s
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%ld"
	.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
	movl	%edi, -4(%rbp)
	leaq	-4(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L5
.L6:
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	h(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
.L5:
	movl	i(%rip), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L6
	jmp	.L7
.L10:
	movl	j(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, j(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	h(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movq	%rax, I(%rip)
	movq	I(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	s
	jmp	.L8
.L9:
	movq	a(%rip), %rdx
	movq	r(%rip), %rax
	addq	%rdx, %rax
	pxor	%xmm0, %xmm0
	cvtsi2sdq	%rax, %xmm0
	movq	I(%rip), %rax
	leaq	0(,%rax,8), %rdx
	leaq	B(%rip), %rax
	movq	(%rdx,%rax), %rax
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rax, %xmm2
	movq	%xmm2, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmax@PLT
	movq	I(%rip), %rdx
	cvttsd2siq	%xmm0, %rax
	leaq	0(,%rdx,8), %rcx
	leaq	B(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	I(%rip), %rax
	negq	%rax
	movq	%rax, %rdx
	movq	I(%rip), %rax
	andq	%rax, %rdx
	movq	I(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, I(%rip)
.L8:
	movq	I(%rip), %rax
	cmpq	$393215, %rax
	jle	.L9
.L7:
	leaq	a(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L10
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	movl	$0, %eax
	call	s
	movl	%eax, %edx
	movq	r(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%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	B
	.bss
	.align 32
	.type	B, @object
	.size	B, 3145728
B:
	.zero	3145728
	.globl	a
	.align 8
	.type	a, @object
	.size	a, 8
a:
	.zero	8
	.globl	r
	.align 8
	.type	r, @object
	.size	r, 8
r:
	.zero	8
	.globl	I
	.align 8
	.type	I, @object
	.size	I, 8
I:
	.zero	8
	.globl	h
	.align 32
	.type	h, @object
	.size	h, 1048576
h:
	.zero	1048576
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.text
	.globl	s
	.type	s, @function
s:
.LFB0:
	.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
	movl	%edi, -4(%rbp)
	movq	$0, r(%rip)
	jmp	.L2
.L3:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	B(%rip), %rax
	movq	(%rdx,%rax), %rax
	pxor	%xmm0, %xmm0
	cvtsi2sdq	%rax, %xmm0
	movq	r(%rip), %rax
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rax, %xmm2
	movq	%xmm2, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmax@PLT
	cvttsd2siq	%xmm0, %rax
	movq	%rax, r(%rip)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	andl	%eax, -4(%rbp)
.L2:
	cmpl	$0, -4(%rbp)
	jne	.L3
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	s, .-s
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%ld"
	.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
	movl	%edi, -4(%rbp)
	leaq	-4(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L5
.L6:
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	h(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
.L5:
	movl	i(%rip), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L6
	jmp	.L7
.L10:
	movl	j(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, j(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	h(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movq	%rax, I(%rip)
	movq	I(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	s
	jmp	.L8
.L9:
	movq	a(%rip), %rdx
	movq	r(%rip), %rax
	addq	%rdx, %rax
	pxor	%xmm0, %xmm0
	cvtsi2sdq	%rax, %xmm0
	movq	I(%rip), %rax
	leaq	0(,%rax,8), %rdx
	leaq	B(%rip), %rax
	movq	(%rdx,%rax), %rax
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rax, %xmm2
	movq	%xmm2, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmax@PLT
	movq	I(%rip), %rdx
	cvttsd2siq	%xmm0, %rax
	leaq	0(,%rdx,8), %rcx
	leaq	B(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	I(%rip), %rax
	negq	%rax
	movq	%rax, %rdx
	movq	I(%rip), %rax
	andq	%rax, %rdx
	movq	I(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, I(%rip)
.L8:
	movq	I(%rip), %rax
	cmpq	$393215, %rax
	jle	.L9
.L7:
	leaq	a(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	cmpl	$-1, %eax
	jne	.L10
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	movl	$0, %eax
	call	s
	movl	%eax, %edx
	movq	r(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%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:
