Given the following C code and 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;
}
```

Assembly Code:

```assembly
	.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:
```

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.
Optimized Assembly Code:

user
```assembly
	.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
```assembly
	.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:
```
```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;
}
```
Given the following C 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;
}
```

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.
Optimized Assembly Code:

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 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;
}
```

Assembly Code:

```assembly
	.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:
```

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.
Optimized Assembly Code:

train
```assembly
	.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:
```