// File: /workspace/github_cpp_makefile_star2_O2/sighingnow[P]compile-pascal/pl0_tac_gen.cpp
// Function: pl0_tac_case_stmt(pl0_ast_case_stmt const*)
void pl0_tac_case_stmt(pl0_ast_case_stmt const *stmt) {
    cout << __func__;
    auto case_cond = pl0_tac_expr(stmt->expr);
    // add case condition value to symbol table.
    Value *cond;
    if (case_cond.first->t == Value::TYPE::STR && case_cond.first->sv[0] == '~') {
        cond = new Value(string("~") + case_cond.first->sv, case_cond.second);
        irb.emit("def", cond, new Value(case_cond.second, "string"), new Value(-1, "integer"));
        irb.emit("=", cond, case_cond.first);
    }
    else {
        cond = case_cond.first;
    }
    int endlabel = irb.makelabel();
    std::vector<int> labels;
    for (auto && item: stmt->terms) {
        labels.emplace_back(irb.makelabel());
    }
    labels.emplace_back(endlabel);
    irb.emit("goto", new Value("jmp", "string"), new Value(labels[0], "integer"));
    for (size_t i = 0; i < stmt->terms.size(); ++i) {
        int t = irb.makelabel();
        irb.emitlabel(labels[i]);
        irb.emit("cmp", new Value(t, "integer"), cond, new Value(stmt->terms[i]->constv->val, "integer"));
        irb.emit("goto", new Value("jne", "string"), new Value(labels[i+1], "integer"));
        irb.emitlabel(t);
        pl0_tac_stmt(stmt->terms[i]->stmt);
        irb.emit("goto", new Value("jmp", "string"), new Value(endlabel, "integer"));
    }
    irb.emitlabel(endlabel);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x338, %rsp            # imm = 0x338
movq %rdi, %rbx
movq 0x49926(%rip), %rdi     # 0x8afd8
leaq 0x19e86(%rip), %rsi     # 0x5b53f
callq 0x5250
movq %rbx, 0x10(%rsp)
movq 0x18(%rbx), %rsi
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x44859
movq (%rbx), %r12
cmpl $0x1, (%r12)
jne 0x418b9
movq 0x8(%r12), %rax
cmpb $0x7e, (%rax)
jne 0x418b9
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %r12
leaq 0x193de(%rip), %rsi     # 0x5aae0
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xfa26
movq 0x50(%rsp), %rdx
addq $0x8, %rdx
leaq 0x218(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xfda4
leaq 0x58(%rsp), %r14
leaq 0x1f8(%rsp), %rdi
movq %r14, %rsi
callq 0x5340
leaq 0x218(%rsp), %rsi
leaq 0x1f8(%rsp), %rdx
movq %r12, %rdi
callq 0x46fc0
leaq 0x1f8(%rsp), %rdi
callq 0x5120
leaq 0x218(%rsp), %rdi
callq 0x5120
leaq 0x20(%rsp), %rdi
callq 0x5120
leaq 0x19217(%rip), %rsi     # 0x5a99b
leaq 0x1d8(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0xfa26
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %rbx
leaq 0x1b8(%rsp), %rdi
movq %r14, %rsi
callq 0x5340
leaq 0x19af0(%rip), %rsi     # 0x5b2a8
leaq 0x198(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xfa26
movb $0x1, %bpl
leaq 0x1b8(%rsp), %rsi
leaq 0x198(%rsp), %rdx
movq %rbx, %rdi
callq 0x46fc0
xorl %ebp, %ebp
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %r15
leaq 0x17916(%rip), %rsi     # 0x5910f
leaq 0x178(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0xfa26
movb $0x1, %bpl
pushq $-0x1
popq %rsi
leaq 0x178(%rsp), %rdx
movq %r15, %rdi
callq 0x46ac6
xorl %ebp, %ebp
leaq 0x4ada6(%rip), %rdi     # 0x8c5d0
leaq 0x1d8(%rsp), %rsi
movq %r12, %rdx
movq %rbx, %rcx
movq %r15, %r8
callq 0x46a38
leaq 0x178(%rsp), %rdi
callq 0x5120
leaq 0x198(%rsp), %rdi
callq 0x5120
leaq 0x1b8(%rsp), %rdi
callq 0x5120
leaq 0x1d8(%rsp), %rdi
callq 0x5120
leaq 0x1789d(%rip), %rsi     # 0x59118
leaq 0x158(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0xfa26
movq 0x50(%rsp), %rcx
leaq 0x4ad37(%rip), %rdi     # 0x8c5d0
leaq 0x158(%rsp), %rsi
movq %r12, %rdx
xorl %r8d, %r8d
callq 0x46a38
leaq 0x158(%rsp), %rdi
callq 0x5120
movq %r12, 0x48(%rsp)
leaq 0x4ad0b(%rip), %rdi     # 0x8c5d0
callq 0x3bb88
movl %eax, 0x8(%rsp)
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rbx
movaps %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
movq 0x10(%rsp), %rax
movq 0x20(%rax), %r12
movq 0x28(%rax), %r13
leaq 0x4acde(%rip), %r14     # 0x8c5d0
leaq 0x4(%rsp), %r15
cmpq %r13, %r12
je 0x41919
movq %r14, %rdi
callq 0x3bb88
movl %eax, 0x4(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x47790
addq $0x8, %r12
jmp 0x418f7
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x477c4
leaq 0x19193(%rip), %rsi     # 0x5aac2
leaq 0x138(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0xfa26
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %rbx
leaq 0x19189(%rip), %rsi     # 0x5aadc
leaq 0x118(%rsp), %rdi
leaq 0x2(%rsp), %rdx
callq 0xfa26
leaq 0x1993c(%rip), %rsi     # 0x5b2a8
leaq 0xf8(%rsp), %rdi
leaq 0x1(%rsp), %rdx
callq 0xfa26
movb $0x1, %bpl
leaq 0x118(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
movq %rbx, %rdi
callq 0x46fc0
xorl %ebp, %ebp
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %r15
movq 0x20(%rsp), %rax
movl (%rax), %ebp
leaq 0x1775b(%rip), %rsi     # 0x5910f
leaq 0xd8(%rsp), %rdi
leaq 0x3(%rsp), %rdx
callq 0xfa26
movb $0x1, %r14b
leaq 0xd8(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
callq 0x46ac6
xorl %r14d, %r14d
leaq 0x4abeb(%rip), %rdi     # 0x8c5d0
leaq 0x138(%rsp), %rsi
movq %rbx, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x46a38
leaq 0xd8(%rsp), %rdi
callq 0x5120
leaq 0xf8(%rsp), %rdi
callq 0x5120
leaq 0x118(%rsp), %rdi
callq 0x5120
leaq 0x138(%rsp), %rdi
callq 0x5120
xorl %r12d, %r12d
leaq 0x4ab97(%rip), %rbx     # 0x8c5d0
leaq 0xb8(%rsp), %r14
leaq 0x1907a(%rip), %r15     # 0x5aac2
movq 0x10(%rsp), %rcx
movq 0x28(%rcx), %rax
subq 0x20(%rcx), %rax
sarq $0x3, %rax
cmpq %rax, %r12
jae 0x41da0
movq %rbx, %rdi
callq 0x3bb88
movl %eax, 0xc(%rsp)
movq 0x20(%rsp), %rax
movl (%rax,%r12,4), %esi
movq %rbx, %rdi
callq 0x46b94
movq %r14, %rdi
leaq 0x19035(%rip), %rsi     # 0x5aabe
leaq 0x4(%rsp), %rdx
callq 0xfa26
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %rbp
leaq 0x318(%rsp), %r14
movq %r14, %rdi
leaq 0x1765f(%rip), %rsi     # 0x5910f
leaq 0x2(%rsp), %rdx
callq 0xfa26
movq %r15, %r13
movb $0x1, %bl
movq %rbp, %rdi
movl 0xc(%rsp), %esi
movq %r14, %rdx
callq 0x46ac6
xorl %ebx, %ebx
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %r14
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
movq %r12, 0x18(%rsp)
movq (%rax,%r12,8), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %ebx
leaq 0x2f8(%rsp), %r15
movq %r15, %rdi
leaq 0x17609(%rip), %rsi     # 0x5910f
leaq 0x1(%rsp), %rdx
callq 0xfa26
movb $0x1, %r12b
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x46ac6
leaq 0x4aaa9(%rip), %rdi     # 0x8c5d0
leaq 0xb8(%rsp), %rbx
xorl %r12d, %r12d
movq %rbx, %rsi
movq %rbp, %rdx
movq 0x48(%rsp), %rcx
movq %r14, %r8
callq 0x46a38
leaq 0x2f8(%rsp), %rdi
callq 0x5120
leaq 0x318(%rsp), %rdi
callq 0x5120
movq %rbx, %rdi
callq 0x5120
leaq 0x2d8(%rsp), %rdi
movq %r13, %r15
movq %r13, %rsi
leaq 0x4(%rsp), %rdx
callq 0xfa26
pushq $0x48
popq %rdi
callq 0x5260
movq 0x18(%rsp), %r12
leaq 0x2b8(%rsp), %rbx
movq %rax, %rbp
leaq 0x98(%rsp), %rdi
leaq 0x18f2f(%rip), %rsi     # 0x5aad5
leaq 0x2(%rsp), %rdx
callq 0xfa26
movq %rbx, %rdi
leaq 0x196ee(%rip), %rsi     # 0x5b2a8
leaq 0x1(%rsp), %rdx
callq 0xfa26
movq %rbx, %rdx
movb $0x1, %bl
movq %rbp, %rdi
leaq 0x98(%rsp), %rsi
callq 0x46fc0
xorl %ebx, %ebx
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %r14
movq 0x20(%rsp), %rax
movl 0x4(%rax,%r12,4), %ebx
leaq 0x298(%rsp), %r13
movq %r13, %rdi
leaq 0x1750d(%rip), %rsi     # 0x5910f
leaq 0x3(%rsp), %rdx
callq 0xfa26
movb $0x1, %r12b
movq %r14, %rdi
movl %ebx, %esi
movq %r13, %rdx
callq 0x46ac6
leaq 0x4a9ad(%rip), %rbx     # 0x8c5d0
leaq 0x2d8(%rsp), %r13
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x46a38
leaq 0x298(%rsp), %rdi
callq 0x5120
leaq 0x2b8(%rsp), %rdi
callq 0x5120
leaq 0x98(%rsp), %rdi
callq 0x5120
movq %r13, %rdi
callq 0x5120
movq %rbx, %rdi
movl 0xc(%rsp), %esi
callq 0x46b94
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rdi
callq 0x3fe31
leaq 0x278(%rsp), %rdi
movq %r15, %rsi
leaq 0x4(%rsp), %rdx
callq 0xfa26
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %r13
leaq 0x78(%rsp), %rdi
leaq 0x18e18(%rip), %rsi     # 0x5aadc
leaq 0x2(%rsp), %rdx
callq 0xfa26
leaq 0x258(%rsp), %r14
movq %r14, %rdi
leaq 0x195c8(%rip), %rsi     # 0x5b2a8
leaq 0x1(%rsp), %rdx
callq 0xfa26
movb $0x1, %bl
movq %r13, %rdi
leaq 0x78(%rsp), %rsi
movq %r14, %rdx
callq 0x46fc0
xorl %ebx, %ebx
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %r14
movl 0x8(%rsp), %ebx
leaq 0x238(%rsp), %rbp
movq %rbp, %rdi
leaq 0x173f0(%rip), %rsi     # 0x5910f
leaq 0x3(%rsp), %rdx
callq 0xfa26
movb $0x1, %r12b
movq %r14, %rdi
movl %ebx, %esi
movq %rbp, %rdx
callq 0x46ac6
leaq 0x4a890(%rip), %rbx     # 0x8c5d0
leaq 0x278(%rsp), %rbp
xorl %r12d, %r12d
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x46a38
leaq 0x238(%rsp), %rdi
callq 0x5120
leaq 0x258(%rsp), %rdi
callq 0x5120
leaq 0x78(%rsp), %rdi
callq 0x5120
movq %rbp, %rdi
callq 0x5120
movq 0x18(%rsp), %r12
incq %r12
leaq 0xb8(%rsp), %r14
jmp 0x41a48
movl 0x8(%rsp), %esi
leaq 0x4a825(%rip), %rdi     # 0x8c5d0
callq 0x46b94
leaq 0x20(%rsp), %rdi
callq 0x481ca
leaq 0x58(%rsp), %rdi
callq 0x5120
addq $0x338, %rsp            # imm = 0x338
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
leaq 0x158(%rsp), %rdi
callq 0x5120
jmp 0x420d2
jmp 0x41ee5
movq %rax, %r12
jmp 0x41e78
movq %rax, %r12
movb $0x1, %bpl
jmp 0x41e97
movq %rax, %r12
jmp 0x41ea9
movq %rax, %r12
jmp 0x41eb4
jmp 0x41ee5
movq %rax, %r15
leaq 0x1f8(%rsp), %rdi
callq 0x5120
jmp 0x41e2d
movq %rax, %r15
leaq 0x218(%rsp), %rdi
callq 0x5120
jmp 0x41e3f
movq %rax, %r15
leaq 0x20(%rsp), %rdi
callq 0x5120
jmp 0x41e4e
movq %rax, %r15
pushq $0x48
popq %rsi
movq %r12, %rdi
callq 0x5270
jmp 0x420d2
jmp 0x41ee5
movq %rax, %r12
leaq 0x178(%rsp), %rdi
callq 0x5120
testb %bpl, %bpl
je 0x41e83
pushq $0x48
popq %rsi
movq %r15, %rdi
callq 0x5270
xorl %ebp, %ebp
jmp 0x41e8a
movq %rax, %r12
leaq 0x198(%rsp), %rdi
callq 0x5120
leaq 0x1b8(%rsp), %rdi
callq 0x5120
testb %bpl, %bpl
je 0x41eb4
pushq $0x48
popq %rsi
movq %rbx, %rdi
callq 0x5270
leaq 0x1d8(%rsp), %rdi
callq 0x5120
movq %r12, %r15
jmp 0x420d2
movq %rax, %r12
jmp 0x41f07
movq %rax, %r12
movb $0x1, %bpl
jmp 0x41f26
movq %rax, %r12
jmp 0x41f38
movq %rax, %r12
jmp 0x41f43
jmp 0x420c5
movq %rax, %r15
jmp 0x420d2
jmp 0x420c5
movq %rax, %r12
leaq 0xd8(%rsp), %rdi
callq 0x5120
testb %r14b, %r14b
je 0x41f12
pushq $0x48
popq %rsi
movq %r15, %rdi
callq 0x5270
xorl %ebp, %ebp
jmp 0x41f19
movq %rax, %r12
leaq 0xf8(%rsp), %rdi
callq 0x5120
leaq 0x118(%rsp), %rdi
callq 0x5120
testb %bpl, %bpl
je 0x41f43
pushq $0x48
popq %rsi
movq %rbx, %rdi
callq 0x5270
leaq 0x138(%rsp), %rdi
callq 0x5120
movq %r12, %r15
jmp 0x420c8
jmp 0x420c5
movq %rax, %r15
jmp 0x41fff
movq %rax, %r15
movb $0x1, %bl
jmp 0x41ff1
movq %rax, %r15
jmp 0x4200a
movq %rax, %r15
jmp 0x41fd7
jmp 0x420c5
movq %rax, %r15
jmp 0x420a9
jmp 0x420c5
movq %rax, %r15
jmp 0x42086
movq %rax, %r15
jmp 0x420b4
movq %rax, %r15
movb $0x1, %bl
jmp 0x4204b
movq %rax, %r15
jmp 0x4205c
movq %rax, %r15
jmp 0x42067
movq %rax, %r15
jmp 0x42031
movq %rax, %r15
jmp 0x41fe4
movq %rax, %r15
leaq 0x238(%rsp), %rdi
callq 0x5120
testb %r12b, %r12b
je 0x41fe2
pushq $0x48
popq %rsi
movq %r14, %rdi
callq 0x5270
xorl %ebx, %ebx
leaq 0x258(%rsp), %rdi
callq 0x5120
leaq 0x78(%rsp), %rdi
callq 0x5120
testb %bl, %bl
je 0x4200a
pushq $0x48
popq %rsi
movq %r13, %rdi
callq 0x5270
leaq 0x278(%rsp), %rdi
jmp 0x420bc
movq %rax, %r15
jmp 0x4203e
movq %rax, %r15
leaq 0x298(%rsp), %rdi
callq 0x5120
testb %r12b, %r12b
je 0x4203c
pushq $0x48
popq %rsi
movq %r14, %rdi
callq 0x5270
xorl %ebx, %ebx
leaq 0x2b8(%rsp), %rdi
callq 0x5120
leaq 0x98(%rsp), %rdi
callq 0x5120
testb %bl, %bl
je 0x42067
pushq $0x48
popq %rsi
movq %rbp, %rdi
callq 0x5270
leaq 0x2d8(%rsp), %rdi
jmp 0x420bc
movq %rax, %r15
leaq 0x2f8(%rsp), %rdi
callq 0x5120
testb %r12b, %r12b
je 0x42091
pushq $0x48
popq %rsi
movq %r14, %rdi
callq 0x5270
xorl %ebx, %ebx
jmp 0x42098
movq %rax, %r15
leaq 0x318(%rsp), %rdi
callq 0x5120
testb %bl, %bl
je 0x420b4
pushq $0x48
popq %rsi
movq %rbp, %rdi
callq 0x5270
leaq 0xb8(%rsp), %rdi
callq 0x5120
jmp 0x420c8
jmp 0x420c5
movq %rax, %r15
leaq 0x20(%rsp), %rdi
callq 0x481ca
leaq 0x58(%rsp), %rdi
callq 0x5120
movq %r15, %rdi
callq 0x53f0