// File: /workspace/github_cpp_makefile_star2_O1/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, -0x30(%rbp)
movq %rsi, %r15
movq %rdi, %r13
leaq -0xe0(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rdx), %rsi
movq %rdx, -0x38(%rbp)
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq -0xf0(%rbp), %rbx
movq %rbx, %rdi
callq 0x8766
leaq 0xccaa(%rip), %rsi      # 0x14051
movq %rbx, %rdi
callq 0x34f0
leaq -0xf0(%rbp), %rsi
movq %r15, %rdi
callq 0xdd18
movl %eax, %ebx
movq -0xf0(%rbp), %rdi
cmpq %r14, %rdi
je 0x73d1
callq 0x3270
testb %bl, %bl
je 0x765a
leaq -0x98(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0xa8(%rbp), %rbx
movq %rbx, %rdi
callq 0x8766
leaq 0xcc49(%rip), %rsi      # 0x14051
movq %rbx, %rdi
callq 0x34f0
leaq -0xf0(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
movq %r15, %rsi
callq 0xde70
movq %r15, -0x48(%rbp)
movq -0xa8(%rbp), %rdi
cmpq %r14, %rdi
je 0x743b
callq 0x3270
leaq -0x58(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %rdi
callq 0x8766
leaq 0xcc5d(%rip), %rsi      # 0x140be
leaq -0x68(%rbp), %rdi
callq 0x34f0
movq -0xc0(%rbp), %rax
subq -0xc8(%rbp), %rax
sarq $0x5, %rax
movabsq $-0x5555555555555555, %r12 # imm = 0xAAAAAAAAAAAAAAAB
movq -0x30(%rbp), %rdx
movq 0x8(%rdx), %rcx
subq (%rdx), %rcx
imulq %r12, %rax
sarq $0x4, %rcx
imulq %r12, %rcx
cmpq %rcx, %rax
jne 0x76b3
movq %r13, -0x40(%rbp)
movq -0xc8(%rbp), %rax
cmpq %rax, -0xc0(%rbp)
je 0x75f3
xorl %r15d, %r15d
leaq -0x198(%rbp), %r13
xorl %r14d, %r14d
cmpb $0x1, 0x28(%rax,%r15,2)
jne 0x75ca
movq %r13, %rdi
callq 0xed7c
movq -0x30(%rbp), %rax
movq (%rax), %rbx
movq (%rbx,%r15), %rax
movq %rax, -0x120(%rbp)
leaq -0x108(%rbp), %rax
movq %rax, -0x118(%rbp)
movq 0x8(%rbx,%r15), %rsi
movq 0x10(%rbx,%r15), %rdx
addq %rsi, %rdx
leaq -0x118(%rbp), %rdi
callq 0x8766
movl 0x28(%rbx,%r15), %eax
movl %eax, -0xf8(%rbp)
leaq -0xa8(%rbp), %rbx
movq %rbx, %rdi
movl %r14d, %esi
movl $0x2, %edx
leaq -0x120(%rbp), %rcx
callq 0xed3a
movq %r13, %rdi
movq %rbx, %rsi
callq 0xed90
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x7564
callq 0x3270
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0x757c
callq 0x3270
leaq -0xa8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq %r13, %rcx
callq 0x4af0
movq -0x80(%rbp), %rax
cmpq -0x78(%rbp), %rax
jne 0x76fe
leaq -0x80(%rbp), %rdi
callq 0x7926
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x75c2
callq 0x3270
movq %r13, %rdi
callq 0x870c
incq %r14
movq -0xc8(%rbp), %rax
movq -0xc0(%rbp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
imulq %r12, %rcx
addq $0x30, %r15
cmpq %rcx, %r14
jb 0x74cb
leaq -0x130(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
leaq -0x140(%rbp), %rdi
leaq -0x58(%rbp), %r15
callq 0x8766
movq -0x40(%rbp), %r13
movq -0x48(%rbp), %rdi
addq $0x30, %rdi
leaq -0x140(%rbp), %rsi
leaq -0xf0(%rbp), %rcx
movq -0x30(%rbp), %rdx
callq 0x11c3e
movq -0x140(%rbp), %rdi
cmpq %r14, %rdi
je 0x764d
callq 0x3270
movq %r13, %rdi
callq 0x13488
jmp 0x7778
leaq -0x1a8(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0xc9ec(%rip), %rsi      # 0x14058
leaq 0xc9f9(%rip), %rdx      # 0x1406c
leaq -0x1b8(%rbp), %rbx
movq %rbx, %rdi
callq 0x8800
movq %r13, %rdi
movq %rbx, %rsi
callq 0x134ae
movq -0x1b8(%rbp), %rdi
cmpq %r14, %rdi
je 0x769e
callq 0x3270
movq %r13, %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x170(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0xcaac(%rip), %rsi      # 0x14171
leaq 0xcab2(%rip), %rdx      # 0x1417e
leaq -0x180(%rbp), %rdi
callq 0x8800
leaq -0x180(%rbp), %rsi
movq %r13, %rdi
callq 0x134ae
movq -0x180(%rbp), %rdi
cmpq %r14, %rdi
je 0x7778
callq 0x3270
jmp 0x7778
leaq -0x150(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0xcae9(%rip), %rsi      # 0x141f9
leaq 0xcafc(%rip), %rdx      # 0x14213
leaq -0x160(%rbp), %rdi
callq 0x8800
leaq -0x160(%rbp), %rsi
movq -0x40(%rbp), %r13
movq %r13, %rdi
leaq -0x58(%rbp), %r15
callq 0x134ae
movq -0x160(%rbp), %rdi
cmpq %r14, %rdi
je 0x774b
callq 0x3270
leaq -0x80(%rbp), %rdi
callq 0x7926
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x776c
callq 0x3270
leaq -0x198(%rbp), %rdi
callq 0x870c
leaq -0xc8(%rbp), %rbx
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0x778d
callq 0x3270
movq %rbx, %rdi
callq 0x8304
leaq -0xd8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x7699
jmp 0x769e
movq %rax, %rbx
movq -0x160(%rbp), %rdi
cmpq %r14, %rdi
je 0x77c7
callq 0x3270
jmp 0x77c7
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x78ca
jmp 0x7898
movq %rax, %rbx
movq -0x140(%rbp), %rdi
jmp 0x77ee
movq %rax, %rbx
movq -0x180(%rbp), %rdi
cmpq %r14, %rdi
je 0x78a4
callq 0x3270
jmp 0x78a4
jmp 0x7856
jmp 0x7856
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
jne 0x78b1
jmp 0x78b6
movq %rax, %rbx
jmp 0x78b6
jmp 0x7830
movq %rax, %rbx
movq -0x1b8(%rbp), %rdi
jmp 0x7848
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
jmp 0x7848
jmp 0x783e
movq %rax, %rbx
movq -0xf0(%rbp), %rdi
cmpq %r14, %rdi
je 0x78c2
callq 0x3270
jmp 0x78c2
jmp 0x785b
movq %rax, %rbx
jmp 0x78a4
movq %rax, %rbx
jmp 0x7898
movq %rax, %rbx
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x7880
callq 0x3270
jmp 0x7880
movq %rax, %rbx
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0x7898
callq 0x3270
leaq -0x198(%rbp), %rdi
callq 0x870c
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x78b6
callq 0x3270
leaq -0xf0(%rbp), %rdi
callq 0x78f8
movq %rbx, %rdi
callq 0x3480