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

```c
/* 
   AOJ 2019
   Princess's Marriage
   2015/6/10
*/

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



struct node
{
  int distance, probably;
  struct node *next;
};

struct node *head = NULL;


void trav(void)
{
  struct node *next;
  for(next = head; next != NULL; next = next->next)
    {
      printf("%d->", next->probably);
    }
  printf("\n");
}


void create_list(int distance, int probably)
{
  struct node *new = malloc(sizeof(*new)), *prev, *next;


  new->distance = distance;
  new->probably = probably;

  if(head == NULL)
    {
      head = new;
      new->next = NULL;
    }
  else
    {
      next = head;
      prev = head;
      while(next != NULL && probably < next->probably)
      	{
	  /* printf("next->pro = %d", next->probably); */
	  /* fflush(stdout); */
	  prev = next;
	  next = next->next;
	  /* printf("hoge"); */
	  /* fflush(stdout); */
	}
      if(next == head)
	{
	  head = new;
	  new->next = next;
	  return;
	}
      prev->next = new;
      new->next = next;
    }
  /* trav(); */
}

int calc_prob(int estimate, int sum_prob)
{
  struct node *next;
  int i;
  for(next = head; next != NULL; next = next->next)
    {
      
      for(i = 0; estimate > 0 && i < next->distance; i++)
	{
	  //	  printf("%d->", next->probably);
	  sum_prob -= next->probably;
	  estimate--;
	  //	  printf("sum_prob %d estimate %d\n", sum_prob, estimate);
	}
    }
  //  printf("\n");
  return sum_prob;

}

/* void free(void) */
/* { */
/*   struct node *point = head, *prev; */
/*   while(1) */
/*     { */
/*       prev = point; */
/*       point = point->next; */
      
/*     } */
/* } */

int main(void)
{
  int section_num, estimate, distance, probably, i, j, sum = 0;
  while(1)
    {
      scanf("%d %d", &section_num, &estimate);
      if(section_num == 0 && estimate == 0)
	{
	  break;
	}
      for(i = 0; i < section_num; i++)
	{
	  scanf("%d %d", &distance, &probably);
	  sum += probably * distance;
	  /* printf("-----%d\n", sum); */
	  create_list(distance, probably);
	}

      printf("%d\n" ,calc_prob(estimate, sum));
      sum = 0;
      head = NULL;
      /* trav(); */
    }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	head
	.bss
	.align 8
	.type	head, @object
	.size	head, 8
head:
	.zero	8
	.section	.rodata
.LC0:
	.string	"%d->"
	.text
	.globl	trav
	.type	trav, @function
trav:
.LFB6:
	.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
	movq	head(%rip), %rax
	movq	%rax, -8(%rbp)
	jmp	.L2
.L3:
	movq	-8(%rbp), %rax
	movl	4(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
.L2:
	cmpq	$0, -8(%rbp)
	jne	.L3
	movl	$10, %edi
	call	putchar@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	trav, .-trav
	.globl	create_list
	.type	create_list, @function
create_list:
.LFB7:
	.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
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	-36(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	-40(%rbp), %edx
	movl	%edx, 4(%rax)
	movq	head(%rip), %rax
	testq	%rax, %rax
	jne	.L5
	movq	-8(%rbp), %rax
	movq	%rax, head(%rip)
	movq	-8(%rbp), %rax
	movq	$0, 8(%rax)
	jmp	.L4
.L5:
	movq	head(%rip), %rax
	movq	%rax, -16(%rbp)
	movq	head(%rip), %rax
	movq	%rax, -24(%rbp)
	jmp	.L7
.L9:
	movq	-16(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -16(%rbp)
.L7:
	cmpq	$0, -16(%rbp)
	je	.L8
	movq	-16(%rbp), %rax
	movl	4(%rax), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L9
.L8:
	movq	head(%rip), %rax
	cmpq	%rax, -16(%rbp)
	jne	.L10
	movq	-8(%rbp), %rax
	movq	%rax, head(%rip)
	movq	-8(%rbp), %rax
	movq	-16(%rbp), %rdx
	movq	%rdx, 8(%rax)
	jmp	.L4
.L10:
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, 8(%rax)
	movq	-8(%rbp), %rax
	movq	-16(%rbp), %rdx
	movq	%rdx, 8(%rax)
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	create_list, .-create_list
	.globl	calc_prob
	.type	calc_prob, @function
calc_prob:
.LFB8:
	.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	%esi, -24(%rbp)
	movq	head(%rip), %rax
	movq	%rax, -8(%rbp)
	jmp	.L12
.L16:
	movl	$0, -12(%rbp)
	jmp	.L13
.L15:
	movq	-8(%rbp), %rax
	movl	4(%rax), %eax
	subl	%eax, -24(%rbp)
	subl	$1, -20(%rbp)
	addl	$1, -12(%rbp)
.L13:
	cmpl	$0, -20(%rbp)
	jle	.L14
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L15
.L14:
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
.L12:
	cmpq	$0, -8(%rbp)
	jne	.L16
	movl	-24(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	calc_prob, .-calc_prob
	.section	.rodata
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -12(%rbp)
.L23:
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32(%rbp), %eax
	testl	%eax, %eax
	jne	.L19
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	je	.L27
.L19:
	movl	$0, -16(%rbp)
	jmp	.L21
.L22:
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	imull	%edx, %eax
	addl	%eax, -12(%rbp)
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	create_list
	addl	$1, -16(%rbp)
.L21:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L22
	movl	-28(%rbp), %eax
	movl	-12(%rbp), %edx
	movl	%edx, %esi
	movl	%eax, %edi
	call	calc_prob
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -12(%rbp)
	movq	$0, head(%rip)
	jmp	.L23
.L27:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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->"
	.text
	.p2align 4
	.globl	trav
	.type	trav, @function
trav:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movq	head(%rip), %rbx
	testq	%rbx, %rbx
	je	.L2
	leaq	.LC0(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L3:
	movl	4(%rbx), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.L3
.L2:
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	movl	$10, %edi
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	putchar@PLT
	.cfi_endproc
.LFE39:
	.size	trav, .-trav
	.p2align 4
	.globl	create_list
	.type	create_list, @function
create_list:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%edi, %ebp
	movl	$16, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%esi, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	call	malloc@PLT
	movq	head(%rip), %rdi
	movd	%ebp, %xmm0
	movd	%ebx, %xmm1
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, (%rax)
	movq	%rdi, %rdx
	movq	%rdi, %rsi
	testq	%rdi, %rdi
	jne	.L11
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%rcx, %rdx
.L11:
	cmpl	%ebx, 4(%rdx)
	jle	.L24
	movq	8(%rdx), %rcx
	movq	%rdx, %rsi
	testq	%rcx, %rcx
	jne	.L25
.L13:
	movq	%rax, 8(%rdx)
	movq	%rcx, 8(%rax)
	addq	$8, %rsp
	.cfi_remember_state
	.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
.L24:
	.cfi_restore_state
	cmpq	%rdx, %rdi
	je	.L26
	movq	%rdx, %rcx
	movq	%rsi, %rdx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L23:
	xorl	%ecx, %ecx
	movq	%rax, head(%rip)
	movq	%rcx, 8(%rax)
	addq	$8, %rsp
	.cfi_remember_state
	.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
.L26:
	.cfi_restore_state
	movq	%rdi, %rcx
	movq	%rax, head(%rip)
	movq	%rcx, 8(%rax)
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	create_list, .-create_list
	.p2align 4
	.globl	calc_prob
	.type	calc_prob, @function
calc_prob:
.LFB41:
	.cfi_startproc
	endbr64
	movq	head(%rip), %rcx
	movl	%esi, %r8d
	testq	%rcx, %rcx
	je	.L37
	.p2align 4,,10
	.p2align 3
.L28:
	testl	%edi, %edi
	jle	.L33
	movl	(%rcx), %esi
	movl	%edi, %eax
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L31:
	subl	4(%rcx), %r8d
	subl	$1, %eax
	je	.L35
.L34:
	movl	%edi, %edx
	subl	%eax, %edx
	cmpl	%edx, %esi
	jg	.L31
	movl	%eax, %edi
.L30:
	movq	8(%rcx), %rcx
	testq	%rcx, %rcx
	jne	.L28
.L37:
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L35:
	xorl	%edi, %edi
	jmp	.L30
.L33:
	movq	8(%rcx), %rax
	testq	%rax, %rax
	je	.L37
	.p2align 4,,10
	.p2align 3
.L32:
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L32
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE41:
	.size	calc_prob, .-calc_prob
	.section	.rodata.str1.1
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	44(%rsp), %rax
	movq	%rax, 24(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 16(%rsp)
	leaq	52(%rsp), %rax
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L61:
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %r14d
	testl	%r14d, %r14d
	jne	.L83
	movl	44(%rsp), %ecx
	testl	%ecx, %ecx
	je	.L84
	movq	head(%rip), %rsi
	.p2align 4,,10
	.p2align 3
.L82:
	testq	%rsi, %rsi
	je	.L55
	.p2align 4,,10
	.p2align 3
.L54:
	testl	%ecx, %ecx
	jle	.L59
	movl	(%rsi), %edi
	movl	%ecx, %eax
	jmp	.L60
	.p2align 4,,10
	.p2align 3
.L57:
	subl	4(%rsi), %r14d
	subl	$1, %eax
	je	.L66
.L60:
	movl	%ecx, %edx
	subl	%eax, %edx
	cmpl	%edx, %edi
	jg	.L57
	movl	%eax, %ecx
.L56:
	movq	8(%rsi), %rsi
	testq	%rsi, %rsi
	jne	.L54
.L55:
	movl	%r14d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	$0, head(%rip)
	jmp	.L61
	.p2align 4,,10
	.p2align 3
.L66:
	xorl	%ecx, %ecx
	jmp	.L56
.L83:
	jle	.L85
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
	leaq	48(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L45:
	movq	8(%rsp), %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	52(%rsp), %r13d
	movl	48(%rsp), %ebx
	movl	$16, %edi
	movl	%r13d, %eax
	imull	%ebx, %eax
	addl	%eax, %r14d
	call	malloc@PLT
	movq	head(%rip), %rsi
	movd	%ebx, %xmm0
	movd	%r13d, %xmm1
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, (%rax)
	movq	%rsi, %rdi
	movq	%rsi, %rdx
	testq	%rsi, %rsi
	jne	.L49
	jmp	.L86
	.p2align 4,,10
	.p2align 3
.L88:
	movq	%rcx, %rdx
.L49:
	cmpl	4(%rdx), %r13d
	jge	.L87
	movq	8(%rdx), %rcx
	movq	%rdx, %rdi
	testq	%rcx, %rcx
	jne	.L88
.L51:
	movq	%rax, 8(%rdx)
.L50:
	movq	%rcx, 8(%rax)
	addl	$1, %r15d
	cmpl	%r15d, 40(%rsp)
	jg	.L45
	movl	44(%rsp), %ecx
	jmp	.L82
	.p2align 4,,10
	.p2align 3
.L87:
	cmpq	%rdx, %rsi
	je	.L89
	movq	%rdx, %rcx
	movq	%rdi, %rdx
	jmp	.L51
	.p2align 4,,10
	.p2align 3
.L86:
	movq	%rax, head(%rip)
	xorl	%ecx, %ecx
	movq	%rax, %rsi
	jmp	.L50
	.p2align 4,,10
	.p2align 3
.L89:
	movq	%rsi, %rcx
	movq	%rax, head(%rip)
	movq	%rax, %rsi
	jmp	.L50
.L59:
	movq	8(%rsi), %rax
	testq	%rax, %rax
	je	.L55
	.p2align 4,,10
	.p2align 3
.L58:
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L58
	jmp	.L55
.L84:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L90
	addq	$72, %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
.L85:
	.cfi_restore_state
	movl	44(%rsp), %ecx
	movq	head(%rip), %rsi
	xorl	%r14d, %r14d
	jmp	.L82
.L90:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	head
	.bss
	.align 8
	.type	head, @object
	.size	head, 8
head:
	.zero	8
	.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->"
	.text
	.p2align 4
	.globl	trav
	.type	trav, @function
trav:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movq	head(%rip), %rbx
	testq	%rbx, %rbx
	je	.L2
	leaq	.LC0(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L3:
	movl	4(%rbx), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.L3
.L2:
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	movl	$10, %edi
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	putchar@PLT
	.cfi_endproc
.LFE39:
	.size	trav, .-trav
	.p2align 4
	.globl	create_list
	.type	create_list, @function
create_list:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%edi, %ebp
	movl	$16, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%esi, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	call	malloc@PLT
	movq	head(%rip), %rdi
	movd	%ebp, %xmm0
	movd	%ebx, %xmm1
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, (%rax)
	movq	%rdi, %rdx
	movq	%rdi, %rsi
	testq	%rdi, %rdi
	jne	.L11
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%rcx, %rdx
.L11:
	cmpl	%ebx, 4(%rdx)
	jle	.L24
	movq	8(%rdx), %rcx
	movq	%rdx, %rsi
	testq	%rcx, %rcx
	jne	.L25
.L13:
	movq	%rax, 8(%rdx)
	movq	%rcx, 8(%rax)
	addq	$8, %rsp
	.cfi_remember_state
	.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
.L24:
	.cfi_restore_state
	cmpq	%rdx, %rdi
	je	.L26
	movq	%rdx, %rcx
	movq	%rsi, %rdx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L23:
	xorl	%ecx, %ecx
	movq	%rax, head(%rip)
	movq	%rcx, 8(%rax)
	addq	$8, %rsp
	.cfi_remember_state
	.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
.L26:
	.cfi_restore_state
	movq	%rdi, %rcx
	movq	%rax, head(%rip)
	movq	%rcx, 8(%rax)
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	create_list, .-create_list
	.p2align 4
	.globl	calc_prob
	.type	calc_prob, @function
calc_prob:
.LFB41:
	.cfi_startproc
	endbr64
	movq	head(%rip), %rcx
	movl	%esi, %r8d
	testq	%rcx, %rcx
	je	.L37
	.p2align 4,,10
	.p2align 3
.L28:
	testl	%edi, %edi
	jle	.L33
	movl	(%rcx), %esi
	movl	%edi, %eax
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L31:
	subl	4(%rcx), %r8d
	subl	$1, %eax
	je	.L35
.L34:
	movl	%edi, %edx
	subl	%eax, %edx
	cmpl	%edx, %esi
	jg	.L31
	movl	%eax, %edi
.L30:
	movq	8(%rcx), %rcx
	testq	%rcx, %rcx
	jne	.L28
.L37:
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L35:
	xorl	%edi, %edi
	jmp	.L30
.L33:
	movq	8(%rcx), %rax
	testq	%rax, %rax
	je	.L37
	.p2align 4,,10
	.p2align 3
.L32:
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L32
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE41:
	.size	calc_prob, .-calc_prob
	.section	.rodata.str1.1
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	44(%rsp), %rax
	movq	%rax, 24(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 16(%rsp)
	leaq	52(%rsp), %rax
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L61:
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %r14d
	testl	%r14d, %r14d
	jne	.L83
	movl	44(%rsp), %ecx
	testl	%ecx, %ecx
	je	.L84
	movq	head(%rip), %rsi
	.p2align 4,,10
	.p2align 3
.L82:
	testq	%rsi, %rsi
	je	.L55
	.p2align 4,,10
	.p2align 3
.L54:
	testl	%ecx, %ecx
	jle	.L59
	movl	(%rsi), %edi
	movl	%ecx, %eax
	jmp	.L60
	.p2align 4,,10
	.p2align 3
.L57:
	subl	4(%rsi), %r14d
	subl	$1, %eax
	je	.L66
.L60:
	movl	%ecx, %edx
	subl	%eax, %edx
	cmpl	%edx, %edi
	jg	.L57
	movl	%eax, %ecx
.L56:
	movq	8(%rsi), %rsi
	testq	%rsi, %rsi
	jne	.L54
.L55:
	movl	%r14d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	$0, head(%rip)
	jmp	.L61
	.p2align 4,,10
	.p2align 3
.L66:
	xorl	%ecx, %ecx
	jmp	.L56
.L83:
	jle	.L85
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
	leaq	48(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L45:
	movq	8(%rsp), %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	52(%rsp), %r13d
	movl	48(%rsp), %ebx
	movl	$16, %edi
	movl	%r13d, %eax
	imull	%ebx, %eax
	addl	%eax, %r14d
	call	malloc@PLT
	movq	head(%rip), %rsi
	movd	%ebx, %xmm0
	movd	%r13d, %xmm1
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, (%rax)
	movq	%rsi, %rdi
	movq	%rsi, %rdx
	testq	%rsi, %rsi
	jne	.L49
	jmp	.L86
	.p2align 4,,10
	.p2align 3
.L88:
	movq	%rcx, %rdx
.L49:
	cmpl	4(%rdx), %r13d
	jge	.L87
	movq	8(%rdx), %rcx
	movq	%rdx, %rdi
	testq	%rcx, %rcx
	jne	.L88
.L51:
	movq	%rax, 8(%rdx)
.L50:
	movq	%rcx, 8(%rax)
	addl	$1, %r15d
	cmpl	%r15d, 40(%rsp)
	jg	.L45
	movl	44(%rsp), %ecx
	jmp	.L82
	.p2align 4,,10
	.p2align 3
.L87:
	cmpq	%rdx, %rsi
	je	.L89
	movq	%rdx, %rcx
	movq	%rdi, %rdx
	jmp	.L51
	.p2align 4,,10
	.p2align 3
.L86:
	movq	%rax, head(%rip)
	xorl	%ecx, %ecx
	movq	%rax, %rsi
	jmp	.L50
	.p2align 4,,10
	.p2align 3
.L89:
	movq	%rsi, %rcx
	movq	%rax, head(%rip)
	movq	%rax, %rsi
	jmp	.L50
.L59:
	movq	8(%rsi), %rax
	testq	%rax, %rax
	je	.L55
	.p2align 4,,10
	.p2align 3
.L58:
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L58
	jmp	.L55
.L84:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L90
	addq	$72, %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
.L85:
	.cfi_restore_state
	movl	44(%rsp), %ecx
	movq	head(%rip), %rsi
	xorl	%r14d, %r14d
	jmp	.L82
.L90:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	head
	.bss
	.align 8
	.type	head, @object
	.size	head, 8
head:
	.zero	8
	.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:

/* 
   AOJ 2019
   Princess's Marriage
   2015/6/10
*/

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



struct node
{
  int distance, probably;
  struct node *next;
};

struct node *head = NULL;


void trav(void)
{
  struct node *next;
  for(next = head; next != NULL; next = next->next)
    {
      printf("%d->", next->probably);
    }
  printf("\n");
}


void create_list(int distance, int probably)
{
  struct node *new = malloc(sizeof(*new)), *prev, *next;


  new->distance = distance;
  new->probably = probably;

  if(head == NULL)
    {
      head = new;
      new->next = NULL;
    }
  else
    {
      next = head;
      prev = head;
      while(next != NULL && probably < next->probably)
      	{
	  /* printf("next->pro = %d", next->probably); */
	  /* fflush(stdout); */
	  prev = next;
	  next = next->next;
	  /* printf("hoge"); */
	  /* fflush(stdout); */
	}
      if(next == head)
	{
	  head = new;
	  new->next = next;
	  return;
	}
      prev->next = new;
      new->next = next;
    }
  /* trav(); */
}

int calc_prob(int estimate, int sum_prob)
{
  struct node *next;
  int i;
  for(next = head; next != NULL; next = next->next)
    {
      
      for(i = 0; estimate > 0 && i < next->distance; i++)
	{
	  //	  printf("%d->", next->probably);
	  sum_prob -= next->probably;
	  estimate--;
	  //	  printf("sum_prob %d estimate %d\n", sum_prob, estimate);
	}
    }
  //  printf("\n");
  return sum_prob;

}

/* void free(void) */
/* { */
/*   struct node *point = head, *prev; */
/*   while(1) */
/*     { */
/*       prev = point; */
/*       point = point->next; */
      
/*     } */
/* } */

int main(void)
{
  int section_num, estimate, distance, probably, i, j, sum = 0;
  while(1)
    {
      scanf("%d %d", &section_num, &estimate);
      if(section_num == 0 && estimate == 0)
	{
	  break;
	}
      for(i = 0; i < section_num; i++)
	{
	  scanf("%d %d", &distance, &probably);
	  sum += probably * distance;
	  /* printf("-----%d\n", sum); */
	  create_list(distance, probably);
	}

      printf("%d\n" ,calc_prob(estimate, sum));
      sum = 0;
      head = NULL;
      /* trav(); */
    }
  return 0;
}
2 8
5 6
4 5
3 2
5 10
5 10
5 10
0 0
 2 8
5 6
4 5
3 2
5 10
3 10
5 10
0 0
 2 8
5 6
4 5
3 2
1 10
5 10
5 10
0 0
 2 8
5 6
4 5
3 1
3 10
5 10
5 10
0 0
 2 8
5 6
4 5
3 2
5 10
7 10
5 10
0 0
 2 8
5 6
4 5
3 2
0 10
5 10
5 10
0 0
 2 8
5 6
4 5
3 2
0 10
7 10
5 10
0 0
 2 8
5 6
4 5
3 4
0 5
5 10
5 10
0 0
 2 8
5 6
4 5
3 2
0 6
7 10
4 7
0 0
 2 8
7 6
4 5
3 2
5 10
3 10
5 10
0 0

5
130
 5
110
 5
90
 5
120
 5
150
 5
80
 5
100
 5
60
 5
78
 15
110

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

```c
/* 
   AOJ 2019
   Princess's Marriage
   2015/6/10
*/

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



