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>

int n;   // 荷物の数
int k;   // トラックの台数
int w[100000] = {};  // それぞれの荷物の重さ

// 最大積載量Pのk台のトラックで何個の荷物が詰めるか
int check(int P) {
    int j = 0;
    int sum;

    for (int i = 0; i < k; i++) {
        sum = 0;
        while (sum + w[j] <= P) {
            sum += w[j];
            j++;
            if (j == n) return n;
        }
    }
    return j;
}

// 二分探索
int binarySearch() {
    int left = 0;
    int right = 10000 * 100000;  // 1つあたりの荷物の重さ * 荷物の最大量
    int mid;

    while(left < right) {
        mid = (left + right) / 2;
        int checkResult = check(mid);
        if (checkResult >= n) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    return right;
}

int main(void)
{
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &w[i]);
    }

    int P = binarySearch();
    printf("%d\n", P);

    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	w
	.align 32
	.type	w, @object
	.size	w, 400000
w:
	.zero	400000
	.text
	.globl	check
	.type	check, @function
check:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L6:
	movl	$0, -8(%rbp)
	jmp	.L3
.L5:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -8(%rbp)
	addl	$1, -12(%rbp)
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jne	.L3
	movl	n(%rip), %eax
	jmp	.L4
.L3:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -20(%rbp)
	jge	.L5
	addl	$1, -4(%rbp)
