// File: /workspace/github_cpp_makefile_star2_O2/sighingnow[P]compile-pascal/pl0_x86.cpp
// Function: pl0_x86_gen_header(BasicBlock&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&)
static void pl0_x86_gen_header(BasicBlock & bb, std::vector<std::string> & buffer) {
    runtime.tag(); old.emplace_back(dist); dist = 0;
    size_t p = pl0_x86_gen_param(bb.code, 0);
    buffer.emplace_back(string(""));
    buffer.emplace_back(string("    global ") + bb.code[p].rd->sv);
    buffer.emplace_back(string(bb.code[p].rd->sv) + ":");
    buffer.emplace_back(string("    push ebp"));
    buffer.emplace_back(string("    mov ebp, esp"));
    // prepare displays.
    int d = runtime.depth();
    runtime.push(LOC(string("$fn") + bb.code[p].rd->sv, d));
    buffer.emplace_back("    mov ebx, dword [ebp]");
    for (int i = 1; i < d; ++i) {
        buffer.emplace_back("    push dword [ebx-" + to_string(i*4) + "]");
    }
    dist = dist - 4 * d;
    buffer.emplace_back("    push ebp");
    if (++p < bb.size() && bb.code[p].op == "allocret") {
        dist = dist - 4;
        runtime.push(LOC(bb.code[p].rd->sv, dist));
        buffer.emplace_back(string("    sub esp, ") + to_string(4) + "\t\t;; " + bb.code[p].str());
        p = p + 1;
    }
    while (p < bb.size() && bb.code[p].op == "def") {
        buffer.emplace_back(x86_gen_def(bb.code[p++]));
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rsi, 0x8(%rsp)
movq %rdi, 0x40(%rsp)
leaq 0x3b9b9(%rip), %rdi     # 0x8c720
callq 0x56dfc
leaq 0x3b995(%rip), %rdi     # 0x8c708
leaq 0x3baf6(%rip), %rsi     # 0x8c870
callq 0x477c4
andl $0x0, 0x3baea(%rip)     # 0x8c870
pushq $0x8
popq %rbp
pushq $0x1
popq %rax
movq %rax, 0x48(%rsp)
xorl %r14d, %r14d
leaq 0x20(%rsp), %r12
leaq 0x9c52(%rip), %r13      # 0x5a9f2
leaq 0x50(%rsp), %rbx
movq 0x40(%rsp), %r15
movq 0x18(%r15), %rdi
addq %r14, %rdi
leaq 0x9c43(%rip), %rsi      # 0x5a9fb
callq 0x15c52
testb %al, %al
jne 0x50dd4
movq 0x18(%r15), %rdi
addq %r14, %rdi
movq %r13, %rsi
callq 0x15c52
testb %al, %al
je 0x50e38
movq 0x18(%r15), %rax
movq 0x20(%rax,%r14), %rsi
addq $0x8, %rsi
movq %r12, %rdi
callq 0x5340
movq 0x18(%r15), %rdi
addq %r14, %rdi
movq %r13, %rsi
callq 0x15c52
movzbl %al, %ecx
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x4f3f0
leaq 0x3b911(%rip), %rdi     # 0x8c720
movq %rbx, %rsi
callq 0x5012e
movq %rbx, %rdi
callq 0x4f1b6
movq %r12, %rdi
callq 0x5120
addl $0x4, %ebp
addq $0x50, %r14
incq 0x48(%rsp)
jmp 0x50daa
leaq 0xa700(%rip), %rsi      # 0x5b53f
leaq 0x50(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0xfa26
leaq 0x50(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x4728c
movq 0x40(%rsp), %r15
leaq 0x50(%rsp), %rdi
callq 0x5120
leaq 0xa1b6(%rip), %rsi      # 0x5b029
leaq 0x20(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0xfa26
movq 0x18(%r15), %rax
movq 0x20(%rax,%r14), %rdx
addq $0x8, %rdx
leaq 0x50(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xfda4
leaq 0x50(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x4728c
leaq 0x50(%rsp), %rdi
callq 0x5120
leaq 0x20(%rsp), %rdi
callq 0x5120
movq 0x18(%r15), %rax
movq 0x20(%rax,%r14), %rsi
addq $0x8, %rsi
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x5340
leaq 0x81c5(%rip), %rdx      # 0x590aa
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0xfd14
leaq 0x50(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x4728c
leaq 0x50(%rsp), %rdi
callq 0x5120
leaq 0x20(%rsp), %rdi
callq 0x5120
leaq 0xa119(%rip), %rsi      # 0x5b035
leaq 0x50(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0xfa26
leaq 0x50(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x4728c
leaq 0x50(%rsp), %rdi
callq 0x5120
leaq 0xa0f7(%rip), %rsi      # 0x5b042
leaq 0x50(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0xfa26
leaq 0x50(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x4728c
leaq 0x50(%rsp), %rdi
callq 0x5120
movq 0x3b7c6(%rip), %rbx     # 0x8c740
subq 0x3b7b7(%rip), %rbx     # 0x8c738
leaq 0xa0cb(%rip), %rsi      # 0x5b053
leaq 0x20(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0xfa26
movq 0x18(%r15), %rax
movq 0x20(%rax,%r14), %rdx
addq $0x8, %rdx
leaq 0x118(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xfda4
movq %rbx, %rdx
shrq $0x2, %rdx
decl %edx
leaq 0x50(%rsp), %rdi
leaq 0x118(%rsp), %rsi
movq %rdx, 0x18(%rsp)
xorl %ecx, %ecx
callq 0x4f3f0
leaq 0x3b73e(%rip), %rdi     # 0x8c720
leaq 0x50(%rsp), %rsi
callq 0x5012e
leaq 0x50(%rsp), %r15
movq %r15, %rdi
callq 0x4f1b6
leaq 0x118(%rsp), %rdi
callq 0x5120
leaq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x5120
leaq 0xa03d(%rip), %rsi      # 0x5b057
movq 0x8(%rsp), %rdi
callq 0x56e1e
pushq $0x1
popq %rbx
pushq $0x4
popq %rbp
leaq 0x98(%rsp), %r13
cmpl 0x18(%rsp), %ebx
jge 0x51092
movq %r13, %rdi
movl %ebp, %esi
callq 0x3cc01
movq %r12, %rdi
leaq 0xa024(%rip), %rsi      # 0x5b070
movq %r13, %rdx
callq 0xfac0
movq %r15, %rdi
movq %r12, %rsi
leaq 0x9be7(%rip), %rdx      # 0x5ac48
callq 0xfd14
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x4728c
movq %r15, %rdi
callq 0x5120
movq %r12, %rdi
callq 0x5120
movq %r13, %rdi
callq 0x5120
incl %ebx
addl $0x4, %ebp
jmp 0x51032
movq 0x18(%rsp), %rax
shll $0x2, %eax
subl %eax, 0x3b7d0(%rip)     # 0x8c870
leaq 0x9f8e(%rip), %rsi      # 0x5b035
movq 0x8(%rsp), %rdi
callq 0x56e58
movq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x49d70
movq 0x48(%rsp), %r12
cmpq %rax, %r12
jae 0x51239
movq 0x18(%r15), %rax
leaq (%rax,%r14), %rdi
addq $0x50, %rdi
leaq 0x9c73(%rip), %rsi      # 0x5ad52
callq 0x15c52
testb %al, %al
je 0x51239
addl $-0x4, 0x3b77d(%rip)    # 0x8c870
movq 0x18(%r15), %rax
movq 0x70(%rax,%r14), %rsi
addq $0x8, %rsi
leaq 0x158(%rsp), %rbx
movq %rbx, %rdi
callq 0x5340
movl 0x3b75a(%rip), %edx     # 0x8c870
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x4f3f0
leaq 0x3b5f4(%rip), %rdi     # 0x8c720
leaq 0x50(%rsp), %rsi
callq 0x5012e
leaq 0x50(%rsp), %rdi
callq 0x4f1b6
leaq 0x158(%rsp), %rdi
callq 0x5120
leaq 0x9f31(%rip), %rsi      # 0x5b085
leaq 0xf8(%rsp), %rdi
leaq 0x138(%rsp), %rdx
callq 0xfa26
leaq 0xd8(%rsp), %rdi
pushq $0x4
popq %rsi
callq 0x3cc01
leaq 0x98(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
leaq 0xd8(%rsp), %rdx
callq 0xfd33
leaq 0x9ef6(%rip), %rdx      # 0x5b093
leaq 0x20(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0xfd14
movq 0x18(%r15), %rax
leaq (%rax,%r14), %rsi
addq $0x50, %rsi
leaq 0xb8(%rsp), %rdi
callq 0x3b76c
leaq 0x50(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0xfd33
leaq 0x50(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x4728c
leaq 0x50(%rsp), %rdi
callq 0x5120
leaq 0xb8(%rsp), %rdi
callq 0x5120
leaq 0x20(%rsp), %rdi
callq 0x5120
leaq 0x98(%rsp), %rdi
callq 0x5120
leaq 0xd8(%rsp), %rdi
callq 0x5120
leaq 0xf8(%rsp), %rdi
callq 0x5120
incq %r12
imulq $0x50, %r12, %r14
leaq 0x50(%rsp), %rbp
leaq 0xf8(%rsp), %r15
movq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x49d70
movq %r12, 0x48(%rsp)
cmpq %rax, %r12
jae 0x513de
movq 0x18(%rbx), %rdi
addq %r14, %rdi
leaq 0x9728(%rip), %rsi      # 0x5a99b
callq 0x15c52
testb %al, %al
je 0x513de
movq %r15, %r13
movq 0x18(%rbx), %r12
movq 0x28(%r12,%r14), %rdi
addq $0x8, %rdi
leaq 0x7e78(%rip), %rsi      # 0x5910f
callq 0x15c52
movq 0x30(%r12,%r14), %rax
movl 0x4(%rax), %eax
leal (,%rax,4), %ebx
cmpl $-0x1, %eax
pushq $0x4
popq %rax
cmovel %eax, %ebx
subl %ebx, 0x3b5b6(%rip)     # 0x8c870
movq %r14, 0x18(%rsp)
movq 0x20(%r12,%r14), %rsi
addq $0x8, %rsi
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x5340
movl 0x3b595(%rip), %edx     # 0x8c870
movq %rbp, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x4f3f0
leaq 0x3b431(%rip), %rdi     # 0x8c720
movq %rbp, %rsi
callq 0x5012e
movq %r13, %r15
movq %rbp, %rdi
callq 0x4f1b6
leaq 0x20(%rsp), %rdi
callq 0x5120
movq %r13, %rdi
leaq 0x9d6f(%rip), %rsi      # 0x5b085
leaq 0x17(%rsp), %rdx
callq 0xfa26
leaq 0xd8(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x3cc01
leaq 0x98(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xfd33
movq %r14, %rbx
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x9d3b(%rip), %rdx      # 0x5b093
callq 0xfd14
addq 0x18(%rsp), %r12
leaq 0xb8(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x3b76c
leaq 0x138(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0xfd33
movq %r14, %rdi
callq 0x5120
movq %rbp, %rdi
callq 0x5120
movq %r13, %rdi
callq 0x5120
movq %rbx, %rdi
callq 0x5120
movq %r15, %rdi
callq 0x5120
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x4728c
movq %r12, %rdi
movq 0x48(%rsp), %r12
incq %r12
callq 0x5120
movq 0x18(%rsp), %r14
addq $0x50, %r14
jmp 0x5124a
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x5120
jmp 0x51402
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x5120
jmp 0x51414
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x514ee
jmp 0x514df
jmp 0x51502
jmp 0x514b0
jmp 0x514b5
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4f1b6
jmp 0x51444
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
jmp 0x5155e
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4f1b6
jmp 0x51463
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
jmp 0x5148b
jmp 0x51556
jmp 0x514b5
jmp 0x5149c
jmp 0x514b5
jmp 0x5149c
jmp 0x514b5
jmp 0x51483
jmp 0x51556
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x5120
jmp 0x51559
jmp 0x51556
jmp 0x514b5
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0x5155e
jmp 0x514b5
jmp 0x51556
movq %rax, %rbx
jmp 0x51512
movq %rax, %rbx
jmp 0x51563
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
jmp 0x5155e
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x5120
jmp 0x514e9
movq %rax, %rbx
jmp 0x514f3
jmp 0x51547
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x5120
leaq 0x98(%rsp), %rdi
callq 0x5120
jmp 0x51505
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x5120
leaq 0xf8(%rsp), %rdi
jmp 0x5155e
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x5120
jmp 0x5152e
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x5120
jmp 0x5153d
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
jmp 0x5155e
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4f1b6
jmp 0x51559
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x5120
movq %rbx, %rdi
callq 0x53f0