// File: /workspace/github_cpp_makefile_star2_O2/sighingnow[P]compile-pascal/pl0_tac_gen.cpp
// Function: pl0_tac_expr[abi:cxx11](pl0_ast_expression const*)
pair<Value *, string> pl0_tac_expr(pl0_ast_expression const *expr) {
    cout << __func__;
    bool needtmp = true;
    std::string t = "";
    pair<Value *, string> head = pl0_tac_term(expr->terms[0].second);
    Value *ans = head.first, *prev = head.first;
    if (expr->terms[0].first->op == '-') {
        ans = new Value(irb.maketmp(), head.second);
        irb.emit("-", ans, new Value(0, head.second), prev);
        needtmp = false; // no more temporary variable.
    }
    if (expr->terms.size() > 1) {
        head.second = "integer"; // type casting.
        for (size_t i = 1; i < expr->terms.size(); ++i) {
            if (needtmp) { ans = new Value(irb.maketmp(), head.second); }
            auto element = pl0_tac_term(expr->terms[i].second);
            // if (element.second != head.second) {
            //     pl0_ast_error(expr->terms[i].second->loc, "do +/- operation on two terms with different types.");
            // }
            irb.emit(string(1, expr->terms[i].first->op), ans, needtmp ? prev : ans, element.first);
            needtmp = false; // no more temporary variable.
        }
    }
    ans->dt = head.second;
    return make_pair(ans, head.second);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rsi, %r14
movq %rdi, %r15
movq 0x46761(%rip), %rdi     # 0x8afd8
leaq 0x16cc1(%rip), %rbx     # 0x5b53f
movq %rbx, %rsi
callq 0x5250
leaq 0x118(%rsp), %rdi
leaq 0x28(%rsp), %rdx
movq %rbx, %rsi
callq 0xfa26
movq 0x8(%r14), %rax
movq 0x8(%rax), %rsi
leaq 0x28(%rsp), %rdi
callq 0x44c2e
movq 0x28(%rsp), %r13
movq 0x8(%r14), %rax
movq (%rax), %rcx
cmpb $0x2d, 0xc(%rcx)
setne %cl
movl %ecx, 0xc(%rsp)
movq %r13, 0x18(%rsp)
jne 0x449bd
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %r13
leaq 0x47cef(%rip), %rsi     # 0x8c5d0
leaq 0xf8(%rsp), %rdi
callq 0x3bb90
leaq 0x30(%rsp), %rbx
leaq 0xd8(%rsp), %rdi
movq %rbx, %rsi
callq 0x5340
leaq 0xf8(%rsp), %rsi
leaq 0xd8(%rsp), %rdx
movq %r13, %rdi
callq 0x46fc0
leaq 0xd8(%rsp), %rdi
callq 0x5120
leaq 0xf8(%rsp), %rdi
callq 0x5120
leaq 0x16793(%rip), %rsi     # 0x5b0cf
leaq 0xb8(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0xfa26
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %r12
leaq 0x98(%rsp), %rdi
movq %rbx, %rsi
callq 0x5340
movb $0x1, %bpl
leaq 0x98(%rsp), %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x46ac6
xorl %ebp, %ebp
leaq 0x47c49(%rip), %rdi     # 0x8c5d0
leaq 0xb8(%rsp), %rsi
movq %r13, %rdx
movq %r12, %rcx
movq 0x18(%rsp), %r8
callq 0x46a38
leaq 0x98(%rsp), %rdi
callq 0x5120
leaq 0xb8(%rsp), %rdi
callq 0x5120
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
subq %rax, %rcx
cmpq $0x11, %rcx
jb 0x44aff
leaq 0x30(%rsp), %rdi
leaq 0x14735(%rip), %rsi     # 0x5910f
callq 0x5450
movq %r14, 0x10(%rsp)
movq %r15, 0x20(%rsp)
pushq $0x1
popq %r15
xorl %ebx, %ebx
leaq 0x138(%rsp), %r14
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
subq %rax, %rcx
sarq $0x4, %rcx
cmpq %rcx, %r15
jae 0x44afa
movq %r13, %r12
testb $0x1, 0xc(%rsp)
je 0x44a7c
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %r12
leaq 0x158(%rsp), %r13
movq %r13, %rdi
leaq 0x47b95(%rip), %rsi     # 0x8c5d0
callq 0x3bb90
movq %r14, %rbp
movq %r14, %rdi
leaq 0x30(%rsp), %rsi
callq 0x5340
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x46fc0
movq %rbp, %rdi
callq 0x5120
movq %r13, %rdi
callq 0x5120
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rsp), %r13
movq 0x18(%rax,%rbx), %rsi
leaq 0x70(%rsp), %rdi
callq 0x44c2e
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax,%rbx), %rax
movsbl 0xc(%rax), %edx
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0x50(%rsp), %rbp
movq %rbp, %rdi
pushq $0x1
popq %rsi
callq 0x52e0
movq 0x70(%rsp), %r8
leaq 0x47b0d(%rip), %rdi     # 0x8c5d0
movq %rbp, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x46a38
movq %rbp, %rdi
callq 0x5120
leaq 0x78(%rsp), %rdi
callq 0x5120
incq %r15
addq $0x10, %rbx
movl $0x0, 0xc(%rsp)
movq %r12, %r13
jmp 0x449f7
movq 0x20(%rsp), %r15
leaq 0x30(%rsp), %rbx
leaq 0x28(%r13), %rdi
movq %rbx, %rsi
callq 0x5160
movq %r13, (%r15)
leaq 0x8(%r15), %rdi
movq %rbx, %rsi
callq 0x5340
movq %rbx, %rdi
callq 0x5120
leaq 0x118(%rsp), %rdi
callq 0x5120
movq %r15, %rax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x44b9c
movq %rax, %rbx
jmp 0x44ba7
jmp 0x44c0c
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x5120
jmp 0x44b6d
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x5120
jmp 0x44b7f
movq %rax, %rbx
pushq $0x48
popq %rsi
movq %r13, %rdi
jmp 0x44be5
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x5120
testb %bpl, %bpl
je 0x44ba7
pushq $0x48
popq %rsi
movq %r12, %rdi
callq 0x5270
leaq 0xb8(%rsp), %rdi
jmp 0x44c05
movq %rax, %rbx
jmp 0x44c19
jmp 0x44c0c
movq %rax, %rbx
jmp 0x44bdf
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x5120
jmp 0x44bd2
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0x5120
pushq $0x48
popq %rsi
movq %r12, %rdi
callq 0x5270
jmp 0x44c0f
jmp 0x44c0c
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x5120
jmp 0x44c00
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x5120
jmp 0x44c0f
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x5120
leaq 0x118(%rsp), %rdi
callq 0x5120
movq %rbx, %rdi
callq 0x53f0