// File: /workspace/github_cpp_makefile_star2_O2/ChaohuiYu[P]BPlusTree/commands.cpp
// Function: createRelation(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&, int)
void createRelation(const string& relationName, const string& keyType, int recordLength) {
    cout << "Try to create relation \"" << relationName << "\":\n";

    // check if relationName exists
    if (isRelationExist(relationName)) {
        cout << "    Error: Relation " << relationName << " already exists.\n";
        return;
    }

    // check if keyType is integer or string
    if (!(keyType == "integer" || keyType == "Integer" || keyType == "int"
    || keyType == "string" || keyType == "String" || keyType == "str")) {
        cout << "    Error: Key type \"" << keyType << "\" is invalid.\n";
        return;
    }

    // check if recordLength <= 500
    if (recordLength > 500) {
        cout << "    Error: Record length > 500\n";
        return;
    }

    if (keyType == "integer" || keyType == "Integer" || keyType == "int") {
        auto relationPtr = new Relation<int>(relationName, "integer", recordLength);
        relationNameToRelationInt[relationName] = relationPtr;
    }
    else if (keyType == "string" || keyType == "String" || keyType == "str") {
        auto relationPtr = new Relation<string>(relationName, "string", recordLength);
        relationNameToRelationStr[relationName] = relationPtr;
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x30, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movq 0xa635(%rip), %rdi      # 0xdfc8
leaq 0x5934(%rip), %rsi      # 0x92ce
callq 0x21e0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21d0
leaq 0x5936(%rip), %rsi      # 0x92e7
movq %rax, %rdi
callq 0x21e0
movq %rbx, %rdi
callq 0x3bff
testb %al, %al
je 0x39f2
movq 0xa5fc(%rip), %rdi      # 0xdfc8
leaq 0x5918(%rip), %rsi      # 0x92eb
callq 0x21e0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21d0
leaq 0x5916(%rip), %rsi      # 0x9300
movq %rax, %rdi
jmp 0x3a7e
leaq 0x5919(%rip), %rsi      # 0x9312
movq %r14, %rdi
callq 0x35fd
testb %al, %al
jne 0x3a68
leaq 0x590e(%rip), %rsi      # 0x931a
movq %r14, %rdi
callq 0x35fd
testb %al, %al
jne 0x3a68
leaq 0x5903(%rip), %rsi      # 0x9322
movq %r14, %rdi
callq 0x35fd
testb %al, %al
jne 0x3a68
leaq 0x58f4(%rip), %rsi      # 0x9326
movq %r14, %rdi
callq 0x35fd
testb %al, %al
jne 0x3a68
leaq 0x58e8(%rip), %rsi      # 0x932d
movq %r14, %rdi
callq 0x35fd
testb %al, %al
jne 0x3a68
leaq 0x58dc(%rip), %rsi      # 0x9334
movq %r14, %rdi
callq 0x35fd
testb %al, %al
je 0x3baa
cmpl $0x1f5, %ebp            # imm = 0x1F5
jl 0x3a8b
movq 0xa551(%rip), %rdi      # 0xdfc8
leaq 0x58df(%rip), %rsi      # 0x935d
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x21e0
leaq 0x5880(%rip), %rsi      # 0x9312
movq %r14, %rdi
callq 0x35fd
testb %al, %al
jne 0x3ac4
leaq 0x5875(%rip), %rsi      # 0x931a
movq %r14, %rdi
callq 0x35fd
testb %al, %al
jne 0x3ac4
leaq 0x586a(%rip), %rsi      # 0x9322
movq %r14, %rdi
callq 0x35fd
testb %al, %al
je 0x3b1e
movl $0xe0, %edi
callq 0x21f0
movq %rax, %r14
leaq 0x583a(%rip), %rsi      # 0x9312
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x25ea
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x4df4
leaq 0x10(%rsp), %rdi
callq 0x2100
leaq 0xa6b6(%rip), %rdi      # 0xe1c0
movq %rbx, %rsi
callq 0x4482
movq %r14, (%rax)
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x5801(%rip), %rsi      # 0x9326
movq %r14, %rdi
callq 0x35fd
testb %al, %al
jne 0x3b57
leaq 0x57f5(%rip), %rsi      # 0x932d
movq %r14, %rdi
callq 0x35fd
testb %al, %al
jne 0x3b57
leaq 0x57e9(%rip), %rsi      # 0x9334
movq %r14, %rdi
callq 0x35fd
testb %al, %al
je 0x3b15
movl $0xe0, %edi
callq 0x21f0
movq %rax, %r14
leaq 0x57bb(%rip), %rsi      # 0x9326
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x25ea
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x5404
leaq 0x10(%rsp), %rdi
callq 0x2100
leaq 0xa653(%rip), %rdi      # 0xe1f0
movq %rbx, %rsi
callq 0x44e8
jmp 0x3b12
movq 0xa417(%rip), %rdi      # 0xdfc8
leaq 0x5780(%rip), %rsi      # 0x9338
callq 0x21e0
movq %rax, %rdi
movq %r14, %rsi
callq 0x21d0
leaq 0x577f(%rip), %rsi      # 0x934e
jmp 0x39ea
jmp 0x3bd8
jmp 0x3be7
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2100
jmp 0x3bea
movq %rax, %rbx
movl $0xe0, %esi
movq %r14, %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x22e0