struct node
{
  int distance, probably;
  struct node *next;
};

struct node *head = NULL;


void trav(void)
{
  struct node *next;
  for(next = head; next != NULL; next = next->next)
    {
      printf("%d->", next->probably);
    }
  printf("\n");
}


void create_list(int distance, int probably)
{
  struct node *new = malloc(sizeof(*new)), *prev, *next;


  new->distance = distance;
  new->probably = probably;

  if(head == NULL)
    {
      head = new;
      new->next = NULL;
    }
  else
    {
      next = head;
      prev = head;
      while(next != NULL && probably < next->probably)
      	{
	  /* printf("next->pro = %d", next->probably); */
	  /* fflush(stdout); */
	  prev = next;
	  next = next->next;
	  /* printf("hoge"); */
	  /* fflush(stdout); */
	}
      if(next == head)
	{
	  head = new;
	  new->next = next;
	  return;
	}
      prev->next = new;
      new->next = next;
    }
  /* trav(); */
}

int calc_prob(int estimate, int sum_prob)
{
  struct node *next;
  int i;
  for(next = head; next != NULL; next = next->next)
    {
      
      for(i = 0; estimate > 0 && i < next->distance; i++)
	{
	  //	  printf("%d->", next->probably);
	  sum_prob -= next->probably;
	  estimate--;
	  //	  printf("sum_prob %d estimate %d\n", sum_prob, estimate);
	}
    }
  //  printf("\n");
  return sum_prob;

}

/* void free(void) */
/* { */
/*   struct node *point = head, *prev; */
/*   while(1) */
/*     { */
/*       prev = point; */
/*       point = point->next; */
      
/*     } */
/* } */

int main(void)
{
  int section_num, estimate, distance, probably, i, j, sum = 0;
  while(1)
    {
      scanf("%d %d", &section_num, &estimate);
      if(section_num == 0 && estimate == 0)
	{
	  break;
	}
      for(i = 0; i < section_num; i++)
	{
	  scanf("%d %d", &distance, &probably);
	  sum += probably * distance;
	  /* printf("-----%d\n", sum); */
	  create_list(distance, probably);
	}

      printf("%d\n" ,calc_prob(estimate, sum));
      sum = 0;
      head = NULL;
      /* trav(); */
    }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	head
	.bss
	.align 8
	.type	head, @object
	.size	head, 8
head:
	.zero	8
	.section	.rodata
.LC0:
	.string	"%d->"
	.text
	.globl	trav
	.type	trav, @function
trav:
.LFB6:
	.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
	movq	head(%rip), %rax
	movq	%rax, -8(%rbp)
	jmp	.L2
.L3:
	movq	-8(%rbp), %rax
	movl	4(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
.L2:
	cmpq	$0, -8(%rbp)
	jne	.L3
	movl	$10, %edi
	call	putchar@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	trav, .-trav
	.globl	create_list
	.type	create_list, @function
create_list:
.LFB7:
	.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
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	-36(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	-40(%rbp), %edx
	movl	%edx, 4(%rax)
	movq	head(%rip), %rax
	testq	%rax, %rax
	jne	.L5
	movq	-8(%rbp), %rax
	movq	%rax, head(%rip)
	movq	-8(%rbp), %rax
	movq	$0, 8(%rax)
	jmp	.L4
.L5:
	movq	head(%rip), %rax
	movq	%rax, -16(%rbp)
	movq	head(%rip), %rax
	movq	%rax, -24(%rbp)
	jmp	.L7
.L9:
	movq	-16(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -16(%rbp)
.L7:
	cmpq	$0, -16(%rbp)
	je	.L8
	movq	-16(%rbp), %rax
	movl	4(%rax), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L9
.L8:
	movq	head(%rip), %rax
	cmpq	%rax, -16(%rbp)
	jne	.L10
	movq	-8(%rbp), %rax
	movq	%rax, head(%rip)
	movq	-8(%rbp), %rax
	movq	-16(%rbp), %rdx
	movq	%rdx, 8(%rax)
	jmp	.L4
.L10:
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, 8(%rax)
	movq	-8(%rbp), %rax
	movq	-16(%rbp), %rdx
	movq	%rdx, 8(%rax)
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	create_list, .-create_list
	.globl	calc_prob
	.type	calc_prob, @function
calc_prob:
.LFB8:
	.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	%esi, -24(%rbp)
	movq	head(%rip), %rax
	movq	%rax, -8(%rbp)
	jmp	.L12
.L16:
	movl	$0, -12(%rbp)
	jmp	.L13
.L15:
	movq	-8(%rbp), %rax
	movl	4(%rax), %eax
	subl	%eax, -24(%rbp)
	subl	$1, -20(%rbp)
	addl	$1, -12(%rbp)
.L13:
	cmpl	$0, -20(%rbp)
	jle	.L14
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L15
.L14:
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
.L12:
	cmpq	$0, -8(%rbp)
	jne	.L16
	movl	-24(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	calc_prob, .-calc_prob
	.section	.rodata
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -12(%rbp)
.L23:
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32(%rbp), %eax
	testl	%eax, %eax
	jne	.L19
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	je	.L27
.L19:
	movl	$0, -16(%rbp)
	jmp	.L21
.L22:
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	imull	%edx, %eax
	addl	%eax, -12(%rbp)
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	create_list
	addl	$1, -16(%rbp)
.L21:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L22
	movl	-28(%rbp), %eax
	movl	-12(%rbp), %edx
	movl	%edx, %esi
	movl	%eax, %edi
	call	calc_prob
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -12(%rbp)
	movq	$0, head(%rip)
	jmp	.L23
.L27:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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	head
	.bss
	.align 8
	.type	head, @object
	.size	head, 8
head:
	.zero	8
	.section	.rodata
.LC0:
	.string	"%d->"
	.text
	.globl	trav
	.type	trav, @function
trav:
.LFB6:
	.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
	movq	head(%rip), %rax
	movq	%rax, -8(%rbp)
	jmp	.L2
.L3:
	movq	-8(%rbp), %rax
	movl	4(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
.L2:
	cmpq	$0, -8(%rbp)
	jne	.L3
	movl	$10, %edi
	call	putchar@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	trav, .-trav
	.globl	create_list
	.type	create_list, @function
create_list:
.LFB7:
	.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
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	-36(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	-40(%rbp), %edx
	movl	%edx, 4(%rax)
	movq	head(%rip), %rax
	testq	%rax, %rax
	jne	.L5
	movq	-8(%rbp), %rax
	movq	%rax, head(%rip)
	movq	-8(%rbp), %rax
	movq	$0, 8(%rax)
	jmp	.L4
.L5:
	movq	head(%rip), %rax
	movq	%rax, -16(%rbp)
	movq	head(%rip), %rax
	movq	%rax, -24(%rbp)
	jmp	.L7
.L9:
	movq	-16(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -16(%rbp)
.L7:
	cmpq	$0, -16(%rbp)
	je	.L8
	movq	-16(%rbp), %rax
	movl	4(%rax), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L9
.L8:
	movq	head(%rip), %rax
	cmpq	%rax, -16(%rbp)
	jne	.L10
	movq	-8(%rbp), %rax
	movq	%rax, head(%rip)
	movq	-8(%rbp), %rax
	movq	-16(%rbp), %rdx
	movq	%rdx, 8(%rax)
	jmp	.L4
.L10:
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, 8(%rax)
	movq	-8(%rbp), %rax
	movq	-16(%rbp), %rdx
	movq	%rdx, 8(%rax)
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	create_list, .-create_list
	.globl	calc_prob
	.type	calc_prob, @function
calc_prob:
.LFB8:
	.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	%esi, -24(%rbp)
	movq	head(%rip), %rax
	movq	%rax, -8(%rbp)
	jmp	.L12
.L16:
	movl	$0, -12(%rbp)
	jmp	.L13
.L15:
	movq	-8(%rbp), %rax
	movl	4(%rax), %eax
	subl	%eax, -24(%rbp)
	subl	$1, -20(%rbp)
	addl	$1, -12(%rbp)
.L13:
	cmpl	$0, -20(%rbp)
	jle	.L14
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L15
.L14:
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
.L12:
	cmpq	$0, -8(%rbp)
	jne	.L16
	movl	-24(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	calc_prob, .-calc_prob
	.section	.rodata
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -12(%rbp)
.L23:
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32(%rbp), %eax
	testl	%eax, %eax
	jne	.L19
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	je	.L27
.L19:
	movl	$0, -16(%rbp)
	jmp	.L21
.L22:
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	imull	%edx, %eax
	addl	%eax, -12(%rbp)
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	create_list
	addl	$1, -16(%rbp)
.L21:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L22
	movl	-28(%rbp), %eax
	movl	-12(%rbp), %edx
	movl	%edx, %esi
	movl	%eax, %edi
	call	calc_prob
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, -12(%rbp)
	movq	$0, head(%rip)
	jmp	.L23
.L27:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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:
