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

```c
/*
  AOJ 0231
  Title:
  @kankichi573
*/
#include <stdio.h>


int n,m[100],a[100],b[100];

int total_weight(int tim)
{
  int i,ret;
  for(i=ret=0;i<n;i++)
    {
      if(tim>=a[i] && tim<b[i])
	ret+=m[i];
    }
  return(ret);
}

main()
{
  int i,ret;

  while(scanf("%d",&n)  && (n))
    {
      for(i=0;i<n;i++)
	scanf("%d %d %d",&m[i],&a[i],&b[i]);
      ret=1;
      for(i=0;i<n;i++)
	{
	  if(total_weight(a[i])>150||total_weight(b[i])>150)
	    {
	      ret=0;
	      break;
	    }
	}
      printf("%s\n",ret?"OK":"NG");
    }
  return(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400
a:
	.zero	400
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400
b:
	.zero	400
	.text
	.globl	total_weight
	.type	total_weight, @function
total_weight:
.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	$0, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L2
.L4:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jge	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -4(%rbp)
.L3:
	addl	$1, -8(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L4
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	total_weight, .-total_weight
	.section	.rodata
.LC0:
	.string	"%d %d %d"
.LC1:
	.string	"OK"
.LC2:
	.string	"NG"
.LC3:
	.string	"%d"
	.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	$16, %rsp
	jmp	.L7
.L18:
	movl	$0, -8(%rbp)
	jmp	.L8
.L9:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rsi
	leaq	m(%rip), %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L8:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L9
	movl	$1, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L10
.L14:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	total_weight
	cmpl	$150, %eax
	jg	.L11
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	total_weight
	cmpl	$150, %eax
	jle	.L12
.L11:
	movl	$0, -4(%rbp)
	jmp	.L13
.L12:
	addl	$1, -8(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L14
.L13:
	cmpl	$0, -4(%rbp)
	je	.L15
	leaq	.LC1(%rip), %rax
	jmp	.L16
.L15:
	leaq	.LC2(%rip), %rax
.L16:
	movq	%rax, %rdi
	call	puts@PLT
.L7:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L17
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L18
.L17:
	movl	$0, %eax
	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	total_weight
	.type	total_weight, @function
total_weight:
.LFB23:
	.cfi_startproc
	endbr64
	movl	n(%rip), %esi
	testl	%esi, %esi
	jle	.L11
	leal	-1(%rsi), %eax
	cmpl	$2, %eax
	jbe	.L12
	movl	%esi, %edx
	movd	%edi, %xmm5
	pxor	%xmm2, %xmm2
	xorl	%eax, %eax
	shrl	$2, %edx
	pshufd	$0, %xmm5, %xmm3
	leaq	a(%rip), %rcx
	salq	$4, %rdx
	leaq	b(%rip), %r9
	leaq	m(%rip), %r8
	movdqa	%xmm2, %xmm4
	.p2align 4,,10
	.p2align 3
.L4:
	movdqa	(%rcx,%rax), %xmm0
	movdqa	(%r9,%rax), %xmm1
	pcmpgtd	%xmm3, %xmm0
	pcmpgtd	%xmm3, %xmm1
	pcmpeqd	%xmm4, %xmm0
	pand	%xmm1, %xmm0
	pand	(%r8,%rax), %xmm0
	addq	$16, %rax
	paddd	%xmm0, %xmm2
	cmpq	%rax, %rdx
	jne	.L4
	movdqa	%xmm2, %xmm0
	movl	%esi, %edx
	psrldq	$8, %xmm0
	andl	$-4, %edx
	paddd	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %eax
	testb	$3, %sil
	je	.L15
.L3:
	movslq	%edx, %r8
	cmpl	(%rcx,%r8,4), %edi
	jge	.L16
.L7:
	leal	1(%rdx), %r8d
	cmpl	%esi, %r8d
	jge	.L1
	movslq	%r8d, %r8
	cmpl	%edi, (%rcx,%r8,4)
	jle	.L17
.L8:
	addl	$2, %edx
	cmpl	%edx, %esi
	jle	.L1
	movslq	%edx, %rdx
	cmpl	(%rcx,%rdx,4), %edi
	jl	.L1
	leaq	b(%rip), %rcx
	cmpl	(%rcx,%rdx,4), %edi
	jge	.L1
	leaq	m(%rip), %rcx
	addl	(%rcx,%rdx,4), %eax
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	xorl	%eax, %eax
.L1:
	ret
	.p2align 4,,10
	.p2align 3
.L16:
	leaq	b(%rip), %r9
	cmpl	%edi, (%r9,%r8,4)
	jle	.L7
	leaq	m(%rip), %r9
	addl	(%r9,%r8,4), %eax
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L17:
	leaq	b(%rip), %r9
	cmpl	(%r9,%r8,4), %edi
	jge	.L8
	leaq	m(%rip), %r9
	addl	(%r9,%r8,4), %eax
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L15:
	ret
.L12:
	xorl	%eax, %eax
	xorl	%edx, %edx
	leaq	a(%rip), %rcx
	jmp	.L3
	.cfi_endproc
.LFE23:
	.size	total_weight, .-total_weight
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"OK"
.LC1:
	.string	"NG"
.LC2:
	.string	"%d %d %d"
.LC3:
	.string	"%d"
	.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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	b(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	a(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L19:
	xorl	%eax, %eax
	leaq	n(%rip), %rsi
	leaq	.LC3(%rip), %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L51
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L51
	movl	$0, %ebp
	movl	$0, %ebx
	leaq	m(%rip), %r14
	leaq	.LC2(%rip), %r15
	jle	.L39
	.p2align 4,,10
	.p2align 3
.L20:
	leaq	0(%r13,%rbp), %rcx
	leaq	(%r12,%rbp), %rdx
	xorl	%eax, %eax
	movq	%r15, %rdi
	leaq	(%r14,%rbp), %rsi
	addl	$1, %ebx
	addq	$4, %rbp
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	pxor	%xmm3, %xmm3
	cmpl	%ebx, %ecx
	jg	.L20
	testl	%ecx, %ecx
	jle	.L39
	movl	%ecx, %eax
	movl	%ecx, %edi
	leal	-1(%rcx), %r8d
	movl	%ecx, %r9d
	shrl	$2, %eax
	andl	$-4, %edi
	xorl	%esi, %esi
	leal	-1(%rax), %edx
	addq	$1, %rdx
	salq	$4, %rdx
	.p2align 4,,10
	.p2align 3
.L38:
	movl	(%r12,%rsi,4), %r11d
	cmpl	$2, %r8d
	jbe	.L43
	movd	%r11d, %xmm5
	xorl	%eax, %eax
	pxor	%xmm2, %xmm2
	pshufd	$0, %xmm5, %xmm4
	.p2align 4,,10
	.p2align 3
.L24:
	movdqa	(%r12,%rax), %xmm0
	movdqa	0(%r13,%rax), %xmm1
	pcmpgtd	%xmm4, %xmm0
	pcmpgtd	%xmm4, %xmm1
	pcmpeqd	%xmm3, %xmm0
	pand	%xmm1, %xmm0
	pand	(%r14,%rax), %xmm0
	addq	$16, %rax
	paddd	%xmm0, %xmm2
	cmpq	%rax, %rdx
	jne	.L24
	movdqa	%xmm2, %xmm0
	movl	%edi, %r10d
	psrldq	$8, %xmm0
	paddd	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %eax
	cmpl	%edi, %ecx
	je	.L63
.L23:
	movslq	%r10d, %r15
	cmpl	(%r12,%r15,4), %r11d
	jl	.L26
	cmpl	0(%r13,%r15,4), %r11d
	jge	.L26
	addl	(%r14,%r15,4), %eax
.L26:
	leal	1(%r10), %r15d
	cmpl	%r15d, %ecx
	jle	.L27
	movslq	%r15d, %r15
	cmpl	(%r12,%r15,4), %r11d
	jl	.L28
	cmpl	0(%r13,%r15,4), %r11d
	jge	.L28
	addl	(%r14,%r15,4), %eax
.L28:
	addl	$2, %r10d
	cmpl	%r10d, %ecx
	jle	.L27
	movslq	%r10d, %r10
	cmpl	(%r12,%r10,4), %r11d
	jl	.L27
	cmpl	0(%r13,%r10,4), %r11d
	jge	.L27
	addl	(%r14,%r10,4), %eax
	.p2align 4,,10
	.p2align 3
.L27:
	cmpl	$150, %eax
	jg	.L48
	movl	0(%r13,%rsi,4), %r11d
	cmpl	$2, %r8d
	jbe	.L45
.L41:
	movd	%r11d, %xmm6
	xorl	%eax, %eax
	pxor	%xmm2, %xmm2
	pshufd	$0, %xmm6, %xmm4
	.p2align 4,,10
	.p2align 3
.L32:
	movdqa	(%r12,%rax), %xmm0
	movdqa	0(%r13,%rax), %xmm1
	pcmpgtd	%xmm4, %xmm0
	pcmpgtd	%xmm4, %xmm1
	pcmpeqd	%xmm3, %xmm0
	pand	%xmm1, %xmm0
	pand	(%r14,%rax), %xmm0
	addq	$16, %rax
	paddd	%xmm0, %xmm2
	cmpq	%rax, %rdx
	jne	.L32
	movdqa	%xmm2, %xmm0
	movl	%edi, %r10d
	psrldq	$8, %xmm0
	paddd	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %eax
	cmpl	%edi, %ecx
	je	.L33
.L31:
	movslq	%r10d, %r15
	cmpl	%r11d, (%r12,%r15,4)
	jg	.L34
	cmpl	%r11d, 0(%r13,%r15,4)
	jle	.L34
	addl	(%r14,%r15,4), %eax
.L34:
	leal	1(%r10), %r15d
	cmpl	%r15d, %ecx
	jle	.L33
	movslq	%r15d, %r15
	cmpl	%r11d, (%r12,%r15,4)
	jg	.L35
	cmpl	%r11d, 0(%r13,%r15,4)
	jle	.L35
	addl	(%r14,%r15,4), %eax
.L35:
	addl	$2, %r10d
	cmpl	%r10d, %ecx
	jle	.L33
	movslq	%r10d, %r10
	cmpl	%r11d, (%r12,%r10,4)
	jg	.L33
	cmpl	%r11d, 0(%r13,%r10,4)
	jle	.L33
	addl	(%r14,%r10,4), %eax
	.p2align 4,,10
	.p2align 3
.L33:
	cmpl	$150, %eax
	jg	.L48
	addq	$1, %rsi
	cmpq	%rsi, %r9
	jne	.L38
.L39:
	leaq	.LC0(%rip), %rdi
.L22:
	call	puts@PLT
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L63:
	cmpl	$150, %eax
	jg	.L48
	movl	0(%r13,%rsi,4), %r11d
	jmp	.L41
	.p2align 4,,10
	.p2align 3
.L43:
	xorl	%eax, %eax
	xorl	%r10d, %r10d
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L45:
	xorl	%eax, %eax
	xorl	%r10d, %r10d
	jmp	.L31
.L48:
	leaq	.LC1(%rip), %rdi
	jmp	.L22
.L51:
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	b
	.bss
	.align 32
	.type	b, @object
	.size	b, 400
b:
	.zero	400
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400
a:
	.zero	400
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	total_weight
	.type	total_weight, @function
total_weight:
.LFB23:
	.cfi_startproc
	endbr64
	movl	n(%rip), %esi
	testl	%esi, %esi
	jle	.L11
	leal	-1(%rsi), %eax
	cmpl	$2, %eax
	jbe	.L12
	movl	%esi, %edx
	movd	%edi, %xmm5
	pxor	%xmm2, %xmm2
	xorl	%eax, %eax
	shrl	$2, %edx
	pshufd	$0, %xmm5, %xmm3
	leaq	a(%rip), %rcx
	salq	$4, %rdx
	leaq	b(%rip), %r9
	leaq	m(%rip), %r8
	movdqa	%xmm2, %xmm4
	.p2align 4,,10
	.p2align 3
.L4:
	movdqa	(%rcx,%rax), %xmm0
	movdqa	(%r9,%rax), %xmm1
	pcmpgtd	%xmm3, %xmm0
	pcmpgtd	%xmm3, %xmm1
	pcmpeqd	%xmm4, %xmm0
	pand	%xmm1, %xmm0
	pand	(%r8,%rax), %xmm0
	addq	$16, %rax
	paddd	%xmm0, %xmm2
	cmpq	%rax, %rdx
	jne	.L4
	movdqa	%xmm2, %xmm0
	movl	%esi, %edx
	psrldq	$8, %xmm0
	andl	$-4, %edx
	paddd	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %eax
	testb	$3, %sil
	je	.L15
.L3:
	movslq	%edx, %r8
	cmpl	(%rcx,%r8,4), %edi
	jge	.L16
.L7:
	leal	1(%rdx), %r8d
	cmpl	%esi, %r8d
	jge	.L1
	movslq	%r8d, %r8
	cmpl	%edi, (%rcx,%r8,4)
	jle	.L17
.L8:
	addl	$2, %edx
	cmpl	%edx, %esi
	jle	.L1
	movslq	%edx, %rdx
	cmpl	(%rcx,%rdx,4), %edi
	jl	.L1
	leaq	b(%rip), %rcx
	cmpl	(%rcx,%rdx,4), %edi
	jge	.L1
	leaq	m(%rip), %rcx
	addl	(%rcx,%rdx,4), %eax
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	xorl	%eax, %eax
.L1:
	ret
	.p2align 4,,10
	.p2align 3
.L16:
	leaq	b(%rip), %r9
	cmpl	%edi, (%r9,%r8,4)
	jle	.L7
	leaq	m(%rip), %r9
	addl	(%r9,%r8,4), %eax
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L17:
	leaq	b(%rip), %r9
	cmpl	(%r9,%r8,4), %edi
	jge	.L8
	leaq	m(%rip), %r9
	addl	(%r9,%r8,4), %eax
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L15:
	ret
.L12:
	xorl	%eax, %eax
	xorl	%edx, %edx
	leaq	a(%rip), %rcx
	jmp	.L3
	.cfi_endproc
.LFE23:
	.size	total_weight, .-total_weight
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"OK"
.LC1:
	.string	"NG"
.LC2:
	.string	"%d %d %d"
.LC3:
	.string	"%d"
	.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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	b(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	a(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L19:
	xorl	%eax, %eax
	leaq	n(%rip), %rsi
	leaq	.LC3(%rip), %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L51
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L51
	movl	$0, %ebp
	movl	$0, %ebx
	leaq	m(%rip), %r14
	leaq	.LC2(%rip), %r15
	jle	.L39
	.p2align 4,,10
	.p2align 3
.L20:
	leaq	0(%r13,%rbp), %rcx
	leaq	(%r12,%rbp), %rdx
	xorl	%eax, %eax
	movq	%r15, %rdi
	leaq	(%r14,%rbp), %rsi
	addl	$1, %ebx
	addq	$4, %rbp
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	pxor	%xmm3, %xmm3
	cmpl	%ebx, %ecx
	jg	.L20
	testl	%ecx, %ecx
	jle	.L39
	movl	%ecx, %eax
	movl	%ecx, %edi
	leal	-1(%rcx), %r8d
	movl	%ecx, %r9d
	shrl	$2, %eax
	andl	$-4, %edi
	xorl	%esi, %esi
	leal	-1(%rax), %edx
	addq	$1, %rdx
	salq	$4, %rdx
	.p2align 4,,10
	.p2align 3
.L38:
	movl	(%r12,%rsi,4), %r11d
	cmpl	$2, %r8d
	jbe	.L43
	movd	%r11d, %xmm5
	xorl	%eax, %eax
	pxor	%xmm2, %xmm2
	pshufd	$0, %xmm5, %xmm4
	.p2align 4,,10
	.p2align 3
.L24:
	movdqa	(%r12,%rax), %xmm0
	movdqa	0(%r13,%rax), %xmm1
	pcmpgtd	%xmm4, %xmm0
	pcmpgtd	%xmm4, %xmm1
	pcmpeqd	%xmm3, %xmm0
	pand	%xmm1, %xmm0
	pand	(%r14,%rax), %xmm0
	addq	$16, %rax
	paddd	%xmm0, %xmm2
	cmpq	%rax, %rdx
	jne	.L24
	movdqa	%xmm2, %xmm0
	movl	%edi, %r10d
	psrldq	$8, %xmm0
	paddd	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %eax
	cmpl	%edi, %ecx
	je	.L63
.L23:
	movslq	%r10d, %r15
	cmpl	(%r12,%r15,4), %r11d
	jl	.L26
	cmpl	0(%r13,%r15,4), %r11d
	jge	.L26
	addl	(%r14,%r15,4), %eax
.L26:
	leal	1(%r10), %r15d
	cmpl	%r15d, %ecx
	jle	.L27
	movslq	%r15d, %r15
	cmpl	(%r12,%r15,4), %r11d
	jl	.L28
	cmpl	0(%r13,%r15,4), %r11d
	jge	.L28
	addl	(%r14,%r15,4), %eax
.L28:
	addl	$2, %r10d
	cmpl	%r10d, %ecx
	jle	.L27
	movslq	%r10d, %r10
	cmpl	(%r12,%r10,4), %r11d
	jl	.L27
	cmpl	0(%r13,%r10,4), %r11d
	jge	.L27
	addl	(%r14,%r10,4), %eax
	.p2align 4,,10
	.p2align 3
.L27:
	cmpl	$150, %eax
	jg	.L48
	movl	0(%r13,%rsi,4), %r11d
	cmpl	$2, %r8d
	jbe	.L45
.L41:
	movd	%r11d, %xmm6
	xorl	%eax, %eax
	pxor	%xmm2, %xmm2
	pshufd	$0, %xmm6, %xmm4
	.p2align 4,,10
	.p2align 3
.L32:
	movdqa	(%r12,%rax), %xmm0
	movdqa	0(%r13,%rax), %xmm1
	pcmpgtd	%xmm4, %xmm0
	pcmpgtd	%xmm4, %xmm1
	pcmpeqd	%xmm3, %xmm0
	pand	%xmm1, %xmm0
	pand	(%r14,%rax), %xmm0
	addq	$16, %rax
	paddd	%xmm0, %xmm2
	cmpq	%rax, %rdx
	jne	.L32
	movdqa	%xmm2, %xmm0
	movl	%edi, %r10d
	psrldq	$8, %xmm0
	paddd	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %eax
	cmpl	%edi, %ecx
	je	.L33
.L31:
	movslq	%r10d, %r15
	cmpl	%r11d, (%r12,%r15,4)
	jg	.L34
	cmpl	%r11d, 0(%r13,%r15,4)
	jle	.L34
	addl	(%r14,%r15,4), %eax
.L34:
	leal	1(%r10), %r15d
	cmpl	%r15d, %ecx
	jle	.L33
	movslq	%r15d, %r15
	cmpl	%r11d, (%r12,%r15,4)
	jg	.L35
	cmpl	%r11d, 0(%r13,%r15,4)
	jle	.L35
	addl	(%r14,%r15,4), %eax
.L35:
	addl	$2, %r10d
	cmpl	%r10d, %ecx
	jle	.L33
	movslq	%r10d, %r10
	cmpl	%r11d, (%r12,%r10,4)
	jg	.L33
	cmpl	%r11d, 0(%r13,%r10,4)
	jle	.L33
	addl	(%r14,%r10,4), %eax
	.p2align 4,,10
	.p2align 3
.L33:
	cmpl	$150, %eax
	jg	.L48
	addq	$1, %rsi
	cmpq	%rsi, %r9
	jne	.L38
.L39:
	leaq	.LC0(%rip), %rdi
.L22:
	call	puts@PLT
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L63:
	cmpl	$150, %eax
	jg	.L48
	movl	0(%r13,%rsi,4), %r11d
	jmp	.L41
	.p2align 4,,10
	.p2align 3
.L43:
	xorl	%eax, %eax
	xorl	%r10d, %r10d
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L45:
	xorl	%eax, %eax
	xorl	%r10d, %r10d
	jmp	.L31
.L48:
	leaq	.LC1(%rip), %rdi
	jmp	.L22
.L51:
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	b
	.bss
	.align 32
	.type	b, @object
	.size	b, 400
b:
	.zero	400
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400
a:
	.zero	400
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.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:

/*
  AOJ 0231
  Title:
  @kankichi573
*/
#include <stdio.h>


int n,m[100],a[100],b[100];

int total_weight(int tim)
{
  int i,ret;
  for(i=ret=0;i<n;i++)
    {
      if(tim>=a[i] && tim<b[i])
	ret+=m[i];
    }
  return(ret);
}

main()
{
  int i,ret;

  while(scanf("%d",&n)  && (n))
    {
      for(i=0;i<n;i++)
	scanf("%d %d %d",&m[i],&a[i],&b[i]);
      ret=1;
      for(i=0;i<n;i++)
	{
	  if(total_weight(a[i])>150||total_weight(b[i])>150)
	    {
	      ret=0;
	      break;
	    }
	}
      printf("%s\n",ret?"OK":"NG");
    }
  return(0);
}
3
80 0 30
50 5 25
90 27 50
3
80 0 30
70 5 25
71 30 84
0
 3
80 0 15
64 5 25
149 27 50
3
80 0 10
70 10 25
22 30 84
0
 3
80 0 30
50 5 25
90 27 50
3
80 0 30
70 5 25
71 23 50
0
 3
1 0 30
50 5 25
90 28 50
3
80 0 40
70 5 25
71 30 84
0
 3
80 0 15
64 3 49
149 27 50
0
80 1 10
70 10 25
22 30 84
0
 3
80 0 8
50 5 29
90 51 50
0
80 0 10
70 5 25
71 3 84
0
 3
80 0 30
50 5 25
90 27 50
3
80 0 10
70 5 25
71 30 84
0
 3
80 0 30
50 5 25
149 27 50
3
80 0 10
70 5 25
71 30 84
0
 3
80 0 30
50 5 25
149 27 50
3
80 0 10
70 5 25
22 30 84
0
 3
80 0 30
50 5 25
149 27 50
3
80 0 10
70 10 25
22 30 84
0

NG
OK
 OK
OK
 NG
NG
 OK
NG
 NG
 OK
 NG
OK
 NG
OK
 NG
OK
 NG
OK

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

```c
/*
  AOJ 0231
  Title:
  @kankichi573
*/
#include <stdio.h>


