// File: zimpha[P]MiniSQL/API.cc
// Function: API::createTable(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<AttrType, std::allocator<AttrType>>&, int)
Response API::createTable(const std::string &tableName, std::vector<AttrType> &data, int pk) {
    if (cm.hasTable(tableName + ".table")) {
        return Response("This table already exists");
    }
    
    Table nt = cm.createTable(tableName + ".table", data);
    nt.attributes[pk].unique = true;
    nt.write();

    std::string dbName = tableName + ".db";
    // Record Manager creat database
    // 传入数据库文件名(dbName)
    rm.RecordManagerTableCreate(dbName);

    return createIndex(tableName + ".PrimaryKeyDefault", tableName, nt.attributes[pk].name);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x170(%rbp)
movq %rdi, %rax
movq %rax, -0x168(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x18(%rbp), %rsi
leaq 0x22a0f(%rip), %rdx     # 0x27035
leaq -0x48(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0x76d0
movq -0x160(%rbp), %rdi
movq -0x158(%rbp), %rsi
callq 0x1b550
movb %al, -0x149(%rbp)
jmp 0x4651
leaq -0x48(%rbp), %rdi
callq 0x35b8
movb -0x149(%rbp), %al
testb $0x1, %al
jne 0x4669
jmp 0x4706
leaq -0x79(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x3500
movq -0x178(%rbp), %rdx
leaq 0x22aa1(%rip), %rsi     # 0x27128
leaq -0x78(%rbp), %rdi
callq 0x3400
jmp 0x4692
movq -0x170(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x24ba0
jmp 0x46a4
leaq -0x78(%rbp), %rdi
callq 0x35b8
leaq -0x79(%rbp), %rdi
callq 0x3320
jmp 0x48d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x35b8
jmp 0x48e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x46f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x35b8
leaq -0x79(%rbp), %rdi
callq 0x3320
jmp 0x48e8
movq -0x18(%rbp), %rsi
leaq 0x22924(%rip), %rdx     # 0x27035
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x76d0
movq -0x160(%rbp), %rsi
movq -0x180(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0xc8(%rbp), %rdi
callq 0x1b690
jmp 0x4744
leaq -0xe8(%rbp), %rdi
callq 0x35b8
leaq -0xa0(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x7810
movb $0x1, 0x28(%rax)
leaq -0xc8(%rbp), %rdi
callq 0x240c0
jmp 0x4772
movq -0x18(%rbp), %rsi
leaq 0x22925(%rip), %rdx     # 0x270a2
leaq -0x108(%rbp), %rdi
callq 0x76d0
jmp 0x478b
movq -0x160(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x188(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x3130
jmp 0x47b2
movq -0x188(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x22ab0
jmp 0x47c7
leaq -0x128(%rbp), %rdi
callq 0x35b8
movq -0x18(%rbp), %rsi
leaq 0x22964(%rip), %rdx     # 0x27142
leaq -0x148(%rbp), %rdi
callq 0x76d0
jmp 0x47ec
movq -0x18(%rbp), %rax
movq %rax, -0x190(%rbp)
leaq -0xa0(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x7810
movq -0x170(%rbp), %rdi
movq -0x160(%rbp), %rsi
movq -0x190(%rbp), %rcx
movq %rax, %r8
leaq -0x148(%rbp), %rdx
callq 0x3b70
jmp 0x482d
leaq -0x148(%rbp), %rdi
callq 0x35b8
leaq -0x108(%rbp), %rdi
callq 0x35b8
leaq -0xc8(%rbp), %rdi
callq 0x7920
jmp 0x48d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x35b8
jmp 0x48e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x48ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x48be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x35b8
jmp 0x48be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x35b8
leaq -0x108(%rbp), %rdi
callq 0x35b8
leaq -0xc8(%rbp), %rdi
callq 0x7920
jmp 0x48e8
movq -0x168(%rbp), %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x34f0
nopw %cs:(%rax,%rax)