// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movq 0xba73(%rip), %r15      # 0xffd0
leaq 0x6d88(%rip), %rsi      # 0xb2ec
movl $0x18, %edx
movq %r15, %rdi
callq 0x2220
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r15, %rdi
callq 0x2220
leaq 0x6d7e(%rip), %rsi      # 0xb305
movl $0x3, %edx
movq %rax, %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x4853
testb %al, %al
je 0x45de
movq 0xba29(%rip), %r14      # 0xffd0
leaq 0x6d5b(%rip), %rsi      # 0xb309
movl $0x14, %edx
movq %r14, %rdi
callq 0x2220
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x2220
leaq 0x6d4d(%rip), %rsi      # 0xb31e
movl $0x11, %edx
movq %rax, %rdi
jmp 0x46ae
leaq 0x6d4b(%rip), %rsi      # 0xb330
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x4693
leaq 0x6d3c(%rip), %rsi      # 0xb338
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x4693
leaq 0x6d2d(%rip), %rsi      # 0xb340
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x4693
leaq 0x6d1e(%rip), %rsi      # 0xb344
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x4693
leaq 0x6d12(%rip), %rsi      # 0xb34b
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x4693
leaq 0x6d06(%rip), %rsi      # 0xb352
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x4693
movq 0xb971(%rip), %rbx      # 0xffd0
leaq 0x6cf0(%rip), %rsi      # 0xb356
movl $0x15, %edx
movq %rbx, %rdi
callq 0x2220
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x2220
leaq 0x6ce3(%rip), %rsi      # 0xb36c
movl $0xe, %edx
jmp 0x45d6
cmpl $0x1f5, %ebp            # imm = 0x1F5
jl 0x46bd
movq 0xb92e(%rip), %rdi      # 0xffd0
leaq 0x6cd2(%rip), %rsi      # 0xb37b
movl $0x1f, %edx
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2220
leaq 0x6c6c(%rip), %rsi      # 0xb330
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x47a7
leaq 0x6c5d(%rip), %rsi      # 0xb338
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x47a7
leaq 0x6c4e(%rip), %rsi      # 0xb340
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x47a7
leaq 0x6c3b(%rip), %rsi      # 0xb344
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x473f
leaq 0x6c2f(%rip), %rsi      # 0xb34b
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x473f
leaq 0x6c23(%rip), %rsi      # 0xb352
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
jne 0x4810
movl $0xe0, %edi
callq 0x21d0
movq %rax, %r14
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x6be8(%rip), %rsi      # 0xb344
leaq 0x6be7(%rip), %rdx      # 0xb34a
leaq 0x8(%rsp), %rdi
callq 0x2692
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x68c6
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x4796
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21e0
leaq 0xba4b(%rip), %rdi      # 0x101e8
movq %rbx, %rsi
callq 0x5796
jmp 0x480d
movl $0xe0, %edi
callq 0x21d0
movq %rax, %r14
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x6b6c(%rip), %rsi      # 0xb330
leaq 0x6b6c(%rip), %rdx      # 0xb337
leaq 0x8(%rsp), %rdi
callq 0x2692
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x603c
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x47fe
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21e0
leaq 0xb9b3(%rip), %rdi      # 0x101b8
movq %rbx, %rsi
callq 0x571a
movq %r14, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x481f
jmp 0x483b
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x483e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x483e
movq %rax, %rbx
movl $0xe0, %esi
movq %r14, %rdi
callq 0x21e0
movq %rbx, %rdi
callq 0x22e0