int n,m[100],a[100],b[100];

int total_weight(int tim)
{
  int i,ret;
  for(i=ret=0;i<n;i++)
    {
      if(tim>=a[i] && tim<b[i])
	ret+=m[i];
    }
  return(ret);
}

main()
{
  int i,ret;

  while(scanf("%d",&n)  && (n))
    {
      for(i=0;i<n;i++)
	scanf("%d %d %d",&m[i],&a[i],&b[i]);
      ret=1;
      for(i=0;i<n;i++)
	{
	  if(total_weight(a[i])>150||total_weight(b[i])>150)
	    {
	      ret=0;
	      break;
	    }
	}
      printf("%s\n",ret?"OK":"NG");
    }
  return(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400
a:
	.zero	400
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400
b:
	.zero	400
	.text
	.globl	total_weight
	.type	total_weight, @function
total_weight:
.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	$0, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L2
.L4:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jge	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -4(%rbp)
.L3:
	addl	$1, -8(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L4
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	total_weight, .-total_weight
	.section	.rodata
.LC0:
	.string	"%d %d %d"
.LC1:
	.string	"OK"
.LC2:
	.string	"NG"
.LC3:
	.string	"%d"
	.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	$16, %rsp
	jmp	.L7
.L18:
	movl	$0, -8(%rbp)
	jmp	.L8
.L9:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rsi
	leaq	m(%rip), %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L8:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L9
	movl	$1, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L10
.L14:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	total_weight
	cmpl	$150, %eax
	jg	.L11
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	total_weight
	cmpl	$150, %eax
	jle	.L12
.L11:
	movl	$0, -4(%rbp)
	jmp	.L13
.L12:
	addl	$1, -8(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L14
.L13:
	cmpl	$0, -4(%rbp)
	je	.L15
	leaq	.LC1(%rip), %rax
	jmp	.L16
.L15:
	leaq	.LC2(%rip), %rax
.L16:
	movq	%rax, %rdi
	call	puts@PLT
.L7:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L17
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L18
.L17:
	movl	$0, %eax
	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	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400
a:
	.zero	400
	.globl	b
	.align 32
	.type	b, @object
	.size	b, 400
b:
	.zero	400
	.text
	.globl	total_weight
	.type	total_weight, @function
total_weight:
.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	$0, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L2
.L4:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jge	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -4(%rbp)
.L3:
	addl	$1, -8(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L4
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	total_weight, .-total_weight
	.section	.rodata
.LC0:
	.string	"%d %d %d"
.LC1:
	.string	"OK"
.LC2:
	.string	"NG"
.LC3:
	.string	"%d"
	.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	$16, %rsp
	jmp	.L7
.L18:
	movl	$0, -8(%rbp)
	jmp	.L8
.L9:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rsi
	leaq	m(%rip), %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8(%rbp)
.L8:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L9
	movl	$1, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L10
.L14:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	total_weight
	cmpl	$150, %eax
	jg	.L11
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	b(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	total_weight
	cmpl	$150, %eax
	jle	.L12
.L11:
	movl	$0, -4(%rbp)
	jmp	.L13
.L12:
	addl	$1, -8(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L14
.L13:
	cmpl	$0, -4(%rbp)
	je	.L15
	leaq	.LC1(%rip), %rax
	jmp	.L16
.L15:
	leaq	.LC2(%rip), %rax
.L16:
	movq	%rax, %rdi
	call	puts@PLT
.L7:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L17
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L18
.L17:
	movl	$0, %eax
	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:
