// File: /workspace/github_cpp_makefile_star2_O3/sighingnow[P]compile-pascal/pl0_tac_gen.cpp
// Function: pl0_tac_call_proc(pl0_ast_call_proc const*)
void pl0_tac_call_proc(pl0_ast_call_proc const *stmt) {
    cout << __func__;
    std::vector<std::pair<Value *, std::string>> args;
    if (stmt->args) {
        for (auto argexpr: stmt->args->args) {
            args.emplace(args.begin(), pl0_tac_expr(argexpr->arg));
        }
    }
    proc p;
    proctb.find(stmt->id->id, true, p);
    if (p.name.length() == 0) {
        pl0_ast_error(stmt->id->loc, "use of undeclared identifier '" + stmt->id->id + "'");
    }
    std::vector<std::pair<Value *, bool>> pushes; // <Value * val, bool is_ref>
    if (args.size() != p.param_t.size()) {
        pl0_ast_error(stmt->args->loc, string("unmatched number of parameters and arguments."));
    }
    else {
        size_t len = args.size();
        for (size_t i = 0; i < len; ++i) {
            bool is_ref = p.param_t[len-1-i].length() > 4 && p.param_t[len-1-i].substr(0, 4) == "ref_";
            // if (args[i].second != (is_ref ? p.param_t[len-1-i].substr(4): p.param_t[len-1-i])) {
            //     pl0_ast_error(stmt->args->args[i]->loc, string("unmatched type of parameter and argument."));
            // }
            if (is_ref) {
                if (args[i].first->t == Value::TYPE::IMM || (args[i].first->sv.back() != '#' && args[i].first->sv.front() == '~')) {
                    pl0_ast_error(stmt->args->args[i]->loc, string("use constant or expression as reference value."));
                }
                pushes.emplace_back(make_pair(args[i].first, true));
            }
            else {
                pushes.emplace_back(make_pair(args[i].first, false));
            }
        }
    }
    irb.emit("call", new Value(p.name, "string"), pushes);
    irb.emit("label", new Value(irb.makelabel(), "integer"), new Value("allsuffix", "string"));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rdi, %rbx
movq 0x4c328(%rip), %rdi     # 0xb9fd8
leaq 0x25858(%rip), %rsi     # 0x9350f
xorl %edx, %edx
callq 0x52e0
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
movq %rbx, 0x8(%rsp)
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x6dd41
movq 0x8(%rax), %rbx
movq 0x10(%rax), %rbp
cmpq %rbp, %rbx
je 0x6dd41
leaq 0x88(%rsp), %r13
leaq 0x70(%rsp), %r14
leaq 0x50(%rsp), %r15
movq (%rbx), %rax
movq 0x50(%rsp), %r12
movq 0x8(%rax), %rsi
movq %r14, %rdi
callq 0x71f89
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x793a6
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x6dd38
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5260
addq $0x8, %rbx
cmpq %rbp, %rbx
jne 0x6dcfc
leaq 0x80(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rcx)
movq %rax, 0x20(%rcx)
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rsi
addq $0x8, %rsi
leaq 0x4d8db(%rip), %rdi     # 0xbb650
leaq 0x70(%rsp), %rcx
movl $0x1, %edx
callq 0x77090
cmpq $0x0, 0x78(%rsp)
jne 0x6de57
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdx
movq (%rdx), %r14
addq $0x8, %rdx
leaq 0x24d1b(%rip), %rsi     # 0x92ac2
leaq 0x10(%rsp), %rdi
callq 0x16234
leaq 0x24d27(%rip), %rsi     # 0x92adf
leaq 0x10(%rsp), %rdi
callq 0x5420
leaq 0x138(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x6ddf2
movq %rdx, 0x128(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x138(%rsp)
jmp 0x6ddf8
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
leaq 0x128(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r14, %rdi
callq 0x65f40
movq 0x128(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6de3c
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x5260
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6de57
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x5260
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x3333333333333333, %rbp # imm = 0xCCCCCCCCCCCCCCCD
imulq %rdx, %rbp
movq 0x98(%rsp), %rdx
subq 0x90(%rsp), %rdx
sarq $0x5, %rdx
cmpq %rdx, %rbp
jne 0x6e062
cmpq %rax, %rcx
je 0x6e0c2
cmpq $0x1, %rbp
movq %rbp, %rbx
adcq $0x0, %rbx
shlq $0x5, %rbp
addq $-0x20, %rbp
xorl %r12d, %r12d
leaq 0x10(%rsp), %r13
leaq 0x108(%rsp), %r14
xorl %r15d, %r15d
movq 0x90(%rsp), %rsi
cmpq $0x4, 0x8(%rsi,%rbp)
jbe 0x6df37
addq %rbp, %rsi
movl $0x4, %ecx
movq %r13, %rdi
xorl %edx, %edx
callq 0x52a0
movq %r13, %rdi
leaq 0x24acb(%rip), %rsi     # 0x929cd
callq 0x50c0
movl %eax, %r13d
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x6df26
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x50(%rsp), %rax
testl %r13d, %r13d
je 0x6df82
leaq 0x10(%rsp), %r13
jmp 0x6df3c
movq 0x50(%rsp), %rax
movq (%rax,%r12), %rax
movq %rax, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x6df69
movups 0x10(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x38(%rsp)
jmp 0x6e04c
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x79772
leaq 0x10(%rsp), %r13
jmp 0x6e04c
movq (%rax,%r12), %rax
cmpl $0x0, (%rax)
je 0x6df9f
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rax
cmpb $0x23, -0x1(%rcx,%rax)
je 0x6e009
cmpb $0x7e, (%rcx)
jne 0x6e009
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rax
movq (%rax,%r15,8), %rax
movq (%rax), %r13
leaq 0x118(%rsp), %rax
movq %rax, 0x108(%rsp)
movq %r14, %rdi
leaq 0x24b42(%rip), %rsi     # 0x92b0f
leaq 0x24b69(%rip), %rdx     # 0x92b3d
callq 0x253d0
movq %r13, %rdi
movq %r14, %rsi
callq 0x65f40
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x6e009
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x50(%rsp), %rax
movq (%rax,%r12), %rax
movq %rax, 0x10(%rsp)
movb $0x1, 0x18(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x6e038
movups 0x10(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x38(%rsp)
jmp 0x6e047
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x79772
leaq 0x10(%rsp), %r13
incq %r15
addq $-0x20, %rbp
addq $0x28, %r12
cmpq %r15, %rbx
jne 0x6ded6
jmp 0x6e0c2
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rbx
leaq 0x1d8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x24a60(%rip), %rsi     # 0x92ae1
leaq 0x24a86(%rip), %rdx     # 0x92b0e
leaq 0x1c8(%rsp), %rdi
callq 0x253d0
leaq 0x1c8(%rsp), %rsi
movq %rbx, %rdi
callq 0x65f40
movq 0x1c8(%rsp), %rdi
cmpq %r14, %rdi
je 0x6e0c2
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x5260
leaq 0x1b8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x23991(%rip), %rsi     # 0x91a66
leaq 0x2398e(%rip), %rdx     # 0x91a6a
leaq 0x1a8(%rsp), %rdi
callq 0x253d0
movl $0x48, %edi
callq 0x5250
movq %rax, %r14
leaq 0xf8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
addq %rsi, %rdx
leaq 0xe8(%rsp), %rdi
callq 0x351dc
leaq 0x198(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x25148(%rip), %rsi     # 0x93278
leaq 0x25147(%rip), %rdx     # 0x9327e
leaq 0x188(%rsp), %rdi
callq 0x253d0
movb $0x1, %r13b
leaq 0xe8(%rsp), %rsi
leaq 0x188(%rsp), %rdx
movq %r14, %rdi
callq 0x7653e
xorl %r13d, %r13d
leaq 0x4d43f(%rip), %rdi     # 0xbb5a8
leaq 0x1a8(%rsp), %rsi
leaq 0x30(%rsp), %rcx
movq %r14, %rdx
xorl %r8d, %r8d
callq 0x77216
movq 0x188(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6e19e
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0xe8(%rsp), %rdi
cmpq %r12, %rdi
je 0x6e1bb
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x1a8(%rsp), %rdi
cmpq %r15, %rdi
je 0x6e1d8
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x5260
leaq 0x178(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x24953(%rip), %rsi     # 0x92b3e
leaq 0x24951(%rip), %rdx     # 0x92b43
leaq 0x168(%rsp), %rdi
callq 0x253d0
movl $0x48, %edi
callq 0x5250
movq %rax, %r14
leaq 0x4d395(%rip), %rdi     # 0xbb5a8
callq 0x632aa
movl %eax, %ebx
leaq 0xd8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x22ee2(%rip), %rsi     # 0x9110f
leaq 0x22ee2(%rip), %rdx     # 0x91116
leaq 0xc8(%rsp), %rdi
callq 0x253d0
movb $0x1, %bpl
leaq 0xc8(%rsp), %rdx
movq %r14, %rdi
movl %ebx, %esi
callq 0x75d42
xorl %ebp, %ebp
movl $0x48, %edi
callq 0x5250
movq %rax, %r15
leaq 0xb8(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x248cc(%rip), %rsi     # 0x92b44
leaq 0x248ce(%rip), %rdx     # 0x92b4d
leaq 0xa8(%rsp), %rdi
callq 0x253d0
leaq 0x158(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x24fd8(%rip), %rsi     # 0x93278
leaq 0x24fd7(%rip), %rdx     # 0x9327e
leaq 0x148(%rsp), %rdi
callq 0x253d0
movb $0x1, %bl
leaq 0xa8(%rsp), %rsi
leaq 0x148(%rsp), %rdx
movq %r15, %rdi
callq 0x7653e
xorl %ebx, %ebx
leaq 0x4d2d1(%rip), %rdi     # 0xbb5a8
leaq 0x168(%rsp), %rsi
movq %r14, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x75c2c
movq 0x148(%rsp), %rdi
cmpq %r12, %rdi
je 0x6e30a
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0xa8(%rsp), %rdi
cmpq %rbp, %rdi
leaq 0x80(%rsp), %r14
leaq 0xd8(%rsp), %rbx
je 0x6e337
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0xc8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6e354
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0x168(%rsp), %rdi
cmpq %r13, %rdi
je 0x6e371
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x5260
leaq 0x90(%rsp), %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6e390
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x5260
movq %rbx, %rdi
callq 0x757a6
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0x6e3b2
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x5260
leaq 0x50(%rsp), %rdi
callq 0x77304
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, 0x8(%rsp)
movq 0x128(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6e3f7
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x5260
jmp 0x6e3f7
movq %rax, 0x8(%rsp)
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6e64f
movq 0x20(%rsp), %rsi
incq %rsi
jmp 0x6e64a
jmp 0x6e50c
movq %rax, 0x8(%rsp)
movq 0x1c8(%rsp), %rdi
cmpq %r14, %rdi
je 0x6e638
movq 0x1d8(%rsp), %rsi
jmp 0x6e627
jmp 0x6e633
jmp 0x6e633
movq %rax, 0x8(%rsp)
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x6e638
movq 0x118(%rsp), %rsi
jmp 0x6e627
jmp 0x6e633
movq %rax, 0x8(%rsp)
movq 0xa8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x6e559
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x5260
jmp 0x6e559
movq %rax, 0x8(%rsp)
jmp 0x6e559
jmp 0x6e4af
movq %rax, 0x8(%rsp)
jmp 0x6e599
movq %rax, 0x8(%rsp)
jmp 0x6e5a6
jmp 0x6e633
movq %rax, 0x8(%rsp)
movq 0xe8(%rsp), %rdi
cmpq %r12, %rdi
je 0x6e605
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x5260
jmp 0x6e605
movq %rax, 0x8(%rsp)
jmp 0x6e605
movq %rax, 0x8(%rsp)
jmp 0x6e612
jmp 0x6e633
movq %rax, 0x8(%rsp)
jmp 0x6e64f
movq %rax, 0x8(%rsp)
movq 0x148(%rsp), %rdi
cmpq %r12, %rdi
je 0x6e538
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0xa8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x6e555
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x5260
testb %bl, %bl
je 0x6e566
movl $0x48, %esi
movq %r15, %rdi
callq 0x5260
xorl %ebp, %ebp
jmp 0x6e56f
movq %rax, 0x8(%rsp)
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x6e594
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x5260
testb %bpl, %bpl
je 0x6e5a6
movl $0x48, %esi
movq %r14, %rdi
callq 0x5260
movq 0x168(%rsp), %rdi
cmpq %r13, %rdi
je 0x6e638
movq 0x178(%rsp), %rsi
jmp 0x6e627
movq %rax, 0x8(%rsp)
movq 0x188(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6e5e3
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x5260
movq 0xe8(%rsp), %rdi
cmpq %r12, %rdi
je 0x6e600
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x5260
testb %r13b, %r13b
je 0x6e612
movl $0x48, %esi
movq %r14, %rdi
callq 0x5260
movq 0x1a8(%rsp), %rdi
cmpq %r15, %rdi
je 0x6e638
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x5260
jmp 0x6e638
jmp 0x6e633
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6e64f
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x5260
leaq 0x70(%rsp), %rdi
callq 0x768c0
jmp 0x6e681
movq %rax, 0x8(%rsp)
jmp 0x6e681
movq %rax, 0x8(%rsp)
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x6e681
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x5260
leaq 0x50(%rsp), %rdi
callq 0x77304
movq 0x8(%rsp), %rdi
callq 0x53d0