// File: sighingnow[P]compile-pascal/pl0_tac_gen.cpp
// Function: pl0_tac_procedure_stmt(pl0_ast_procedure_stmt const*)
void pl0_tac_procedure_stmt(pl0_ast_procedure_stmt const *stmts) {
    cout << __func__;
    for (auto && p: stmts->procs) {
        // validate.
        string pid = p.first->id->id;
        if (valtb.find(pid, false) || vartb.find(pid, false) || proctb.find(pid, false) || functb.find(pid, false)
                || (!scope.empty() && pid == scope.back())) {
            pl0_ast_error(p.first->id->loc, string("overloaded identifier ") + "\"" + pid + "\"" + " isn't a function");
        }
        else {
            scope.emplace_back(pid); // update global scope.
            vector<string> proctype = pl0_tac_procedure_header(p.first);
            irb.emit("procedure", new Value(scope_name(), "string"));
            proctb.push(proc(scope_name(), proctype)); // update symbol table.
            proctb.tag(); functb.tag();
            pl0_tac_prog(p.second);
            irb.emit("endproc", new Value(scope_name(), "string"));
            // end of current scope.
            scope.pop_back(); // restore scope.
            valtb.detag(); vartb.detag();
            proctb.detag(), functb.detag();
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x8(%rbp)
movq 0xaeee2(%rip), %rdi     # 0x15efd8
leaq 0x41b32(%rip), %rsi     # 0xf1c2f
callq 0x5330
movq -0x8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x36f50
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x36f80
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x37360
testb $0x1, %al
jne 0xb013e
jmp 0xb08c2
leaq -0x18(%rbp), %rdi
callq 0x373d0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
addq $0x8, %rsi
leaq -0x48(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x5150
movq -0x260(%rbp), %rsi
leaq 0xb05d0(%rip), %rdi     # 0x160748
xorl %edx, %edx
callq 0xbe630
movb %al, -0x253(%rbp)
jmp 0xb0187
movb -0x253(%rbp), %al
testb $0x1, %al
jne 0xb0242
jmp 0xb0197
leaq 0xb057a(%rip), %rdi     # 0x160718
leaq -0x48(%rbp), %rsi
xorl %edx, %edx
callq 0xbe7c0
movb %al, -0x261(%rbp)
jmp 0xb01b1
movb -0x261(%rbp), %al
testb $0x1, %al
jne 0xb0242
jmp 0xb01c1
leaq 0xb05b0(%rip), %rdi     # 0x160778
leaq -0x48(%rbp), %rsi
xorl %edx, %edx
callq 0xbeb90
movb %al, -0x262(%rbp)
jmp 0xb01db
movb -0x262(%rbp), %al
testb $0x1, %al
jne 0xb0242
jmp 0xb01e7
leaq 0xb05ba(%rip), %rdi     # 0x1607a8
leaq -0x48(%rbp), %rsi
xorl %edx, %edx
callq 0xbed20
movb %al, -0x263(%rbp)
jmp 0xb0201
movb -0x263(%rbp), %al
testb $0x1, %al
jne 0xb0242
jmp 0xb020d
leaq 0xb04ec(%rip), %rdi     # 0x160700
callq 0xbe5b0
testb $0x1, %al
jne 0xb03f3
leaq 0xb04d8(%rip), %rdi     # 0x160700
callq 0xbe5f0
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x19db0
testb $0x1, %al
jne 0xb0242
jmp 0xb03f3
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
leaq -0x101(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0x55d0
movq -0x270(%rbp), %rdx
leaq 0x40e3a(%rip), %rsi     # 0xf10af
leaq -0x100(%rbp), %rdi
callq 0x19840
jmp 0xb0283
leaq 0x41491(%rip), %rdx     # 0xf171b
leaq -0xe0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x1a380
jmp 0xb029f
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x1a4d0
jmp 0xb02b8
leaq 0x4145c(%rip), %rdx     # 0xf171b
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x1a380
jmp 0xb02d4
leaq 0x40deb(%rip), %rdx     # 0xf10c6
leaq -0x80(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x1a380
jmp 0xb02ed
movq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xae910
jmp 0xb02fc
leaq -0x80(%rbp), %rdi
callq 0x5200
leaq -0xa0(%rbp), %rdi
callq 0x5200
leaq -0xc0(%rbp), %rdi
callq 0x5200
leaq -0xe0(%rbp), %rdi
callq 0x5200
leaq -0x100(%rbp), %rdi
callq 0x5200
leaq -0x101(%rbp), %rdi
callq 0x53c0
jmp 0xb08a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb08b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb03e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb03d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb03ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb03be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb03b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5200
leaq -0xa0(%rbp), %rdi
callq 0x5200
leaq -0xc0(%rbp), %rdi
callq 0x5200
leaq -0xe0(%rbp), %rdi
callq 0x5200
leaq -0x100(%rbp), %rdi
callq 0x5200
leaq -0x101(%rbp), %rdi
callq 0x53c0
jmp 0xb08b7
leaq 0xb0306(%rip), %rdi     # 0x160700
leaq -0x48(%rbp), %rsi
callq 0xbeeb0
jmp 0xb0405
movq -0x28(%rbp), %rax
movq (%rax), %rsi
leaq -0x120(%rbp), %rdi
callq 0xb1710
jmp 0xb041a
leaq -0x141(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x55d0
movq -0x278(%rbp), %rdx
leaq 0x3fbc5(%rip), %rsi     # 0xf0000
leaq -0x140(%rbp), %rdi
callq 0x19840
jmp 0xb0449
movl $0x48, %edi
callq 0x5340
movq %rax, -0x280(%rbp)
jmp 0xb045c
movb $0x1, -0x18a(%rbp)
leaq -0x168(%rbp), %rdi
callq 0xb1760
jmp 0xb0471
leaq -0x189(%rbp), %rdi
movq %rdi, -0x288(%rbp)
callq 0x55d0
movq -0x288(%rbp), %rdx
leaq 0x4150e(%rip), %rsi     # 0xf19a0
leaq -0x188(%rbp), %rdi
callq 0x19840
jmp 0xb04a0
movq -0x280(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x188(%rbp), %rdx
callq 0xbeae0
jmp 0xb04bc
movq -0x280(%rbp), %rdx
movb $0x0, -0x18a(%rbp)
leaq 0xb01ff(%rip), %rdi     # 0x1606d0
xorl %eax, %eax
movl %eax, %r8d
leaq -0x140(%rbp), %rsi
movq %r8, %rcx
callq 0xbdf00
jmp 0xb04e7
leaq -0x188(%rbp), %rdi
callq 0x5200
leaq -0x189(%rbp), %rdi
callq 0x53c0
leaq -0x168(%rbp), %rdi
callq 0x5200
leaq -0x140(%rbp), %rdi
callq 0x5200
leaq -0x141(%rbp), %rdi
callq 0x53c0
leaq -0x1e8(%rbp), %rdi
callq 0xb1760
jmp 0xb0531
leaq -0x1c8(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
leaq -0x120(%rbp), %rdx
callq 0xa0680
jmp 0xb054d
leaq 0xb0224(%rip), %rdi     # 0x160778
leaq -0x1c8(%rbp), %rsi
callq 0xbef30
jmp 0xb0562
leaq -0x1c8(%rbp), %rdi
callq 0xbef60
leaq -0x1e8(%rbp), %rdi
callq 0x5200
leaq 0xb01f7(%rip), %rdi     # 0x160778
callq 0xbe0d0
jmp 0xb0588
leaq 0xb0219(%rip), %rdi     # 0x1607a8
callq 0xbe110
jmp 0xb0596
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xaef50
jmp 0xb05a5
leaq -0x209(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x55d0
movq -0x290(%rbp), %rdx
leaq 0x40aa5(%rip), %rsi     # 0xf106b
leaq -0x208(%rbp), %rdi
callq 0x19840
jmp 0xb05d4
movl $0x48, %edi
callq 0x5340
movq %rax, -0x298(%rbp)
jmp 0xb05e7
movb $0x1, -0x252(%rbp)
leaq -0x230(%rbp), %rdi
callq 0xb1760
jmp 0xb05fc
leaq -0x251(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x55d0
movq -0x2a0(%rbp), %rdx
leaq 0x41383(%rip), %rsi     # 0xf19a0
leaq -0x250(%rbp), %rdi
callq 0x19840
jmp 0xb062b
movq -0x298(%rbp), %rdi
leaq -0x230(%rbp), %rsi
leaq -0x250(%rbp), %rdx
callq 0xbeae0
jmp 0xb0647
movq -0x298(%rbp), %rdx
movb $0x0, -0x252(%rbp)
leaq 0xb0074(%rip), %rdi     # 0x1606d0
xorl %eax, %eax
movl %eax, %r8d
leaq -0x208(%rbp), %rsi
movq %r8, %rcx
callq 0xbdf00
jmp 0xb0672
leaq -0x250(%rbp), %rdi
callq 0x5200
leaq -0x251(%rbp), %rdi
callq 0x53c0
leaq -0x230(%rbp), %rdi
callq 0x5200
leaq -0x208(%rbp), %rdi
callq 0x5200
leaq -0x209(%rbp), %rdi
callq 0x53c0
leaq 0xb004b(%rip), %rdi     # 0x160700
callq 0xbef90
leaq 0xb0087(%rip), %rdi     # 0x160748
callq 0xbe3d0
jmp 0xb06c8
leaq 0xb0049(%rip), %rdi     # 0x160718
callq 0xbe430
jmp 0xb06d6
leaq 0xb009b(%rip), %rdi     # 0x160778
callq 0xbe490
jmp 0xb06e4
leaq 0xb00bd(%rip), %rdi     # 0x1607a8
callq 0xbe4f0
jmp 0xb06f2
leaq -0x120(%rbp), %rdi
callq 0xbda20
jmp 0xb08a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb0798
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb078c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb076e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb0756
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x5200
leaq -0x189(%rbp), %rdi
callq 0x53c0
leaq -0x168(%rbp), %rdi
callq 0x5200
testb $0x1, -0x18a(%rbp)
jne 0xb0779
jmp 0xb078a
movq -0x280(%rbp), %rdi
movl $0x48, %esi
callq 0x5350
jmp 0xb078c
leaq -0x140(%rbp), %rdi
callq 0x5200
leaq -0x141(%rbp), %rdi
callq 0x53c0
jmp 0xb0892
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb0892
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb07e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0xbef60
leaq -0x1e8(%rbp), %rdi
callq 0x5200
jmp 0xb0892
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb0886
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb087a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb085c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb0844
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x5200
leaq -0x251(%rbp), %rdi
callq 0x53c0
leaq -0x230(%rbp), %rdi
callq 0x5200
testb $0x1, -0x252(%rbp)
jne 0xb0867
jmp 0xb0878
movq -0x298(%rbp), %rdi
movl $0x48, %esi
callq 0x5350
jmp 0xb087a
leaq -0x208(%rbp), %rdi
callq 0x5200
leaq -0x209(%rbp), %rdi
callq 0x53c0
leaq -0x120(%rbp), %rdi
callq 0xbda20
jmp 0xb08b7
leaq -0x48(%rbp), %rdi
callq 0x5200
leaq -0x18(%rbp), %rdi
callq 0x373f0
jmp 0xb0128
leaq -0x48(%rbp), %rdi
callq 0x5200
jmp 0xb08cb
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x55b0
nopw %cs:(%rax,%rax)