.L2:
	movl	k(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L6
	movl	-12(%rbp), %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	check, .-check
	.globl	binarySearch
	.type	binarySearch, @function
binarySearch:
.LFB7:
	.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	$0, -16(%rbp)
	movl	$1000000000, -12(%rbp)
	jmp	.L8
.L10:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	check
	movl	%eax, -4(%rbp)
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L9
	movl	-8(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L8
.L9:
	movl	-8(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -16(%rbp)
.L8:
	movl	-16(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L10
	movl	-12(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	binarySearch, .-binarySearch
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	k(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -8(%rbp)
	jmp	.L13
.L14:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L14
	movl	$0, %eax
	call	binarySearch
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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:
.LFB51:
	.cfi_startproc
	endbr64
	movl	k(%rip), %r9d
	testl	%r9d, %r9d
	jle	.L6
	movl	n(%rip), %ecx
	xorl	%esi, %esi
	xorl	%r8d, %r8d
	leaq	w(%rip), %r10
.L3:
	movslq	%r8d, %rax
	leaq	(%r10,%rax,4), %rdx
	xorl	%eax, %eax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	addl	$1, %r8d
	addq	$4, %rdx
	cmpl	%r8d, %ecx
	je	.L1
.L5:
	addl	(%rdx), %eax
	cmpl	%edi, %eax
	jle	.L4
	addl	$1, %esi
	cmpl	%r9d, %esi
	jne	.L3
.L1:
	movl	%r8d, %eax
	ret
.L6:
	xorl	%r8d, %r8d
	jmp	.L1
	.cfi_endproc
.LFE51:
	.size	check, .-check
	.p2align 4
	.globl	binarySearch
	.type	binarySearch, @function
binarySearch:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movl	n(%rip), %r8d
	movl	$1000000000, %r10d
	xorl	%r11d, %r11d
	movl	k(%rip), %ebx
	leaq	w(%rip), %rdi
	.p2align 4,,10
	.p2align 3
.L20:
	cmpl	%r11d, %r10d
	jle	.L22
.L15:
	leal	(%r10,%r11), %ecx
	xorl	%esi, %esi
	xorl	%r9d, %r9d
	sarl	%ecx
	testl	%ebx, %ebx
	jle	.L11
.L10:
	movslq	%esi, %rax
	xorl	%edx, %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L13:
	addq	$1, %rax
	cmpl	%eax, %r8d
	je	.L18
.L14:
	addl	(%rdi,%rax,4), %edx
	movl	%eax, %esi
	cmpl	%edx, %ecx
	jge	.L13
	addl	$1, %r9d
	cmpl	%r9d, %ebx
	jne	.L10
.L11:
	cmpl	%esi, %r8d
	jle	.L18
	leal	1(%rcx), %r11d
	cmpl	%r11d, %r10d
	jg	.L15
.L22:
	movl	%r10d, %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L18:
	.cfi_restore_state
	movl	%ecx, %r10d
	jmp	.L20
	.cfi_endproc
.LFE52:
	.size	binarySearch, .-binarySearch
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB53:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	k(%rip), %rdx
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC0(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L24
	leaq	w(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %rbp
	cmpl	%ebx, n(%rip)
	jg	.L25
.L24:
	xorl	%eax, %eax
	call	binarySearch
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE53:
	.size	main, .-main
	.globl	w
	.bss
	.align 32
	.type	w, @object
	.size	w, 400000
w:
	.zero	400000
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	check
	.type	check, @function
check:
.LFB51:
	.cfi_startproc
	endbr64
	movl	k(%rip), %r9d
	testl	%r9d, %r9d
	jle	.L6
	movl	n(%rip), %ecx
	xorl	%esi, %esi
	xorl	%r8d, %r8d
	leaq	w(%rip), %r10
.L3:
	movslq	%r8d, %rax
	leaq	(%r10,%rax,4), %rdx
	xorl	%eax, %eax
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	addl	$1, %r8d
	addq	$4, %rdx
	cmpl	%r8d, %ecx
	je	.L1
.L5:
	addl	(%rdx), %eax
	cmpl	%edi, %eax
	jle	.L4
	addl	$1, %esi
	cmpl	%r9d, %esi
	jne	.L3
.L1:
	movl	%r8d, %eax
	ret
.L6:
	xorl	%r8d, %r8d
	jmp	.L1
	.cfi_endproc
.LFE51:
	.size	check, .-check
	.p2align 4
	.globl	binarySearch
	.type	binarySearch, @function
binarySearch:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movl	n(%rip), %r8d
	movl	$1000000000, %r10d
	xorl	%r11d, %r11d
	movl	k(%rip), %ebx
	leaq	w(%rip), %rdi
	.p2align 4,,10
	.p2align 3
.L20:
	cmpl	%r11d, %r10d
	jle	.L22
.L15:
	leal	(%r10,%r11), %ecx
	xorl	%esi, %esi
	xorl	%r9d, %r9d
	sarl	%ecx
	testl	%ebx, %ebx
	jle	.L11
.L10:
	movslq	%esi, %rax
	xorl	%edx, %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L13:
	addq	$1, %rax
	cmpl	%eax, %r8d
	je	.L18
.L14:
	addl	(%rdi,%rax,4), %edx
	movl	%eax, %esi
	cmpl	%edx, %ecx
	jge	.L13
	addl	$1, %r9d
	cmpl	%r9d, %ebx
	jne	.L10
.L11:
	cmpl	%esi, %r8d
	jle	.L18
	leal	1(%rcx), %r11d
	cmpl	%r11d, %r10d
	jg	.L15
.L22:
	movl	%r10d, %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L18:
	.cfi_restore_state
	movl	%ecx, %r10d
	jmp	.L20
	.cfi_endproc
.LFE52:
	.size	binarySearch, .-binarySearch
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB53:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	k(%rip), %rdx
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC0(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L24
	leaq	w(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %rbp
	cmpl	%ebx, n(%rip)
	jg	.L25
.L24:
	xorl	%eax, %eax
	call	binarySearch
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE53:
	.size	main, .-main
	.globl	w
	.bss
	.align 32
	.type	w, @object
	.size	w, 400000
w:
	.zero	400000
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

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

int n;   // 荷物の数
int k;   // トラックの台数
int w[100000] = {};  // それぞれの荷物の重さ

// 最大積載量Pのk台のトラックで何個の荷物が詰めるか
int check(int P) {
    int j = 0;
    int sum;

    for (int i = 0; i < k; i++) {
        sum = 0;
        while (sum + w[j] <= P) {
            sum += w[j];
            j++;
            if (j == n) return n;
        }
    }
    return j;
}

// 二分探索
int binarySearch() {
    int left = 0;
    int right = 10000 * 100000;  // 1つあたりの荷物の重さ * 荷物の最大量
    int mid;

    while(left < right) {
        mid = (left + right) / 2;
        int checkResult = check(mid);
        if (checkResult >= n) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    return right;
}

int main(void)
{
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &w[i]);
    }

    int P = binarySearch();
    printf("%d\n", P);

    return 0;
}

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

10
 6
 8
 7
 4
 3
 5
 9
 11
 12

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>

int n;   // 荷物の数
int k;   // トラックの台数
int w[100000] = {};  // それぞれの荷物の重さ

// 最大積載量Pのk台のトラックで何個の荷物が詰めるか
int check(int P) {
    int j = 0;
    int sum;

    for (int i = 0; i < k; i++) {
        sum = 0;
        while (sum + w[j] <= P) {
            sum += w[j];
            j++;
            if (j == n) return n;
        }
    }
    return j;
}

// 二分探索
int binarySearch() {
    int left = 0;
    int right = 10000 * 100000;  // 1つあたりの荷物の重さ * 荷物の最大量
    int mid;

    while(left < right) {
        mid = (left + right) / 2;
        int checkResult = check(mid);
        if (checkResult >= n) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    return right;
}

int main(void)
{
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &w[i]);
    }

    int P = binarySearch();
    printf("%d\n", P);

    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	w
	.align 32
	.type	w, @object
	.size	w, 400000
w:
	.zero	400000
	.text
	.globl	check
	.type	check, @function
check:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L6:
	movl	$0, -8(%rbp)
	jmp	.L3
.L5:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -8(%rbp)
	addl	$1, -12(%rbp)
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jne	.L3
	movl	n(%rip), %eax
	jmp	.L4
.L3:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -20(%rbp)
	jge	.L5
	addl	$1, -4(%rbp)
.L2:
	movl	k(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L6
	movl	-12(%rbp), %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	check, .-check
	.globl	binarySearch
	.type	binarySearch, @function
binarySearch:
.LFB7:
	.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	$0, -16(%rbp)
	movl	$1000000000, -12(%rbp)
	jmp	.L8
.L10:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	check
	movl	%eax, -4(%rbp)
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L9
	movl	-8(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L8
.L9:
	movl	-8(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -16(%rbp)
.L8:
	movl	-16(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L10
	movl	-12(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	binarySearch, .-binarySearch
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	k(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -8(%rbp)
	jmp	.L13
.L14:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L14
	movl	$0, %eax
	call	binarySearch
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	w
	.align 32
	.type	w, @object
	.size	w, 400000
w:
	.zero	400000
	.text
	.globl	check
	.type	check, @function
check:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L6:
	movl	$0, -8(%rbp)
	jmp	.L3
.L5:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -8(%rbp)
	addl	$1, -12(%rbp)
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jne	.L3
	movl	n(%rip), %eax
	jmp	.L4
.L3:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	cmpl	%eax, -20(%rbp)
	jge	.L5
	addl	$1, -4(%rbp)
.L2:
	movl	k(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L6
	movl	-12(%rbp), %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	check, .-check
	.globl	binarySearch
	.type	binarySearch, @function
binarySearch:
.LFB7:
	.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	$0, -16(%rbp)
	movl	$1000000000, -12(%rbp)
	jmp	.L8
.L10:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	check
	movl	%eax, -4(%rbp)
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L9
	movl	-8(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L8
.L9:
	movl	-8(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -16(%rbp)
.L8:
	movl	-16(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L10
	movl	-12(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	binarySearch, .-binarySearch
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	k(%rip), %rax
	movq	%rax, %rdx
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -8(%rbp)
	jmp	.L13
.L14:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L14
	movl	$0, %eax
	call	binarySearch
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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:
