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

```c
/* 
   AOJ 1148
   Analyzing Login/Logout Records
   2015/9/7
*/

#include<stdio.h>
#define REC_MAX 1000

struct record
{
  int time, pc_id, stu_id, log_flg;
};

struct record records[REC_MAX];

int ans_f(int start_t, int end_t, int questioned_stu_id, int records_n)
{
  int i, login_pc_count = 0, start = 0, timer = 0;

  for(i = 0; i < records_n; i++)
    {
      if(records[i].stu_id == questioned_stu_id)
	{
	  if(records[i].log_flg)
	    {
	      /* login */
	      login_pc_count++;
	      if(login_pc_count == 1)
		{
		  /* first login */
		  if(records[i].time < start_t)
		    {
		      /* login before start_t */
		    }
		  else if(records[i].time >= start_t && records[i].time <= end_t)
		    {
		      /* login after start_t && before end_t*/
		      start = records[i].time;
		    }
		  else
		    {
		      /* login after end_t */
		      return timer;
		    }
		}
	    }
	  else
	    {
	      /* logout */
	      login_pc_count--;
	      if(login_pc_count == 0)
		{
		  /* last logout */
		  if(records[i].time < start_t)
		    {
		      /* logout before start_t */
		    }
		  else if(records[i].time >= start_t && records[i].time <= end_t)
		    {
		      /* logout after start_t && before end_t */
		      if(start == 0)
			{
			  /* first login before start_t*/
			  timer += records[i].time - start_t;
			}
		      else
			{
			  /* first login after start_t */
			  timer += records[i].time - start;
			}
		    }
		  else
		    {
		      /* logout after end_t */
		      if(start == 0)
			{
			  /* first login before start_t */
			  timer += end_t - start_t;
			}
		      else
			{
			  /* first login after start_t */
			  timer += end_t - start;
			}
		      return timer;
		    }
		}
	    }
	}
    }
  return timer;
}

int main(void)
{
  int i, pcs_n, stus_n, records_n, questions_n, start_t, end_t, questioned_stu_id, ans = 0;

  while(1)
    {
      scanf("%d %d", &pcs_n, &stus_n);

      if(pcs_n == 0 && stus_n == 0)
	{
	  break;
	}

      scanf("%d", &records_n);
      for(i = 0; i < records_n; i++)
	{
	  scanf("%d %d %d %d", &records[i].time, &records[i].pc_id, &records[i].stu_id, &records[i].log_flg);
	}
      scanf("%d", &questions_n);
      for(i = 0; i < questions_n; i++)
	{
	  scanf("%d %d %d", &start_t, &end_t, &questioned_stu_id);
	  ans = ans_f(start_t, end_t, questioned_stu_id, records_n);
	  printf("%d\n", ans);
	}
    }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	records
	.bss
	.align 32
	.type	records, @object
	.size	records, 16000
records:
	.zero	16000
	.text
	.globl	ans_f
	.type	ans_f, @function
ans_f:
.LFB0:
	.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)
	movl	%edx, -28(%rbp)
	movl	%ecx, -32(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -4(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L2
.L13:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	8+records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -28(%rbp)
	jne	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	12+records(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L4
	addl	$1, -12(%rbp)
	cmpl	$1, -12(%rbp)
	jne	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jg	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jg	.L6
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L6
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	jmp	.L3
.L6:
	movl	-4(%rbp), %eax
	jmp	.L7
.L4:
	subl	$1, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jg	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jg	.L8
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L8
	cmpl	$0, -8(%rbp)
	jne	.L9
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	-20(%rbp), %eax
	addl	%eax, -4(%rbp)
	jmp	.L3
.L9:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	-8(%rbp), %eax
	addl	%eax, -4(%rbp)
	jmp	.L3
.L8:
	cmpl	$0, -8(%rbp)
	jne	.L11
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	addl	%eax, -4(%rbp)
	jmp	.L12
.L11:
	movl	-24(%rbp), %eax
	subl	-8(%rbp), %eax
	addl	%eax, -4(%rbp)
.L12:
	movl	-4(%rbp), %eax
	jmp	.L7
.L3:
	addl	$1, -16(%rbp)
.L2:
	movl	-16(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jl	.L13
	movl	-4(%rbp), %eax
.L7:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	ans_f, .-ans_f
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d %d %d %d"
.LC3:
	.string	"%d %d %d"
.LC4:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -12(%rbp)
.L21:
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	testl	%eax, %eax
	jne	.L15
	movl	-40(%rbp), %eax
	testl	%eax, %eax
	je	.L25
.L15:
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L17
.L18:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	addq	%rdx, %rax
	leaq	12(%rax), %rsi
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	addq	%rdx, %rax
	leaq	8(%rax), %rcx
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdi
	leaq	records(%rip), %rax
	addq	%rdi, %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -16(%rbp)
.L17:
	movl	-36(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L18
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L19
.L20:
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %ecx
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %esi
	movl	-28(%rbp), %eax
	movl	%eax, %edi
	call	ans_f
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -16(%rbp)
.L19:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L20
	jmp	.L21
.L25:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	ans_f
	.type	ans_f, @function
ans_f:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%esi, %r9d
	movl	%edi, %r8d
	movl	%edx, %esi
	testl	%ecx, %ecx
	jle	.L9
	leal	-1(%rcx), %edx
	leaq	records(%rip), %rax
	xorl	%r10d, %r10d
	xorl	%r11d, %r11d
	leaq	16(%rax), %rcx
	salq	$4, %rdx
	addq	%rcx, %rdx
	xorl	%ecx, %ecx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L3:
	addq	$16, %rax
	cmpq	%rax, %rdx
	je	.L1
.L8:
	cmpl	%esi, 8(%rax)
	jne	.L3
	movl	12(%rax), %edi
	testl	%edi, %edi
	je	.L4
	addl	$1, %ecx
	cmpl	$1, %ecx
	jne	.L3
	movl	(%rax), %edi
	cmpl	%r8d, %edi
	jl	.L3
	cmpl	%r9d, %edi
	jg	.L1
	addq	$16, %rax
	movl	%edi, %r11d
	cmpq	%rax, %rdx
	jne	.L8
.L1:
	movl	%r10d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	subl	$1, %ecx
	jne	.L3
	movl	(%rax), %edi
	cmpl	%r8d, %edi
	jl	.L3
	cmpl	%r9d, %edi
	jg	.L5
	testl	%r11d, %r11d
	jne	.L6
	subl	%r8d, %edi
	addl	%edi, %r10d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L6:
	subl	%r11d, %edi
	addl	%edi, %r10d
	jmp	.L3
.L5:
	testl	%r11d, %r11d
	jne	.L7
	subl	%r8d, %r9d
	addl	%r9d, %r10d
	jmp	.L1
.L9:
	xorl	%r10d, %r10d
	jmp	.L1
.L7:
	subl	%r11d, %r9d
	addl	%r9d, %r10d
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	ans_f, .-ans_f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d %d %d %d"
.LC3:
	.string	"%d %d %d"
.LC4:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC2(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC3(%rip), %r14
	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
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rax
	movq	%rax, 8(%rsp)
	leaq	28(%rsp), %rax
	movq	%rax, (%rsp)
	.p2align 4,,10
	.p2align 3
.L20:
	movq	8(%rsp), %rdx
	movq	(%rsp), %rsi
	xorl	%eax, %eax
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	orl	32(%rsp), %eax
	je	.L14
	leaq	36(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	xorl	%ebp, %ebp
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %edx
	leaq	records(%rip), %rbx
	testl	%edx, %edx
	jle	.L19
	.p2align 4,,10
	.p2align 3
.L18:
	leaq	8(%rbx), %rcx
	leaq	4(%rbx), %rdx
	movq	%rbx, %rsi
	movq	%r15, %rdi
	leaq	12(%rbx), %r8
	xorl	%eax, %eax
	addl	$1, %ebp
	addq	$16, %rbx
	call	__isoc99_scanf@PLT
	cmpl	%ebp, 36(%rsp)
	jg	.L18
.L19:
	leaq	40(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %eax
	testl	%eax, %eax
	jle	.L20
	xorl	%r13d, %r13d
	leaq	52(%rsp), %r12
	leaq	48(%rsp), %rbp
	leaq	44(%rsp), %rbx
	.p2align 4,,10
	.p2align 3
.L16:
	movq	%r12, %rcx
	movq	%rbp, %rdx
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	call	__isoc99_scanf@PLT
	movl	52(%rsp), %edx
	movl	48(%rsp), %esi
	movl	44(%rsp), %edi
	movl	36(%rsp), %ecx
	call	ans_f
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	%r13d, 40(%rsp)
	jg	.L16
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L14:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L28
	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
.L28:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	records
	.bss
	.align 32
	.type	records, @object
	.size	records, 16000
records:
	.zero	16000
	.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	ans_f
	.type	ans_f, @function
ans_f:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%esi, %r9d
	movl	%edi, %r8d
	movl	%edx, %esi
	testl	%ecx, %ecx
	jle	.L9
	leal	-1(%rcx), %edx
	leaq	records(%rip), %rax
	xorl	%r10d, %r10d
	xorl	%r11d, %r11d
	leaq	16(%rax), %rcx
	salq	$4, %rdx
	addq	%rcx, %rdx
	xorl	%ecx, %ecx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L3:
	addq	$16, %rax
	cmpq	%rax, %rdx
	je	.L1
.L8:
	cmpl	%esi, 8(%rax)
	jne	.L3
	movl	12(%rax), %edi
	testl	%edi, %edi
	je	.L4
	addl	$1, %ecx
	cmpl	$1, %ecx
	jne	.L3
	movl	(%rax), %edi
	cmpl	%r8d, %edi
	jl	.L3
	cmpl	%r9d, %edi
	jg	.L1
	addq	$16, %rax
	movl	%edi, %r11d
	cmpq	%rax, %rdx
	jne	.L8
.L1:
	movl	%r10d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	subl	$1, %ecx
	jne	.L3
	movl	(%rax), %edi
	cmpl	%r8d, %edi
	jl	.L3
	cmpl	%r9d, %edi
	jg	.L5
	testl	%r11d, %r11d
	jne	.L6
	subl	%r8d, %edi
	addl	%edi, %r10d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L6:
	subl	%r11d, %edi
	addl	%edi, %r10d
	jmp	.L3
.L5:
	testl	%r11d, %r11d
	jne	.L7
	subl	%r8d, %r9d
	addl	%r9d, %r10d
	jmp	.L1
.L9:
	xorl	%r10d, %r10d
	jmp	.L1
.L7:
	subl	%r11d, %r9d
	addl	%r9d, %r10d
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	ans_f, .-ans_f
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d %d %d %d"
.LC3:
	.string	"%d %d %d"
.LC4:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC2(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC3(%rip), %r14
	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
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rax
	movq	%rax, 8(%rsp)
	leaq	28(%rsp), %rax
	movq	%rax, (%rsp)
	.p2align 4,,10
	.p2align 3
.L20:
	movq	8(%rsp), %rdx
	movq	(%rsp), %rsi
	xorl	%eax, %eax
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	orl	32(%rsp), %eax
	je	.L14
	leaq	36(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	xorl	%ebp, %ebp
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %edx
	leaq	records(%rip), %rbx
	testl	%edx, %edx
	jle	.L19
	.p2align 4,,10
	.p2align 3
.L18:
	leaq	8(%rbx), %rcx
	leaq	4(%rbx), %rdx
	movq	%rbx, %rsi
	movq	%r15, %rdi
	leaq	12(%rbx), %r8
	xorl	%eax, %eax
	addl	$1, %ebp
	addq	$16, %rbx
	call	__isoc99_scanf@PLT
	cmpl	%ebp, 36(%rsp)
	jg	.L18
.L19:
	leaq	40(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %eax
	testl	%eax, %eax
	jle	.L20
	xorl	%r13d, %r13d
	leaq	52(%rsp), %r12
	leaq	48(%rsp), %rbp
	leaq	44(%rsp), %rbx
	.p2align 4,,10
	.p2align 3
.L16:
	movq	%r12, %rcx
	movq	%rbp, %rdx
	movq	%rbx, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	call	__isoc99_scanf@PLT
	movl	52(%rsp), %edx
	movl	48(%rsp), %esi
	movl	44(%rsp), %edi
	movl	36(%rsp), %ecx
	call	ans_f
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	%r13d, 40(%rsp)
	jg	.L16
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L14:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L28
	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
.L28:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	records
	.bss
	.align 32
	.type	records, @object
	.size	records, 16000
records:
	.zero	16000
	.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 1148
   Analyzing Login/Logout Records
   2015/9/7
*/

#include<stdio.h>
#define REC_MAX 1000

struct record
{
  int time, pc_id, stu_id, log_flg;
};

struct record records[REC_MAX];

int ans_f(int start_t, int end_t, int questioned_stu_id, int records_n)
{
  int i, login_pc_count = 0, start = 0, timer = 0;

  for(i = 0; i < records_n; i++)
    {
      if(records[i].stu_id == questioned_stu_id)
	{
	  if(records[i].log_flg)
	    {
	      /* login */
	      login_pc_count++;
	      if(login_pc_count == 1)
		{
		  /* first login */
		  if(records[i].time < start_t)
		    {
		      /* login before start_t */
		    }
		  else if(records[i].time >= start_t && records[i].time <= end_t)
		    {
		      /* login after start_t && before end_t*/
		      start = records[i].time;
		    }
		  else
		    {
		      /* login after end_t */
		      return timer;
		    }
		}
	    }
	  else
	    {
	      /* logout */
	      login_pc_count--;
	      if(login_pc_count == 0)
		{
		  /* last logout */
		  if(records[i].time < start_t)
		    {
		      /* logout before start_t */
		    }
		  else if(records[i].time >= start_t && records[i].time <= end_t)
		    {
		      /* logout after start_t && before end_t */
		      if(start == 0)
			{
			  /* first login before start_t*/
			  timer += records[i].time - start_t;
			}
		      else
			{
			  /* first login after start_t */
			  timer += records[i].time - start;
			}
		    }
		  else
		    {
		      /* logout after end_t */
		      if(start == 0)
			{
			  /* first login before start_t */
			  timer += end_t - start_t;
			}
		      else
			{
			  /* first login after start_t */
			  timer += end_t - start;
			}
		      return timer;
		    }
		}
	    }
	}
    }
  return timer;
}

int main(void)
{
  int i, pcs_n, stus_n, records_n, questions_n, start_t, end_t, questioned_stu_id, ans = 0;

  while(1)
    {
      scanf("%d %d", &pcs_n, &stus_n);

      if(pcs_n == 0 && stus_n == 0)
	{
	  break;
	}

      scanf("%d", &records_n);
      for(i = 0; i < records_n; i++)
	{
	  scanf("%d %d %d %d", &records[i].time, &records[i].pc_id, &records[i].stu_id, &records[i].log_flg);
	}
      scanf("%d", &questions_n);
      for(i = 0; i < questions_n; i++)
	{
	  scanf("%d %d %d", &start_t, &end_t, &questioned_stu_id);
	  ans = ans_f(start_t, end_t, questioned_stu_id, records_n);
	  printf("%d\n", ans);
	}
    }
  return 0;
}
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
 4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
91 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
 4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
91 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
587 600 1
550 650 1
266 620 1
650 750 1
700 800 1
0 0
 6 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
556 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 238 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
 4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
983 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
 6 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 171 1
610 620 1
650 750 1
700 800 1
0 0
 4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
91 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
587 600 1
550 650 1
610 620 1
1045 750 1
700 800 1
0 0
 6 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 238 1
606 650 1
610 620 1
650 937 1
700 800 1
0 0
 4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
107 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
983 1100 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 1192 1
700 800 1
0 0
 4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
156 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1100 15
1000 1200 11
2 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 1178 1
650 750 1
700 800 1
0 0

55
70
30
0
0
50
10
50
0
 60
70
30
0
0
50
10
50
0
 60
70
30
0
0
50
20
50
0
 55
26
30
0
0
50
10
50
0
 55
70
0
0
0
50
10
50
0
 55
70
30
0
0
0
10
50
0
 60
70
30
0
0
50
10
0
0
 55
70
30
0
0
44
10
50
0
 60
70
0
0
0
50
10
50
0
 60
70
30
0
0
50
90
50
0

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

```c
/* 
   AOJ 1148
   Analyzing Login/Logout Records
   2015/9/7
*/

#include<stdio.h>
#define REC_MAX 1000

struct record
{
  int time, pc_id, stu_id, log_flg;
};

struct record records[REC_MAX];

int ans_f(int start_t, int end_t, int questioned_stu_id, int records_n)
{
  int i, login_pc_count = 0, start = 0, timer = 0;

  for(i = 0; i < records_n; i++)
    {
      if(records[i].stu_id == questioned_stu_id)
	{
	  if(records[i].log_flg)
	    {
	      /* login */
	      login_pc_count++;
	      if(login_pc_count == 1)
		{
		  /* first login */
		  if(records[i].time < start_t)
		    {
		      /* login before start_t */
		    }
		  else if(records[i].time >= start_t && records[i].time <= end_t)
		    {
		      /* login after start_t && before end_t*/
		      start = records[i].time;
		    }
		  else
		    {
		      /* login after end_t */
		      return timer;
		    }
		}
	    }
	  else
	    {
	      /* logout */
	      login_pc_count--;
	      if(login_pc_count == 0)
		{
		  /* last logout */
		  if(records[i].time < start_t)
		    {
		      /* logout before start_t */
		    }
		  else if(records[i].time >= start_t && records[i].time <= end_t)
		    {
		      /* logout after start_t && before end_t */
		      if(start == 0)
			{
			  /* first login before start_t*/
			  timer += records[i].time - start_t;
			}
		      else
			{
			  /* first login after start_t */
			  timer += records[i].time - start;
			}
		    }
		  else
		    {
		      /* logout after end_t */
		      if(start == 0)
			{
			  /* first login before start_t */
			  timer += end_t - start_t;
			}
		      else
			{
			  /* first login after start_t */
			  timer += end_t - start;
			}
		      return timer;
		    }
		}
	    }
	}
    }
  return timer;
}

int main(void)
{
  int i, pcs_n, stus_n, records_n, questions_n, start_t, end_t, questioned_stu_id, ans = 0;

  while(1)
    {
      scanf("%d %d", &pcs_n, &stus_n);

      if(pcs_n == 0 && stus_n == 0)
	{
	  break;
	}

      scanf("%d", &records_n);
      for(i = 0; i < records_n; i++)
	{
	  scanf("%d %d %d %d", &records[i].time, &records[i].pc_id, &records[i].stu_id, &records[i].log_flg);
	}
      scanf("%d", &questions_n);
      for(i = 0; i < questions_n; i++)
	{
	  scanf("%d %d %d", &start_t, &end_t, &questioned_stu_id);
	  ans = ans_f(start_t, end_t, questioned_stu_id, records_n);
	  printf("%d\n", ans);
	}
    }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	records
	.bss
	.align 32
	.type	records, @object
	.size	records, 16000
records:
	.zero	16000
	.text
	.globl	ans_f
	.type	ans_f, @function
ans_f:
.LFB0:
	.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)
	movl	%edx, -28(%rbp)
	movl	%ecx, -32(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -4(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L2
.L13:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	8+records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -28(%rbp)
	jne	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	12+records(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L4
	addl	$1, -12(%rbp)
	cmpl	$1, -12(%rbp)
	jne	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jg	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jg	.L6
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L6
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	jmp	.L3
.L6:
	movl	-4(%rbp), %eax
	jmp	.L7
.L4:
	subl	$1, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jg	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jg	.L8
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L8
	cmpl	$0, -8(%rbp)
	jne	.L9
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	-20(%rbp), %eax
	addl	%eax, -4(%rbp)
	jmp	.L3
.L9:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	-8(%rbp), %eax
	addl	%eax, -4(%rbp)
	jmp	.L3
.L8:
	cmpl	$0, -8(%rbp)
	jne	.L11
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	addl	%eax, -4(%rbp)
	jmp	.L12
.L11:
	movl	-24(%rbp), %eax
	subl	-8(%rbp), %eax
	addl	%eax, -4(%rbp)
.L12:
	movl	-4(%rbp), %eax
	jmp	.L7
.L3:
	addl	$1, -16(%rbp)
.L2:
	movl	-16(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jl	.L13
	movl	-4(%rbp), %eax
.L7:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	ans_f, .-ans_f
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d %d %d %d"
.LC3:
	.string	"%d %d %d"
.LC4:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -12(%rbp)
.L21:
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	testl	%eax, %eax
	jne	.L15
	movl	-40(%rbp), %eax
	testl	%eax, %eax
	je	.L25
.L15:
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L17
.L18:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	addq	%rdx, %rax
	leaq	12(%rax), %rsi
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	addq	%rdx, %rax
	leaq	8(%rax), %rcx
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdi
	leaq	records(%rip), %rax
	addq	%rdi, %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -16(%rbp)
.L17:
	movl	-36(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L18
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L19
.L20:
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %ecx
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %esi
	movl	-28(%rbp), %eax
	movl	%eax, %edi
	call	ans_f
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -16(%rbp)
.L19:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L20
	jmp	.L21
.L25:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	records
	.bss
	.align 32
	.type	records, @object
	.size	records, 16000
records:
	.zero	16000
	.text
	.globl	ans_f
	.type	ans_f, @function
ans_f:
.LFB0:
	.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)
	movl	%edx, -28(%rbp)
	movl	%ecx, -32(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -4(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L2
.L13:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	8+records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -28(%rbp)
	jne	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	12+records(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L4
	addl	$1, -12(%rbp)
	cmpl	$1, -12(%rbp)
	jne	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jg	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jg	.L6
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L6
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	jmp	.L3
.L6:
	movl	-4(%rbp), %eax
	jmp	.L7
.L4:
	subl	$1, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jg	.L3
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jg	.L8
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L8
	cmpl	$0, -8(%rbp)
	jne	.L9
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	-20(%rbp), %eax
	addl	%eax, -4(%rbp)
	jmp	.L3
.L9:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	-8(%rbp), %eax
	addl	%eax, -4(%rbp)
	jmp	.L3
.L8:
	cmpl	$0, -8(%rbp)
	jne	.L11
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	addl	%eax, -4(%rbp)
	jmp	.L12
.L11:
	movl	-24(%rbp), %eax
	subl	-8(%rbp), %eax
	addl	%eax, -4(%rbp)
.L12:
	movl	-4(%rbp), %eax
	jmp	.L7
.L3:
	addl	$1, -16(%rbp)
.L2:
	movl	-16(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jl	.L13
	movl	-4(%rbp), %eax
.L7:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	ans_f, .-ans_f
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d %d %d %d"
.LC3:
	.string	"%d %d %d"
.LC4:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -12(%rbp)
.L21:
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	testl	%eax, %eax
	jne	.L15
	movl	-40(%rbp), %eax
	testl	%eax, %eax
	je	.L25
.L15:
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L17
.L18:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	addq	%rdx, %rax
	leaq	12(%rax), %rsi
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	addq	%rdx, %rax
	leaq	8(%rax), %rcx
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	records(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdi
	leaq	records(%rip), %rax
	addq	%rdi, %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -16(%rbp)
.L17:
	movl	-36(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L18
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L19
.L20:
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %ecx
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %esi
	movl	-28(%rbp), %eax
	movl	%eax, %edi
	call	ans_f
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -16(%rbp)
.L19:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L20
	jmp	.L21
.L25:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
