// File: /workspace/github_cpp_makefile_star2_O1/zimpha[P]MiniSQL/API.cc
// Function: API::createIndex(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
Response API::createIndex(const std::string &indexName, const std::string &tableName, const std::string &attrName) {
    if (!cm.hasTable(tableName + ".table")) {
        return Response("Table does not exist");
    }
    Table nt = cm.loadTable(tableName + ".table");
    int attrIndex = -1;
    for (size_t i = 0; i < nt.attributes.size(); ++ i) {
        if (nt.attributes[i].name == attrName) {
            attrIndex = i;
            break;
        }
    }
    if (attrIndex == -1) {
        return Response("Attribute does not exist");
    }
    if (!nt.attributes[attrIndex].unique) {
        return Response("This attribute must be unique");
    }
    if (!cm.createIndex(tableName, indexName, attrIndex)) {
        return Response("This index already exists");
    }
    nt.attributes[attrIndex].indices.insert(indexName);
    nt.write();
    if (nt.attributes[attrIndex].indices.size() == 1) {
        // Index Manager add index
        // 提供index文件名和当前表，以及attrIndex给Record Manager
        // rmAddIndex(tableName+".db",tableName+"."+nt.attributes[attrIndex].name+".index",nt,attrIndex);
        im.create(tableName+"."+nt.attributes[attrIndex].name, tableName+".db", nt, nt.attributes[attrIndex]);
    }
    return Response();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %r8, -0x98(%rbp)
movq %rcx, %r13
movq %rdx, -0x68(%rbp)
movq %rsi, %r15
movq %rdi, %r12
leaq -0xd0(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rcx), %rsi
movq 0x8(%rcx), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %rbx
movq %rbx, %rdi
callq 0x8766
leaq 0x102cc(%rip), %rsi     # 0x14051
movq %rbx, %rdi
callq 0x34f0
leaq -0xe0(%rbp), %rsi
movq %r15, %rdi
callq 0xdd18
movl %eax, %ebx
movq -0xe0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3daf
callq 0x3270
testb %bl, %bl
je 0x3f8e
leaq -0x38(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x8766
leaq 0x10274(%rip), %rsi     # 0x14051
movq %rbx, %rdi
callq 0x34f0
leaq -0xe0(%rbp), %rdi
leaq -0x48(%rbp), %rdx
movq %r15, %rsi
callq 0xde70
movq %r13, -0x58(%rbp)
movq %r15, -0x50(%rbp)
movq %r12, -0x90(%rbp)
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x3e15
callq 0x3270
movq -0xb8(%rbp), %rcx
movq -0xb0(%rbp), %rax
movq %rcx, -0x60(%rbp)
subq %rcx, %rax
je 0x3e89
sarq $0x5, %rax
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r14
movq -0x98(%rbp), %r12
movq (%r12), %r13
movq 0x8(%r12), %r12
cmpq $0x1, %r14
adcq $0x0, %r14
movq -0x60(%rbp), %rax
leaq 0x8(%rax), %r15
xorl %ebx, %ebx
movq (%r15), %rdx
cmpq %r12, %rdx
jne 0x3e7d
testq %rdx, %rdx
je 0x3e8e
movq -0x8(%r15), %rdi
movq %r13, %rsi
callq 0x32b0
testl %eax, %eax
je 0x3e8e
incq %rbx
addq $0x60, %r15
cmpq %rbx, %r14
jne 0x3e60
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq -0xb8(%rbp), %r15
cmpl $-0x1, %ebx
movq -0x90(%rbp), %r12
movq -0x58(%rbp), %r13
je 0x3fe7
movslq %ebx, %rax
leaq (%rax,%rax,2), %r14
shlq $0x5, %r14
movq -0x60(%rbp), %rax
cmpb $0x0, 0x28(%rax,%r14)
je 0x4024
movq -0x50(%rbp), %rdi
movq %r13, %rsi
movq -0x68(%rbp), %rdx
movl %ebx, %ecx
callq 0xe4c8
testb %al, %al
je 0x4061
movq -0xb8(%rbp), %rax
leaq (%rax,%r14), %rdi
addq $0x30, %rdi
movq -0x68(%rbp), %rsi
callq 0x88ea
leaq -0xe0(%rbp), %rdi
callq 0x12cc6
movq -0xb8(%rbp), %rax
cmpq $0x1, 0x58(%rax,%r14)
jne 0x418d
leaq -0x78(%rbp), %rax
movq %rax, -0x10(%rax)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0x8766
leaq 0x10395(%rip), %rsi     # 0x142d0
leaq -0x88(%rbp), %rdi
callq 0x34f0
movq -0xb8(%rbp), %rax
movq (%rax,%r14), %rsi
movq 0x8(%rax,%r14), %rdx
leaq -0x88(%rbp), %rdi
callq 0x30c0
leaq -0x38(%rbp), %rsi
movq %rsi, -0x48(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x40af
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x40b5
leaq -0x170(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x100b8(%rip), %rsi     # 0x14058
leaq 0x100c5(%rip), %rdx     # 0x1406c
leaq -0x180(%rbp), %rbx
movq %rbx, %rdi
callq 0x8800
movq %r12, %rdi
movq %rbx, %rsi
callq 0x134ae
movq -0x180(%rbp), %rdi
cmpq %r14, %rdi
je 0x3fd2
callq 0x3270
movq %r12, %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x150(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x10074(%rip), %rsi     # 0x1406d
leaq 0x10085(%rip), %rdx     # 0x14085
leaq -0x160(%rbp), %rdi
callq 0x8800
leaq -0x160(%rbp), %rsi
movq %r12, %rdi
callq 0x134ae
movq -0x160(%rbp), %rdi
jmp 0x409c
leaq -0x130(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x10050(%rip), %rsi     # 0x14086
leaq 0x10066(%rip), %rdx     # 0x140a3
leaq -0x140(%rbp), %rdi
callq 0x8800
leaq -0x140(%rbp), %rsi
movq %r12, %rdi
callq 0x134ae
movq -0x140(%rbp), %rdi
jmp 0x409c
leaq -0x110(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x10031(%rip), %rsi     # 0x140a4
leaq 0x10043(%rip), %rdx     # 0x140bd
leaq -0x120(%rbp), %rdi
callq 0x8800
leaq -0x120(%rbp), %rsi
movq %r12, %rdi
callq 0x134ae
movq -0x120(%rbp), %rdi
cmpq %r14, %rdi
je 0x4195
callq 0x3270
jmp 0x4195
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0xf0(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x58(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x100(%rbp), %rdi
callq 0x8766
leaq 0xffc6(%rip), %rsi      # 0x140be
leaq -0x100(%rbp), %rdi
callq 0x34f0
movq -0x50(%rbp), %rsi
addq $0x40, %rsi
leaq -0xe0(%rbp), %r8
addq 0x28(%r8), %r14
leaq -0x1c0(%rbp), %rdi
leaq -0x48(%rbp), %rdx
leaq -0x100(%rbp), %rcx
movq %r14, %r9
callq 0xbad0
leaq -0x198(%rbp), %rbx
movq %rbx, %rdi
callq 0x7926
movq -0x20(%rbx), %rdi
leaq -0x1a8(%rbp), %rax
cmpq %rax, %rdi
leaq -0x38(%rbp), %rbx
je 0x4159
callq 0x3270
movq -0x100(%rbp), %rdi
cmpq %r13, %rdi
je 0x416a
callq 0x3270
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x4178
callq 0x3270
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x418d
callq 0x3270
movq %r12, %rdi
callq 0x13488
movq %r15, %rdi
callq 0x8304
leaq -0xc8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x3fcd
jmp 0x3fd2
jmp 0x41b8
movq %rax, %rbx
movq -0x100(%rbp), %rdi
cmpq %r13, %rdi
je 0x41d1
callq 0x3270
jmp 0x41d1
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x41ea
callq 0x3270
jmp 0x41ea
jmp 0x41e7
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
jne 0x4229
jmp 0x4235
jmp 0x4232
movq %rax, %rbx
movq -0x120(%rbp), %rdi
jmp 0x4224
jmp 0x4232
movq %rax, %rbx
movq -0x140(%rbp), %rdi
jmp 0x4224
jmp 0x4232
movq %rax, %rbx
movq -0x160(%rbp), %rdi
cmpq %r14, %rdi
je 0x4235
callq 0x3270
jmp 0x4235
jmp 0x4232
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
callq 0x78f8
jmp 0x4270
jmp 0x4251
movq %rax, %rbx
movq -0x180(%rbp), %rdi
jmp 0x4266
movq %rax, %rbx
movq -0x48(%rbp), %rdi
jmp 0x4266
jmp 0x425c
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
cmpq %r14, %rdi
je 0x4270
callq 0x3270
movq %rbx, %rdi
callq 0x3480