// File: /workspace/github_cpp_makefile_star2_O3/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, %r13
movq %rdx, -0x90(%rbp)
movq %rsi, %r12
movq %rdi, %r15
leaq -0xd0(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rcx), %rsi
movq %rcx, -0x30(%rbp)
movq 0x8(%rcx), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %rbx
movq %rbx, %rdi
callq 0x88b4
leaq 0x102cc(%rip), %rsi     # 0x14051
movq %rbx, %rdi
callq 0x34f0
leaq -0xe0(%rbp), %rsi
movq %r12, %rdi
callq 0xde1c
movl %eax, %ebx
movq -0xe0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3daf
callq 0x3270
testb %bl, %bl
je 0x3eb8
leaq -0x48(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x58(%rbp), %rbx
movq %rbx, %rdi
callq 0x88b4
leaq 0x10271(%rip), %rsi     # 0x14051
movq %rbx, %rdi
callq 0x34f0
leaq -0xe0(%rbp), %rdi
leaq -0x58(%rbp), %rdx
movq %r12, %rsi
callq 0xdf7e
movq %r12, -0x60(%rbp)
movq %r15, -0x38(%rbp)
movq -0x58(%rbp), %rdi
cmpq %r14, %rdi
je 0x3e11
callq 0x3270
movq -0xb8(%rbp), %rcx
movq -0xb0(%rbp), %rax
movq %rcx, -0x68(%rbp)
subq %rcx, %rax
je 0x3f17
sarq $0x5, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
movq (%r13), %rax
movq %rax, -0x98(%rbp)
xorl %r12d, %r12d
cmpq $0x1, %rcx
movl $0x0, %r8d
sbbq %rcx, %r8
movq 0x8(%r13), %r14
movq -0x68(%rbp), %rax
leaq 0x8(%rax), %rbx
movabsq $0x100000000, %rax      # imm = 0x100000000
xorl %r15d, %r15d
cmpq %r14, (%rbx)
jne 0x3ea7
testq %r14, %r14
je 0x3f11
movq -0x8(%rbx), %rdi
movq -0x98(%rbp), %rsi
movq %r8, %r13
movq %r14, %rdx
callq 0x32b0
movq %r13, %r8
testl %eax, %eax
movabsq $0x100000000, %rax      # imm = 0x100000000
je 0x3f11
addq %rax, %r15
decq %r12
addq $0x60, %rbx
cmpq %r12, %r8
jne 0x3e72
jmp 0x3f17
leaq -0x170(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x1018e(%rip), %rsi     # 0x14058
leaq 0x1019b(%rip), %rdx     # 0x1406c
leaq -0x180(%rbp), %rbx
movq %rbx, %rdi
callq 0x8952
movq %r15, %rdi
movq %rbx, %rsi
callq 0x135e0
movq -0x180(%rbp), %rdi
cmpq %r14, %rdi
je 0x3efc
callq 0x3270
movq %r15, %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1, %r12d
jne 0x3f88
leaq -0x150(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x10144(%rip), %rsi     # 0x1406d
leaq 0x10155(%rip), %rdx     # 0x14085
leaq -0x160(%rbp), %rdi
callq 0x8952
leaq -0x160(%rbp), %rsi
movq -0x38(%rbp), %r15
movq %r15, %rdi
callq 0x135e0
movq -0x160(%rbp), %rdi
cmpq %r14, %rdi
je 0x3f60
callq 0x3270
leaq -0xb8(%rbp), %rbx
movq %rbx, %rdi
callq 0x844c
movq -0x20(%rbx), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
jne 0x3ef7
jmp 0x3efc
sarq $0x20, %r15
leaq (%r15,%r15,2), %r13
shlq $0x5, %r13
movq -0x68(%rbp), %rax
cmpb $0x0, 0x28(%rax,%r13)
je 0x4080
negq %r12
movq -0x60(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x90(%rbp), %rbx
movq %rbx, %rdx
movl %r12d, %ecx
callq 0xe5dc
movq -0x38(%rbp), %r15
testb %al, %al
je 0x40c4
movq -0xb8(%rbp), %rax
leaq (%rax,%r13), %rdi
addq $0x30, %rdi
movq %rbx, %rsi
callq 0x8a4a
leaq -0xe0(%rbp), %rdi
callq 0x12df6
movq -0xb8(%rbp), %rax
cmpq $0x1, 0x58(%rax,%r13)
jne 0x41e0
leaq -0x78(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0x88b4
leaq 0x102a3(%rip), %rsi     # 0x142d0
leaq -0x88(%rbp), %rdi
callq 0x34f0
leaq -0x48(%rbp), %r14
movq -0xb8(%rbp), %rax
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
leaq -0x88(%rbp), %rdi
callq 0x30c0
movq %r14, -0x58(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4104
movq %rdx, -0x58(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x48(%rbp)
jmp 0x410b
leaq -0x130(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0xfff4(%rip), %rsi      # 0x14086
leaq 0x1000a(%rip), %rdx     # 0x140a3
leaq -0x140(%rbp), %rdi
callq 0x8952
movq -0x38(%rbp), %r15
leaq -0x140(%rbp), %rsi
movq %r15, %rdi
callq 0x135e0
movq -0x140(%rbp), %rdi
jmp 0x3f56
leaq -0x110(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0xffce(%rip), %rsi      # 0x140a4
leaq 0xffe0(%rip), %rdx      # 0x140bd
leaq -0x120(%rbp), %rdi
callq 0x8952
leaq -0x120(%rbp), %rsi
movq %r15, %rdi
callq 0x135e0
movq -0x120(%rbp), %rdi
jmp 0x3f56
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, -0x50(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0xf0(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x100(%rbp), %rdi
callq 0x88b4
leaq 0xff6f(%rip), %rsi      # 0x140be
leaq -0x100(%rbp), %rdi
callq 0x34f0
movq -0x60(%rbp), %rsi
addq $0x40, %rsi
leaq -0xe0(%rbp), %r8
addq 0x28(%r8), %r13
leaq -0x1c0(%rbp), %rdi
leaq -0x58(%rbp), %rdx
leaq -0x100(%rbp), %rcx
movq %r13, %r9
callq 0xbc26
leaq -0x198(%rbp), %rbx
movq %rbx, %rdi
callq 0x7a6a
movq -0x20(%rbx), %rdi
leaq -0x1a8(%rbp), %rax
cmpq %rax, %rdi
je 0x41ac
callq 0x3270
movq -0x100(%rbp), %rdi
cmpq %r12, %rdi
je 0x41bd
callq 0x3270
movq -0x58(%rbp), %rdi
cmpq %r14, %rdi
leaq -0x78(%rbp), %rbx
je 0x41cf
callq 0x3270
movq -0x88(%rbp), %rdi
cmpq %rbx, %rdi
je 0x41e0
callq 0x3270
movq %r15, %rdi
callq 0x135ba
jmp 0x3f60
jmp 0x41ef
movq %rax, %rbx
movq -0x100(%rbp), %rdi
cmpq %r12, %rdi
je 0x4208
callq 0x3270
jmp 0x4208
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x421f
callq 0x3270
jmp 0x421f
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
jne 0x4271
jmp 0x427b
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r12, %rdi
jne 0x4271
jmp 0x427b
jmp 0x4278
movq %rax, %rbx
movq -0x120(%rbp), %rdi
jmp 0x426c
jmp 0x4278
movq %rax, %rbx
movq -0x140(%rbp), %rdi
jmp 0x426c
jmp 0x4278
jmp 0x4278
movq %rax, %rbx
movq -0x160(%rbp), %rdi
cmpq %r14, %rdi
je 0x427b
callq 0x3270
jmp 0x427b
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
callq 0x7a3c
jmp 0x42b6
jmp 0x4297
movq %rax, %rbx
movq -0x180(%rbp), %rdi
jmp 0x42ac
movq %rax, %rbx
movq -0x58(%rbp), %rdi
jmp 0x42ac
jmp 0x42a2
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
cmpq %r14, %rdi
je 0x42b6
callq 0x3270
movq %rbx, %rdi
callq 0x3480