// File: zimpha[P]MiniSQL/interpreter.cc
// Function: Interpreter::printSelectResult(Table const&, Response const&)
void Interpreter::printSelectResult(const Table &nt, const Response &res) {
    std::vector<int> space(nt.attributes.size());
    for (size_t i = 0; i < space.size(); ++ i) {
        space[i] = nt.attributes[i].name.length() + 1;
    }
    for (size_t i = 0; i < res.result.size(); ++ i) {
        for (size_t j = 0; j < res.result[i].size(); ++ j) {
            std::strstream sin;
            switch (res.result[i][j].type) {
            case 0:
                sin << res.result[i][j].i;
                break;
            case 1:
                sin << res.result[i][j].f;
                break;
            case 2:
                sin << res.result[i][j].s;
                break;
            default: assert(false);
            }
            std::string s; sin >> s;
            space[j] = std::max(space[j], (int)s.length() + 1);
        }
    }
    int sum = std::accumulate(space.begin(), space.end(), space.size() + 1);
    for (int _ = 0; _ < sum; ++ _) std::cout << "-"; 
    std::cout << std::endl;
    std::cout << "|";
    for (size_t i = 0; i < nt.attributes.size(); ++ i) {
        std::cout << nt.attributes[i].name;
        int extra = space[i] - nt.attributes[i].name.length();
        for (int _ = 0; _ < extra; ++ _) std::cout << " ";
        std::cout << "|";
    }
    std::cout << std::endl;
    for (size_t i = 0; i < res.result.size(); ++ i) {
        std::cout << "|";
        for (size_t j = 0; j < res.result[i].size(); ++ j) {
            std::strstream sin;
            switch (res.result[i][j].type) {
            case 0:
                sin << res.result[i][j].i;
                break;
            case 1:
                sin << res.result[i][j].f;
                break;
            case 2:
                sin << res.result[i][j].s;
                break;
            default: assert(false);
            }
            std::string s; sin >> s;
            int extra = space[j] - s.length();
            res.result[i][j].print();
            for (int _ = 0; _ < extra; ++ _) std::cout << " ";
            std::cout << "|";
        }
        std::cout << std::endl;
    }
    for (int _ = 0; _ < sum; ++ _) std::cout << "-";
    std::cout << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4b0, %rsp            # imm = 0x4B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
callq 0x7750
movq %rax, -0x3f0(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x3e8(%rbp)
callq 0x21a60
movq -0x3f0(%rbp), %rsi
movq -0x3e8(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x21a80
jmp 0x21084
leaq -0x31(%rbp), %rdi
callq 0x21af0
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x3f8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x21b10
movq %rax, %rcx
movq -0x3f8(%rbp), %rax
cmpq %rcx, %rax
jae 0x21118
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
movq -0x50(%rbp), %rsi
callq 0x21b30
movq %rax, %rdi
callq 0x3460
addq $0x1, %rax
movl %eax, -0x3fc(%rbp)
movq -0x50(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x21b50
movl -0x3fc(%rbp), %ecx
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x21095
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x21af0
jmp 0x219a8
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x408(%rbp)
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
callq 0x8050
movq %rax, %rcx
movq -0x408(%rbp), %rax
cmpq %rcx, %rax
jae 0x213dd
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x410(%rbp)
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq -0x58(%rbp), %rsi
callq 0x21b70
movq %rax, %rdi
callq 0x8230
movq %rax, %rcx
movq -0x410(%rbp), %rax
cmpq %rcx, %rax
jae 0x213ca
leaq -0x1d8(%rbp), %rdi
callq 0x33f0
jmp 0x21198
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq -0x58(%rbp), %rsi
callq 0x21b70
movq %rax, %rdi
movq -0x60(%rbp), %rsi
callq 0x8260
movl 0x28(%rax), %eax
movl %eax, -0x414(%rbp)
testl %eax, %eax
je 0x211f6
jmp 0x211c4
movl -0x414(%rbp), %eax
subl $0x1, %eax
je 0x21247
jmp 0x211d1
movl -0x414(%rbp), %eax
subl $0x2, %eax
je 0x21287
jmp 0x212c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2199f
leaq -0x1c8(%rbp), %rax
movq %rax, -0x420(%rbp)
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq -0x58(%rbp), %rsi
callq 0x21b70
movq %rax, %rdi
movq -0x60(%rbp), %rsi
callq 0x8260
movq -0x420(%rbp), %rdi
movl (%rax), %esi
callq 0x34e0
jmp 0x21231
jmp 0x212e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x213b9
leaq -0x1c8(%rbp), %rax
movq %rax, -0x428(%rbp)
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq -0x58(%rbp), %rsi
callq 0x21b70
movq %rax, %rdi
movq -0x60(%rbp), %rsi
callq 0x8260
movq -0x428(%rbp), %rdi
movss 0x4(%rax), %xmm0
callq 0x3220
jmp 0x21285
jmp 0x212e8
leaq -0x1c8(%rbp), %rax
movq %rax, -0x430(%rbp)
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq -0x58(%rbp), %rsi
callq 0x21b70
movq %rax, %rdi
movq -0x60(%rbp), %rsi
callq 0x8260
movq -0x430(%rbp), %rdi
movq %rax, %rsi
addq $0x8, %rsi
callq 0x3280
jmp 0x212c7
jmp 0x212e8
leaq 0x5e93(%rip), %rdi      # 0x27163
leaq 0x6399(%rip), %rsi      # 0x27670
movl $0x176, %edx            # imm = 0x176
leaq 0x639c(%rip), %rcx      # 0x2767f
callq 0x31f0
leaq -0x1f8(%rbp), %rdi
movq %rdi, -0x438(%rbp)
callq 0x3410
movq -0x438(%rbp), %rsi
leaq -0x1d8(%rbp), %rdi
callq 0x33a0
jmp 0x21310
movq -0x60(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x21b50
movq %rax, -0x448(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x3460
movq -0x448(%rbp), %rdi
incl %eax
movl %eax, -0x1fc(%rbp)
leaq -0x1fc(%rbp), %rsi
callq 0x21b90
movq %rax, -0x440(%rbp)
jmp 0x21354
movq -0x440(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x44c(%rbp)
movq -0x60(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x21b50
movl -0x44c(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x1f8(%rbp), %rdi
callq 0x35b8
leaq -0x1d8(%rbp), %rdi
callq 0x3550
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x21153
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x35b8
leaq -0x1d8(%rbp), %rdi
callq 0x3550
jmp 0x2199f
jmp 0x213cc
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x21120
leaq -0x30(%rbp), %rdi
movq %rdi, -0x460(%rbp)
callq 0x21c30
movq -0x460(%rbp), %rdi
movq %rax, -0x208(%rbp)
callq 0x21c60
movq -0x460(%rbp), %rdi
movq %rax, -0x210(%rbp)
callq 0x21b10
movq %rax, %rdx
incq %rdx
movq -0x208(%rbp), %rdi
movq -0x210(%rbp), %rsi
callq 0x21bd0
movq %rax, -0x458(%rbp)
jmp 0x21435
movq -0x458(%rbp), %rax
movl %eax, -0x200(%rbp)
movl $0x0, -0x214(%rbp)
movl -0x214(%rbp), %eax
cmpl -0x200(%rbp), %eax
jge 0x21482
movq 0x17b67(%rip), %rdi     # 0x38fc8
leaq 0x625c(%rip), %rsi      # 0x276c4
callq 0x32c0
jmp 0x2146f
jmp 0x21471
movl -0x214(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x214(%rbp)
jmp 0x2144c
movq 0x17b3f(%rip), %rdi     # 0x38fc8
movq 0x17b18(%rip), %rsi     # 0x38fa8
callq 0x3310
jmp 0x21497
movq 0x17b2a(%rip), %rdi     # 0x38fc8
leaq 0x6221(%rip), %rsi      # 0x276c6
callq 0x32c0
jmp 0x214ac
movq $0x0, -0x220(%rbp)
movq -0x220(%rbp), %rax
movq %rax, -0x468(%rbp)
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
callq 0x7750
movq %rax, %rcx
movq -0x468(%rbp), %rax
cmpq %rcx, %rax
jae 0x215c1
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
movq -0x220(%rbp), %rsi
callq 0x21b30
movq %rax, %rsi
movq 0x17ac5(%rip), %rdi     # 0x38fc8
callq 0x3280
jmp 0x2150a
movq -0x220(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x21b50
movslq (%rax), %rax
movq %rax, -0x470(%rbp)
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
movq -0x220(%rbp), %rsi
callq 0x21b30
movq %rax, %rdi
callq 0x3460
movq %rax, %rcx
movq -0x470(%rbp), %rax
subq %rcx, %rax
movl %eax, -0x224(%rbp)
movl $0x0, -0x228(%rbp)
movl -0x228(%rbp), %eax
cmpl -0x224(%rbp), %eax
jge 0x21593
movq 0x17a56(%rip), %rdi     # 0x38fc8
leaq 0x606c(%rip), %rsi      # 0x275e5
callq 0x32c0
jmp 0x21580
jmp 0x21582
movl -0x228(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x228(%rbp)
jmp 0x2155d
movq 0x17a2e(%rip), %rdi     # 0x38fc8
leaq 0x6125(%rip), %rsi      # 0x276c6
callq 0x32c0
jmp 0x215a8
jmp 0x215aa
movq -0x220(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x220(%rbp)
jmp 0x214b7
movq 0x17a00(%rip), %rdi     # 0x38fc8
movq 0x179d9(%rip), %rsi     # 0x38fa8
callq 0x3310
jmp 0x215d6
movq $0x0, -0x230(%rbp)
movq -0x230(%rbp), %rax
movq %rax, -0x478(%rbp)
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
callq 0x8050
movq %rax, %rcx
movq -0x478(%rbp), %rax
cmpq %rcx, %rax
jae 0x21938
movq 0x179b2(%rip), %rdi     # 0x38fc8
leaq 0x60a9(%rip), %rsi      # 0x276c6
callq 0x32c0
jmp 0x21624
movq $0x0, -0x238(%rbp)
movq -0x238(%rbp), %rax
movq %rax, -0x480(%rbp)
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq -0x230(%rbp), %rsi
callq 0x21b70
movq %rax, %rdi
callq 0x8230
movq %rax, %rcx
movq -0x480(%rbp), %rax
cmpq %rcx, %rax
jae 0x2190a
leaq -0x3b0(%rbp), %rdi
callq 0x33f0
jmp 0x2167a
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq -0x230(%rbp), %rsi
callq 0x21b70
movq %rax, %rdi
movq -0x238(%rbp), %rsi
callq 0x8260
movl 0x28(%rax), %eax
movl %eax, -0x484(%rbp)
testl %eax, %eax
je 0x216cd
jmp 0x216ac
movl -0x484(%rbp), %eax
subl $0x1, %eax
je 0x21724
jmp 0x216b9
movl -0x484(%rbp), %eax
subl $0x2, %eax
je 0x2176a
jmp 0x217b2
leaq -0x3a0(%rbp), %rax
movq %rax, -0x490(%rbp)
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq -0x230(%rbp), %rsi
callq 0x21b70
movq %rax, %rdi
movq -0x238(%rbp), %rsi
callq 0x8260
movq -0x490(%rbp), %rdi
movl (%rax), %esi
callq 0x34e0
jmp 0x2170e
jmp 0x217d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x218f9
leaq -0x3a0(%rbp), %rax
movq %rax, -0x498(%rbp)
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq -0x230(%rbp), %rsi
callq 0x21b70
movq %rax, %rdi
movq -0x238(%rbp), %rsi
callq 0x8260
movq -0x498(%rbp), %rdi
movss 0x4(%rax), %xmm0
callq 0x3220
jmp 0x21768
jmp 0x217d1
leaq -0x3a0(%rbp), %rax
movq %rax, -0x4a0(%rbp)
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq -0x230(%rbp), %rsi
callq 0x21b70
movq %rax, %rdi
movq -0x238(%rbp), %rsi
callq 0x8260
movq -0x4a0(%rbp), %rdi
movq %rax, %rsi
addq $0x8, %rsi
callq 0x3280
jmp 0x217b0
jmp 0x217d1
leaq 0x59aa(%rip), %rdi      # 0x27163
leaq 0x5eb0(%rip), %rsi      # 0x27670
movl $0x195, %edx            # imm = 0x195
leaq 0x5eb3(%rip), %rcx      # 0x2767f
callq 0x31f0
leaq -0x3d0(%rbp), %rdi
movq %rdi, -0x4a8(%rbp)
callq 0x3410
movq -0x4a8(%rbp), %rsi
leaq -0x3b0(%rbp), %rdi
callq 0x33a0
jmp 0x217f9
movq -0x238(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x21b50
movl (%rax), %eax
movl %eax, -0x4ac(%rbp)
leaq -0x3d0(%rbp), %rdi
callq 0x3460
movq %rax, %rcx
movl -0x4ac(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x3d4(%rbp)
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq -0x230(%rbp), %rsi
callq 0x21b70
movq %rax, %rdi
movq -0x238(%rbp), %rsi
callq 0x8260
movq %rax, %rdi
callq 0x247b0
jmp 0x2185b
movl $0x0, -0x3d8(%rbp)
movl -0x3d8(%rbp), %eax
cmpl -0x3d4(%rbp), %eax
jge 0x218b5
movq 0x1774e(%rip), %rdi     # 0x38fc8
leaq 0x5d64(%rip), %rsi      # 0x275e5
callq 0x32c0
jmp 0x21888
jmp 0x2188a
movl -0x3d8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3d8(%rbp)
jmp 0x21865
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x3d0(%rbp), %rdi
callq 0x35b8
jmp 0x218f9
movq 0x1770c(%rip), %rdi     # 0x38fc8
leaq 0x5e03(%rip), %rsi      # 0x276c6
callq 0x32c0
jmp 0x218ca
leaq -0x3d0(%rbp), %rdi
callq 0x35b8
leaq -0x3b0(%rbp), %rdi
callq 0x3550
movq -0x238(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x238(%rbp)
jmp 0x2162f
leaq -0x3b0(%rbp), %rdi
callq 0x3550
jmp 0x2199f
movq 0x176b7(%rip), %rdi     # 0x38fc8
movq 0x17690(%rip), %rsi     # 0x38fa8
callq 0x3310
jmp 0x2191f
jmp 0x21921
movq -0x230(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x230(%rbp)
jmp 0x215e1
movl $0x0, -0x3dc(%rbp)
movl -0x3dc(%rbp), %eax
cmpl -0x200(%rbp), %eax
jge 0x21978
movq 0x17671(%rip), %rdi     # 0x38fc8
leaq 0x5d66(%rip), %rsi      # 0x276c4
callq 0x32c0
jmp 0x21965
jmp 0x21967
movl -0x3dc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3dc(%rbp)
jmp 0x21942
movq 0x17649(%rip), %rdi     # 0x38fc8
movq 0x17622(%rip), %rsi     # 0x38fa8
callq 0x3310
jmp 0x2198d
leaq -0x30(%rbp), %rdi
callq 0x21c90
addq $0x4b0, %rsp            # imm = 0x4B0
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x21c90
movq -0x40(%rbp), %rdi
callq 0x34f0
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)