// File: protonpopsicle[P]lang/src/compiler/ByteCoder.cpp
// Function: ByteCoder::evalBool(short, char, char)
char ByteCoder::evalBool(short oper, char lhs, char rhs) {
    // relational expression
    if (lhs == INT && rhs == INT) {
        switch (oper) {
            case '<':
                addOp(OP_L, 0);
                break;
            case '>':
                addOp(OP_G, 0);
                break;
            case LE:
                addOp(OP_LE, 0);
                break;
            case GE:
                addOp(OP_GE, 0);
                break;
            case EQ:
                addOp(OP_EQ, 0);
                break;
            case NE:
                addOp(OP_NE, 0);
        }
        return BOOL;
    }
    // logical expression
    if (lhs == BOOL && rhs == BOOL) {
        switch (oper) {
            case AND:
                addOp(OP_AND, 0);
                break;
            case OR:
                addOp(OP_OR, 0);
                break;
        }
        return BOOL;
    }
    throw Error("type mismatch in boolean expression");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %cl, %al
movb %dl, %cl
movw %si, %dx
movq %rdi, -0x10(%rbp)
movw %dx, -0x12(%rbp)
movb %cl, -0x13(%rbp)
movb %al, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movsbl -0x13(%rbp), %eax
cmpl $0x1, %eax
jne 0x30ba
movsbl -0x14(%rbp), %eax
cmpl $0x1, %eax
jne 0x30ba
movswl -0x12(%rbp), %eax
movl %eax, -0x5c(%rbp)
subl $0x3c, %eax
je 0x3047
jmp 0x300d
movl -0x5c(%rbp), %eax
subl $0x3e, %eax
je 0x3059
jmp 0x3017
movl -0x5c(%rbp), %eax
subl $0x12c, %eax            # imm = 0x12C
je 0x306b
jmp 0x3023
movl -0x5c(%rbp), %eax
subl $0x12d, %eax            # imm = 0x12D
je 0x307d
jmp 0x302f
movl -0x5c(%rbp), %eax
subl $0x12e, %eax            # imm = 0x12E
je 0x308f
jmp 0x303b
movl -0x5c(%rbp), %eax
subl $0x12f, %eax            # imm = 0x12F
je 0x30a1
jmp 0x30b1
movq -0x58(%rbp), %rdi
movl $0x14, %esi
xorl %edx, %edx
callq 0x2550
jmp 0x30b1
movq -0x58(%rbp), %rdi
movl $0x15, %esi
xorl %edx, %edx
callq 0x2550
jmp 0x30b1
movq -0x58(%rbp), %rdi
movl $0x16, %esi
xorl %edx, %edx
callq 0x2550
jmp 0x30b1
movq -0x58(%rbp), %rdi
movl $0x17, %esi
xorl %edx, %edx
callq 0x2550
jmp 0x30b1
movq -0x58(%rbp), %rdi
movl $0x18, %esi
xorl %edx, %edx
callq 0x2550
jmp 0x30b1
movq -0x58(%rbp), %rdi
movl $0x19, %esi
xorl %edx, %edx
callq 0x2550
movb $0x0, -0x1(%rbp)
jmp 0x31b3
movsbl -0x13(%rbp), %eax
cmpl $0x0, %eax
jne 0x3113
movsbl -0x14(%rbp), %eax
cmpl $0x0, %eax
jne 0x3113
movswl -0x12(%rbp), %eax
movl %eax, -0x60(%rbp)
subl $0x130, %eax            # imm = 0x130
je 0x30e8
jmp 0x30dc
movl -0x60(%rbp), %eax
subl $0x131, %eax            # imm = 0x131
je 0x30fa
jmp 0x310a
movq -0x58(%rbp), %rdi
movl $0x1a, %esi
xorl %edx, %edx
callq 0x2550
jmp 0x310a
movq -0x58(%rbp), %rdi
movl $0x1b, %esi
xorl %edx, %edx
callq 0x2550
movb $0x0, -0x1(%rbp)
jmp 0x31b3
movb $0x1, -0x4d(%rbp)
movl $0x20, %edi
callq 0x2120
movq %rax, -0x70(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x68(%rbp)
callq 0x23a0
movq -0x68(%rbp), %rdx
leaq 0xaf4d(%rip), %rsi      # 0xe08a
leaq -0x38(%rbp), %rdi
callq 0x3880
jmp 0x3148
movq -0x70(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x6400
jmp 0x3157
movq -0x70(%rbp), %rdi
movb $0x0, -0x4d(%rbp)
leaq 0x11c4a(%rip), %rsi     # 0x14db0
leaq 0x7c3(%rip), %rdx       # 0x3930
callq 0x2370
jmp 0x31c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3197
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2160
leaq -0x39(%rbp), %rdi
callq 0x2270
testb $0x1, -0x4d(%rbp)
jne 0x31a8
jmp 0x31b1
movq -0x70(%rbp), %rdi
callq 0x21b0
jmp 0x31bc
movb -0x1(%rbp), %al
addq $0x70, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x2390
nopw %cs:(%rax,%rax)