// File: /workspace/github_cpp_makefile_star2_O3/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 0x4802f(%rip), %rdi     # 0xb9fd8
leaq 0x2155f(%rip), %rbx     # 0x9350f
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 0x253d0
movq 0x8(%r15), %rax
movq 0x8(%rax), %rsi
leaq 0x10(%rsp), %rdi
callq 0x72568
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 0x72178
movl $0x48, %edi
callq 0x5250
movq %rax, (%rsp)
leaq 0x49585(%rip), %rsi     # 0xbb5a8
leaq 0x148(%rsp), %rdi
callq 0x632b2
leaq 0x110(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
leaq 0x100(%rsp), %rdi
callq 0x351dc
leaq 0x148(%rsp), %rsi
leaq 0x100(%rsp), %rdx
movq (%rsp), %rdi
callq 0x7653e
movq 0x100(%rsp), %rdi
cmpq %rbx, %rdi
je 0x7208c
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x5260
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x720ad
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x5260
leaq 0xf0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x20fdf(%rip), %rsi     # 0x9309f
leaq 0x20fd9(%rip), %rdx     # 0x930a0
leaq 0xe0(%rsp), %rdi
callq 0x253d0
movl $0x48, %edi
callq 0x5250
movq %rax, %r13
leaq 0xd0(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
leaq 0xc0(%rsp), %rdi
callq 0x351dc
movb $0x1, %bpl
leaq 0xc0(%rsp), %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x75d42
xorl %ebp, %ebp
leaq 0x49483(%rip), %rdi     # 0xbb5a8
leaq 0xe0(%rsp), %rsi
movq (%rsp), %rdx
movq %r13, %rcx
movq 0x8(%rsp), %r8
callq 0x75c2c
movq 0xc0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x7215b
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0xe0(%rsp), %rdi
cmpq %r14, %rdi
je 0x72178
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x10(%r15), %rax
subq 0x8(%r15), %rax
cmpq $0x11, %rax
jb 0x7232f
leaq 0x18(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x1ef75(%rip), %rcx     # 0x9110f
movl $0x7, %r8d
xorl %esi, %esi
callq 0x5370
movq 0x10(%r15), %rax
subq 0x8(%r15), %rax
cmpq $0x11, %rax
jb 0x7232f
movl $0x1, %r13d
xorl %ebp, %ebp
leaq 0x40(%rsp), %r14
movq (%rsp), %rbx
testb $0x1, %r12b
leaq 0x60(%rsp), %r12
je 0x72274
movl $0x48, %edi
callq 0x5250
movq %rax, (%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x493b2(%rip), %rsi     # 0xbb5a8
callq 0x632b2
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x351dc
movq (%rsp), %rdi
leaq 0x80(%rsp), %rsi
movq %r12, %rdx
callq 0x7653e
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x7224a
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x7226f
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 0x72568
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 0x492e8(%rip), %rdi     # 0xbb5a8
movq %r12, %rsi
movq (%rsp), %rdx
movq %rbx, %rcx
callq 0x75c2c
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x722eb
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x72310
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 0x721c6
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 0x351dc
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x72386
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x723ab
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
jmp 0x72442
movq %rax, %r15
jmp 0x7244f
jmp 0x724d2
movq %rax, %r15
movq 0x100(%rsp), %rdi
cmpq %rbx, %rdi
je 0x723f9
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x5260
jmp 0x723f9
movq %rax, %r15
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x724c7
movq 0x158(%rsp), %rsi
jmp 0x724bf
jmp 0x7247e
movq %rax, %r15
movq 0xc0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x7243d
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x5260
testb %bpl, %bpl
je 0x7244f
movl $0x48, %esi
movq %r13, %rdi
callq 0x5260
movq 0xe0(%rsp), %rdi
cmpq %r14, %rdi
je 0x72520
movq 0xf0(%rsp), %rsi
jmp 0x72518
movq %rax, %r15
jmp 0x7253b
jmp 0x724d2
jmp 0x724d2
movq %rax, %r15
jmp 0x724a2
movq %rax, %r15
jmp 0x724c7
movq %rax, %r15
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x724a2
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x724c7
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x5260
movl $0x48, %esi
movq (%rsp), %rdi
jmp 0x7251b
movq %rax, %r15
jmp 0x72520
movq %rax, %r15
jmp 0x724fb
movq %rax, %r15
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x724fb
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x72520
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x5260
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7253b
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x72560
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x5260
movq %r15, %rdi
callq 0x53d0