// File: sighingnow[P]compile-pascal/pl0_tac_gen.cpp
// Function: pl0_tac_var_stmt(pl0_ast_var_stmt const*)
void pl0_tac_var_stmt(pl0_ast_var_stmt const *stmts) {
    cout << __func__;
    if (!stmts) { return; }
    for (auto && s: stmts->stmt) {
        for (auto && var: s->ids) {
            // validate.
            if (!scope.empty() && var->id == scope.back()) {
                pl0_ast_error(var->loc, string("duplicate identifier ") + "\"" + var->id + "\"");
            }
            else if (valtb.find(var->id, false) || vartb.find(var->id, false)) {
                pl0_ast_error(var->loc, string("redefinition of ") + "\"" + var->id + "\"");
            }
            else {
                string t = s->type->type->type + (s->type->len == -1 ? "" : "array");
                vartb.push(variable(var->id, s->type->type->type, t, s->type->len)); // update symbol table.
                irb.emit("def", new Value(var->id, s->type->type->type), new Value(t, "string"), new Value(s->type->len, "integer"));
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x390, %rsp            # imm = 0x390
movq %rdi, -0x8(%rbp)
movq 0xaf912(%rip), %rdi     # 0x15efd8
leaq 0x42562(%rip), %rsi     # 0xf1c2f
callq 0x5330
cmpq $0x0, -0x8(%rbp)
jne 0xaf6de
jmp 0xb00be
movq -0x8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x32f80
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x32fb0
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xbe9d0
testb $0x1, %al
jne 0xaf71a
jmp 0xb00be
leaq -0x18(%rbp), %rdi
callq 0xbea10
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
addq $0x10, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x5aed0
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x5c6f0
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xbea30
testb $0x1, %al
jne 0xaf766
jmp 0xb00ae
leaq -0x38(%rbp), %rdi
callq 0x5ced0
movq %rax, -0x48(%rbp)
leaq 0xb0f86(%rip), %rdi     # 0x160700
callq 0xbe5b0
testb $0x1, %al
jne 0xaf93c
movq -0x48(%rbp), %rax
movq (%rax), %rax
addq $0x8, %rax
movq %rax, -0x348(%rbp)
leaq 0xb0f60(%rip), %rdi     # 0x160700
callq 0xbe5f0
movq -0x348(%rbp), %rdi
movq %rax, %rsi
callq 0x19db0
testb $0x1, %al
jne 0xaf7bd
jmp 0xaf93c
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x350(%rbp)
callq 0x55d0
movq -0x350(%rbp), %rdx
leaq 0x41898(%rip), %rsi     # 0xf1084
leaq -0xd0(%rbp), %rdi
callq 0x19840
jmp 0xaf7fa
leaq 0x41f1a(%rip), %rdx     # 0xf171b
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x1a380
jmp 0xaf816
movq -0x48(%rbp), %rax
movq (%rax), %rdx
addq $0x8, %rdx
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x1a4d0
jmp 0xaf836
leaq 0x41ede(%rip), %rdx     # 0xf171b
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x1a380
jmp 0xaf84f
movq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xae910
jmp 0xaf85e
leaq -0x70(%rbp), %rdi
callq 0x5200
leaq -0x90(%rbp), %rdi
callq 0x5200
leaq -0xb0(%rbp), %rdi
callq 0x5200
leaq -0xd0(%rbp), %rdi
callq 0x5200
leaq -0xd1(%rbp), %rdi
callq 0x53c0
jmp 0xb009e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xaf92b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xaf91f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xaf913
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xaf907
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x5200
leaq -0x90(%rbp), %rdi
callq 0x5200
leaq -0xb0(%rbp), %rdi
callq 0x5200
leaq -0xd0(%rbp), %rdi
callq 0x5200
leaq -0xd1(%rbp), %rdi
callq 0x53c0
jmp 0xb00c7
movq -0x48(%rbp), %rax
movq (%rax), %rsi
addq $0x8, %rsi
leaq 0xb0dfa(%rip), %rdi     # 0x160748
xorl %edx, %edx
callq 0xbe630
testb $0x1, %al
jne 0xaf97b
movq -0x48(%rbp), %rax
movq (%rax), %rsi
addq $0x8, %rsi
leaq 0xb0dad(%rip), %rdi     # 0x160718
xorl %edx, %edx
callq 0xbe7c0
testb $0x1, %al
jne 0xaf97b
jmp 0xafb0c
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
leaq -0x171(%rbp), %rdi
movq %rdi, -0x358(%rbp)
callq 0x55d0
movq -0x358(%rbp), %rdx
leaq 0x416ed(%rip), %rsi     # 0xf109a
leaq -0x170(%rbp), %rdi
callq 0x19840
jmp 0xaf9bb
leaq 0x41d59(%rip), %rdx     # 0xf171b
leaq -0x150(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x1a380
jmp 0xaf9d7
movq -0x48(%rbp), %rax
movq (%rax), %rdx
addq $0x8, %rdx
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x1a4d0
jmp 0xaf9f7
leaq 0x41d1d(%rip), %rdx     # 0xf171b
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x1a380
jmp 0xafa13
movq -0xf0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xae910
jmp 0xafa28
leaq -0x110(%rbp), %rdi
callq 0x5200
leaq -0x130(%rbp), %rdi
callq 0x5200
leaq -0x150(%rbp), %rdi
callq 0x5200
leaq -0x170(%rbp), %rdi
callq 0x5200
leaq -0x171(%rbp), %rdi
callq 0x53c0
jmp 0xb009c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xafafb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xafaef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xafae3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xafad7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x5200
leaq -0x130(%rbp), %rdi
callq 0x5200
leaq -0x150(%rbp), %rdi
callq 0x5200
leaq -0x170(%rbp), %rdi
callq 0x5200
leaq -0x171(%rbp), %rdi
callq 0x53c0
jmp 0xb00c7
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
addq $0x8, %rsi
movl 0x10(%rax), %eax
subl $-0x1, %eax
leaq 0x42103(%rip), %rax     # 0xf1c2f
leaq 0x4166f(%rip), %rdx     # 0xf11a2
cmoveq %rax, %rdx
leaq -0x198(%rbp), %rdi
callq 0x458c0
movq -0x48(%rbp), %rax
movq (%rax), %rsi
addq $0x8, %rsi
leaq -0x220(%rbp), %rdi
callq 0x5150
jmp 0xafb5c
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
addq $0x8, %rsi
leaq -0x240(%rbp), %rdi
callq 0x5150
jmp 0xafb7d
leaq -0x260(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x5150
jmp 0xafb92
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movl 0x10(%rax), %r8d
leaq -0x200(%rbp), %rdi
leaq -0x220(%rbp), %rsi
leaq -0x240(%rbp), %rdx
leaq -0x260(%rbp), %rcx
callq 0xa04e0
jmp 0xafbc4
leaq 0xb0b4d(%rip), %rdi     # 0x160718
leaq -0x200(%rbp), %rsi
callq 0xbea70
jmp 0xafbd9
leaq -0x200(%rbp), %rdi
callq 0xbeaa0
leaq -0x260(%rbp), %rdi
callq 0x5200
leaq -0x240(%rbp), %rdi
callq 0x5200
leaq -0x220(%rbp), %rdi
callq 0x5200
leaq -0x281(%rbp), %rdi
movq %rdi, -0x360(%rbp)
callq 0x55d0
movq -0x360(%rbp), %rdx
leaq 0x41481(%rip), %rsi     # 0xf10ab
leaq -0x280(%rbp), %rdi
callq 0x19840
jmp 0xafc38
movl $0x48, %edi
callq 0x5340
movq %rax, -0x368(%rbp)
jmp 0xafc4b
movb $0x1, -0x2c9(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rsi
addq $0x8, %rsi
leaq -0x2a8(%rbp), %rdi
callq 0x5150
jmp 0xafc6b
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
addq $0x8, %rsi
leaq -0x2c8(%rbp), %rdi
callq 0x5150
jmp 0xafc8c
movq -0x368(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
leaq -0x2c8(%rbp), %rdx
callq 0xbeae0
jmp 0xafca8
movb $0x0, -0x2c9(%rbp)
movl $0x48, %edi
callq 0x5340
movq %rax, -0x370(%rbp)
jmp 0xafcc2
movb $0x1, -0x312(%rbp)
leaq -0x2f0(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x5150
jmp 0xafcde
leaq -0x311(%rbp), %rdi
movq %rdi, -0x378(%rbp)
callq 0x55d0
movq -0x378(%rbp), %rdx
leaq 0x41ca1(%rip), %rsi     # 0xf19a0
leaq -0x310(%rbp), %rdi
callq 0x19840
jmp 0xafd0d
movq -0x370(%rbp), %rdi
leaq -0x2f0(%rbp), %rsi
leaq -0x310(%rbp), %rdx
callq 0xbeae0
jmp 0xafd29
movb $0x0, -0x312(%rbp)
movl $0x48, %edi
callq 0x5340
movq %rax, -0x380(%rbp)
jmp 0xafd43
movb $0x1, -0x33a(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movl 0x10(%rax), %eax
movl %eax, -0x38c(%rbp)
leaq -0x339(%rbp), %rdi
movq %rdi, -0x388(%rbp)
callq 0x55d0
movq -0x388(%rbp), %rdx
leaq 0x3f4c8(%rip), %rsi     # 0xef247
leaq -0x338(%rbp), %rdi
callq 0x19840
jmp 0xafd8d
movl -0x38c(%rbp), %esi
movq -0x380(%rbp), %rdi
leaq -0x338(%rbp), %rdx
callq 0xbdfe0
jmp 0xafda8
movq -0x380(%rbp), %r8
movq -0x370(%rbp), %rcx
movq -0x368(%rbp), %rdx
movb $0x0, -0x33a(%rbp)
leaq 0xb0905(%rip), %rdi     # 0x1606d0
leaq -0x280(%rbp), %rsi
callq 0xbdf00
jmp 0xafdd9
leaq -0x338(%rbp), %rdi
callq 0x5200
leaq -0x339(%rbp), %rdi
callq 0x53c0
leaq -0x310(%rbp), %rdi
callq 0x5200
leaq -0x311(%rbp), %rdi
callq 0x53c0
leaq -0x2f0(%rbp), %rdi
callq 0x5200
leaq -0x2c8(%rbp), %rdi
callq 0x5200
leaq -0x2a8(%rbp), %rdi
callq 0x5200
leaq -0x280(%rbp), %rdi
callq 0x5200
leaq -0x281(%rbp), %rdi
callq 0x53c0
leaq -0x198(%rbp), %rdi
callq 0x5200
jmp 0xb009c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xb008e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xafedf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xafed3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xafec7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x200(%rbp), %rdi
callq 0xbeaa0
leaq -0x260(%rbp), %rdi
callq 0x5200
leaq -0x240(%rbp), %rdi
callq 0x5200
leaq -0x220(%rbp), %rdi
callq 0x5200
jmp 0xb008e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xb0082
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xb0076
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xb0058
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xb004c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xb0040
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xb0022
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xb000a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xafffe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0xaffd4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x338(%rbp), %rdi
callq 0x5200
leaq -0x339(%rbp), %rdi
callq 0x53c0
testb $0x1, -0x33a(%rbp)
jne 0xaffeb
jmp 0xafffc
movq -0x380(%rbp), %rdi
movl $0x48, %esi
callq 0x5350
jmp 0xafffe
leaq -0x310(%rbp), %rdi
callq 0x5200
leaq -0x311(%rbp), %rdi
callq 0x53c0
leaq -0x2f0(%rbp), %rdi
callq 0x5200
testb $0x1, -0x312(%rbp)
jne 0xb002d
jmp 0xb003e
movq -0x370(%rbp), %rdi
movl $0x48, %esi
callq 0x5350
jmp 0xb0040
leaq -0x2c8(%rbp), %rdi
callq 0x5200
leaq -0x2a8(%rbp), %rdi
callq 0x5200
testb $0x1, -0x2c9(%rbp)
jne 0xb0063
jmp 0xb0074
movq -0x368(%rbp), %rdi
movl $0x48, %esi
callq 0x5350
jmp 0xb0076
leaq -0x280(%rbp), %rdi
callq 0x5200
leaq -0x281(%rbp), %rdi
callq 0x53c0
leaq -0x198(%rbp), %rdi
callq 0x5200
jmp 0xb00c7
jmp 0xb009e
jmp 0xb00a0
leaq -0x38(%rbp), %rdi
callq 0xbeb50
jmp 0xaf750
jmp 0xb00b0
leaq -0x18(%rbp), %rdi
callq 0xbeb70
jmp 0xaf704
addq $0x390, %rsp            # imm = 0x390
popq %rbp
retq
movq -0xe0(%rbp), %rdi
callq 0x55b0
nopw %cs:(%rax,%rax)