// File: /workspace/github_cpp_makefile_star2_O1/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 $0x168, %rsp            # imm = 0x168
movq %rsi, %r15
movq %rdi, 0x38(%rsp)
movq 0x486a4(%rip), %rdi     # 0xbffd8
leaq 0x21bd4(%rip), %rbx     # 0x9950f
movq %rbx, %rsi
xorl %edx, %edx
callq 0x52e0
leaq 0xb0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xa0(%rsp), %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x2670a
movq 0x8(%r15), %rax
movq 0x8(%rax), %rsi
leaq 0x10(%rsp), %rdi
callq 0x77ef0
movq 0x10(%rsp), %r14
movq 0x8(%r15), %rax
movq (%rax), %rax
cmpb $0x2d, 0xc(%rax)
setne %r12b
movq %r14, 0x8(%rsp)
movq %r14, (%rsp)
jne 0x77b02
movl $0x48, %edi
callq 0x5250
movq %rax, (%rsp)
leaq 0x49bfa(%rip), %rsi     # 0xc15a8
leaq 0x148(%rsp), %rdi
callq 0x69190
leaq 0x110(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
leaq 0x100(%rsp), %rdi
callq 0x36590
leaq 0x148(%rsp), %rsi
leaq 0x100(%rsp), %rdx
movq (%rsp), %rdi
callq 0x7be1c
movq 0x100(%rsp), %rdi
cmpq %rbx, %rdi
je 0x77a17
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x5260
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x77a38
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x5260
leaq 0xf0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x21654(%rip), %rsi     # 0x9909f
leaq 0x2164e(%rip), %rdx     # 0x990a0
leaq 0xe0(%rsp), %rdi
callq 0x2670a
movl $0x48, %edi
callq 0x5250
movq %rax, %r13
leaq 0xd0(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
leaq 0xc0(%rsp), %rdi
callq 0x36590
movb $0x1, %bl
leaq 0xc0(%rsp), %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x7b654
xorl %ebx, %ebx
leaq 0x49af9(%rip), %rdi     # 0xc15a8
leaq 0xe0(%rsp), %rsi
movq (%rsp), %rdx
movq %r13, %rcx
movq 0x8(%rsp), %r8
callq 0x7b53e
movq 0xc0(%rsp), %rdi
cmpq %rbp, %rdi
je 0x77ae5
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0xe0(%rsp), %rdi
cmpq %r14, %rdi
je 0x77b02
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x10(%r15), %rax
subq 0x8(%r15), %rax
cmpq $0x11, %rax
jb 0x77cb9
leaq 0x18(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x1f5eb(%rip), %rcx     # 0x9710f
movl $0x7, %r8d
xorl %esi, %esi
callq 0x5370
movq 0x10(%r15), %rax
subq 0x8(%r15), %rax
cmpq $0x11, %rax
jb 0x77cb9
movl $0x1, %r13d
xorl %ebp, %ebp
leaq 0x40(%rsp), %r14
movq (%rsp), %rbx
testb $0x1, %r12b
leaq 0x60(%rsp), %r12
je 0x77bfe
movl $0x48, %edi
callq 0x5250
movq %rax, (%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x49a28(%rip), %rsi     # 0xc15a8
callq 0x69190
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x36590
movq (%rsp), %rdi
leaq 0x80(%rsp), %rsi
movq %r12, %rdx
callq 0x7be1c
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x77bd4
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x77bf9
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x8(%rsp), %rbx
movq 0x8(%r15), %rax
movq 0x18(%rax,%rbp), %rsi
leaq 0x120(%rsp), %rdi
callq 0x77ef0
movq 0x8(%r15), %rax
movq 0x10(%rax,%rbp), %rax
movsbl 0xc(%rax), %edx
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movl $0x1, %esi
movq %r14, %r12
movq %r14, %rdi
callq 0x5300
movq 0x120(%rsp), %r8
leaq 0x4995e(%rip), %rdi     # 0xc15a8
movq %r12, %rsi
movq (%rsp), %rdx
movq %rbx, %rcx
callq 0x7b53e
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x77c75
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x77c9a
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x5260
incq %r13
movq 0x10(%r15), %rax
subq 0x8(%r15), %rax
sarq $0x4, %rax
addq $0x10, %rbp
xorl %r12d, %r12d
cmpq %rax, %r13
jb 0x77b50
leaq 0x18(%rsp), %rsi
movq (%rsp), %rax
leaq 0x28(%rax), %rdi
callq 0x5150
movq 0x38(%rsp), %rcx
movq (%rsp), %rax
movq %rax, (%rcx)
leaq 0x8(%rcx), %rdi
leaq 0x18(%rcx), %rax
movq %rax, 0x8(%rcx)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
callq 0x36590
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x77d10
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x77d35
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x38(%rsp), %rax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movb $0x1, %bl
jmp 0x77dc6
movq %rax, %r15
jmp 0x77dd7
jmp 0x77e5a
movq %rax, %r15
movq 0x100(%rsp), %rdi
cmpq %rbx, %rdi
je 0x77d82
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x5260
jmp 0x77d82
movq %rax, %r15
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x77e4f
movq 0x158(%rsp), %rsi
jmp 0x77e47
jmp 0x77e06
movq %rax, %r15
movq 0xc0(%rsp), %rdi
cmpq %rbp, %rdi
je 0x77dc6
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x5260
testb %bl, %bl
je 0x77dd7
movl $0x48, %esi
movq %r13, %rdi
callq 0x5260
movq 0xe0(%rsp), %rdi
cmpq %r14, %rdi
je 0x77ea8
movq 0xf0(%rsp), %rsi
jmp 0x77ea0
movq %rax, %r15
jmp 0x77ec3
jmp 0x77e5a
jmp 0x77e5a
movq %rax, %r15
jmp 0x77e2a
movq %rax, %r15
jmp 0x77e4f
movq %rax, %r15
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x77e2a
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x77e4f
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x5260
movl $0x48, %esi
movq (%rsp), %rdi
jmp 0x77ea3
movq %rax, %r15
jmp 0x77ea8
movq %rax, %r15
jmp 0x77e83
movq %rax, %r15
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x77e83
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x77ea8
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x5260
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x77ec3
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x77ee8
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x5260
movq %r15, %rdi
callq 0x53d0