// File: /workspace/github_cpp_makefile_star2_O2/zimpha[P]MiniSQL/API.cc
// Function: API::Insert(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<element, std::allocator<element>>)
Response API::Insert(const std::string &tableName, const std::vector<element> entry) {
    if (!cm.hasTable(tableName + ".table")) {
        return Response("Table does not exist");
    }
    Table nt = cm.loadTable(tableName + ".table");
    std::string dbName = tableName + ".db";
    if (nt.attributes.size() != entry.size()) {
        return Response("Type mismatch");
    }
    
    for (size_t i = 0; i < nt.attributes.size(); ++ i) {
        if (nt.attributes[i].unique) {
            Filter filter;
            filter.addRule(Rule(i, 2, entry[i]));
            Response tmp = Select(tableName, filter);
            if (!tmp.result.empty()) {
                return Response("unique integrity violation");
            }
        }
    }
    // Record Manager insert record
    // 传入数据库文件名(dbName)，插入数据(entry)，当前表格(nt)
    rm.RecordManagerRecordInsert(dbName, entry, nt);
    // NOTE: table information may be changed after that
    return Response();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rcx, -0x40(%rbp)
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
leaq 0xb675(%rip), %rdx      # 0x11051
leaq -0xd8(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5d7d
movq %r15, -0x38(%rbp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0xb838
movl %eax, %ebx
leaq -0xd8(%rbp), %rdi
callq 0x34f8
testb %bl, %bl
je 0x5b77
leaq 0xb637(%rip), %rdx      # 0x11051
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5d7d
leaq -0xd8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %rbx, %rdx
callq 0xb966
leaq -0x90(%rbp), %rdi
callq 0x34f8
leaq 0xb66c(%rip), %rdx      # 0x110be
leaq -0x170(%rbp), %rdi
movq %r12, %rsi
callq 0x5d7d
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdi
movq %rdi, %rax
subq %rsi, %rax
pushq $0x60
popq %rcx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x40(%rbp), %rdx
movq 0x8(%rdx), %rax
subq (%rdx), %rax
pushq $0x30
popq %r8
cqto
idivq %r8
cmpq %rax, %rcx
jne 0x5bb1
movq %r12, -0x50(%rbp)
movq %r14, -0x48(%rbp)
xorl %r15d, %r15d
leaq -0x130(%rbp), %r13
leaq -0x90(%rbp), %r14
xorl %ebx, %ebx
movq %rdi, %rax
subq %rsi, %rax
cqto
pushq $0x60
popq %rcx
idivq %rcx
cmpq %rax, %rbx
jae 0x5beb
cmpb $0x1, 0x28(%rsi,%r15,2)
jne 0x5b6b
movq %r13, %rdi
callq 0xc5d8
movq -0x40(%rbp), %rax
movq (%rax), %rsi
addq %r15, %rsi
leaq -0x1c0(%rbp), %r12
movq %r12, %rdi
callq 0x5e98
movq %r14, %rdi
movl %ebx, %esi
pushq $0x2
popq %rdx
movq %r12, %rcx
callq 0xc5c2
movq %r13, %rdi
movq %r14, %rsi
callq 0xc5ea
leaq -0x80(%rbp), %rdi
callq 0x34f8
leaq -0x1b8(%rbp), %rdi
callq 0x34f8
movq %r14, %rdi
movq -0x38(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %r13, %rcx
callq 0x427a
movq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rax
jne 0x5c37
movq %r14, %rdi
callq 0x5e02
movq %r13, %rdi
callq 0x6d28
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdi
incq %rbx
addq $0x30, %r15
jmp 0x5ab8
leaq 0xb4da(%rip), %rsi      # 0x11058
leaq -0x190(%rbp), %rdi
leaq -0xd8(%rbp), %rdx
callq 0x30e0
leaq -0x190(%rbp), %rsi
movq %r14, %rdi
callq 0xfde4
leaq -0x190(%rbp), %rdi
callq 0x34f8
jmp 0x5c9d
leaq 0xb5b9(%rip), %rsi      # 0x11171
leaq -0x150(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x30e0
leaq -0x150(%rbp), %rsi
movq %r14, %rdi
callq 0xfde4
leaq -0x150(%rbp), %rdi
callq 0x34f8
jmp 0x5c85
leaq -0xf8(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x3380
movq -0x48(%rbp), %r14
movq -0x38(%rbp), %rdi
addq $0x30, %rdi
leaq -0xf8(%rbp), %rsi
leaq -0xd8(%rbp), %rcx
movq -0x40(%rbp), %rdx
callq 0xebca
leaq -0xf8(%rbp), %rdi
callq 0x34f8
movq %r14, %rdi
callq 0xfdbe
jmp 0x5c85
leaq 0xb5bb(%rip), %rsi      # 0x111f9
leaq -0x118(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x30e0
leaq -0x118(%rbp), %rsi
movq -0x48(%rbp), %r14
movq %r14, %rdi
callq 0xfde4
leaq -0x118(%rbp), %rdi
callq 0x34f8
leaq -0x90(%rbp), %rdi
callq 0x5e02
leaq -0x130(%rbp), %rdi
callq 0x6d28
leaq -0x170(%rbp), %rdi
callq 0x34f8
leaq -0xd8(%rbp), %rdi
callq 0x5e26
movq %r14, %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq -0x118(%rbp), %rdi
callq 0x34f8
jmp 0x5cc6
movq %rax, %r14
leaq -0x90(%rbp), %rdi
callq 0x5e02
jmp 0x5d51
movq %rax, %r14
leaq -0xf8(%rbp), %rdi
jmp 0x5cea
movq %rax, %r14
leaq -0x150(%rbp), %rdi
callq 0x34f8
jmp 0x5d5d
jmp 0x5d28
jmp 0x5d28
movq %rax, %r14
leaq -0x190(%rbp), %rdi
jmp 0x5d21
movq %rax, %r14
jmp 0x5d69
movq %rax, %r14
jmp 0x5d75
movq %rax, %r14
leaq -0x90(%rbp), %rdi
jmp 0x5d21
movq %rax, %r14
leaq -0xd8(%rbp), %rdi
callq 0x34f8
jmp 0x5d75
movq %rax, %r14
jmp 0x5d5d
jmp 0x5d4e
movq %rax, %r14
jmp 0x5d40
movq %rax, %r14
leaq -0x80(%rbp), %rdi
callq 0x34f8
leaq -0x1b8(%rbp), %rdi
callq 0x34f8
jmp 0x5d51
movq %rax, %r14
leaq -0x130(%rbp), %rdi
callq 0x6d28
leaq -0x170(%rbp), %rdi
callq 0x34f8
leaq -0xd8(%rbp), %rdi
callq 0x5e26
movq %r14, %rdi
callq 0x3450