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 BUF_SIZE 1500000
#define min(a, b) ((a) < (b) ? (a) : (b))

int main(void) {
  char buf[BUF_SIZE];
  FILE *fp = stdin;

  if(!fgets(buf, BUF_SIZE, fp)) return 0;

  int num;
  sscanf(buf, "%d", &num);

  if(!fgets(buf, BUF_SIZE, fp)) return 0;

  char *tmpbuf = buf;
  int i;
  long sum_plus = 0;
  long sum_minus = 0;

  long res_plus = 0;
  long res_minus = 0;
  for(i = 0; i < num; i++) {
    char *tmp = strtok(tmpbuf, " ");
    long n = strtol(tmp, NULL, 10);
    sum_plus += n;
    sum_minus += n;
    if (i%2) { // odd
      // start_plus requires sum of minus
      if(sum_plus >= 0) {
        res_plus += sum_plus + 1;
        sum_plus = -1;
      }
      if(sum_minus <= 0) {
        res_minus += 1 - sum_minus; // -1 - n
        sum_minus = 1;
      }
    } else { // even
      if(sum_plus <= 0) {
        res_plus += 1 - sum_plus; // -1 - n
        sum_plus = 1;
      }
      if(sum_minus >= 0) {
        res_minus += sum_minus + 1;
        sum_minus = -1;
      }
    }
    tmpbuf = NULL;
  }

  long res = min(res_plus, res_minus);
  printf("%ld\n", res);

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	" "
.LC2:
	.string	"%ld\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
	leaq	-1499136(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$960, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rax
	movq	%rax, -1500048(%rbp)
	movq	-1500048(%rbp), %rdx
	leaq	-1500016(%rbp), %rax
	movl	$1500000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$0, %eax
	jmp	.L11
.L2:
	leaq	-1500096(%rbp), %rdx
	leaq	-1500016(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movq	-1500048(%rbp), %rdx
	leaq	-1500016(%rbp), %rax
	movl	$1500000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L4
	movl	$0, %eax
	jmp	.L11
.L4:
	leaq	-1500016(%rbp), %rax
	movq	%rax, -1500088(%rbp)
	movq	$0, -1500080(%rbp)
	movq	$0, -1500072(%rbp)
	movq	$0, -1500064(%rbp)
	movq	$0, -1500056(%rbp)
	movl	$0, -1500092(%rbp)
	jmp	.L5
.L10:
	movq	-1500088(%rbp), %rax
	leaq	.LC1(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1500032(%rbp)
	movq	-1500032(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movq	%rax, -1500024(%rbp)
	movq	-1500024(%rbp), %rax
	addq	%rax, -1500080(%rbp)
	movq	-1500024(%rbp), %rax
	addq	%rax, -1500072(%rbp)
	movl	-1500092(%rbp), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L6
	cmpq	$0, -1500080(%rbp)
	js	.L7
	movq	-1500080(%rbp), %rax
	addq	$1, %rax
	addq	%rax, -1500064(%rbp)
	movq	$-1, -1500080(%rbp)
.L7:
	cmpq	$0, -1500072(%rbp)
	jg	.L8
	movl	$1, %eax
	subq	-1500072(%rbp), %rax
	addq	%rax, -1500056(%rbp)
	movq	$1, -1500072(%rbp)
	jmp	.L8
.L6:
	cmpq	$0, -1500080(%rbp)
	jg	.L9
	movl	$1, %eax
	subq	-1500080(%rbp), %rax
	addq	%rax, -1500064(%rbp)
	movq	$1, -1500080(%rbp)
.L9:
	cmpq	$0, -1500072(%rbp)
	js	.L8
	movq	-1500072(%rbp), %rax
	addq	$1, %rax
	addq	%rax, -1500056(%rbp)
	movq	$-1, -1500072(%rbp)
.L8:
	movq	$0, -1500088(%rbp)
	addl	$1, -1500092(%rbp)
.L5:
	movl	-1500096(%rbp), %eax
	cmpl	%eax, -1500092(%rbp)
	jl	.L10
	movq	-1500056(%rbp), %rdx
	movq	-1500064(%rbp), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	%rax, -1500040(%rbp)
	movq	-1500040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L11:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	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	" "
.LC2:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-1499136(%rsp), %r11
	.cfi_def_cfa 11, 1499192
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$904, %rsp
	.cfi_def_cfa_offset 1500096
	movq	stdin(%rip), %r13
	movl	$1500000, %esi
	movq	%r13, %rdx
	movq	%fs:40, %rax
	movq	%rax, 1500024(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %r12
	movq	%r12, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L3
	leaq	12(%rsp), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_sscanf@PLT
	movq	%r13, %rdx
	movl	$1500000, %esi
	movq	%r12, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L3
	xorl	%ebp, %ebp
	xorl	%ebx, %ebx
	cmpl	$0, 12(%rsp)
	jle	.L5
	movq	%r12, %rdi
	xorl	%r13d, %r13d
	xorl	%r15d, %r15d
	xorl	%r14d, %r14d
	leaq	.LC1(%rip), %r12
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L19:
	testq	%r15, %r15
	js	.L7
	leaq	1(%r15,%rbx), %rbx
	movq	$-1, %r15
.L7:
	testq	%r13, %r13
	jg	.L8
	movl	$1, %eax
	subq	%r13, %rax
	movl	$1, %r13d
	addq	%rax, %rbp
.L8:
	addl	$1, %r14d
	xorl	%edi, %edi
	cmpl	%r14d, 12(%rsp)
	jle	.L5
.L10:
	movq	%r12, %rsi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	addq	%rax, %r15
	addq	%rax, %r13
	testb	$1, %r14b
	jne	.L19
	testq	%r15, %r15
	jg	.L9
	movl	$1, %eax
	subq	%r15, %rax
	movl	$1, %r15d
	addq	%rax, %rbx
.L9:
	testq	%r13, %r13
	js	.L8
	leaq	1(%r13,%rbp), %rbp
	addl	$1, %r14d
	xorl	%edi, %edi
	movq	$-1, %r13
	cmpl	%r14d, 12(%rsp)
	jg	.L10
.L5:
	cmpq	%rbp, %rbx
	movq	%rbp, %rdx
	movl	$1, %edi
	cmovle	%rbx, %rdx
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L3:
	movq	1500024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$1500040, %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
.L20:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	" "
.LC2:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-1499136(%rsp), %r11
	.cfi_def_cfa 11, 1499192
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$904, %rsp
	.cfi_def_cfa_offset 1500096
	movq	stdin(%rip), %r13
	movl	$1500000, %esi
	movq	%r13, %rdx
	movq	%fs:40, %rax
	movq	%rax, 1500024(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %r12
	movq	%r12, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L3
	leaq	12(%rsp), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_sscanf@PLT
	movq	%r13, %rdx
	movl	$1500000, %esi
	movq	%r12, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L3
	xorl	%ebp, %ebp
	xorl	%ebx, %ebx
	cmpl	$0, 12(%rsp)
	jle	.L5
	movq	%r12, %rdi
	xorl	%r13d, %r13d
	xorl	%r15d, %r15d
	xorl	%r14d, %r14d
	leaq	.LC1(%rip), %r12
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L19:
	testq	%r15, %r15
	js	.L7
	leaq	1(%r15,%rbx), %rbx
	movq	$-1, %r15
.L7:
	testq	%r13, %r13
	jg	.L8
	movl	$1, %eax
	subq	%r13, %rax
	movl	$1, %r13d
	addq	%rax, %rbp
.L8:
	addl	$1, %r14d
	xorl	%edi, %edi
	cmpl	%r14d, 12(%rsp)
	jle	.L5
.L10:
	movq	%r12, %rsi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	addq	%rax, %r15
	addq	%rax, %r13
	testb	$1, %r14b
	jne	.L19
	testq	%r15, %r15
	jg	.L9
	movl	$1, %eax
	subq	%r15, %rax
	movl	$1, %r15d
	addq	%rax, %rbx
.L9:
	testq	%r13, %r13
	js	.L8
	leaq	1(%r13,%rbp), %rbp
	addl	$1, %r14d
	xorl	%edi, %edi
	movq	$-1, %r13
	cmpl	%r14d, 12(%rsp)
	jg	.L10
.L5:
	cmpq	%rbp, %rbx
	movq	%rbp, %rdx
	movl	$1, %edi
	cmovle	%rbx, %rdx
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L3:
	movq	1500024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$1500040, %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
.L20:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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:

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

#define BUF_SIZE 1500000
#define min(a, b) ((a) < (b) ? (a) : (b))

int main(void) {
  char buf[BUF_SIZE];
  FILE *fp = stdin;

  if(!fgets(buf, BUF_SIZE, fp)) return 0;

  int num;
  sscanf(buf, "%d", &num);

  if(!fgets(buf, BUF_SIZE, fp)) return 0;

  char *tmpbuf = buf;
  int i;
  long sum_plus = 0;
  long sum_minus = 0;

  long res_plus = 0;
  long res_minus = 0;
  for(i = 0; i < num; i++) {
    char *tmp = strtok(tmpbuf, " ");
    long n = strtol(tmp, NULL, 10);
    sum_plus += n;
    sum_minus += n;
    if (i%2) { // odd
      // start_plus requires sum of minus
      if(sum_plus >= 0) {
        res_plus += sum_plus + 1;
        sum_plus = -1;
      }
      if(sum_minus <= 0) {
        res_minus += 1 - sum_minus; // -1 - n
        sum_minus = 1;
      }
    } else { // even
      if(sum_plus <= 0) {
        res_plus += 1 - sum_plus; // -1 - n
        sum_plus = 1;
      }
      if(sum_minus >= 0) {
        res_minus += sum_minus + 1;
        sum_minus = -1;
      }
    }
    tmpbuf = NULL;
  }

  long res = min(res_plus, res_minus);
  printf("%ld\n", res);

  return 0;
}
5
3 -6 4 -8 7
 4
1 -3 1 -1
 6
-1 4 3 2 -5 0
 4
1 -5 1 -1
 6
-1 4 2 2 -5 0
 5
3 -8 4 -12 7
 4
1 -5 0 -1
 6
-1 4 1 2 -5 0
 5
3 -5 4 -12 7
 6
-1 8 1 2 -5 0

1
 3
 12
 5
 11
 7
 6
 10
 4
 14

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 BUF_SIZE 1500000
#define min(a, b) ((a) < (b) ? (a) : (b))

int main(void) {
  char buf[BUF_SIZE];
  FILE *fp = stdin;

  if(!fgets(buf, BUF_SIZE, fp)) return 0;

  int num;
  sscanf(buf, "%d", &num);

  if(!fgets(buf, BUF_SIZE, fp)) return 0;

  char *tmpbuf = buf;
  int i;
  long sum_plus = 0;
  long sum_minus = 0;

  long res_plus = 0;
  long res_minus = 0;
  for(i = 0; i < num; i++) {
    char *tmp = strtok(tmpbuf, " ");
    long n = strtol(tmp, NULL, 10);
    sum_plus += n;
    sum_minus += n;
    if (i%2) { // odd
      // start_plus requires sum of minus
      if(sum_plus >= 0) {
        res_plus += sum_plus + 1;
        sum_plus = -1;
      }
      if(sum_minus <= 0) {
        res_minus += 1 - sum_minus; // -1 - n
        sum_minus = 1;
      }
    } else { // even
      if(sum_plus <= 0) {
        res_plus += 1 - sum_plus; // -1 - n
        sum_plus = 1;
      }
      if(sum_minus >= 0) {
        res_minus += sum_minus + 1;
        sum_minus = -1;
      }
    }
    tmpbuf = NULL;
  }

  long res = min(res_plus, res_minus);
  printf("%ld\n", res);

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	" "
.LC2:
	.string	"%ld\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
	leaq	-1499136(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$960, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rax
	movq	%rax, -1500048(%rbp)
	movq	-1500048(%rbp), %rdx
	leaq	-1500016(%rbp), %rax
	movl	$1500000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$0, %eax
	jmp	.L11
.L2:
	leaq	-1500096(%rbp), %rdx
	leaq	-1500016(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movq	-1500048(%rbp), %rdx
	leaq	-1500016(%rbp), %rax
	movl	$1500000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L4
	movl	$0, %eax
	jmp	.L11
.L4:
	leaq	-1500016(%rbp), %rax
	movq	%rax, -1500088(%rbp)
	movq	$0, -1500080(%rbp)
	movq	$0, -1500072(%rbp)
	movq	$0, -1500064(%rbp)
	movq	$0, -1500056(%rbp)
	movl	$0, -1500092(%rbp)
	jmp	.L5
.L10:
	movq	-1500088(%rbp), %rax
	leaq	.LC1(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1500032(%rbp)
	movq	-1500032(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movq	%rax, -1500024(%rbp)
	movq	-1500024(%rbp), %rax
	addq	%rax, -1500080(%rbp)
	movq	-1500024(%rbp), %rax
	addq	%rax, -1500072(%rbp)
	movl	-1500092(%rbp), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L6
	cmpq	$0, -1500080(%rbp)
	js	.L7
	movq	-1500080(%rbp), %rax
	addq	$1, %rax
	addq	%rax, -1500064(%rbp)
	movq	$-1, -1500080(%rbp)
.L7:
	cmpq	$0, -1500072(%rbp)
	jg	.L8
	movl	$1, %eax
	subq	-1500072(%rbp), %rax
	addq	%rax, -1500056(%rbp)
	movq	$1, -1500072(%rbp)
	jmp	.L8
.L6:
	cmpq	$0, -1500080(%rbp)
	jg	.L9
	movl	$1, %eax
	subq	-1500080(%rbp), %rax
	addq	%rax, -1500064(%rbp)
	movq	$1, -1500080(%rbp)
.L9:
	cmpq	$0, -1500072(%rbp)
	js	.L8
	movq	-1500072(%rbp), %rax
	addq	$1, %rax
	addq	%rax, -1500056(%rbp)
	movq	$-1, -1500072(%rbp)
.L8:
	movq	$0, -1500088(%rbp)
	addl	$1, -1500092(%rbp)
.L5:
	movl	-1500096(%rbp), %eax
	cmpl	%eax, -1500092(%rbp)
	jl	.L10
	movq	-1500056(%rbp), %rdx
	movq	-1500064(%rbp), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	%rax, -1500040(%rbp)
	movq	-1500040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L11:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	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	" "
.LC2:
	.string	"%ld\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
	leaq	-1499136(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$960, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rax
	movq	%rax, -1500048(%rbp)
	movq	-1500048(%rbp), %rdx
	leaq	-1500016(%rbp), %rax
	movl	$1500000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$0, %eax
	jmp	.L11
.L2:
	leaq	-1500096(%rbp), %rdx
	leaq	-1500016(%rbp), %rax
	leaq	.LC0(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movq	-1500048(%rbp), %rdx
	leaq	-1500016(%rbp), %rax
	movl	$1500000, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L4
	movl	$0, %eax
	jmp	.L11
.L4:
	leaq	-1500016(%rbp), %rax
	movq	%rax, -1500088(%rbp)
	movq	$0, -1500080(%rbp)
	movq	$0, -1500072(%rbp)
	movq	$0, -1500064(%rbp)
	movq	$0, -1500056(%rbp)
	movl	$0, -1500092(%rbp)
	jmp	.L5
.L10:
	movq	-1500088(%rbp), %rax
	leaq	.LC1(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1500032(%rbp)
	movq	-1500032(%rbp), %rax
	movl	$10, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movq	%rax, -1500024(%rbp)
	movq	-1500024(%rbp), %rax
	addq	%rax, -1500080(%rbp)
	movq	-1500024(%rbp), %rax
	addq	%rax, -1500072(%rbp)
	movl	-1500092(%rbp), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L6
	cmpq	$0, -1500080(%rbp)
	js	.L7
	movq	-1500080(%rbp), %rax
	addq	$1, %rax
	addq	%rax, -1500064(%rbp)
	movq	$-1, -1500080(%rbp)
.L7:
	cmpq	$0, -1500072(%rbp)
	jg	.L8
	movl	$1, %eax
	subq	-1500072(%rbp), %rax
	addq	%rax, -1500056(%rbp)
	movq	$1, -1500072(%rbp)
	jmp	.L8
.L6:
	cmpq	$0, -1500080(%rbp)
	jg	.L9
	movl	$1, %eax
	subq	-1500080(%rbp), %rax
	addq	%rax, -1500064(%rbp)
	movq	$1, -1500080(%rbp)
.L9:
	cmpq	$0, -1500072(%rbp)
	js	.L8
	movq	-1500072(%rbp), %rax
	addq	$1, %rax
	addq	%rax, -1500056(%rbp)
	movq	$-1, -1500072(%rbp)
.L8:
	movq	$0, -1500088(%rbp)
	addl	$1, -1500092(%rbp)
.L5:
	movl	-1500096(%rbp), %eax
	cmpl	%eax, -1500092(%rbp)
	jl	.L10
	movq	-1500056(%rbp), %rdx
	movq	-1500064(%rbp), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	%rax, -1500040(%rbp)
	movq	-1500040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L11:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	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:
