// File: /workspace/github_cpp_makefile_star2_O3/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 $0x188, %rsp            # imm = 0x188
movq %rcx, -0x30(%rbp)
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r13
leaq -0x120(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq -0x130(%rbp), %rbx
movq %rbx, %rdi
callq 0x88b4
leaq 0xcb69(%rip), %rsi      # 0x14051
movq %rbx, %rdi
callq 0x34f0
leaq -0x130(%rbp), %rsi
movq %r15, %rdi
callq 0xde1c
movl %eax, %ebx
movq -0x130(%rbp), %rdi
cmpq %r14, %rdi
je 0x7512
callq 0x3270
testb %bl, %bl
je 0x77a0
leaq -0x90(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %rbx
movq %rbx, %rdi
callq 0x88b4
leaq 0xcb0a(%rip), %rsi      # 0x14051
movq %rbx, %rdi
callq 0x34f0
leaq -0x130(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
movq %r15, %rsi
callq 0xdf7e
movq %r15, -0x40(%rbp)
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x757a
callq 0x3270
leaq -0x50(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq -0x60(%rbp), %rdi
callq 0x88b4
leaq 0xcb20(%rip), %rsi      # 0x140be
leaq -0x60(%rbp), %rdi
callq 0x34f0
movq -0x108(%rbp), %rax
movq -0x100(%rbp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x5, %rdx
movabsq $-0x5555555555555555, %rbx # imm = 0xAAAAAAAAAAAAAAAB
movq -0x30(%rbp), %rdi
movq 0x8(%rdi), %rsi
subq (%rdi), %rsi
imulq %rbx, %rdx
sarq $0x4, %rsi
imulq %rbx, %rsi
cmpq %rsi, %rdx
jne 0x77f9
movq %r13, -0x38(%rbp)
cmpq %rax, %rcx
je 0x7739
xorl %r15d, %r15d
xorl %r14d, %r14d
cmpb $0x1, 0x28(%rax,%r15,2)
jne 0x771b
movq %rbx, %r13
leaq -0xb8(%rbp), %rdi
callq 0xee88
movq -0x30(%rbp), %rax
movq (%rax), %rbx
movq (%rbx,%r15), %rax
movq %rax, -0xe8(%rbp)
leaq -0xd0(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq 0x8(%rbx,%r15), %rsi
movq 0x10(%rbx,%r15), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %rdi
callq 0x88b4
movl 0x28(%rbx,%r15), %eax
movl %eax, -0xc0(%rbp)
leaq -0xa0(%rbp), %rbx
movq %rbx, %rdi
movl %r14d, %esi
movl $0x2, %edx
leaq -0xe8(%rbp), %rcx
callq 0xee46
leaq -0xb8(%rbp), %rdi
movq %rbx, %rsi
callq 0xee9c
movq %r13, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x76a0
callq 0x3270
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x76b8
callq 0x3270
leaq -0xa0(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq %r12, %rdx
leaq -0xb8(%rbp), %rcx
callq 0x4b36
movq -0x78(%rbp), %rax
cmpq -0x70(%rbp), %rax
jne 0x7844
leaq -0x78(%rbp), %rdi
callq 0x7a6a
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x7701
callq 0x3270
leaq -0xb8(%rbp), %rdi
callq 0x8854
movq -0x108(%rbp), %rax
movq -0x100(%rbp), %rcx
incq %r14
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x5, %rdx
imulq %rbx, %rdx
addq $0x30, %r15
cmpq %rdx, %r14
jb 0x75fc
leaq -0x140(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
addq %rsi, %rdx
leaq -0x150(%rbp), %rdi
leaq -0x50(%rbp), %r15
callq 0x88b4
movq -0x38(%rbp), %r13
movq -0x40(%rbp), %rdi
addq $0x30, %rdi
leaq -0x150(%rbp), %rsi
leaq -0x130(%rbp), %rcx
movq -0x30(%rbp), %rdx
callq 0x11d96
movq -0x150(%rbp), %rdi
cmpq %r14, %rdi
je 0x7793
callq 0x3270
movq %r13, %rdi
callq 0x135ba
jmp 0x78be
leaq -0x1a0(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0xc8a6(%rip), %rsi      # 0x14058
leaq 0xc8b3(%rip), %rdx      # 0x1406c
leaq -0x1b0(%rbp), %rbx
movq %rbx, %rdi
callq 0x8952
movq %r13, %rdi
movq %rbx, %rsi
callq 0x135e0
movq -0x1b0(%rbp), %rdi
cmpq %r14, %rdi
je 0x77e4
callq 0x3270
movq %r13, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x180(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0xc966(%rip), %rsi      # 0x14171
leaq 0xc96c(%rip), %rdx      # 0x1417e
leaq -0x190(%rbp), %rdi
callq 0x8952
leaq -0x190(%rbp), %rsi
movq %r13, %rdi
callq 0x135e0
movq -0x190(%rbp), %rdi
cmpq %r14, %rdi
je 0x78be
callq 0x3270
jmp 0x78be
leaq -0x160(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0xc9a3(%rip), %rsi      # 0x141f9
leaq 0xc9b6(%rip), %rdx      # 0x14213
leaq -0x170(%rbp), %rdi
callq 0x8952
leaq -0x170(%rbp), %rsi
movq -0x38(%rbp), %r13
movq %r13, %rdi
leaq -0x50(%rbp), %r15
callq 0x135e0
movq -0x170(%rbp), %rdi
cmpq %r14, %rdi
je 0x7891
callq 0x3270
leaq -0x78(%rbp), %rdi
callq 0x7a6a
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x78b2
callq 0x3270
leaq -0xb8(%rbp), %rdi
callq 0x8854
leaq -0x108(%rbp), %rbx
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
je 0x78d3
callq 0x3270
movq %rbx, %rdi
callq 0x844c
leaq -0x118(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x77df
jmp 0x77e4
movq %rax, %rbx
movq -0x170(%rbp), %rdi
cmpq %r14, %rdi
je 0x790d
callq 0x3270
jmp 0x790d
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x7a0e
jmp 0x79db
movq %rax, %rbx
movq -0x150(%rbp), %rdi
jmp 0x7934
movq %rax, %rbx
movq -0x190(%rbp), %rdi
cmpq %r14, %rdi
je 0x79e7
callq 0x3270
jmp 0x79e7
jmp 0x799c
jmp 0x799c
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r15, %rdi
jne 0x79f4
jmp 0x79f9
movq %rax, %rbx
jmp 0x79f9
jmp 0x7976
movq %rax, %rbx
movq -0x1b0(%rbp), %rdi
jmp 0x798e
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
jmp 0x798e
jmp 0x7984
movq %rax, %rbx
movq -0x130(%rbp), %rdi
cmpq %r14, %rdi
je 0x7a05
callq 0x3270
jmp 0x7a05
jmp 0x79a1
movq %rax, %rbx
jmp 0x79e7
movq %rax, %rbx
jmp 0x79db
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x79c3
callq 0x3270
jmp 0x79c3
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x79db
callq 0x3270
leaq -0xb8(%rbp), %rdi
callq 0x8854
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x79f9
callq 0x3270
leaq -0x130(%rbp), %rdi
callq 0x7a3c
movq %rbx, %rdi
callq 0x3480
nop