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>
 
int main (void){
    int score, bscore = -1, a_c;
    int h;
    int i, j, before;
    int del = -1;
    int f, e;
    while(1)
    {
        score = 0;
        bscore = -1;
        scanf("%d", &h);
        int a[h][5];
        if (h == 0) break;
        for (i = 0; i < h; i++) {
            a_c = 0;
            for (j = 0; j < 5; j++) {
                scanf("%d", &a[i][j]);
            }
        }
        while (score != bscore) {
            bscore = score;
            for (i = 0; i < h; i++){
                a_c = 0;
                del = -1;
                for (j = 0; j < 5; j++) 
                {
                    //printf("%d ", a_c);
                    if (j == 0) {
                        before = a[i][j];
                        a_c++;
                        f = j;
                    } else if (before == a[i][j]) {
                        a_c++;
                        //printf("%d ", a_c);
                    } else {
                        if (a_c >= 3 && before != -1) {
                            score += before * a_c;
                            del = before;
                            e = j;
                        }
                        a_c = 1;
                        before = a[i][j];
                        if(j <= 2){
                        	f = j;
                        }
                    }
                    if(j == 4) {
                        if (a_c >= 3 && before != -1) {
                            score += before * a_c;
                            del = before;
                            e = j;
                        }
                        a_c = 0;
                    }
                }
                for (j = 0; j < 5; j++) {
                    if(a[i][j]==del && j >= f && j <= e){
                        a[i][j]=-1;
                    }
                }
 
            }
 
 
 
/*
            printf("\n");
            for (i = 0; i < h; i++){
                for (j = 0; j < 5; j++) {
                    printf("%d ", a[i][j]);
                }
                printf("\n");
            }
*/
 
 
            int flag = 0, i_;
                for(j = 0; j < 5; j++){
                    flag = 0;
                    for(i = h-1; i >= 0; i--){
                        if(a[i][j] == -1){
                            int k = i - 1;
                            while(k >= 0){
                                if(a[k][j] != -1){
                                    a[i][j] = a[k][j];
                                    a[k][j] = -1;
                                    break;
                                }
                                k--;
                            }
                        }
                    }
                }
 
/*
            printf("\n");
            for (i = 0; i < h; i++){
                for (j = 0; j < 5; j++) {
                    printf("%d ", a[i][j]);
                }
                printf("\n");
            }
*/
 
        }
        printf("%d\n", score);
    }
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movl	$-1, -112(%rbp)
	movl	$-1, -92(%rbp)
.L34:
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -116(%rbp)
	movl	$-1, -112(%rbp)
	leaq	-120(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-120(%rbp), %ecx
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movslq	%ecx, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	imulq	$160, %r13, %rdx
	imulq	$0, %r12, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$160, %eax
	mulq	%r12
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	imulq	$160, %r15, %rdx
	imulq	$0, %r14, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$160, %eax
	mulq	%r14
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	-120(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	jmp	.L36
.L5:
	movl	$0, -104(%rbp)
	jmp	.L7
.L10:
	movl	$0, -108(%rbp)
	movl	$0, -100(%rbp)
	jmp	.L8
.L9:
	movl	-100(%rbp), %eax
	movslq	%eax, %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -100(%rbp)
.L8:
	cmpl	$4, -100(%rbp)
	jle	.L9
	addl	$1, -104(%rbp)
.L7:
	movl	-120(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L10
	jmp	.L11
.L33:
	movl	-116(%rbp), %eax
	movl	%eax, -112(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L12
.L24:
	movl	$0, -108(%rbp)
	movl	$-1, -92(%rbp)
	movl	$0, -100(%rbp)
	jmp	.L13
.L20:
	cmpl	$0, -100(%rbp)
	jne	.L14
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	movl	%eax, -96(%rbp)
	addl	$1, -108(%rbp)
	movl	-100(%rbp), %eax
	movl	%eax, -88(%rbp)
	jmp	.L15
.L14:
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	cmpl	%eax, -96(%rbp)
	jne	.L16
	addl	$1, -108(%rbp)
	jmp	.L15
.L16:
	cmpl	$2, -108(%rbp)
	jle	.L17
	cmpl	$-1, -96(%rbp)
	je	.L17
	movl	-96(%rbp), %eax
	imull	-108(%rbp), %eax
	addl	%eax, -116(%rbp)
	movl	-96(%rbp), %eax
	movl	%eax, -92(%rbp)
	movl	-100(%rbp), %eax
	movl	%eax, -84(%rbp)
.L17:
	movl	$1, -108(%rbp)
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	movl	%eax, -96(%rbp)
	cmpl	$2, -100(%rbp)
	jg	.L15
	movl	-100(%rbp), %eax
	movl	%eax, -88(%rbp)
.L15:
	cmpl	$4, -100(%rbp)
	jne	.L18
	cmpl	$2, -108(%rbp)
	jle	.L19
	cmpl	$-1, -96(%rbp)
	je	.L19
	movl	-96(%rbp), %eax
	imull	-108(%rbp), %eax
	addl	%eax, -116(%rbp)
	movl	-96(%rbp), %eax
	movl	%eax, -92(%rbp)
	movl	-100(%rbp), %eax
	movl	%eax, -84(%rbp)
.L19:
	movl	$0, -108(%rbp)
.L18:
	addl	$1, -100(%rbp)
.L13:
	cmpl	$4, -100(%rbp)
	jle	.L20
	movl	$0, -100(%rbp)
	jmp	.L21
.L23:
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	cmpl	%eax, -92(%rbp)
	jne	.L22
	movl	-100(%rbp), %eax
	cmpl	-88(%rbp), %eax
	jl	.L22
	movl	-100(%rbp), %eax
	cmpl	-84(%rbp), %eax
	jg	.L22
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	$-1, (%rdx,%rax,4)
.L22:
	addl	$1, -100(%rbp)
.L21:
	cmpl	$4, -100(%rbp)
	jle	.L23
	addl	$1, -104(%rbp)
.L12:
	movl	-120(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L24
	movl	$0, -76(%rbp)
	movl	$0, -100(%rbp)
	jmp	.L25
.L32:
	movl	$0, -76(%rbp)
	movl	-120(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -104(%rbp)
	jmp	.L26
.L31:
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L27
	movl	-104(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -80(%rbp)
	jmp	.L28
.L30:
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-80(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	cmpl	$-1, %eax
	je	.L29
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-80(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %ecx
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rdi
	movl	-104(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	addq	%rdi, %rax
	movl	%ecx, (%rdx,%rax,4)
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-80(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	$-1, (%rdx,%rax,4)
	jmp	.L27
.L29:
	subl	$1, -80(%rbp)
.L28:
	cmpl	$0, -80(%rbp)
	jns	.L30
.L27:
	subl	$1, -104(%rbp)
.L26:
	cmpl	$0, -104(%rbp)
	jns	.L31
	addl	$1, -100(%rbp)
.L25:
	cmpl	$4, -100(%rbp)
	jle	.L32
.L11:
	movl	-116(%rbp), %eax
	cmpl	-112(%rbp), %eax
	jne	.L33
	movl	-116(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	%rbx, %rsp
	jmp	.L34
.L36:
	call	__stack_chk_fail@PLT
.L35:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	movl	%edi, %r13d
	pushq	%r12
	pushq	%rbx
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	leaq	.LC0(%rip), %rbx
	subq	$72, %rsp
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	leaq	-60(%rbp), %rax
	movq	%rax, -104(%rbp)
.L34:
	movq	-104(%rbp), %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	movq	%rsp, -96(%rbp)
	call	__isoc99_scanf@PLT
	movslq	-60(%rbp), %rax
	movq	%rsp, %rcx
	movl	%eax, -76(%rbp)
	leaq	(%rax,%rax,4), %rax
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L80:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L80
.L3:
	movq	%rdx, %rax
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L4
	orq	$0, -8(%rsp,%rax)
.L4:
	movl	-76(%rbp), %ecx
	movq	%rsp, %r15
	testl	%ecx, %ecx
	je	.L5
	leaq	20(%r15), %rax
	movq	%rax, -72(%rbp)
	jle	.L81
	movl	%r13d, -88(%rbp)
	movq	%rax, %r12
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L8:
	leaq	-20(%r12), %r13
.L7:
	movq	%r13, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addq	$4, %r13
	call	__isoc99_scanf@PLT
	cmpq	%r13, %r12
	jne	.L7
	movl	-60(%rbp), %eax
	addq	$1, %r14
	addq	$20, %r12
	cmpl	%r14d, %eax
	jg	.L8
	movl	%eax, -76(%rbp)
	movl	-88(%rbp), %r13d
.L6:
	movq	-72(%rbp), %rdi
	subl	$1, %eax
	movl	-76(%rbp), %edx
	movl	$0, -72(%rbp)
	movq	%rax, %r9
	leaq	(%rax,%rax,4), %rax
	movl	-72(%rbp), %r8d
	leaq	(%rdi,%rax,4), %r10
	movslq	%r9d, %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%r15,%rax,4), %rax
	movq	%rax, -88(%rbp)
	movq	%r15, %rax
	testl	%edx, %edx
	jg	.L32
	jmp	.L82
	.p2align 4,,10
	.p2align 3
.L10:
	cmpl	%ecx, %edx
	je	.L83
.L12:
	cmpl	%ecx, %edi
	je	.L84
.L14:
	cmpl	%ecx, %r11d
	je	.L85
.L36:
	cmpl	%ecx, %r12d
	je	.L86
.L15:
	addq	$20, %rax
	cmpq	%r10, %rax
	je	.L16
.L32:
	movl	(%rax), %esi
	movl	4(%rax), %edx
	xorl	%ecx, %ecx
	movl	8(%rax), %edi
	movl	12(%rax), %r11d
	cmpl	%edx, %esi
	movl	16(%rax), %r12d
	sete	%cl
	xorl	%r14d, %r14d
	addl	$2, %ecx
	cmpl	%edx, %esi
	setne	%r14b
	cmpl	%edi, %edx
	je	.L87
	movl	$2, %r14d
	cmpl	%edi, %r11d
	jne	.L44
	movl	$1, %ecx
	cmpl	%r11d, %r12d
	jne	.L44
.L21:
	addl	$2, %ecx
	cmpl	$-1, %r12d
	je	.L44
	imull	%r12d, %ecx
	movl	$4, %r13d
	addl	%ecx, %r8d
	movl	%r12d, %ecx
	.p2align 4,,10
	.p2align 3
.L22:
	cmpl	%ecx, %esi
	jne	.L10
	testl	%r14d, %r14d
	jne	.L10
	movl	$-1, (%rax)
	cmpl	%ecx, %edx
	jne	.L12
	movl	$-1, 4(%rax)
.L88:
	cmpl	%ecx, %edi
	jne	.L14
	.p2align 4,,10
	.p2align 3
.L84:
	movl	$-1, 8(%rax)
	cmpl	%ecx, %r11d
	jne	.L36
	.p2align 4,,10
	.p2align 3
.L85:
	movl	$-1, 12(%rax)
	cmpl	%ecx, %r12d
	jne	.L15
	.p2align 4,,10
	.p2align 3
.L86:
	cmpl	$4, %r13d
	jne	.L15
	movl	$-1, 16(%rax)
	addq	$20, %rax
	cmpq	%r10, %rax
	jne	.L32
	.p2align 4,,10
	.p2align 3
.L16:
	testl	%r9d, %r9d
	js	.L24
.L39:
	movq	-88(%rbp), %r12
	xorl	%r11d, %r11d
.L30:
	movq	%r12, %rsi
	movl	%r9d, %ecx
	movslq	%r11d, %rdi
	jmp	.L38
	.p2align 4,,10
	.p2align 3
.L25:
	testl	%ecx, %ecx
	js	.L26
.L28:
	subq	$20, %rsi
.L38:
	subl	$1, %ecx
	cmpl	$-1, (%rsi)
	jne	.L25
	cmpl	$-1, %ecx
	je	.L26
	movq	%rsi, %rdx
	movl	%ecx, %eax
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L27:
	subl	$1, %eax
	subq	$20, %rdx
	cmpl	$-1, %eax
	je	.L28
.L29:
	movl	-20(%rdx), %r14d
	cmpl	$-1, %r14d
	je	.L27
	cltq
	movl	%r14d, (%rsi)
	leaq	(%rax,%rax,4), %rax
	addq	%rdi, %rax
	movl	$-1, (%r15,%rax,4)
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L87:
	cmpl	%r11d, %edx
	je	.L19
	cmpl	$2, %ecx
	jle	.L44
	cmpl	$-1, %edx
	je	.L44
	leal	(%rdx,%rdx,2), %ecx
	movl	$3, %r13d
	addl	%ecx, %r8d
	movl	%edx, %ecx
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L83:
	cmpl	$2, %r14d
	je	.L12
	movl	$-1, 4(%rax)
	jmp	.L88
	.p2align 4,,10
	.p2align 3
.L44:
	movl	$-1, %ecx
	jmp	.L22
.L19:
	cmpl	%edx, %r12d
	je	.L21
	addl	$1, %ecx
	cmpl	$2, %ecx
	jle	.L44
	cmpl	$-1, %edx
	je	.L44
	imull	%edx, %ecx
	movl	$4, %r13d
	addl	%ecx, %r8d
	movl	%edx, %ecx
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L26:
	addq	$1, %r11
	addq	$4, %r12
	cmpq	$5, %r11
	jne	.L30
.L24:
	cmpl	%r8d, -72(%rbp)
	je	.L31
	movl	-76(%rbp), %edx
	movl	%r8d, -72(%rbp)
	movq	%r15, %rax
	testl	%edx, %edx
	jg	.L32
.L82:
	testl	%r9d, %r9d
	jns	.L39
.L31:
	movl	%r8d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	-96(%rbp), %rsp
	jmp	.L34
.L5:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L89
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L81:
	.cfi_restore_state
	movl	-76(%rbp), %eax
	jmp	.L6
.L89:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	movl	%edi, %r13d
	pushq	%r12
	pushq	%rbx
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	leaq	.LC0(%rip), %rbx
	subq	$72, %rsp
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	leaq	-60(%rbp), %rax
	movq	%rax, -104(%rbp)
.L34:
	movq	-104(%rbp), %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	movq	%rsp, -96(%rbp)
	call	__isoc99_scanf@PLT
	movslq	-60(%rbp), %rax
	movq	%rsp, %rcx
	movl	%eax, -76(%rbp)
	leaq	(%rax,%rax,4), %rax
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rcx
	andq	$-16, %rdx
	cmpq	%rcx, %rsp
	je	.L3
.L80:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rcx, %rsp
	jne	.L80
.L3:
	movq	%rdx, %rax
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L4
	orq	$0, -8(%rsp,%rax)
.L4:
	movl	-76(%rbp), %ecx
	movq	%rsp, %r15
	testl	%ecx, %ecx
	je	.L5
	leaq	20(%r15), %rax
	movq	%rax, -72(%rbp)
	jle	.L81
	movl	%r13d, -88(%rbp)
	movq	%rax, %r12
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L8:
	leaq	-20(%r12), %r13
.L7:
	movq	%r13, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addq	$4, %r13
	call	__isoc99_scanf@PLT
	cmpq	%r13, %r12
	jne	.L7
	movl	-60(%rbp), %eax
	addq	$1, %r14
	addq	$20, %r12
	cmpl	%r14d, %eax
	jg	.L8
	movl	%eax, -76(%rbp)
	movl	-88(%rbp), %r13d
.L6:
	movq	-72(%rbp), %rdi
	subl	$1, %eax
	movl	-76(%rbp), %edx
	movl	$0, -72(%rbp)
	movq	%rax, %r9
	leaq	(%rax,%rax,4), %rax
	movl	-72(%rbp), %r8d
	leaq	(%rdi,%rax,4), %r10
	movslq	%r9d, %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%r15,%rax,4), %rax
	movq	%rax, -88(%rbp)
	movq	%r15, %rax
	testl	%edx, %edx
	jg	.L32
	jmp	.L82
	.p2align 4,,10
	.p2align 3
.L10:
	cmpl	%ecx, %edx
	je	.L83
.L12:
	cmpl	%ecx, %edi
	je	.L84
.L14:
	cmpl	%ecx, %r11d
	je	.L85
.L36:
	cmpl	%ecx, %r12d
	je	.L86
.L15:
	addq	$20, %rax
	cmpq	%r10, %rax
	je	.L16
.L32:
	movl	(%rax), %esi
	movl	4(%rax), %edx
	xorl	%ecx, %ecx
	movl	8(%rax), %edi
	movl	12(%rax), %r11d
	cmpl	%edx, %esi
	movl	16(%rax), %r12d
	sete	%cl
	xorl	%r14d, %r14d
	addl	$2, %ecx
	cmpl	%edx, %esi
	setne	%r14b
	cmpl	%edi, %edx
	je	.L87
	movl	$2, %r14d
	cmpl	%edi, %r11d
	jne	.L44
	movl	$1, %ecx
	cmpl	%r11d, %r12d
	jne	.L44
.L21:
	addl	$2, %ecx
	cmpl	$-1, %r12d
	je	.L44
	imull	%r12d, %ecx
	movl	$4, %r13d
	addl	%ecx, %r8d
	movl	%r12d, %ecx
	.p2align 4,,10
	.p2align 3
.L22:
	cmpl	%ecx, %esi
	jne	.L10
	testl	%r14d, %r14d
	jne	.L10
	movl	$-1, (%rax)
	cmpl	%ecx, %edx
	jne	.L12
	movl	$-1, 4(%rax)
.L88:
	cmpl	%ecx, %edi
	jne	.L14
	.p2align 4,,10
	.p2align 3
.L84:
	movl	$-1, 8(%rax)
	cmpl	%ecx, %r11d
	jne	.L36
	.p2align 4,,10
	.p2align 3
.L85:
	movl	$-1, 12(%rax)
	cmpl	%ecx, %r12d
	jne	.L15
	.p2align 4,,10
	.p2align 3
.L86:
	cmpl	$4, %r13d
	jne	.L15
	movl	$-1, 16(%rax)
	addq	$20, %rax
	cmpq	%r10, %rax
	jne	.L32
	.p2align 4,,10
	.p2align 3
.L16:
	testl	%r9d, %r9d
	js	.L24
.L39:
	movq	-88(%rbp), %r12
	xorl	%r11d, %r11d
.L30:
	movq	%r12, %rsi
	movl	%r9d, %ecx
	movslq	%r11d, %rdi
	jmp	.L38
	.p2align 4,,10
	.p2align 3
.L25:
	testl	%ecx, %ecx
	js	.L26
.L28:
	subq	$20, %rsi
.L38:
	subl	$1, %ecx
	cmpl	$-1, (%rsi)
	jne	.L25
	cmpl	$-1, %ecx
	je	.L26
	movq	%rsi, %rdx
	movl	%ecx, %eax
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L27:
	subl	$1, %eax
	subq	$20, %rdx
	cmpl	$-1, %eax
	je	.L28
.L29:
	movl	-20(%rdx), %r14d
	cmpl	$-1, %r14d
	je	.L27
	cltq
	movl	%r14d, (%rsi)
	leaq	(%rax,%rax,4), %rax
	addq	%rdi, %rax
	movl	$-1, (%r15,%rax,4)
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L87:
	cmpl	%r11d, %edx
	je	.L19
	cmpl	$2, %ecx
	jle	.L44
	cmpl	$-1, %edx
	je	.L44
	leal	(%rdx,%rdx,2), %ecx
	movl	$3, %r13d
	addl	%ecx, %r8d
	movl	%edx, %ecx
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L83:
	cmpl	$2, %r14d
	je	.L12
	movl	$-1, 4(%rax)
	jmp	.L88
	.p2align 4,,10
	.p2align 3
.L44:
	movl	$-1, %ecx
	jmp	.L22
.L19:
	cmpl	%edx, %r12d
	je	.L21
	addl	$1, %ecx
	cmpl	$2, %ecx
	jle	.L44
	cmpl	$-1, %edx
	je	.L44
	imull	%edx, %ecx
	movl	$4, %r13d
	addl	%ecx, %r8d
	movl	%edx, %ecx
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L26:
	addq	$1, %r11
	addq	$4, %r12
	cmpq	$5, %r11
	jne	.L30
.L24:
	cmpl	%r8d, -72(%rbp)
	je	.L31
	movl	-76(%rbp), %edx
	movl	%r8d, -72(%rbp)
	movq	%r15, %rax
	testl	%edx, %edx
	jg	.L32
.L82:
	testl	%r9d, %r9d
	jns	.L39
.L31:
	movl	%r8d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	-96(%rbp), %rsp
	jmp	.L34
.L5:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L89
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L81:
	.cfi_restore_state
	movl	-76(%rbp), %eax
	jmp	.L6
.L89:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
 
int main (void){
    int score, bscore = -1, a_c;
    int h;
    int i, j, before;
    int del = -1;
    int f, e;
    while(1)
    {
        score = 0;
        bscore = -1;
        scanf("%d", &h);
        int a[h][5];
        if (h == 0) break;
        for (i = 0; i < h; i++) {
            a_c = 0;
            for (j = 0; j < 5; j++) {
                scanf("%d", &a[i][j]);
            }
        }
        while (score != bscore) {
            bscore = score;
            for (i = 0; i < h; i++){
                a_c = 0;
                del = -1;
                for (j = 0; j < 5; j++) 
                {
                    //printf("%d ", a_c);
                    if (j == 0) {
                        before = a[i][j];
                        a_c++;
                        f = j;
                    } else if (before == a[i][j]) {
                        a_c++;
                        //printf("%d ", a_c);
                    } else {
                        if (a_c >= 3 && before != -1) {
                            score += before * a_c;
                            del = before;
                            e = j;
                        }
                        a_c = 1;
                        before = a[i][j];
                        if(j <= 2){
                        	f = j;
                        }
                    }
                    if(j == 4) {
                        if (a_c >= 3 && before != -1) {
                            score += before * a_c;
                            del = before;
                            e = j;
                        }
                        a_c = 0;
                    }
                }
                for (j = 0; j < 5; j++) {
                    if(a[i][j]==del && j >= f && j <= e){
                        a[i][j]=-1;
                    }
                }
 
            }
 
 
 
/*
            printf("\n");
            for (i = 0; i < h; i++){
                for (j = 0; j < 5; j++) {
                    printf("%d ", a[i][j]);
                }
                printf("\n");
            }
*/
 
 
            int flag = 0, i_;
                for(j = 0; j < 5; j++){
                    flag = 0;
                    for(i = h-1; i >= 0; i--){
                        if(a[i][j] == -1){
                            int k = i - 1;
                            while(k >= 0){
                                if(a[k][j] != -1){
                                    a[i][j] = a[k][j];
                                    a[k][j] = -1;
                                    break;
                                }
                                k--;
                            }
                        }
                    }
                }
 
/*
            printf("\n");
            for (i = 0; i < h; i++){
                for (j = 0; j < 5; j++) {
                    printf("%d ", a[i][j]);
                }
                printf("\n");
            }
*/
 
        }
        printf("%d\n", score);
    }
    return 0;
}

1
6 9 9 9 9
5
5 9 5 2 9
5 5 6 9 9
4 6 3 6 9
3 3 2 9 9
2 2 1 1 1
10
3 5 6 5 6
2 2 2 8 3
6 2 5 9 2
7 7 7 6 1
4 6 6 4 9
8 9 1 1 8
5 6 1 8 1
6 8 2 1 2
9 6 3 3 5
5 3 8 8 8
5
1 2 3 4 5
6 7 8 9 1
2 3 4 5 6
7 8 9 1 2
3 4 5 6 7
3
2 2 8 7 4
6 5 7 7 7
8 8 9 9 9
0
 1
6 9 9 9 9
5
5 9 5 2 9
5 5 6 9 9
4 6 3 6 9
3 2 2 9 9
2 2 1 1 1
10
3 5 6 5 6
2 2 2 8 3
6 2 5 9 2
7 7 7 6 1
4 6 6 4 9
8 9 1 1 8
5 6 1 8 1
6 8 2 1 2
9 6 3 3 5
5 3 8 8 8
5
1 2 3 4 5
6 7 8 9 1
2 3 4 5 6
7 8 9 1 2
3 4 5 6 7
3
2 2 8 7 4
6 5 7 7 7
8 8 9 9 9
0
 1
6 9 9 9 9
5
5 9 5 2 9
5 5 6 9 9
4 6 3 6 9
3 2 2 9 9
2 2 1 1 1
10
3 5 6 5 6
2 2 2 8 3
6 2 5 9 2
7 7 7 6 1
4 9 6 4 9
8 9 1 1 8
5 6 1 8 1
6 8 2 1 2
9 6 3 3 5
5 3 8 8 8
5
1 2 3 4 5
6 7 8 9 1
2 3 4 5 6
7 8 9 1 2
3 4 5 6 7
3
2 2 8 7 4
6 5 7 7 7
8 8 9 9 9
0
 1
6 9 9 9 9
5
5 9 5 2 9
5 5 6 9 9
4 6 3 6 9
3 2 2 9 9
2 2 1 1 1
10
3 5 6 5 6
2 2 2 8 3
6 2 5 9 2
7 7 7 6 1
4 9 6 4 9
8 9 1 1 8
5 6 1 8 1
6 8 2 1 2
9 6 3 3 5
5 3 8 8 8
5
1 2 3 4 5
6 7 8 9 1
2 3 4 5 6
7 8 9 1 2
3 4 5 6 7
3
2 2 4 7 4
6 5 7 7 7
8 8 9 9 9
0
 1
6 9 9 9 9
5
5 9 5 2 9
5 5 6 9 9
4 6 3 10 9
3 2 2 9 9
2 2 1 1 1
10
3 5 6 5 6
2 2 2 8 3
6 2 5 9 2
7 7 7 6 1
4 9 6 4 9
8 9 1 1 8
5 6 1 8 1
6 8 2 1 2
9 6 3 3 5
5 3 8 8 8
5
1 2 3 4 5
6 7 8 9 1
2 3 4 5 6
7 8 9 1 2
3 4 5 6 7
3
2 2 4 7 4
6 5 7 7 7
8 8 9 9 9
0
 1
6 9 9 9 9
5
5 9 5 2 9
5 5 6 9 9
4 6 3 10 9
3 2 2 9 9
2 2 1 1 1
10
3 5 6 5 6
2 2 2 8 3
6 2 5 9 2
8 7 7 6 1
4 9 6 4 9
8 9 1 1 8
5 6 1 8 1
6 8 2 1 2
9 6 3 3 5
5 3 8 8 8
5
1 2 3 4 5
6 7 8 9 1
2 3 4 5 6
7 8 9 1 2
3 4 5 6 12
3
2 2 4 7 4
6 5 7 7 7
8 8 9 9 9
0
 1
6 9 9 9 9
5
5 9 5 5 9
5 5 6 9 9
4 6 3 6 9
3 3 2 9 9
2 2 1 1 1
10
3 5 6 5 6
2 2 2 8 3
6 2 5 9 2
7 7 7 6 1
4 2 6 4 9
8 9 1 1 8
5 6 1 8 1
6 8 2 1 2
9 6 3 3 5
5 3 8 8 8
5
1 2 3 4 5
6 7 8 9 1
2 3 4 5 6
7 8 9 1 2
3 4 5 6 7
3
2 2 8 7 4
6 5 7 7 7
8 8 9 9 9
0
 1
6 9 9 9 9
5
5 9 5 2 9
5 5 6 9 9
4 6 3 6 9
3 2 2 9 9
2 2 1 1 1
10
3 5 6 5 6
2 2 2 8 3
6 2 5 9 2
3 7 7 6 1
4 6 6 4 9
8 9 1 1 8
5 6 1 8 1
6 8 2 1 2
9 6 3 3 5
5 3 8 8 8
5
1 2 3 4 5
6 7 8 9 1
2 3 4 5 6
7 8 9 1 2
3 4 5 6 7
3
2 2 8 7 4
6 5 7 7 7
8 8 9 9 9
0
 1
6 9 9 9 9
5
5 9 5 2 9
5 6 6 9 9
4 6 3 10 9
3 2 2 9 9
2 2 1 1 1
10
3 5 6 5 6
2 2 2 8 3
6 2 5 9 2
8 7 7 6 1
4 9 6 4 9
8 9 1 1 8
5 6 1 8 1
6 8 2 1 2
9 6 3 3 5
5 3 8 8 8
5
1 2 3 4 5
6 7 8 9 1
2 3 4 5 6
7 8 9 1 2
3 4 5 6 12
3
2 2 4 7 4
6 5 7 7 7
8 8 9 9 9
0
 1
6 9 9 9 9
5
5 9 5 5 9
5 5 6 9 9
4 6 3 6 9
3 3 2 9 9
2 2 1 1 1
10
3 5 6 5 6
2 2 2 8 3
6 2 5 9 2
7 7 7 6 1
4 2 6 4 9
8 9 1 1 8
5 6 1 8 1
6 8 2 1 2
9 6 3 3 5
5 3 8 8 8
5
1 2 3 4 5
6 7 8 9 1
2 3 4 5 6
7 8 9 1 2
3 4 5 6 7
3
2 2 10 7 4
6 5 7 7 7
8 8 9 9 9
0

36
33
99
0
72
 36
42
99
0
72
 36
42
81
0
72
 36
42
81
0
48
 36
24
81
0
48
 36
24
60
0
48
 36
38
81
0
72
 36
42
60
0
72
 36
9
60
0
48
 36
38
81
0
48

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>
 
int main (void){
    int score, bscore = -1, a_c;
    int h;
    int i, j, before;
    int del = -1;
    int f, e;
    while(1)
    {
        score = 0;
        bscore = -1;
        scanf("%d", &h);
        int a[h][5];
        if (h == 0) break;
        for (i = 0; i < h; i++) {
            a_c = 0;
            for (j = 0; j < 5; j++) {
                scanf("%d", &a[i][j]);
            }
        }
        while (score != bscore) {
            bscore = score;
            for (i = 0; i < h; i++){
                a_c = 0;
                del = -1;
                for (j = 0; j < 5; j++) 
                {
                    //printf("%d ", a_c);
                    if (j == 0) {
                        before = a[i][j];
                        a_c++;
                        f = j;
                    } else if (before == a[i][j]) {
                        a_c++;
                        //printf("%d ", a_c);
                    } else {
                        if (a_c >= 3 && before != -1) {
                            score += before * a_c;
                            del = before;
                            e = j;
                        }
                        a_c = 1;
                        before = a[i][j];
                        if(j <= 2){
                        	f = j;
                        }
                    }
                    if(j == 4) {
                        if (a_c >= 3 && before != -1) {
                            score += before * a_c;
                            del = before;
                            e = j;
                        }
                        a_c = 0;
                    }
                }
                for (j = 0; j < 5; j++) {
                    if(a[i][j]==del && j >= f && j <= e){
                        a[i][j]=-1;
                    }
                }
 
            }
 
 
 
/*
            printf("\n");
            for (i = 0; i < h; i++){
                for (j = 0; j < 5; j++) {
                    printf("%d ", a[i][j]);
                }
                printf("\n");
            }
*/
 
 
            int flag = 0, i_;
                for(j = 0; j < 5; j++){
                    flag = 0;
                    for(i = h-1; i >= 0; i--){
                        if(a[i][j] == -1){
                            int k = i - 1;
                            while(k >= 0){
                                if(a[k][j] != -1){
                                    a[i][j] = a[k][j];
                                    a[k][j] = -1;
                                    break;
                                }
                                k--;
                            }
                        }
                    }
                }
 
/*
            printf("\n");
            for (i = 0; i < h; i++){
                for (j = 0; j < 5; j++) {
                    printf("%d ", a[i][j]);
                }
                printf("\n");
            }
*/
 
        }
        printf("%d\n", score);
    }
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movl	$-1, -112(%rbp)
	movl	$-1, -92(%rbp)
.L34:
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -116(%rbp)
	movl	$-1, -112(%rbp)
	leaq	-120(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-120(%rbp), %ecx
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movslq	%ecx, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	imulq	$160, %r13, %rdx
	imulq	$0, %r12, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$160, %eax
	mulq	%r12
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	imulq	$160, %r15, %rdx
	imulq	$0, %r14, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$160, %eax
	mulq	%r14
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	-120(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	jmp	.L36
.L5:
	movl	$0, -104(%rbp)
	jmp	.L7
.L10:
	movl	$0, -108(%rbp)
	movl	$0, -100(%rbp)
	jmp	.L8
.L9:
	movl	-100(%rbp), %eax
	movslq	%eax, %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -100(%rbp)
.L8:
	cmpl	$4, -100(%rbp)
	jle	.L9
	addl	$1, -104(%rbp)
.L7:
	movl	-120(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L10
	jmp	.L11
.L33:
	movl	-116(%rbp), %eax
	movl	%eax, -112(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L12
.L24:
	movl	$0, -108(%rbp)
	movl	$-1, -92(%rbp)
	movl	$0, -100(%rbp)
	jmp	.L13
.L20:
	cmpl	$0, -100(%rbp)
	jne	.L14
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	movl	%eax, -96(%rbp)
	addl	$1, -108(%rbp)
	movl	-100(%rbp), %eax
	movl	%eax, -88(%rbp)
	jmp	.L15
.L14:
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	cmpl	%eax, -96(%rbp)
	jne	.L16
	addl	$1, -108(%rbp)
	jmp	.L15
.L16:
	cmpl	$2, -108(%rbp)
	jle	.L17
	cmpl	$-1, -96(%rbp)
	je	.L17
	movl	-96(%rbp), %eax
	imull	-108(%rbp), %eax
	addl	%eax, -116(%rbp)
	movl	-96(%rbp), %eax
	movl	%eax, -92(%rbp)
	movl	-100(%rbp), %eax
	movl	%eax, -84(%rbp)
.L17:
	movl	$1, -108(%rbp)
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	movl	%eax, -96(%rbp)
	cmpl	$2, -100(%rbp)
	jg	.L15
	movl	-100(%rbp), %eax
	movl	%eax, -88(%rbp)
.L15:
	cmpl	$4, -100(%rbp)
	jne	.L18
	cmpl	$2, -108(%rbp)
	jle	.L19
	cmpl	$-1, -96(%rbp)
	je	.L19
	movl	-96(%rbp), %eax
	imull	-108(%rbp), %eax
	addl	%eax, -116(%rbp)
	movl	-96(%rbp), %eax
	movl	%eax, -92(%rbp)
	movl	-100(%rbp), %eax
	movl	%eax, -84(%rbp)
.L19:
	movl	$0, -108(%rbp)
.L18:
	addl	$1, -100(%rbp)
.L13:
	cmpl	$4, -100(%rbp)
	jle	.L20
	movl	$0, -100(%rbp)
	jmp	.L21
.L23:
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	cmpl	%eax, -92(%rbp)
	jne	.L22
	movl	-100(%rbp), %eax
	cmpl	-88(%rbp), %eax
	jl	.L22
	movl	-100(%rbp), %eax
	cmpl	-84(%rbp), %eax
	jg	.L22
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	$-1, (%rdx,%rax,4)
.L22:
	addl	$1, -100(%rbp)
.L21:
	cmpl	$4, -100(%rbp)
	jle	.L23
	addl	$1, -104(%rbp)
.L12:
	movl	-120(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L24
	movl	$0, -76(%rbp)
	movl	$0, -100(%rbp)
	jmp	.L25
.L32:
	movl	$0, -76(%rbp)
	movl	-120(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -104(%rbp)
	jmp	.L26
.L31:
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L27
	movl	-104(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -80(%rbp)
	jmp	.L28
.L30:
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-80(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	cmpl	$-1, %eax
	je	.L29
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-80(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %ecx
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rdi
	movl	-104(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	addq	%rdi, %rax
	movl	%ecx, (%rdx,%rax,4)
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-80(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	$-1, (%rdx,%rax,4)
	jmp	.L27
.L29:
	subl	$1, -80(%rbp)
.L28:
	cmpl	$0, -80(%rbp)
	jns	.L30
.L27:
	subl	$1, -104(%rbp)
.L26:
	cmpl	$0, -104(%rbp)
	jns	.L31
	addl	$1, -100(%rbp)
.L25:
	cmpl	$4, -100(%rbp)
	jle	.L32
.L11:
	movl	-116(%rbp), %eax
	cmpl	-112(%rbp), %eax
	jne	.L33
	movl	-116(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	%rbx, %rsp
	jmp	.L34
.L36:
	call	__stack_chk_fail@PLT
.L35:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movl	$-1, -112(%rbp)
	movl	$-1, -92(%rbp)
.L34:
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -116(%rbp)
	movl	$-1, -112(%rbp)
	leaq	-120(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-120(%rbp), %ecx
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movslq	%ecx, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	imulq	$160, %r13, %rdx
	imulq	$0, %r12, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$160, %eax
	mulq	%r12
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	imulq	$160, %r15, %rdx
	imulq	$0, %r14, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$160, %eax
	mulq	%r14
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	-120(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	movq	%rbx, %rsp
	movl	$0, %eax
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	jmp	.L36
.L5:
	movl	$0, -104(%rbp)
	jmp	.L7
.L10:
	movl	$0, -108(%rbp)
	movl	$0, -100(%rbp)
	jmp	.L8
.L9:
	movl	-100(%rbp), %eax
	movslq	%eax, %rcx
	movl	-104(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -100(%rbp)
.L8:
	cmpl	$4, -100(%rbp)
	jle	.L9
	addl	$1, -104(%rbp)
.L7:
	movl	-120(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L10
	jmp	.L11
.L33:
	movl	-116(%rbp), %eax
	movl	%eax, -112(%rbp)
	movl	$0, -104(%rbp)
	jmp	.L12
.L24:
	movl	$0, -108(%rbp)
	movl	$-1, -92(%rbp)
	movl	$0, -100(%rbp)
	jmp	.L13
.L20:
	cmpl	$0, -100(%rbp)
	jne	.L14
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	movl	%eax, -96(%rbp)
	addl	$1, -108(%rbp)
	movl	-100(%rbp), %eax
	movl	%eax, -88(%rbp)
	jmp	.L15
.L14:
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	cmpl	%eax, -96(%rbp)
	jne	.L16
	addl	$1, -108(%rbp)
	jmp	.L15
.L16:
	cmpl	$2, -108(%rbp)
	jle	.L17
	cmpl	$-1, -96(%rbp)
	je	.L17
	movl	-96(%rbp), %eax
	imull	-108(%rbp), %eax
	addl	%eax, -116(%rbp)
	movl	-96(%rbp), %eax
	movl	%eax, -92(%rbp)
	movl	-100(%rbp), %eax
	movl	%eax, -84(%rbp)
.L17:
	movl	$1, -108(%rbp)
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	movl	%eax, -96(%rbp)
	cmpl	$2, -100(%rbp)
	jg	.L15
	movl	-100(%rbp), %eax
	movl	%eax, -88(%rbp)
.L15:
	cmpl	$4, -100(%rbp)
	jne	.L18
	cmpl	$2, -108(%rbp)
	jle	.L19
	cmpl	$-1, -96(%rbp)
	je	.L19
	movl	-96(%rbp), %eax
	imull	-108(%rbp), %eax
	addl	%eax, -116(%rbp)
	movl	-96(%rbp), %eax
	movl	%eax, -92(%rbp)
	movl	-100(%rbp), %eax
	movl	%eax, -84(%rbp)
.L19:
	movl	$0, -108(%rbp)
.L18:
	addl	$1, -100(%rbp)
.L13:
	cmpl	$4, -100(%rbp)
	jle	.L20
	movl	$0, -100(%rbp)
	jmp	.L21
.L23:
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	cmpl	%eax, -92(%rbp)
	jne	.L22
	movl	-100(%rbp), %eax
	cmpl	-88(%rbp), %eax
	jl	.L22
	movl	-100(%rbp), %eax
	cmpl	-84(%rbp), %eax
	jg	.L22
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	$-1, (%rdx,%rax,4)
.L22:
	addl	$1, -100(%rbp)
.L21:
	cmpl	$4, -100(%rbp)
	jle	.L23
	addl	$1, -104(%rbp)
.L12:
	movl	-120(%rbp), %eax
	cmpl	%eax, -104(%rbp)
	jl	.L24
	movl	$0, -76(%rbp)
	movl	$0, -100(%rbp)
	jmp	.L25
.L32:
	movl	$0, -76(%rbp)
	movl	-120(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -104(%rbp)
	jmp	.L26
.L31:
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-104(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L27
	movl	-104(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -80(%rbp)
	jmp	.L28
.L30:
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-80(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %eax
	cmpl	$-1, %eax
	je	.L29
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-80(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	(%rdx,%rax,4), %ecx
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rdi
	movl	-104(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	addq	%rdi, %rax
	movl	%ecx, (%rdx,%rax,4)
	movq	-64(%rbp), %rdx
	movl	-100(%rbp), %eax
	movslq	%eax, %rsi
	movl	-80(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rsi, %rax
	movl	$-1, (%rdx,%rax,4)
	jmp	.L27
.L29:
	subl	$1, -80(%rbp)
.L28:
	cmpl	$0, -80(%rbp)
	jns	.L30
.L27:
	subl	$1, -104(%rbp)
.L26:
	cmpl	$0, -104(%rbp)
	jns	.L31
	addl	$1, -100(%rbp)
.L25:
	cmpl	$4, -100(%rbp)
	jle	.L32
.L11:
	movl	-116(%rbp), %eax
	cmpl	-112(%rbp), %eax
	jne	.L33
	movl	-116(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	%rbx, %rsp
	jmp	.L34
.L36:
	call	__stack_chk_fail@PLT
.L35:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
