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 counter(int z){
    if(z==0) return 0;
    else return counter(z>>1)+(z&1);
}
int main(void){
    int n,i,j,k,max=0,cnt,flag=1;
    int a[20],x[20][20],y[20][20];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        for(j=0;j<a[i];j++){
            scanf("%d %d",&x[i][j],&y[i][j]);
        }
    }
    for(i=0;i<(1<<n);i++){
        flag=1;
        for(j=0;j<n;j++){
            if(!(i&(1<<j))) continue;
            for(k=0;k<a[j];k++){
                if((i>>(x[j][k]-1)&1)^y[j][k]){
                    flag=0;
                    break;
                }
            }
        }
        if(flag){
            cnt=counter(i);
            if(max<cnt) max=cnt;
        }
    }
    printf("%d\n",max);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	counter
	.type	counter, @function
counter:
.LFB0:
	.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
	movl	%edi, -4(%rbp)
	cmpl	$0, -4(%rbp)
	jne	.L2
	movl	$0, %eax
	jmp	.L3
.L2:
	movl	-4(%rbp), %eax
	sarl	%eax
	movl	%eax, %edi
	call	counter
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$1, %eax
	addl	%edx, %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	counter, .-counter
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$3328, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -3308(%rbp)
	movl	$1, -3304(%rbp)
	leaq	-3324(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3320(%rbp)
	jmp	.L5
.L8:
	leaq	-3296(%rbp), %rdx
	movl	-3320(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3316(%rbp)
	jmp	.L6
.L7:
	leaq	-1616(%rbp), %rcx
	movl	-3316(%rbp), %eax
	movslq	%eax, %rsi
	movl	-3320(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-3216(%rbp), %rsi
	movl	-3316(%rbp), %eax
	movslq	%eax, %rdi
	movl	-3320(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -3316(%rbp)
.L6:
	movl	-3320(%rbp), %eax
	cltq
	movl	-3296(%rbp,%rax,4), %eax
	cmpl	%eax, -3316(%rbp)
	jl	.L7
	addl	$1, -3320(%rbp)
.L5:
	movl	-3324(%rbp), %eax
	cmpl	%eax, -3320(%rbp)
	jl	.L8
	movl	$0, -3320(%rbp)
	jmp	.L9
.L18:
	movl	$1, -3304(%rbp)
	movl	$0, -3316(%rbp)
	jmp	.L10
.L16:
	movl	-3316(%rbp), %eax
	movl	-3320(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L21
	movl	$0, -3312(%rbp)
	jmp	.L13
.L15:
	movl	-3312(%rbp), %eax
	movslq	%eax, %rcx
	movl	-3316(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	-3216(%rbp,%rax,4), %eax
	subl	$1, %eax
	movl	-3320(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	movl	%eax, %ecx
	movl	-3312(%rbp), %eax
	movslq	%eax, %rsi
	movl	-3316(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movl	-1616(%rbp,%rax,4), %eax
	cmpl	%eax, %ecx
	je	.L14
	movl	$0, -3304(%rbp)
	jmp	.L12
.L14:
	addl	$1, -3312(%rbp)
.L13:
	movl	-3316(%rbp), %eax
	cltq
	movl	-3296(%rbp,%rax,4), %eax
	cmpl	%eax, -3312(%rbp)
	jl	.L15
	jmp	.L12
.L21:
	nop
.L12:
	addl	$1, -3316(%rbp)
.L10:
	movl	-3324(%rbp), %eax
	cmpl	%eax, -3316(%rbp)
	jl	.L16
	cmpl	$0, -3304(%rbp)
	je	.L17
	movl	-3320(%rbp), %eax
	movl	%eax, %edi
	call	counter
	movl	%eax, -3300(%rbp)
	movl	-3308(%rbp), %eax
	cmpl	-3300(%rbp), %eax
	jge	.L17
	movl	-3300(%rbp), %eax
	movl	%eax, -3308(%rbp)
.L17:
	addl	$1, -3320(%rbp)
.L9:
	movl	-3324(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	cmpl	%eax, -3320(%rbp)
	jl	.L18
	movl	-3308(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	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	counter
	.type	counter, @function
counter:
.LFB23:
	.cfi_startproc
	endbr64
	xorl	%r8d, %r8d
	testl	%edi, %edi
	je	.L1
	.p2align 4,,10
	.p2align 3
.L2:
	movl	%edi, %eax
	andl	$1, %eax
	addl	%eax, %r8d
	sarl	%edi
	jne	.L2
.L1:
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	counter, .-counter
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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	$3336, %rsp
	.cfi_def_cfa_offset 3392
	movq	%fs:40, %rax
	movq	%rax, 3320(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %ebp
	testl	%ebp, %ebp
	jle	.L11
	movl	$0, 12(%rsp)
	leaq	32(%rsp), %rbx
	xorl	%r14d, %r14d
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbx, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rbx), %eax
	testl	%eax, %eax
	jle	.L15
	leaq	0(,%r14,4), %rax
	xorl	%ebp, %ebp
	leaq	112(%rsp,%rax), %r13
	leaq	1712(%rsp,%rax), %r15
	.p2align 4,,10
	.p2align 3
.L14:
	movq	%r15, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	addl	$1, %ebp
	addq	$4, %r13
	addq	$4, %r15
	cmpl	%ebp, (%rbx)
	jg	.L14
.L15:
	addl	$1, 12(%rsp)
	movl	28(%rsp), %ebp
	addq	$4, %rbx
	addq	$20, %r14
	movl	12(%rsp), %eax
	cmpl	%eax, %ebp
	jg	.L13
.L11:
	movl	$1, %r12d
	movl	%ebp, %ecx
	xorl	%r13d, %r13d
	xorl	%r9d, %r9d
	sall	%cl, %r12d
	movslq	%ebp, %r11
	.p2align 4,,10
	.p2align 3
.L16:
	testl	%ebp, %ebp
	jle	.L25
	leaq	112(%rsp), %rdi
	leaq	1712(%rsp), %rsi
	xorl	%r10d, %r10d
	movl	$1, %ebx
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$1, %r10
	addq	$80, %rdi
	addq	$80, %rsi
	cmpq	%r10, %r11
	je	.L44
.L19:
	btl	%r10d, %r9d
	jnc	.L17
	movslq	32(%rsp,%r10,4), %r8
	testl	%r8d, %r8d
	jle	.L17
	xorl	%eax, %eax
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L45:
	addq	$1, %rax
	cmpq	%rax, %r8
	je	.L17
.L18:
	movl	(%rdi,%rax,4), %ecx
	movl	%r9d, %edx
	subl	$1, %ecx
	sarl	%cl, %edx
	andl	$1, %edx
	cmpl	(%rsi,%rax,4), %edx
	je	.L45
	xorl	%ebx, %ebx
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L44:
	testl	%ebx, %ebx
	jne	.L25
.L20:
	addl	$1, %r9d
	cmpl	%r9d, %r12d
	jne	.L16
	xorl	%eax, %eax
	movl	%r13d, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	3320(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L46
	addq	$3336, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L25:
	.cfi_restore_state
	movl	%r9d, %eax
	xorl	%ecx, %ecx
	testl	%r9d, %r9d
	je	.L22
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%eax, %edx
	andl	$1, %edx
	addl	%edx, %ecx
	sarl	%eax
	jne	.L21
.L22:
	cmpl	%ecx, %r13d
	cmovl	%ecx, %r13d
	jmp	.L20
.L46:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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
	.p2align 4
	.globl	counter
	.type	counter, @function
counter:
.LFB23:
	.cfi_startproc
	endbr64
	xorl	%r8d, %r8d
	testl	%edi, %edi
	je	.L1
	.p2align 4,,10
	.p2align 3
.L2:
	movl	%edi, %eax
	andl	$1, %eax
	addl	%eax, %r8d
	sarl	%edi
	jne	.L2
.L1:
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	counter, .-counter
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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	$3336, %rsp
	.cfi_def_cfa_offset 3392
	movq	%fs:40, %rax
	movq	%rax, 3320(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %ebp
	testl	%ebp, %ebp
	jle	.L11
	movl	$0, 12(%rsp)
	leaq	32(%rsp), %rbx
	xorl	%r14d, %r14d
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbx, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rbx), %eax
	testl	%eax, %eax
	jle	.L15
	leaq	0(,%r14,4), %rax
	xorl	%ebp, %ebp
	leaq	112(%rsp,%rax), %r13
	leaq	1712(%rsp,%rax), %r15
	.p2align 4,,10
	.p2align 3
.L14:
	movq	%r15, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	addl	$1, %ebp
	addq	$4, %r13
	addq	$4, %r15
	cmpl	%ebp, (%rbx)
	jg	.L14
.L15:
	addl	$1, 12(%rsp)
	movl	28(%rsp), %ebp
	addq	$4, %rbx
	addq	$20, %r14
	movl	12(%rsp), %eax
	cmpl	%eax, %ebp
	jg	.L13
.L11:
	movl	$1, %r12d
	movl	%ebp, %ecx
	xorl	%r13d, %r13d
	xorl	%r9d, %r9d
	sall	%cl, %r12d
	movslq	%ebp, %r11
	.p2align 4,,10
	.p2align 3
.L16:
	testl	%ebp, %ebp
	jle	.L25
	leaq	112(%rsp), %rdi
	leaq	1712(%rsp), %rsi
	xorl	%r10d, %r10d
	movl	$1, %ebx
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$1, %r10
	addq	$80, %rdi
	addq	$80, %rsi
	cmpq	%r10, %r11
	je	.L44
.L19:
	btl	%r10d, %r9d
	jnc	.L17
	movslq	32(%rsp,%r10,4), %r8
	testl	%r8d, %r8d
	jle	.L17
	xorl	%eax, %eax
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L45:
	addq	$1, %rax
	cmpq	%rax, %r8
	je	.L17
.L18:
	movl	(%rdi,%rax,4), %ecx
	movl	%r9d, %edx
	subl	$1, %ecx
	sarl	%cl, %edx
	andl	$1, %edx
	cmpl	(%rsi,%rax,4), %edx
	je	.L45
	xorl	%ebx, %ebx
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L44:
	testl	%ebx, %ebx
	jne	.L25
.L20:
	addl	$1, %r9d
	cmpl	%r9d, %r12d
	jne	.L16
	xorl	%eax, %eax
	movl	%r13d, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	3320(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L46
	addq	$3336, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L25:
	.cfi_restore_state
	movl	%r9d, %eax
	xorl	%ecx, %ecx
	testl	%r9d, %r9d
	je	.L22
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%eax, %edx
	andl	$1, %edx
	addl	%edx, %ecx
	sarl	%eax
	jne	.L21
.L22:
	cmpl	%ecx, %r13d
	cmovl	%ecx, %r13d
	jmp	.L20
.L46:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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 counter(int z){
    if(z==0) return 0;
    else return counter(z>>1)+(z&1);
}
int main(void){
    int n,i,j,k,max=0,cnt,flag=1;
    int a[20],x[20][20],y[20][20];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        for(j=0;j<a[i];j++){
            scanf("%d %d",&x[i][j],&y[i][j]);
        }
    }
    for(i=0;i<(1<<n);i++){
        flag=1;
        for(j=0;j<n;j++){
            if(!(i&(1<<j))) continue;
            for(k=0;k<a[j];k++){
                if((i>>(x[j][k]-1)&1)^y[j][k]){
                    flag=0;
                    break;
                }
            }
        }
        if(flag){
            cnt=counter(i);
            if(max<cnt) max=cnt;
        }
    }
    printf("%d\n",max);
    return 0;
}
3
2
2 1
3 0
2
3 1
1 0
2
1 1
2 -1
 2
1
2 0
1
1 1
 3
1
3 1
1
1 1
1
2 0
 3
1
3 1
1
1 1
0
2 0
 3
2
2 1
3 0
2
3 1
1 0
2
1 0
2 0
 3
1
1 1
1
1 1
0
2 0
 3
2
2 0
3 0
2
3 1
1 0
2
1 1
2 0
 3
1
2 1
1
2 1
1
2 0
 3
2
2 0
3 0
2
3 1
1 0
2
1 1
2 -1
 3
1
3 0
1
1 1
1
2 0

0
 1
 2
 3
 1
 3
 1
 2
 1
 2

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 counter(int z){
    if(z==0) return 0;
    else return counter(z>>1)+(z&1);
}
int main(void){
    int n,i,j,k,max=0,cnt,flag=1;
    int a[20],x[20][20],y[20][20];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        for(j=0;j<a[i];j++){
            scanf("%d %d",&x[i][j],&y[i][j]);
        }
    }
    for(i=0;i<(1<<n);i++){
        flag=1;
        for(j=0;j<n;j++){
            if(!(i&(1<<j))) continue;
            for(k=0;k<a[j];k++){
                if((i>>(x[j][k]-1)&1)^y[j][k]){
                    flag=0;
                    break;
                }
            }
        }
        if(flag){
            cnt=counter(i);
            if(max<cnt) max=cnt;
        }
    }
    printf("%d\n",max);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	counter
	.type	counter, @function
counter:
.LFB0:
	.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
	movl	%edi, -4(%rbp)
	cmpl	$0, -4(%rbp)
	jne	.L2
	movl	$0, %eax
	jmp	.L3
.L2:
	movl	-4(%rbp), %eax
	sarl	%eax
	movl	%eax, %edi
	call	counter
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$1, %eax
	addl	%edx, %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	counter, .-counter
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$3328, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -3308(%rbp)
	movl	$1, -3304(%rbp)
	leaq	-3324(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3320(%rbp)
	jmp	.L5
.L8:
	leaq	-3296(%rbp), %rdx
	movl	-3320(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3316(%rbp)
	jmp	.L6
.L7:
	leaq	-1616(%rbp), %rcx
	movl	-3316(%rbp), %eax
	movslq	%eax, %rsi
	movl	-3320(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-3216(%rbp), %rsi
	movl	-3316(%rbp), %eax
	movslq	%eax, %rdi
	movl	-3320(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -3316(%rbp)
.L6:
	movl	-3320(%rbp), %eax
	cltq
	movl	-3296(%rbp,%rax,4), %eax
	cmpl	%eax, -3316(%rbp)
	jl	.L7
	addl	$1, -3320(%rbp)
.L5:
	movl	-3324(%rbp), %eax
	cmpl	%eax, -3320(%rbp)
	jl	.L8
	movl	$0, -3320(%rbp)
	jmp	.L9
.L18:
	movl	$1, -3304(%rbp)
	movl	$0, -3316(%rbp)
	jmp	.L10
.L16:
	movl	-3316(%rbp), %eax
	movl	-3320(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L21
	movl	$0, -3312(%rbp)
	jmp	.L13
.L15:
	movl	-3312(%rbp), %eax
	movslq	%eax, %rcx
	movl	-3316(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	-3216(%rbp,%rax,4), %eax
	subl	$1, %eax
	movl	-3320(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	movl	%eax, %ecx
	movl	-3312(%rbp), %eax
	movslq	%eax, %rsi
	movl	-3316(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movl	-1616(%rbp,%rax,4), %eax
	cmpl	%eax, %ecx
	je	.L14
	movl	$0, -3304(%rbp)
	jmp	.L12
.L14:
	addl	$1, -3312(%rbp)
.L13:
	movl	-3316(%rbp), %eax
	cltq
	movl	-3296(%rbp,%rax,4), %eax
	cmpl	%eax, -3312(%rbp)
	jl	.L15
	jmp	.L12
.L21:
	nop
.L12:
	addl	$1, -3316(%rbp)
.L10:
	movl	-3324(%rbp), %eax
	cmpl	%eax, -3316(%rbp)
	jl	.L16
	cmpl	$0, -3304(%rbp)
	je	.L17
	movl	-3320(%rbp), %eax
	movl	%eax, %edi
	call	counter
	movl	%eax, -3300(%rbp)
	movl	-3308(%rbp), %eax
	cmpl	-3300(%rbp), %eax
	jge	.L17
	movl	-3300(%rbp), %eax
	movl	%eax, -3308(%rbp)
.L17:
	addl	$1, -3320(%rbp)
.L9:
	movl	-3324(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	cmpl	%eax, -3320(%rbp)
	jl	.L18
	movl	-3308(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	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	counter
	.type	counter, @function
counter:
.LFB0:
	.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
	movl	%edi, -4(%rbp)
	cmpl	$0, -4(%rbp)
	jne	.L2
	movl	$0, %eax
	jmp	.L3
.L2:
	movl	-4(%rbp), %eax
	sarl	%eax
	movl	%eax, %edi
	call	counter
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$1, %eax
	addl	%edx, %eax
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	counter, .-counter
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$3328, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -3308(%rbp)
	movl	$1, -3304(%rbp)
	leaq	-3324(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3320(%rbp)
	jmp	.L5
.L8:
	leaq	-3296(%rbp), %rdx
	movl	-3320(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -3316(%rbp)
	jmp	.L6
.L7:
	leaq	-1616(%rbp), %rcx
	movl	-3316(%rbp), %eax
	movslq	%eax, %rsi
	movl	-3320(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	leaq	-3216(%rbp), %rsi
	movl	-3316(%rbp), %eax
	movslq	%eax, %rdi
	movl	-3320(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -3316(%rbp)
.L6:
	movl	-3320(%rbp), %eax
	cltq
	movl	-3296(%rbp,%rax,4), %eax
	cmpl	%eax, -3316(%rbp)
	jl	.L7
	addl	$1, -3320(%rbp)
.L5:
	movl	-3324(%rbp), %eax
	cmpl	%eax, -3320(%rbp)
	jl	.L8
	movl	$0, -3320(%rbp)
	jmp	.L9
.L18:
	movl	$1, -3304(%rbp)
	movl	$0, -3316(%rbp)
	jmp	.L10
.L16:
	movl	-3316(%rbp), %eax
	movl	-3320(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L21
	movl	$0, -3312(%rbp)
	jmp	.L13
.L15:
	movl	-3312(%rbp), %eax
	movslq	%eax, %rcx
	movl	-3316(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	-3216(%rbp,%rax,4), %eax
	subl	$1, %eax
	movl	-3320(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	movl	%eax, %ecx
	movl	-3312(%rbp), %eax
	movslq	%eax, %rsi
	movl	-3316(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movl	-1616(%rbp,%rax,4), %eax
	cmpl	%eax, %ecx
	je	.L14
	movl	$0, -3304(%rbp)
	jmp	.L12
.L14:
	addl	$1, -3312(%rbp)
.L13:
	movl	-3316(%rbp), %eax
	cltq
	movl	-3296(%rbp,%rax,4), %eax
	cmpl	%eax, -3312(%rbp)
	jl	.L15
	jmp	.L12
.L21:
	nop
.L12:
	addl	$1, -3316(%rbp)
.L10:
	movl	-3324(%rbp), %eax
	cmpl	%eax, -3316(%rbp)
	jl	.L16
	cmpl	$0, -3304(%rbp)
	je	.L17
	movl	-3320(%rbp), %eax
	movl	%eax, %edi
	call	counter
	movl	%eax, -3300(%rbp)
	movl	-3308(%rbp), %eax
	cmpl	-3300(%rbp), %eax
	jge	.L17
	movl	-3300(%rbp), %eax
	movl	%eax, -3308(%rbp)
.L17:
	addl	$1, -3320(%rbp)
.L9:
	movl	-3324(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	cmpl	%eax, -3320(%rbp)
	jl	.L18
	movl	-3308(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	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:
