// File: protonpopsicle[P]lang/src/compiler/ByteCoder.cpp
// Function: ByteCoder::evalArith(char, char, char)
char ByteCoder::evalArith(char oper, char lhs, char rhs) {
    if (lhs == INT && rhs == INT) {
        switch (oper) {
            case '+':
                addOp(OP_ADD, 0);
                break;
            case '-':
                addOp(OP_SUBTRACT, 0);
                break;
            case '*':
                addOp(OP_MULTIPLY, 0);
                break;
            case '/':
                addOp(OP_DIVIDE, 0);
                break;
        }
        return INT;
    }
    if (oper == '+') {          
        if (lhs == STRING && rhs == STRING) {
            addOp(OP_CAT_STRING, 0);
        }
        else if (lhs == STRING && rhs == INT) {
            addOp(OP_CAT_STRING_INT, 0);
        }
        else if (lhs == INT && rhs == STRING) {
            addOp(OP_CAT_INT_STRING, 0);
        }
        return STRING;
    }
    throw Error("type mismatch in arithmetic expression");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %cl, %al
movb %dl, %cl
movb %sil, %dl
movq %rdi, -0x10(%rbp)
movb %dl, -0x11(%rbp)
movb %cl, -0x12(%rbp)
movb %al, -0x13(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movsbl -0x12(%rbp), %eax
cmpl $0x1, %eax
jne 0x2e8b
movsbl -0x13(%rbp), %eax
cmpl $0x1, %eax
jne 0x2e8b
movsbl -0x11(%rbp), %eax
addl $-0x2a, %eax
movl %eax, %ecx
movq %rcx, -0x60(%rbp)
subl $0x5, %eax
ja 0x2e82
movq -0x60(%rbp), %rax
leaq 0xb1d1(%rip), %rcx      # 0xe004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x58(%rbp), %rdi
movl $0x7, %esi
xorl %edx, %edx
callq 0x2550
jmp 0x2e82
movq -0x58(%rbp), %rdi
movl $0x8, %esi
xorl %edx, %edx
callq 0x2550
jmp 0x2e82
movq -0x58(%rbp), %rdi
movl $0x9, %esi
xorl %edx, %edx
callq 0x2550
jmp 0x2e82
movq -0x58(%rbp), %rdi
movl $0xa, %esi
xorl %edx, %edx
callq 0x2550
movb $0x1, -0x1(%rbp)
jmp 0x2fab
movsbl -0x11(%rbp), %eax
cmpl $0x2b, %eax
jne 0x2f0b
movsbl -0x12(%rbp), %eax
cmpl $0x2, %eax
jne 0x2eb8
movsbl -0x13(%rbp), %eax
cmpl $0x2, %eax
jne 0x2eb8
movq -0x58(%rbp), %rdi
movl $0xb, %esi
xorl %edx, %edx
callq 0x2550
jmp 0x2f02
movsbl -0x12(%rbp), %eax
cmpl $0x2, %eax
jne 0x2edc
movsbl -0x13(%rbp), %eax
cmpl $0x1, %eax
jne 0x2edc
movq -0x58(%rbp), %rdi
movl $0xc, %esi
xorl %edx, %edx
callq 0x2550
jmp 0x2f00
movsbl -0x12(%rbp), %eax
cmpl $0x1, %eax
jne 0x2efe
movsbl -0x13(%rbp), %eax
cmpl $0x2, %eax
jne 0x2efe
movq -0x58(%rbp), %rdi
movl $0xd, %esi
xorl %edx, %edx
callq 0x2550
jmp 0x2f00
jmp 0x2f02
movb $0x2, -0x1(%rbp)
jmp 0x2fab
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 0xb12e(%rip), %rsi      # 0xe063
leaq -0x38(%rbp), %rdi
callq 0x3880
jmp 0x2f40
movq -0x70(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x6400
jmp 0x2f4f
movq -0x70(%rbp), %rdi
movb $0x0, -0x4d(%rbp)
leaq 0x11e52(%rip), %rsi     # 0x14db0
leaq 0x9cb(%rip), %rdx       # 0x3930
callq 0x2370
jmp 0x2fbd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2f8f
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 0x2fa0
jmp 0x2fa9
movq -0x70(%rbp), %rdi
callq 0x21b0
jmp 0x2fb4
movb -0x1(%rbp), %al
addq $0x70, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x2390
nopl (%rax)