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

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


int main(int argc, char* argv[]){
        char buf[128]={0};
        char* p=NULL;
        int a = 0;
        int b = 0;
        int c = 0;
        int x = 0;

        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        a = atoi(buf);

        memset(buf, 0, sizeof(buf));
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        b = atoi(p);

        memset(buf, 0, sizeof(buf));
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        c = atoi(p);

        memset(buf, 0, sizeof(buf));
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        x = atoi(p);

#ifdef DEBUG1
        printf("input: a=%d, b=%d, c=%d, x=%d\n", a, b, c, x);
#endif
        int ans=0;

        for(int i=0; i<a+1; i++){
                for(int j=0; j<b+1; j++){
                        for(int k=0; k<c+1; k++){
                                int v = 500*i+100*j+50*k;
                                if(v==x){ans++;}
                        }
                }
        }

        printf("%d\n", ans);
        return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	" "
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$208, %rsp
	movl	%edi, -196(%rbp)
	movq	%rsi, -208(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -144(%rbp)
	movq	$0, -136(%rbp)
	movq	$0, -128(%rbp)
	movq	$0, -120(%rbp)
	movq	$0, -112(%rbp)
	movq	$0, -104(%rbp)
	movq	$0, -96(%rbp)
	movq	$0, -88(%rbp)
	movq	$0, -80(%rbp)
	movq	$0, -72(%rbp)
	movq	$0, -64(%rbp)
	movq	$0, -56(%rbp)
	movq	$0, -48(%rbp)
	movq	$0, -40(%rbp)
	movq	$0, -32(%rbp)
	movq	$0, -24(%rbp)
	movq	$0, -152(%rbp)
	movl	$0, -172(%rbp)
	movl	$0, -168(%rbp)
	movl	$0, -164(%rbp)
	movl	$0, -160(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-144(%rbp), %rax
	movl	$127, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$1, %eax
	jmp	.L14
.L2:
	leaq	-144(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -172(%rbp)
	leaq	-144(%rbp), %rax
	movl	$128, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movq	stdin(%rip), %rdx
	leaq	-144(%rbp), %rax
	movl	$127, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L4
	movl	$1, %eax
	jmp	.L14
.L4:
	leaq	-144(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -152(%rbp)
	movq	-152(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -168(%rbp)
	leaq	-144(%rbp), %rax
	movl	$128, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movq	stdin(%rip), %rdx
	leaq	-144(%rbp), %rax
	movl	$127, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L5
	movl	$1, %eax
	jmp	.L14
.L5:
	leaq	-144(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -152(%rbp)
	movq	-152(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -164(%rbp)
	leaq	-144(%rbp), %rax
	movl	$128, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movq	stdin(%rip), %rdx
	leaq	-144(%rbp), %rax
	movl	$127, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L6
	movl	$1, %eax
	jmp	.L14
.L6:
	leaq	-144(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -152(%rbp)
	movq	-152(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -160(%rbp)
	movl	$0, -188(%rbp)
	movl	$0, -184(%rbp)
	jmp	.L7
.L13:
	movl	$0, -180(%rbp)
	jmp	.L8
.L12:
	movl	$0, -176(%rbp)
	jmp	.L9
.L11:
	movl	-184(%rbp), %eax
	imull	$500, %eax, %edx
	movl	-180(%rbp), %eax
	imull	$100, %eax, %eax
	addl	%eax, %edx
	movl	-176(%rbp), %eax
	imull	$50, %eax, %eax
	addl	%edx, %eax
	movl	%eax, -156(%rbp)
	movl	-156(%rbp), %eax
	cmpl	-160(%rbp), %eax
	jne	.L10
	addl	$1, -188(%rbp)
.L10:
	addl	$1, -176(%rbp)
.L9:
	movl	-164(%rbp), %eax
	cmpl	-176(%rbp), %eax
	jge	.L11
	addl	$1, -180(%rbp)
.L8:
	movl	-168(%rbp), %eax
	cmpl	-180(%rbp), %eax
	jge	.L12
	addl	$1, -184(%rbp)
.L7:
	movl	-172(%rbp), %eax
	cmpl	-184(%rbp), %eax
	jge	.L13
	movl	-188(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L14:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	" "
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pxor	%xmm0, %xmm0
	movl	$127, %esi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$168, %rsp
	.cfi_def_cfa_offset 224
	movq	stdin(%rip), %rdx
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %r13
	movaps	%xmm0, 16(%rsp)
	movq	%r13, %rdi
	movaps	%xmm0, 32(%rsp)
	movaps	%xmm0, 48(%rsp)
	movaps	%xmm0, 64(%rsp)
	movaps	%xmm0, 80(%rsp)
	movaps	%xmm0, 96(%rsp)
	movaps	%xmm0, 112(%rsp)
	movaps	%xmm0, 128(%rsp)
	call	fgets@PLT
	testq	%rax, %rax
	je	.L4
	xorl	%esi, %esi
	movl	$10, %edx
	movq	%r13, %rdi
	call	strtol@PLT
	movl	$16, %ecx
	movq	%r13, %rdi
	movq	stdin(%rip), %rdx
	movq	%rax, %r12
	xorl	%eax, %eax
	movl	$127, %esi
	rep stosq
	movq	%r13, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L4
	leaq	.LC1(%rip), %r15
	movq	%r13, %rdi
	xorl	%r14d, %r14d
	movq	%r15, %rsi
	call	strtok@PLT
	xorl	%esi, %esi
	movl	$10, %edx
	movq	%rax, %rdi
	call	strtol@PLT
	movl	$32, %ecx
	movq	%r13, %rdi
	movq	stdin(%rip), %rdx
	movq	%rax, %rbx
	movl	%r14d, %eax
	movl	$127, %esi
	rep stosl
	movq	%r13, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L4
	movq	%r15, %rsi
	movq	%r13, %rdi
	call	strtok@PLT
	xorl	%esi, %esi
	movl	$10, %edx
	movq	%rax, %rdi
	call	strtol@PLT
	movl	$32, %ecx
	movq	%r13, %rdi
	movq	stdin(%rip), %rdx
	movq	%rax, %rbp
	movl	%r14d, %eax
	movl	$127, %esi
	rep stosl
	movq	%r13, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L4
	movq	%r15, %rsi
	movq	%r13, %rdi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, %r9d
	testl	%r12d, %r12d
	js	.L23
	leal	1(%r12), %eax
	movl	%ebp, %r8d
	movl	%ebp, %r12d
	movl	%ebx, 8(%rsp)
	addl	$1, %ebp
	movl	%eax, 12(%rsp)
	movd	%r9d, %xmm7
	xorl	%r13d, %r13d
	movl	%ebp, %esi
	movl	%ebp, %r11d
	movdqa	.LC2(%rip), %xmm5
	xorl	%edx, %edx
	shrl	$2, %esi
	leal	1(%rbx), %r15d
	pshufd	$0, %xmm7, %xmm6
	andl	$-4, %r11d
	.p2align 4,,10
	.p2align 3
.L6:
	movl	8(%rsp), %eax
	testl	%eax, %eax
	js	.L18
	movl	%r14d, %eax
	xorl	%r10d, %r10d
	.p2align 4,,10
	.p2align 3
.L21:
	testl	%r8d, %r8d
	js	.L20
	cmpl	$6, %r12d
	jbe	.L24
	movd	%eax, %xmm7
	movdqa	.LC0(%rip), %xmm3
	xorl	%ecx, %ecx
	pxor	%xmm2, %xmm2
	pshufd	$0, %xmm7, %xmm4
	.p2align 4,,10
	.p2align 3
.L8:
	movdqa	%xmm3, %xmm1
	addl	$1, %ecx
	paddd	%xmm5, %xmm3
	movdqa	%xmm1, %xmm0
	pslld	$1, %xmm0
	paddd	%xmm1, %xmm0
	pslld	$3, %xmm0
	paddd	%xmm1, %xmm0
	pslld	$1, %xmm0
	paddd	%xmm4, %xmm0
	pcmpeqd	%xmm6, %xmm0
	psubd	%xmm0, %xmm2
	cmpl	%ecx, %esi
	jne	.L8
	movdqa	%xmm2, %xmm0
	psrldq	$8, %xmm0
	paddd	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %ecx
	addl	%ecx, %edx
	movl	%r11d, %ecx
	cmpl	%r11d, %ebp
	je	.L20
.L7:
	imull	$50, %ecx, %edi
	leal	(%rax,%rdi), %ebx
	cmpl	%r9d, %ebx
	sete	%bl
	movzbl	%bl, %ebx
	addl	%ebx, %edx
	leal	1(%rcx), %ebx
	cmpl	%r8d, %ebx
	jg	.L20
	leal	50(%rdi,%rax), %ebx
	cmpl	%ebx, %r9d
	sete	%bl
	movzbl	%bl, %ebx
	addl	%ebx, %edx
	leal	2(%rcx), %ebx
	cmpl	%ebx, %r8d
	jl	.L20
	leal	100(%rdi,%rax), %ebx
	cmpl	%ebx, %r9d
	sete	%bl
	movzbl	%bl, %ebx
	addl	%ebx, %edx
	leal	3(%rcx), %ebx
	cmpl	%ebx, %r8d
	jl	.L20
	leal	150(%rdi,%rax), %ebx
	cmpl	%ebx, %r9d
	sete	%bl
	movzbl	%bl, %ebx
	addl	%ebx, %edx
	leal	4(%rcx), %ebx
	cmpl	%ebx, %r8d
	jl	.L20
	leal	200(%rdi,%rax), %ebx
	cmpl	%ebx, %r9d
	sete	%bl
	movzbl	%bl, %ebx
	addl	%ebx, %edx
	leal	5(%rcx), %ebx
	cmpl	%ebx, %r8d
	jl	.L20
	leal	250(%rdi,%rax), %ebx
	cmpl	%ebx, %r9d
	sete	%bl
	addl	$6, %ecx
	movzbl	%bl, %ebx
	addl	%ebx, %edx
	cmpl	%ecx, %r8d
	jl	.L20
	leal	300(%rdi,%rax), %ecx
	cmpl	%ecx, %r9d
	sete	%cl
	movzbl	%cl, %ecx
	addl	%ecx, %edx
.L20:
	addl	$1, %r10d
	addl	$100, %eax
	cmpl	%r15d, %r10d
	jne	.L21
.L18:
	addl	$1, %r13d
	addl	$500, %r14d
	cmpl	12(%rsp), %r13d
	jne	.L6
.L5:
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	jmp	.L1
.L4:
	movl	$1, %eax
.L1:
	movq	152(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L39
	addq	$168, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L24:
	.cfi_restore_state
	xorl	%ecx, %ecx
	jmp	.L7
.L23:
	xorl	%edx, %edx
	jmp	.L5
.L39:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC2:
	.long	4
	.long	4
	.long	4
	.long	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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	" "
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pxor	%xmm0, %xmm0
	movl	$127, %esi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$168, %rsp
	.cfi_def_cfa_offset 224
	movq	stdin(%rip), %rdx
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %r13
	movaps	%xmm0, 16(%rsp)
	movq	%r13, %rdi
	movaps	%xmm0, 32(%rsp)
	movaps	%xmm0, 48(%rsp)
	movaps	%xmm0, 64(%rsp)
	movaps	%xmm0, 80(%rsp)
	movaps	%xmm0, 96(%rsp)
	movaps	%xmm0, 112(%rsp)
	movaps	%xmm0, 128(%rsp)
	call	fgets@PLT
	testq	%rax, %rax
	je	.L4
	xorl	%esi, %esi
	movl	$10, %edx
	movq	%r13, %rdi
	call	strtol@PLT
	movl	$16, %ecx
	movq	%r13, %rdi
	movq	stdin(%rip), %rdx
	movq	%rax, %r12
	xorl	%eax, %eax
	movl	$127, %esi
	rep stosq
	movq	%r13, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L4
	leaq	.LC1(%rip), %r15
	movq	%r13, %rdi
	xorl	%r14d, %r14d
	movq	%r15, %rsi
	call	strtok@PLT
	xorl	%esi, %esi
	movl	$10, %edx
	movq	%rax, %rdi
	call	strtol@PLT
	movl	$32, %ecx
	movq	%r13, %rdi
	movq	stdin(%rip), %rdx
	movq	%rax, %rbx
	movl	%r14d, %eax
	movl	$127, %esi
	rep stosl
	movq	%r13, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L4
	movq	%r15, %rsi
	movq	%r13, %rdi
	call	strtok@PLT
	xorl	%esi, %esi
	movl	$10, %edx
	movq	%rax, %rdi
	call	strtol@PLT
	movl	$32, %ecx
	movq	%r13, %rdi
	movq	stdin(%rip), %rdx
	movq	%rax, %rbp
	movl	%r14d, %eax
	movl	$127, %esi
	rep stosl
	movq	%r13, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L4
	movq	%r15, %rsi
	movq	%r13, %rdi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, %r9d
	testl	%r12d, %r12d
	js	.L23
	leal	1(%r12), %eax
	movl	%ebp, %r8d
	movl	%ebp, %r12d
	movl	%ebx, 8(%rsp)
	addl	$1, %ebp
	movl	%eax, 12(%rsp)
	movd	%r9d, %xmm7
	xorl	%r13d, %r13d
	movl	%ebp, %esi
	movl	%ebp, %r11d
	movdqa	.LC2(%rip), %xmm5
	xorl	%edx, %edx
	shrl	$2, %esi
	leal	1(%rbx), %r15d
	pshufd	$0, %xmm7, %xmm6
	andl	$-4, %r11d
	.p2align 4,,10
	.p2align 3
.L6:
	movl	8(%rsp), %eax
	testl	%eax, %eax
	js	.L18
	movl	%r14d, %eax
	xorl	%r10d, %r10d
	.p2align 4,,10
	.p2align 3
.L21:
	testl	%r8d, %r8d
	js	.L20
	cmpl	$6, %r12d
	jbe	.L24
	movd	%eax, %xmm7
	movdqa	.LC0(%rip), %xmm3
	xorl	%ecx, %ecx
	pxor	%xmm2, %xmm2
	pshufd	$0, %xmm7, %xmm4
	.p2align 4,,10
	.p2align 3
.L8:
	movdqa	%xmm3, %xmm1
	addl	$1, %ecx
	paddd	%xmm5, %xmm3
	movdqa	%xmm1, %xmm0
	pslld	$1, %xmm0
	paddd	%xmm1, %xmm0
	pslld	$3, %xmm0
	paddd	%xmm1, %xmm0
	pslld	$1, %xmm0
	paddd	%xmm4, %xmm0
	pcmpeqd	%xmm6, %xmm0
	psubd	%xmm0, %xmm2
	cmpl	%ecx, %esi
	jne	.L8
	movdqa	%xmm2, %xmm0
	psrldq	$8, %xmm0
	paddd	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %ecx
	addl	%ecx, %edx
	movl	%r11d, %ecx
	cmpl	%r11d, %ebp
	je	.L20
.L7:
	imull	$50, %ecx, %edi
	leal	(%rax,%rdi), %ebx
	cmpl	%r9d, %ebx
	sete	%bl
	movzbl	%bl, %ebx
	addl	%ebx, %edx
	leal	1(%rcx), %ebx
	cmpl	%r8d, %ebx
	jg	.L20
	leal	50(%rdi,%rax), %ebx
	cmpl	%ebx, %r9d
	sete	%bl
	movzbl	%bl, %ebx
	addl	%ebx, %edx
	leal	2(%rcx), %ebx
	cmpl	%ebx, %r8d
	jl	.L20
	leal	100(%rdi,%rax), %ebx
	cmpl	%ebx, %r9d
	sete	%bl
	movzbl	%bl, %ebx
	addl	%ebx, %edx
	leal	3(%rcx), %ebx
	cmpl	%ebx, %r8d
	jl	.L20
	leal	150(%rdi,%rax), %ebx
	cmpl	%ebx, %r9d
	sete	%bl
	movzbl	%bl, %ebx
	addl	%ebx, %edx
	leal	4(%rcx), %ebx
	cmpl	%ebx, %r8d
	jl	.L20
	leal	200(%rdi,%rax), %ebx
	cmpl	%ebx, %r9d
	sete	%bl
	movzbl	%bl, %ebx
	addl	%ebx, %edx
	leal	5(%rcx), %ebx
	cmpl	%ebx, %r8d
	jl	.L20
	leal	250(%rdi,%rax), %ebx
	cmpl	%ebx, %r9d
	sete	%bl
	addl	$6, %ecx
	movzbl	%bl, %ebx
	addl	%ebx, %edx
	cmpl	%ecx, %r8d
	jl	.L20
	leal	300(%rdi,%rax), %ecx
	cmpl	%ecx, %r9d
	sete	%cl
	movzbl	%cl, %ecx
	addl	%ecx, %edx
.L20:
	addl	$1, %r10d
	addl	$100, %eax
	cmpl	%r15d, %r10d
	jne	.L21
.L18:
	addl	$1, %r13d
	addl	$500, %r14d
	cmpl	12(%rsp), %r13d
	jne	.L6
.L5:
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	jmp	.L1
.L4:
	movl	$1, %eax
.L1:
	movq	152(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L39
	addq	$168, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L24:
	.cfi_restore_state
	xorl	%ecx, %ecx
	jmp	.L7
.L23:
	xorl	%edx, %edx
	jmp	.L5
.L39:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC2:
	.long	4
	.long	4
	.long	4
	.long	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:

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


int main(int argc, char* argv[]){
        char buf[128]={0};
        char* p=NULL;
        int a = 0;
        int b = 0;
        int c = 0;
        int x = 0;

        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        a = atoi(buf);

        memset(buf, 0, sizeof(buf));
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        b = atoi(p);

        memset(buf, 0, sizeof(buf));
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        c = atoi(p);

        memset(buf, 0, sizeof(buf));
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        x = atoi(p);

#ifdef DEBUG1
        printf("input: a=%d, b=%d, c=%d, x=%d\n", a, b, c, x);
#endif
        int ans=0;

        for(int i=0; i<a+1; i++){
                for(int j=0; j<b+1; j++){
                        for(int k=0; k<c+1; k++){
                                int v = 500*i+100*j+50*k;
                                if(v==x){ans++;}
                        }
                }
        }

        printf("%d\n", ans);
        return 0;
}
2
2
4
100
 30
40
77
6000
 5
0
0
150
 30
47
77
6000
 5
0
0
0
 2
2
5
100
 2
2
10
100
 30
47
77
10696
 5
0
1
0
 2
0
10
100

2
 293
 0
 319
 1
 2
 2
 0
 1
 1

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

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


int main(int argc, char* argv[]){
        char buf[128]={0};
        char* p=NULL;
        int a = 0;
        int b = 0;
        int c = 0;
        int x = 0;

        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        a = atoi(buf);

        memset(buf, 0, sizeof(buf));
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        b = atoi(p);

        memset(buf, 0, sizeof(buf));
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        c = atoi(p);

        memset(buf, 0, sizeof(buf));
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        x = atoi(p);

#ifdef DEBUG1
        printf("input: a=%d, b=%d, c=%d, x=%d\n", a, b, c, x);
#endif
        int ans=0;

        for(int i=0; i<a+1; i++){
                for(int j=0; j<b+1; j++){
                        for(int k=0; k<c+1; k++){
                                int v = 500*i+100*j+50*k;
                                if(v==x){ans++;}
                        }
                }
        }

        printf("%d\n", ans);
        return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	" "
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$208, %rsp
	movl	%edi, -196(%rbp)
	movq	%rsi, -208(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -144(%rbp)
	movq	$0, -136(%rbp)
	movq	$0, -128(%rbp)
	movq	$0, -120(%rbp)
	movq	$0, -112(%rbp)
	movq	$0, -104(%rbp)
	movq	$0, -96(%rbp)
	movq	$0, -88(%rbp)
	movq	$0, -80(%rbp)
	movq	$0, -72(%rbp)
	movq	$0, -64(%rbp)
	movq	$0, -56(%rbp)
	movq	$0, -48(%rbp)
	movq	$0, -40(%rbp)
	movq	$0, -32(%rbp)
	movq	$0, -24(%rbp)
	movq	$0, -152(%rbp)
	movl	$0, -172(%rbp)
	movl	$0, -168(%rbp)
	movl	$0, -164(%rbp)
	movl	$0, -160(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-144(%rbp), %rax
	movl	$127, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$1, %eax
	jmp	.L14
.L2:
	leaq	-144(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -172(%rbp)
	leaq	-144(%rbp), %rax
	movl	$128, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movq	stdin(%rip), %rdx
	leaq	-144(%rbp), %rax
	movl	$127, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L4
	movl	$1, %eax
	jmp	.L14
.L4:
	leaq	-144(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -152(%rbp)
	movq	-152(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -168(%rbp)
	leaq	-144(%rbp), %rax
	movl	$128, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movq	stdin(%rip), %rdx
	leaq	-144(%rbp), %rax
	movl	$127, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L5
	movl	$1, %eax
	jmp	.L14
.L5:
	leaq	-144(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -152(%rbp)
	movq	-152(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -164(%rbp)
	leaq	-144(%rbp), %rax
	movl	$128, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movq	stdin(%rip), %rdx
	leaq	-144(%rbp), %rax
	movl	$127, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L6
	movl	$1, %eax
	jmp	.L14
.L6:
	leaq	-144(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -152(%rbp)
	movq	-152(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -160(%rbp)
	movl	$0, -188(%rbp)
	movl	$0, -184(%rbp)
	jmp	.L7
.L13:
	movl	$0, -180(%rbp)
	jmp	.L8
.L12:
	movl	$0, -176(%rbp)
	jmp	.L9
.L11:
	movl	-184(%rbp), %eax
	imull	$500, %eax, %edx
	movl	-180(%rbp), %eax
	imull	$100, %eax, %eax
	addl	%eax, %edx
	movl	-176(%rbp), %eax
	imull	$50, %eax, %eax
	addl	%edx, %eax
	movl	%eax, -156(%rbp)
	movl	-156(%rbp), %eax
	cmpl	-160(%rbp), %eax
	jne	.L10
	addl	$1, -188(%rbp)
.L10:
	addl	$1, -176(%rbp)
.L9:
	movl	-164(%rbp), %eax
	cmpl	-176(%rbp), %eax
	jge	.L11
	addl	$1, -180(%rbp)
.L8:
	movl	-168(%rbp), %eax
	cmpl	-180(%rbp), %eax
	jge	.L12
	addl	$1, -184(%rbp)
.L7:
	movl	-172(%rbp), %eax
	cmpl	-184(%rbp), %eax
	jge	.L13
	movl	-188(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L14:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	" "
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$208, %rsp
	movl	%edi, -196(%rbp)
	movq	%rsi, -208(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -144(%rbp)
	movq	$0, -136(%rbp)
	movq	$0, -128(%rbp)
	movq	$0, -120(%rbp)
	movq	$0, -112(%rbp)
	movq	$0, -104(%rbp)
	movq	$0, -96(%rbp)
	movq	$0, -88(%rbp)
	movq	$0, -80(%rbp)
	movq	$0, -72(%rbp)
	movq	$0, -64(%rbp)
	movq	$0, -56(%rbp)
	movq	$0, -48(%rbp)
	movq	$0, -40(%rbp)
	movq	$0, -32(%rbp)
	movq	$0, -24(%rbp)
	movq	$0, -152(%rbp)
	movl	$0, -172(%rbp)
	movl	$0, -168(%rbp)
	movl	$0, -164(%rbp)
	movl	$0, -160(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-144(%rbp), %rax
	movl	$127, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$1, %eax
	jmp	.L14
.L2:
	leaq	-144(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -172(%rbp)
	leaq	-144(%rbp), %rax
	movl	$128, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movq	stdin(%rip), %rdx
	leaq	-144(%rbp), %rax
	movl	$127, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L4
	movl	$1, %eax
	jmp	.L14
.L4:
	leaq	-144(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -152(%rbp)
	movq	-152(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -168(%rbp)
	leaq	-144(%rbp), %rax
	movl	$128, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movq	stdin(%rip), %rdx
	leaq	-144(%rbp), %rax
	movl	$127, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L5
	movl	$1, %eax
	jmp	.L14
.L5:
	leaq	-144(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -152(%rbp)
	movq	-152(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -164(%rbp)
	leaq	-144(%rbp), %rax
	movl	$128, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movq	stdin(%rip), %rdx
	leaq	-144(%rbp), %rax
	movl	$127, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L6
	movl	$1, %eax
	jmp	.L14
.L6:
	leaq	-144(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -152(%rbp)
	movq	-152(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -160(%rbp)
	movl	$0, -188(%rbp)
	movl	$0, -184(%rbp)
	jmp	.L7
.L13:
	movl	$0, -180(%rbp)
	jmp	.L8
.L12:
	movl	$0, -176(%rbp)
	jmp	.L9
.L11:
	movl	-184(%rbp), %eax
	imull	$500, %eax, %edx
	movl	-180(%rbp), %eax
	imull	$100, %eax, %eax
	addl	%eax, %edx
	movl	-176(%rbp), %eax
	imull	$50, %eax, %eax
	addl	%edx, %eax
	movl	%eax, -156(%rbp)
	movl	-156(%rbp), %eax
	cmpl	-160(%rbp), %eax
	jne	.L10
	addl	$1, -188(%rbp)
.L10:
	addl	$1, -176(%rbp)
.L9:
	movl	-164(%rbp), %eax
	cmpl	-176(%rbp), %eax
	jge	.L11
	addl	$1, -180(%rbp)
.L8:
	movl	-168(%rbp), %eax
	cmpl	-180(%rbp), %eax
	jge	.L12
	addl	$1, -184(%rbp)
.L7:
	movl	-172(%rbp), %eax
	cmpl	-184(%rbp), %eax
	jge	.L13
	movl	-188(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L14:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
