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>
#include <stdbool.h>
#include <math.h>

int main(void){
    int n,p,even=0,odd=0;
    long long ans=1,tmp1=1,tmp2=0;
    scanf("%d%d",&n,&p);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        if(a[i]%2==0){
            even++;
        } else {
            odd++;
        }
    }
    if (p==0){
        for (int i=0; i<even; i++){
            ans*=2;
        }
        for (int i=0; i<=odd/2; i++){
            for (int j=0; j<i*2; j++){
                tmp1=tmp1*(odd-j)/(j+1);
            }
            tmp2+=tmp1;
            tmp1=1;
        }
        ans=ans*tmp2;
    } else {
        for (int i=0; i<even; i++){
            ans*=2;
        }
        for (int i=0; i<odd/2; i++){
            for(int j=0; j<i*2+1; j++){
                tmp1=tmp1*(odd-j)/(j+1);
            }
            tmp2+=tmp1;
            tmp1=1;
        }
        ans=ans*tmp2;
    }
    printf("%lld\n",ans);
	return 0 ;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$104, %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
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -132(%rbp)
	movl	$0, -128(%rbp)
	movq	$1, -96(%rbp)
	movq	$1, -88(%rbp)
	movq	$0, -80(%rbp)
	leaq	-136(%rbp), %rdx
	leaq	-140(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-140(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %ecx
	movl	$0, %edx
	divq	%rcx
	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	$0, -124(%rbp)
	jmp	.L5
.L8:
	movl	-124(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	movl	-124(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L6
	addl	$1, -132(%rbp)
	jmp	.L7
.L6:
	addl	$1, -128(%rbp)
.L7:
	addl	$1, -124(%rbp)
.L5:
	movl	-140(%rbp), %eax
	cmpl	%eax, -124(%rbp)
	jl	.L8
	movl	-136(%rbp), %eax
	testl	%eax, %eax
	jne	.L9
	movl	$0, -120(%rbp)
	jmp	.L10
.L11:
	salq	-96(%rbp)
	addl	$1, -120(%rbp)
.L10:
	movl	-120(%rbp), %eax
	cmpl	-132(%rbp), %eax
	jl	.L11
	movl	$0, -116(%rbp)
	jmp	.L12
.L15:
	movl	$0, -112(%rbp)
	jmp	.L13
.L14:
	movl	-128(%rbp), %eax
	subl	-112(%rbp), %eax
	cltq
	imulq	-88(%rbp), %rax
	movl	-112(%rbp), %edx
	addl	$1, %edx
	movslq	%edx, %rsi
	cqto
	idivq	%rsi
	movq	%rax, -88(%rbp)
	addl	$1, -112(%rbp)
.L13:
	movl	-116(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -112(%rbp)
	jl	.L14
	movq	-88(%rbp), %rax
	addq	%rax, -80(%rbp)
	movq	$1, -88(%rbp)
	addl	$1, -116(%rbp)
.L12:
	movl	-128(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -116(%rbp)
	jle	.L15
	movq	-96(%rbp), %rax
	imulq	-80(%rbp), %rax
	movq	%rax, -96(%rbp)
	jmp	.L16
.L9:
	movl	$0, -108(%rbp)
	jmp	.L17
.L18:
	salq	-96(%rbp)
	addl	$1, -108(%rbp)
.L17:
	movl	-108(%rbp), %eax
	cmpl	-132(%rbp), %eax
	jl	.L18
	movl	$0, -104(%rbp)
	jmp	.L19
.L22:
	movl	$0, -100(%rbp)
	jmp	.L20
.L21:
	movl	-128(%rbp), %eax
	subl	-100(%rbp), %eax
	cltq
	imulq	-88(%rbp), %rax
	movl	-100(%rbp), %edx
	addl	$1, %edx
	movslq	%edx, %rdi
	cqto
	idivq	%rdi
	movq	%rax, -88(%rbp)
	addl	$1, -100(%rbp)
.L20:
	movl	-104(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -100(%rbp)
	jle	.L21
	movq	-88(%rbp), %rax
	addq	%rax, -80(%rbp)
	movq	$1, -88(%rbp)
	addl	$1, -104(%rbp)
.L19:
	movl	-128(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -104(%rbp)
	jl	.L22
	movq	-96(%rbp), %rax
	imulq	-80(%rbp), %rax
	movq	%rax, -96(%rbp)
.L16:
	movq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %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
	call	__isoc99_scanf@PLT
	movslq	-64(%rbp), %rax
	movq	%rsp, %rsi
	movq	%rax, %rcx
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rsi
	andq	$-16, %rdx
	cmpq	%rsi, %rsp
	je	.L3
.L40:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L40
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L41
.L4:
	movq	%rsp, %r12
	testl	%ecx, %ecx
	jle	.L5
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r15
	xorl	%r14d, %r14d
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L43:
	addl	$1, %r14d
	addl	$1, %r13d
	addq	$4, %r12
	cmpl	%r13d, -64(%rbp)
	jle	.L42
.L8:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%r15, %rdi
	call	__isoc99_scanf@PLT
	testb	$1, (%r12)
	je	.L43
	addl	$1, %ebx
	addl	$1, %r13d
	addq	$4, %r12
	cmpl	%r13d, -64(%rbp)
	jg	.L8
.L42:
	movl	-60(%rbp), %eax
	testl	%eax, %eax
	je	.L12
	xorl	%eax, %eax
	movl	$1, %r8d
	testl	%r14d, %r14d
	je	.L14
	.p2align 4,,10
	.p2align 3
.L13:
	addl	$1, %eax
	addq	%r8, %r8
	cmpl	%eax, %r14d
	jne	.L13
.L14:
	movl	%ebx, %eax
	sarl	%eax
	je	.L27
	leal	1(%rax), %r10d
	movslq	%ebx, %rsi
	movl	$2, %edi
	xorl	%r9d, %r9d
	addq	%r10, %r10
	addq	$1, %rsi
	.p2align 4,,10
	.p2align 3
.L20:
	movl	$1, %ecx
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L21:
	movq	%rsi, %rdx
	subq	%rcx, %rdx
	imulq	%rdx, %rax
	cqto
	idivq	%rcx
	addq	$1, %rcx
	cmpq	%rcx, %rdi
	jne	.L21
	addq	$2, %rdi
	addq	%rax, %r9
	cmpq	%r10, %rdi
	jne	.L20
.L11:
	movq	%r8, %rdx
	xorl	%eax, %eax
	movl	$1, %edi
	imulq	%r9, %rdx
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L44
	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
.L12:
	.cfi_restore_state
	movl	$1, %r9d
	testl	%r14d, %r14d
	je	.L15
	.p2align 4,,10
	.p2align 3
.L16:
	addl	$1, %eax
	addq	%r9, %r9
	cmpl	%eax, %r14d
	jne	.L16
.L15:
	movl	%ebx, %eax
	sarl	%eax
	je	.L26
	leal	-1(%rax), %r10d
	movslq	%ebx, %rsi
	movl	$3, %edi
	movl	$1, %r8d
	addq	%r10, %r10
	addq	$1, %rsi
	addq	$5, %r10
	.p2align 4,,10
	.p2align 3
.L17:
	movl	$1, %ecx
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%rsi, %rdx
	subq	%rcx, %rdx
	imulq	%rdx, %rax
	cqto
	idivq	%rcx
	addq	$1, %rcx
	cmpq	%rcx, %rdi
	jne	.L18
	addq	$2, %rdi
	addq	%rax, %r8
	cmpq	%rdi, %r10
	jne	.L17
	jmp	.L11
.L41:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L5:
	cmpl	$0, -60(%rbp)
	je	.L23
	movl	$1, %r8d
	xorl	%r9d, %r9d
	jmp	.L11
.L23:
	movl	$1, %r9d
	movl	$1, %r8d
	jmp	.L11
.L27:
	xorl	%r9d, %r9d
	jmp	.L11
.L44:
	call	__stack_chk_fail@PLT
.L26:
	movl	$1, %r8d
	jmp	.L11
	.cfi_endproc
.LFE51:
	.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%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %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
	call	__isoc99_scanf@PLT
	movslq	-64(%rbp), %rax
	movq	%rsp, %rsi
	movq	%rax, %rcx
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rsi
	andq	$-16, %rdx
	cmpq	%rsi, %rsp
	je	.L3
.L40:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L40
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L41
.L4:
	movq	%rsp, %r12
	testl	%ecx, %ecx
	jle	.L5
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r15
	xorl	%r14d, %r14d
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L43:
	addl	$1, %r14d
	addl	$1, %r13d
	addq	$4, %r12
	cmpl	%r13d, -64(%rbp)
	jle	.L42
.L8:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%r15, %rdi
	call	__isoc99_scanf@PLT
	testb	$1, (%r12)
	je	.L43
	addl	$1, %ebx
	addl	$1, %r13d
	addq	$4, %r12
	cmpl	%r13d, -64(%rbp)
	jg	.L8
.L42:
	movl	-60(%rbp), %eax
	testl	%eax, %eax
	je	.L12
	xorl	%eax, %eax
	movl	$1, %r8d
	testl	%r14d, %r14d
	je	.L14
	.p2align 4,,10
	.p2align 3
.L13:
	addl	$1, %eax
	addq	%r8, %r8
	cmpl	%eax, %r14d
	jne	.L13
.L14:
	movl	%ebx, %eax
	sarl	%eax
	je	.L27
	leal	1(%rax), %r10d
	movslq	%ebx, %rsi
	movl	$2, %edi
	xorl	%r9d, %r9d
	addq	%r10, %r10
	addq	$1, %rsi
	.p2align 4,,10
	.p2align 3
.L20:
	movl	$1, %ecx
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L21:
	movq	%rsi, %rdx
	subq	%rcx, %rdx
	imulq	%rdx, %rax
	cqto
	idivq	%rcx
	addq	$1, %rcx
	cmpq	%rcx, %rdi
	jne	.L21
	addq	$2, %rdi
	addq	%rax, %r9
	cmpq	%r10, %rdi
	jne	.L20
.L11:
	movq	%r8, %rdx
	xorl	%eax, %eax
	movl	$1, %edi
	imulq	%r9, %rdx
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L44
	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
.L12:
	.cfi_restore_state
	movl	$1, %r9d
	testl	%r14d, %r14d
	je	.L15
	.p2align 4,,10
	.p2align 3
.L16:
	addl	$1, %eax
	addq	%r9, %r9
	cmpl	%eax, %r14d
	jne	.L16
.L15:
	movl	%ebx, %eax
	sarl	%eax
	je	.L26
	leal	-1(%rax), %r10d
	movslq	%ebx, %rsi
	movl	$3, %edi
	movl	$1, %r8d
	addq	%r10, %r10
	addq	$1, %rsi
	addq	$5, %r10
	.p2align 4,,10
	.p2align 3
.L17:
	movl	$1, %ecx
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%rsi, %rdx
	subq	%rcx, %rdx
	imulq	%rdx, %rax
	cqto
	idivq	%rcx
	addq	$1, %rcx
	cmpq	%rcx, %rdi
	jne	.L18
	addq	$2, %rdi
	addq	%rax, %r8
	cmpq	%rdi, %r10
	jne	.L17
	jmp	.L11
.L41:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L5:
	cmpl	$0, -60(%rbp)
	je	.L23
	movl	$1, %r8d
	xorl	%r9d, %r9d
	jmp	.L11
.L23:
	movl	$1, %r9d
	movl	$1, %r8d
	jmp	.L11
.L27:
	xorl	%r9d, %r9d
	jmp	.L11
.L44:
	call	__stack_chk_fail@PLT
.L26:
	movl	$1, %r8d
	jmp	.L11
	.cfi_endproc
.LFE51:
	.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>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int n,p,even=0,odd=0;
    long long ans=1,tmp1=1,tmp2=0;
    scanf("%d%d",&n,&p);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        if(a[i]%2==0){
            even++;
        } else {
            odd++;
        }
    }
    if (p==0){
        for (int i=0; i<even; i++){
            ans*=2;
        }
        for (int i=0; i<=odd/2; i++){
            for (int j=0; j<i*2; j++){
                tmp1=tmp1*(odd-j)/(j+1);
            }
            tmp2+=tmp1;
            tmp1=1;
        }
        ans=ans*tmp2;
    } else {
        for (int i=0; i<even; i++){
            ans*=2;
        }
        for (int i=0; i<odd/2; i++){
            for(int j=0; j<i*2+1; j++){
                tmp1=tmp1*(odd-j)/(j+1);
            }
            tmp2+=tmp1;
            tmp1=1;
        }
        ans=ans*tmp2;
    }
    printf("%lld\n",ans);
	return 0 ;
}
1 1
67
 45 1
17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 68 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26
 3 1
1 1 1
 2 0
1 1
 1 1
42
 45 1
17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 68 25 9 89 71 41 16 53 11 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26
 45 1
17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 68 25 9 89 71 41 16 53 11 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 24 26
 45 1
17 55 85 55 74 20 90 67 40 121 39 89 91 50 16 24 14 43 24 68 25 9 89 71 41 16 53 11 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 24 26
 45 1
17 55 85 55 74 20 90 67 40 121 39 89 91 50 16 38 14 43 24 68 25 9 89 71 41 16 53 11 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 24 26
 45 1
17 55 85 55 74 20 90 67 40 121 39 178 91 50 16 38 14 43 24 68 25 9 89 71 41 16 53 11 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 24 26

0
 17592186044416
 3
 2
 0
 17592186044416
 17592181850112
 17592186044416
 17592186044416
 17592181850112

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>
#include <stdbool.h>
#include <math.h>

int main(void){
    int n,p,even=0,odd=0;
    long long ans=1,tmp1=1,tmp2=0;
    scanf("%d%d",&n,&p);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        if(a[i]%2==0){
            even++;
        } else {
            odd++;
        }
    }
    if (p==0){
        for (int i=0; i<even; i++){
            ans*=2;
        }
        for (int i=0; i<=odd/2; i++){
            for (int j=0; j<i*2; j++){
                tmp1=tmp1*(odd-j)/(j+1);
            }
            tmp2+=tmp1;
            tmp1=1;
        }
        ans=ans*tmp2;
    } else {
        for (int i=0; i<even; i++){
            ans*=2;
        }
        for (int i=0; i<odd/2; i++){
            for(int j=0; j<i*2+1; j++){
                tmp1=tmp1*(odd-j)/(j+1);
            }
            tmp2+=tmp1;
            tmp1=1;
        }
        ans=ans*tmp2;
    }
    printf("%lld\n",ans);
	return 0 ;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$104, %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
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -132(%rbp)
	movl	$0, -128(%rbp)
	movq	$1, -96(%rbp)
	movq	$1, -88(%rbp)
	movq	$0, -80(%rbp)
	leaq	-136(%rbp), %rdx
	leaq	-140(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-140(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %ecx
	movl	$0, %edx
	divq	%rcx
	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	$0, -124(%rbp)
	jmp	.L5
.L8:
	movl	-124(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	movl	-124(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L6
	addl	$1, -132(%rbp)
	jmp	.L7
.L6:
	addl	$1, -128(%rbp)
.L7:
	addl	$1, -124(%rbp)
.L5:
	movl	-140(%rbp), %eax
	cmpl	%eax, -124(%rbp)
	jl	.L8
	movl	-136(%rbp), %eax
	testl	%eax, %eax
	jne	.L9
	movl	$0, -120(%rbp)
	jmp	.L10
.L11:
	salq	-96(%rbp)
	addl	$1, -120(%rbp)
.L10:
	movl	-120(%rbp), %eax
	cmpl	-132(%rbp), %eax
	jl	.L11
	movl	$0, -116(%rbp)
	jmp	.L12
.L15:
	movl	$0, -112(%rbp)
	jmp	.L13
.L14:
	movl	-128(%rbp), %eax
	subl	-112(%rbp), %eax
	cltq
	imulq	-88(%rbp), %rax
	movl	-112(%rbp), %edx
	addl	$1, %edx
	movslq	%edx, %rsi
	cqto
	idivq	%rsi
	movq	%rax, -88(%rbp)
	addl	$1, -112(%rbp)
.L13:
	movl	-116(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -112(%rbp)
	jl	.L14
	movq	-88(%rbp), %rax
	addq	%rax, -80(%rbp)
	movq	$1, -88(%rbp)
	addl	$1, -116(%rbp)
.L12:
	movl	-128(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -116(%rbp)
	jle	.L15
	movq	-96(%rbp), %rax
	imulq	-80(%rbp), %rax
	movq	%rax, -96(%rbp)
	jmp	.L16
.L9:
	movl	$0, -108(%rbp)
	jmp	.L17
.L18:
	salq	-96(%rbp)
	addl	$1, -108(%rbp)
.L17:
	movl	-108(%rbp), %eax
	cmpl	-132(%rbp), %eax
	jl	.L18
	movl	$0, -104(%rbp)
	jmp	.L19
.L22:
	movl	$0, -100(%rbp)
	jmp	.L20
.L21:
	movl	-128(%rbp), %eax
	subl	-100(%rbp), %eax
	cltq
	imulq	-88(%rbp), %rax
	movl	-100(%rbp), %edx
	addl	$1, %edx
	movslq	%edx, %rdi
	cqto
	idivq	%rdi
	movq	%rax, -88(%rbp)
	addl	$1, -100(%rbp)
.L20:
	movl	-104(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -100(%rbp)
	jle	.L21
	movq	-88(%rbp), %rax
	addq	%rax, -80(%rbp)
	movq	$1, -88(%rbp)
	addl	$1, -104(%rbp)
.L19:
	movl	-128(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -104(%rbp)
	jl	.L22
	movq	-96(%rbp), %rax
	imulq	-80(%rbp), %rax
	movq	%rax, -96(%rbp)
.L16:
	movq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%lld\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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$104, %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
	movq	%rsp, %rax
	movq	%rax, %rbx
	movl	$0, -132(%rbp)
	movl	$0, -128(%rbp)
	movq	$1, -96(%rbp)
	movq	$1, -88(%rbp)
	movq	$0, -80(%rbp)
	leaq	-136(%rbp), %rdx
	leaq	-140(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-140(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %ecx
	movl	$0, %edx
	divq	%rcx
	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	$0, -124(%rbp)
	jmp	.L5
.L8:
	movl	-124(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-64(%rbp), %rax
	movl	-124(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L6
	addl	$1, -132(%rbp)
	jmp	.L7
.L6:
	addl	$1, -128(%rbp)
.L7:
	addl	$1, -124(%rbp)
.L5:
	movl	-140(%rbp), %eax
	cmpl	%eax, -124(%rbp)
	jl	.L8
	movl	-136(%rbp), %eax
	testl	%eax, %eax
	jne	.L9
	movl	$0, -120(%rbp)
	jmp	.L10
.L11:
	salq	-96(%rbp)
	addl	$1, -120(%rbp)
.L10:
	movl	-120(%rbp), %eax
	cmpl	-132(%rbp), %eax
	jl	.L11
	movl	$0, -116(%rbp)
	jmp	.L12
.L15:
	movl	$0, -112(%rbp)
	jmp	.L13
.L14:
	movl	-128(%rbp), %eax
	subl	-112(%rbp), %eax
	cltq
	imulq	-88(%rbp), %rax
	movl	-112(%rbp), %edx
	addl	$1, %edx
	movslq	%edx, %rsi
	cqto
	idivq	%rsi
	movq	%rax, -88(%rbp)
	addl	$1, -112(%rbp)
.L13:
	movl	-116(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -112(%rbp)
	jl	.L14
	movq	-88(%rbp), %rax
	addq	%rax, -80(%rbp)
	movq	$1, -88(%rbp)
	addl	$1, -116(%rbp)
.L12:
	movl	-128(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -116(%rbp)
	jle	.L15
	movq	-96(%rbp), %rax
	imulq	-80(%rbp), %rax
	movq	%rax, -96(%rbp)
	jmp	.L16
.L9:
	movl	$0, -108(%rbp)
	jmp	.L17
.L18:
	salq	-96(%rbp)
	addl	$1, -108(%rbp)
.L17:
	movl	-108(%rbp), %eax
	cmpl	-132(%rbp), %eax
	jl	.L18
	movl	$0, -104(%rbp)
	jmp	.L19
.L22:
	movl	$0, -100(%rbp)
	jmp	.L20
.L21:
	movl	-128(%rbp), %eax
	subl	-100(%rbp), %eax
	cltq
	imulq	-88(%rbp), %rax
	movl	-100(%rbp), %edx
	addl	$1, %edx
	movslq	%edx, %rdi
	cqto
	idivq	%rdi
	movq	%rax, -88(%rbp)
	addl	$1, -100(%rbp)
.L20:
	movl	-104(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -100(%rbp)
	jle	.L21
	movq	-88(%rbp), %rax
	addq	%rax, -80(%rbp)
	movq	$1, -88(%rbp)
	addl	$1, -104(%rbp)
.L19:
	movl	-128(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -104(%rbp)
	jl	.L22
	movq	-96(%rbp), %rax
	imulq	-80(%rbp), %rax
	movq	%rax, -96(%rbp)
.L16:
	movq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.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:
