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 <string.h>

int bind[128];
char *i;

int rdp(void)
{
    int a, b;
    char c, op;

    switch (c = *i++) {
        case '0':
        case '1':
        case '2':
            return c - '0';
        case 'P':
        case 'Q':
        case 'R':
            return bind[c];
        case '-':
            return -(rdp() - 1) + 1;
        case '(':
            a = rdp();
            switch (op = *i++) {
                case '*':
                    a = (a * rdp() + 1) / 2;
                    break;
                case '+':
                    b = rdp();
                    a = (a == 1 && b == 1) ? 1 : (a + b >= 2 ? 2 : a + b);
                    break;
            }
            ++i;    // skip ')'
            return a;
    }
    return a;
}

int main(void)
{
    for (;;) {
        char s[81];
        int p, q, r, c = 0;

        scanf("%s", s);
        if (strcmp(s, ".") == 0)
            break;

        for (p = 0; p < 3; ++p) {
            bind['P'] = p;
            for (q = 0; q < 3; ++q) {
                bind['Q'] = q;
                for (r = 0; r < 3; ++r) {
                    bind['R'] = r;
                    i = s;
                    if (rdp() == 2)
                        ++c;
                }
            }
        }

        printf("%d\n", c);
    }

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	bind
	.bss
	.align 32
	.type	bind, @object
	.size	bind, 512
bind:
	.zero	512
	.globl	i
	.align 8
	.type	i, @object
	.size	i, 8
i:
	.zero	8
	.text
	.globl	rdp
	.type	rdp, @function
rdp:
.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
	movq	i(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, i(%rip)
	movzbl	(%rax), %eax
	movb	%al, -10(%rbp)
	movsbl	-10(%rbp), %eax
	cmpl	$82, %eax
	jg	.L2
	cmpl	$80, %eax
	jge	.L3
	cmpl	$50, %eax
	jg	.L2
	cmpl	$48, %eax
	jge	.L4
	cmpl	$40, %eax
	je	.L5
	cmpl	$45, %eax
	je	.L6
	jmp	.L2
.L4:
	movsbl	-10(%rbp), %eax
	subl	$48, %eax
	jmp	.L7
.L3:
	movsbl	-10(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	bind(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L7
.L6:
	call	rdp
	movl	%eax, %edx
	movl	$2, %eax
	subl	%edx, %eax
	jmp	.L7
.L5:
	call	rdp
	movl	%eax, -8(%rbp)
	movq	i(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, i(%rip)
	movzbl	(%rax), %eax
	movb	%al, -9(%rbp)
	movsbl	-9(%rbp), %eax
	cmpl	$42, %eax
	je	.L8
	cmpl	$43, %eax
	je	.L9
	jmp	.L10
.L8:
	call	rdp
	imull	-8(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -8(%rbp)
	jmp	.L10
.L9:
	call	rdp
	movl	%eax, -4(%rbp)
	cmpl	$1, -8(%rbp)
	jne	.L11
	cmpl	$1, -4(%rbp)
	je	.L12
.L11:
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	movl	$2, %edx
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	jmp	.L13
.L12:
	movl	$1, %eax
.L13:
	movl	%eax, -8(%rbp)
	nop
.L10:
	movq	i(%rip), %rax
	addq	$1, %rax
	movq	%rax, i(%rip)
	movl	-8(%rbp), %eax
	jmp	.L7
.L2:
	movl	-8(%rbp), %eax
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	rdp, .-rdp
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"."
.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	$112, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L24:
	movl	$0, -100(%rbp)
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-96(%rbp), %rax
	leaq	.LC1(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L15
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	jmp	.L26
.L15:
	movl	$0, -112(%rbp)
	jmp	.L17
.L23:
	movl	-112(%rbp), %eax
	movl	%eax, 320+bind(%rip)
	movl	$0, -108(%rbp)
	jmp	.L18
.L22:
	movl	-108(%rbp), %eax
	movl	%eax, 324+bind(%rip)
	movl	$0, -104(%rbp)
	jmp	.L19
.L21:
	movl	-104(%rbp), %eax
	movl	%eax, 328+bind(%rip)
	leaq	-96(%rbp), %rax
	movq	%rax, i(%rip)
	call	rdp
	cmpl	$2, %eax
	jne	.L20
	addl	$1, -100(%rbp)
.L20:
	addl	$1, -104(%rbp)
.L19:
	cmpl	$2, -104(%rbp)
	jle	.L21
	addl	$1, -108(%rbp)
.L18:
	cmpl	$2, -108(%rbp)
	jle	.L22
	addl	$1, -112(%rbp)
.L17:
	cmpl	$2, -112(%rbp)
	jle	.L23
	movl	-100(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L24
.L26:
	call	__stack_chk_fail@PLT
.L25:
	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	rdp
	.type	rdp, @function
rdp:
.LFB35:
	.cfi_startproc
	endbr64
	movq	i(%rip), %rax
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	$1, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	1(%rax), %rdx
	xorl	%ebx, %ebx
.L9:
	movq	%rdx, i(%rip)
	movsbl	-1(%rdx), %ecx
	movl	%ecx, %eax
	cmpb	$50, %cl
	jg	.L2
	cmpb	$47, %cl
	jg	.L3
	cmpb	$40, %cl
	je	.L4
	cmpb	$45, %cl
	jne	.L6
	leal	(%rbp,%rbp), %eax
	addq	$1, %rdx
	negl	%ebp
	addl	%eax, %ebx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L2:
	subl	$80, %eax
	cmpb	$2, %al
	ja	.L6
	leaq	bind(%rip), %rax
	movslq	%ecx, %rcx
	imull	(%rax,%rcx,4), %ebp
	leal	(%rbx,%rbp), %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	subl	$48, %ecx
	imull	%ecx, %ebp
	leal	(%rbx,%rbp), %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	call	rdp
	movl	%eax, %r12d
	movq	i(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, i(%rip)
	movzbl	(%rax), %eax
	cmpb	$42, %al
	je	.L10
	cmpb	$43, %al
	je	.L11
.L15:
	imull	%r12d, %ebp
.L12:
	addq	$1, %rdx
	leal	(%rbx,%rbp), %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	movq	%rdx, i(%rip)
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L6:
	.cfi_restore_state
	xorl	%ebp, %ebp
	leal	(%rbx,%rbp), %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	call	rdp
	movq	i(%rip), %rdx
	cmpl	$1, %r12d
	jne	.L13
	cmpl	$1, %eax
	je	.L12
.L13:
	addl	%eax, %r12d
	movl	$2, %eax
	cmpl	%eax, %r12d
	cmovg	%eax, %r12d
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L10:
	call	rdp
	movq	i(%rip), %rdx
	imull	%r12d, %eax
	addl	$1, %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%ecx, %eax
	sarl	%eax
	imull	%eax, %ebp
	jmp	.L12
	.cfi_endproc
.LFE35:
	.size	rdp, .-rdp
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"."
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC2(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	bind(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %r12
	leaq	1(%rsp), %rbx
	.p2align 4,,10
	.p2align 3
.L37:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	cmpw	$46, (%r12)
	je	.L45
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
.L36:
	movl	%r8d, 320+bind(%rip)
	xorl	%r10d, %r10d
.L35:
	movl	%r10d, 324+bind(%rip)
	xorl	%edi, %edi
.L34:
	movl	%edi, 328+bind(%rip)
	movq	%rbx, %rdx
	movl	$1, %esi
	xorl	%r11d, %r11d
.L28:
	movq	%rdx, i(%rip)
	movsbl	-1(%rdx), %ecx
	movl	%ecx, %eax
	cmpb	$50, %cl
	jg	.L21
	cmpb	$47, %cl
	jg	.L22
	cmpb	$40, %cl
	je	.L23
	cmpb	$45, %cl
	jne	.L25
	leal	(%rsi,%rsi), %eax
	addq	$1, %rdx
	negl	%esi
	addl	%eax, %r11d
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L21:
	subl	$80, %eax
	cmpb	$2, %al
	ja	.L25
	movslq	%ecx, %rcx
	imull	0(%rbp,%rcx,4), %esi
.L27:
	addl	%r11d, %esi
	xorl	%eax, %eax
	cmpl	$2, %esi
	sete	%al
	addl	$1, %edi
	addl	%eax, %r9d
	cmpl	$3, %edi
	jne	.L34
	addl	$1, %r10d
	cmpl	$3, %r10d
	jne	.L35
	addl	$1, %r8d
	cmpl	$3, %r8d
	jne	.L36
	movl	%r9d, %edx
	movq	%r14, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L25:
	xorl	%esi, %esi
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L23:
	call	rdp
	movl	%eax, %r15d
	movq	i(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, i(%rip)
	movzbl	(%rax), %eax
	cmpb	$42, %al
	je	.L29
	cmpb	$43, %al
	jne	.L44
	call	rdp
	movq	i(%rip), %rdx
	cmpl	$1, %r15d
	jne	.L32
	cmpl	$1, %eax
	jne	.L32
	.p2align 4,,10
	.p2align 3
.L31:
	addq	$1, %rdx
	movq	%rdx, i(%rip)
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L22:
	subl	$48, %ecx
	imull	%ecx, %esi
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L32:
	addl	%eax, %r15d
	movl	$2, %eax
	cmpl	%eax, %r15d
	cmovg	%eax, %r15d
.L44:
	imull	%r15d, %esi
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L29:
	call	rdp
	movq	i(%rip), %rdx
	imull	%r15d, %eax
	addl	$1, %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%ecx, %eax
	sarl	%eax
	imull	%eax, %esi
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L45:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L46
	addq	$104, %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
.L46:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.globl	i
	.bss
	.align 8
	.type	i, @object
	.size	i, 8
i:
	.zero	8
	.globl	bind
	.align 32
	.type	bind, @object
	.size	bind, 512
bind:
	.zero	512
	.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	rdp
	.type	rdp, @function
rdp:
.LFB35:
	.cfi_startproc
	endbr64
	movq	i(%rip), %rax
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	$1, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	1(%rax), %rdx
	xorl	%ebx, %ebx
.L9:
	movq	%rdx, i(%rip)
	movsbl	-1(%rdx), %ecx
	movl	%ecx, %eax
	cmpb	$50, %cl
	jg	.L2
	cmpb	$47, %cl
	jg	.L3
	cmpb	$40, %cl
	je	.L4
	cmpb	$45, %cl
	jne	.L6
	leal	(%rbp,%rbp), %eax
	addq	$1, %rdx
	negl	%ebp
	addl	%eax, %ebx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L2:
	subl	$80, %eax
	cmpb	$2, %al
	ja	.L6
	leaq	bind(%rip), %rax
	movslq	%ecx, %rcx
	imull	(%rax,%rcx,4), %ebp
	leal	(%rbx,%rbp), %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	subl	$48, %ecx
	imull	%ecx, %ebp
	leal	(%rbx,%rbp), %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	call	rdp
	movl	%eax, %r12d
	movq	i(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, i(%rip)
	movzbl	(%rax), %eax
	cmpb	$42, %al
	je	.L10
	cmpb	$43, %al
	je	.L11
.L15:
	imull	%r12d, %ebp
.L12:
	addq	$1, %rdx
	leal	(%rbx,%rbp), %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	movq	%rdx, i(%rip)
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L6:
	.cfi_restore_state
	xorl	%ebp, %ebp
	leal	(%rbx,%rbp), %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	call	rdp
	movq	i(%rip), %rdx
	cmpl	$1, %r12d
	jne	.L13
	cmpl	$1, %eax
	je	.L12
.L13:
	addl	%eax, %r12d
	movl	$2, %eax
	cmpl	%eax, %r12d
	cmovg	%eax, %r12d
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L10:
	call	rdp
	movq	i(%rip), %rdx
	imull	%r12d, %eax
	addl	$1, %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%ecx, %eax
	sarl	%eax
	imull	%eax, %ebp
	jmp	.L12
	.cfi_endproc
.LFE35:
	.size	rdp, .-rdp
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"."
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC2(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	bind(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %r12
	leaq	1(%rsp), %rbx
	.p2align 4,,10
	.p2align 3
.L37:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	cmpw	$46, (%r12)
	je	.L45
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
.L36:
	movl	%r8d, 320+bind(%rip)
	xorl	%r10d, %r10d
.L35:
	movl	%r10d, 324+bind(%rip)
	xorl	%edi, %edi
.L34:
	movl	%edi, 328+bind(%rip)
	movq	%rbx, %rdx
	movl	$1, %esi
	xorl	%r11d, %r11d
.L28:
	movq	%rdx, i(%rip)
	movsbl	-1(%rdx), %ecx
	movl	%ecx, %eax
	cmpb	$50, %cl
	jg	.L21
	cmpb	$47, %cl
	jg	.L22
	cmpb	$40, %cl
	je	.L23
	cmpb	$45, %cl
	jne	.L25
	leal	(%rsi,%rsi), %eax
	addq	$1, %rdx
	negl	%esi
	addl	%eax, %r11d
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L21:
	subl	$80, %eax
	cmpb	$2, %al
	ja	.L25
	movslq	%ecx, %rcx
	imull	0(%rbp,%rcx,4), %esi
.L27:
	addl	%r11d, %esi
	xorl	%eax, %eax
	cmpl	$2, %esi
	sete	%al
	addl	$1, %edi
	addl	%eax, %r9d
	cmpl	$3, %edi
	jne	.L34
	addl	$1, %r10d
	cmpl	$3, %r10d
	jne	.L35
	addl	$1, %r8d
	cmpl	$3, %r8d
	jne	.L36
	movl	%r9d, %edx
	movq	%r14, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L25:
	xorl	%esi, %esi
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L23:
	call	rdp
	movl	%eax, %r15d
	movq	i(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, i(%rip)
	movzbl	(%rax), %eax
	cmpb	$42, %al
	je	.L29
	cmpb	$43, %al
	jne	.L44
	call	rdp
	movq	i(%rip), %rdx
	cmpl	$1, %r15d
	jne	.L32
	cmpl	$1, %eax
	jne	.L32
	.p2align 4,,10
	.p2align 3
.L31:
	addq	$1, %rdx
	movq	%rdx, i(%rip)
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L22:
	subl	$48, %ecx
	imull	%ecx, %esi
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L32:
	addl	%eax, %r15d
	movl	$2, %eax
	cmpl	%eax, %r15d
	cmovg	%eax, %r15d
.L44:
	imull	%r15d, %esi
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L29:
	call	rdp
	movq	i(%rip), %rdx
	imull	%r15d, %eax
	addl	$1, %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%ecx, %eax
	sarl	%eax
	imull	%eax, %esi
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L45:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L46
	addq	$104, %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
.L46:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.globl	i
	.bss
	.align 8
	.type	i, @object
	.size	i, 8
i:
	.zero	8
	.globl	bind
	.align 32
	.type	bind, @object
	.size	bind, 512
bind:
	.zero	512
	.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 <string.h>

int bind[128];
char *i;

int rdp(void)
{
    int a, b;
    char c, op;

    switch (c = *i++) {
        case '0':
        case '1':
        case '2':
            return c - '0';
        case 'P':
        case 'Q':
        case 'R':
            return bind[c];
        case '-':
            return -(rdp() - 1) + 1;
        case '(':
            a = rdp();
            switch (op = *i++) {
                case '*':
                    a = (a * rdp() + 1) / 2;
                    break;
                case '+':
                    b = rdp();
                    a = (a == 1 && b == 1) ? 1 : (a + b >= 2 ? 2 : a + b);
                    break;
            }
            ++i;    // skip ')'
            return a;
    }
    return a;
}

int main(void)
{
    for (;;) {
        char s[81];
        int p, q, r, c = 0;

        scanf("%s", s);
        if (strcmp(s, ".") == 0)
            break;

        for (p = 0; p < 3; ++p) {
            bind['P'] = p;
            for (q = 0; q < 3; ++q) {
                bind['Q'] = q;
                for (r = 0; r < 3; ++r) {
                    bind['R'] = r;
                    i = s;
                    if (rdp() == 2)
                        ++c;
                }
            }
        }

        printf("%d\n", c);
    }

    return 0;
}
(P*Q)
(--R+(P*R))
(P*-P)
2
1
(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))
.
 (P*Q)
(--R+(P*Q))
(P*-P)
1
1
(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))
.
 (P*Q)
(--R+(P*R))
(P*-P)
1
0
(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))
.
 (P*Q)
(--R+(P*Q))
(P*-P)
1
2
(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))
.
 (Q*Q)
(--R+(P*R))
(P*-P)
2
0
(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))
.
 (P*Q)
(--R+(P*Q))
(P*-P)
1
2
(-1+(((---P+Q)*(--R+---R))*(-R+-P)))
.
 (P*Q)
(--R+(P*R))
(P*-P)
2
0
(-1+(((---P+Q)*(--Q+---R))*(-R+-Q)))
.
 (P*Q)
(--R+(P*R))
(P*-P)
-2
2
(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))
.
 (P*P)
(--R+(P*R))
(P*-P)
1
0
(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))
.
 (P+Q)
(--R+(P*R))
(P*-P)
0
1
(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))
.

3
9
0
27
0
7
 3
11
0
0
0
7
 3
9
0
0
0
7
 3
11
0
0
27
7
 9
9
0
27
0
7
 3
11
0
0
27
8
 3
9
0
27
0
5
 3
9
0
0
27
7
 9
9
0
0
0
7
 15
9
0
0
0
7

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 <string.h>

int bind[128];
char *i;

int rdp(void)
{
    int a, b;
    char c, op;

    switch (c = *i++) {
        case '0':
        case '1':
        case '2':
            return c - '0';
        case 'P':
        case 'Q':
        case 'R':
            return bind[c];
        case '-':
            return -(rdp() - 1) + 1;
        case '(':
            a = rdp();
            switch (op = *i++) {
                case '*':
                    a = (a * rdp() + 1) / 2;
                    break;
                case '+':
                    b = rdp();
                    a = (a == 1 && b == 1) ? 1 : (a + b >= 2 ? 2 : a + b);
                    break;
            }
            ++i;    // skip ')'
            return a;
    }
    return a;
}

int main(void)
{
    for (;;) {
        char s[81];
        int p, q, r, c = 0;

        scanf("%s", s);
        if (strcmp(s, ".") == 0)
            break;

        for (p = 0; p < 3; ++p) {
            bind['P'] = p;
            for (q = 0; q < 3; ++q) {
                bind['Q'] = q;
                for (r = 0; r < 3; ++r) {
                    bind['R'] = r;
                    i = s;
                    if (rdp() == 2)
                        ++c;
                }
            }
        }

        printf("%d\n", c);
    }

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	bind
	.bss
	.align 32
	.type	bind, @object
	.size	bind, 512
bind:
	.zero	512
	.globl	i
	.align 8
	.type	i, @object
	.size	i, 8
i:
	.zero	8
	.text
	.globl	rdp
	.type	rdp, @function
rdp:
.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
	movq	i(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, i(%rip)
	movzbl	(%rax), %eax
	movb	%al, -10(%rbp)
	movsbl	-10(%rbp), %eax
	cmpl	$82, %eax
	jg	.L2
	cmpl	$80, %eax
	jge	.L3
	cmpl	$50, %eax
	jg	.L2
	cmpl	$48, %eax
	jge	.L4
	cmpl	$40, %eax
	je	.L5
	cmpl	$45, %eax
	je	.L6
	jmp	.L2
.L4:
	movsbl	-10(%rbp), %eax
	subl	$48, %eax
	jmp	.L7
.L3:
	movsbl	-10(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	bind(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L7
.L6:
	call	rdp
	movl	%eax, %edx
	movl	$2, %eax
	subl	%edx, %eax
	jmp	.L7
.L5:
	call	rdp
	movl	%eax, -8(%rbp)
	movq	i(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, i(%rip)
	movzbl	(%rax), %eax
	movb	%al, -9(%rbp)
	movsbl	-9(%rbp), %eax
	cmpl	$42, %eax
	je	.L8
	cmpl	$43, %eax
	je	.L9
	jmp	.L10
.L8:
	call	rdp
	imull	-8(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -8(%rbp)
	jmp	.L10
.L9:
	call	rdp
	movl	%eax, -4(%rbp)
	cmpl	$1, -8(%rbp)
	jne	.L11
	cmpl	$1, -4(%rbp)
	je	.L12
.L11:
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	movl	$2, %edx
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	jmp	.L13
.L12:
	movl	$1, %eax
.L13:
	movl	%eax, -8(%rbp)
	nop
.L10:
	movq	i(%rip), %rax
	addq	$1, %rax
	movq	%rax, i(%rip)
	movl	-8(%rbp), %eax
	jmp	.L7
.L2:
	movl	-8(%rbp), %eax
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	rdp, .-rdp
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"."
.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	$112, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L24:
	movl	$0, -100(%rbp)
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-96(%rbp), %rax
	leaq	.LC1(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L15
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	jmp	.L26
.L15:
	movl	$0, -112(%rbp)
	jmp	.L17
.L23:
	movl	-112(%rbp), %eax
	movl	%eax, 320+bind(%rip)
	movl	$0, -108(%rbp)
	jmp	.L18
.L22:
	movl	-108(%rbp), %eax
	movl	%eax, 324+bind(%rip)
	movl	$0, -104(%rbp)
	jmp	.L19
.L21:
	movl	-104(%rbp), %eax
	movl	%eax, 328+bind(%rip)
	leaq	-96(%rbp), %rax
	movq	%rax, i(%rip)
	call	rdp
	cmpl	$2, %eax
	jne	.L20
	addl	$1, -100(%rbp)
.L20:
	addl	$1, -104(%rbp)
.L19:
	cmpl	$2, -104(%rbp)
	jle	.L21
	addl	$1, -108(%rbp)
.L18:
	cmpl	$2, -108(%rbp)
	jle	.L22
	addl	$1, -112(%rbp)
.L17:
	cmpl	$2, -112(%rbp)
	jle	.L23
	movl	-100(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L24
.L26:
	call	__stack_chk_fail@PLT
.L25:
	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	bind
	.bss
	.align 32
	.type	bind, @object
	.size	bind, 512
bind:
	.zero	512
	.globl	i
	.align 8
	.type	i, @object
	.size	i, 8
i:
	.zero	8
	.text
	.globl	rdp
	.type	rdp, @function
rdp:
.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
	movq	i(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, i(%rip)
	movzbl	(%rax), %eax
	movb	%al, -10(%rbp)
	movsbl	-10(%rbp), %eax
	cmpl	$82, %eax
	jg	.L2
	cmpl	$80, %eax
	jge	.L3
	cmpl	$50, %eax
	jg	.L2
	cmpl	$48, %eax
	jge	.L4
	cmpl	$40, %eax
	je	.L5
	cmpl	$45, %eax
	je	.L6
	jmp	.L2
.L4:
	movsbl	-10(%rbp), %eax
	subl	$48, %eax
	jmp	.L7
.L3:
	movsbl	-10(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	bind(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L7
.L6:
	call	rdp
	movl	%eax, %edx
	movl	$2, %eax
	subl	%edx, %eax
	jmp	.L7
.L5:
	call	rdp
	movl	%eax, -8(%rbp)
	movq	i(%rip), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, i(%rip)
	movzbl	(%rax), %eax
	movb	%al, -9(%rbp)
	movsbl	-9(%rbp), %eax
	cmpl	$42, %eax
	je	.L8
	cmpl	$43, %eax
	je	.L9
	jmp	.L10
.L8:
	call	rdp
	imull	-8(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -8(%rbp)
	jmp	.L10
.L9:
	call	rdp
	movl	%eax, -4(%rbp)
	cmpl	$1, -8(%rbp)
	jne	.L11
	cmpl	$1, -4(%rbp)
	je	.L12
.L11:
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	movl	$2, %edx
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	jmp	.L13
.L12:
	movl	$1, %eax
.L13:
	movl	%eax, -8(%rbp)
	nop
.L10:
	movq	i(%rip), %rax
	addq	$1, %rax
	movq	%rax, i(%rip)
	movl	-8(%rbp), %eax
	jmp	.L7
.L2:
	movl	-8(%rbp), %eax
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	rdp, .-rdp
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"."
.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	$112, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L24:
	movl	$0, -100(%rbp)
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-96(%rbp), %rax
	leaq	.LC1(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L15
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	jmp	.L26
.L15:
	movl	$0, -112(%rbp)
	jmp	.L17
.L23:
	movl	-112(%rbp), %eax
	movl	%eax, 320+bind(%rip)
	movl	$0, -108(%rbp)
	jmp	.L18
.L22:
	movl	-108(%rbp), %eax
	movl	%eax, 324+bind(%rip)
	movl	$0, -104(%rbp)
	jmp	.L19
.L21:
	movl	-104(%rbp), %eax
	movl	%eax, 328+bind(%rip)
	leaq	-96(%rbp), %rax
	movq	%rax, i(%rip)
	call	rdp
	cmpl	$2, %eax
	jne	.L20
	addl	$1, -100(%rbp)
.L20:
	addl	$1, -104(%rbp)
.L19:
	cmpl	$2, -104(%rbp)
	jle	.L21
	addl	$1, -108(%rbp)
.L18:
	cmpl	$2, -108(%rbp)
	jle	.L22
	addl	$1, -112(%rbp)
.L17:
	cmpl	$2, -112(%rbp)
	jle	.L23
	movl	-100(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L24
.L26:
	call	__stack_chk_fail@PLT
.L25:
	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:
