// File: /workspace/github_cpp_makefile_star2_O1/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 0xba33(%rip), %r15      # 0xffd0
leaq 0x6d48(%rip), %rsi      # 0xb2ec
movl $0x18, %edx
movq %r15, %rdi
callq 0x2220
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r15, %rdi
callq 0x2220
leaq 0x6d3e(%rip), %rsi      # 0xb305
movl $0x3, %edx
movq %rax, %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x4893
testb %al, %al
je 0x461e
movq 0xb9e9(%rip), %r14      # 0xffd0
leaq 0x6d1b(%rip), %rsi      # 0xb309
movl $0x14, %edx
movq %r14, %rdi
callq 0x2220
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x2220
leaq 0x6d0d(%rip), %rsi      # 0xb31e
movl $0x11, %edx
movq %rax, %rdi
jmp 0x46ee
leaq 0x6d0b(%rip), %rsi      # 0xb330
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x46d3
leaq 0x6cfc(%rip), %rsi      # 0xb338
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x46d3
leaq 0x6ced(%rip), %rsi      # 0xb340
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x46d3
leaq 0x6cde(%rip), %rsi      # 0xb344
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x46d3
leaq 0x6cd2(%rip), %rsi      # 0xb34b
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x46d3
leaq 0x6cc6(%rip), %rsi      # 0xb352
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x46d3
movq 0xb931(%rip), %rbx      # 0xffd0
leaq 0x6cb0(%rip), %rsi      # 0xb356
movl $0x15, %edx
movq %rbx, %rdi
callq 0x2220
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x2220
leaq 0x6ca3(%rip), %rsi      # 0xb36c
movl $0xe, %edx
jmp 0x4616
cmpl $0x1f5, %ebp            # imm = 0x1F5
jl 0x46fd
movq 0xb8ee(%rip), %rdi      # 0xffd0
leaq 0x6c92(%rip), %rsi      # 0xb37b
movl $0x1f, %edx
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2220
leaq 0x6c2c(%rip), %rsi      # 0xb330
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x47e7
leaq 0x6c1d(%rip), %rsi      # 0xb338
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x47e7
leaq 0x6c0e(%rip), %rsi      # 0xb340
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x47e7
leaq 0x6bfb(%rip), %rsi      # 0xb344
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x477f
leaq 0x6bef(%rip), %rsi      # 0xb34b
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
je 0x477f
leaq 0x6be3(%rip), %rsi      # 0xb352
movq %r14, %rdi
callq 0x20b0
testl %eax, %eax
jne 0x4850
movl $0xe0, %edi
callq 0x21d0
movq %rax, %r14
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x6ba8(%rip), %rsi      # 0xb344
leaq 0x6ba7(%rip), %rdx      # 0xb34a
leaq 0x8(%rsp), %rdi
callq 0x2692
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x6908
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x47d6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21e0
leaq 0xba0b(%rip), %rdi      # 0x101e8
movq %rbx, %rsi
callq 0x57da
jmp 0x484d
movl $0xe0, %edi
callq 0x21d0
movq %rax, %r14
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x6b2c(%rip), %rsi      # 0xb330
leaq 0x6b2c(%rip), %rdx      # 0xb337
leaq 0x8(%rsp), %rdi
callq 0x2692
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x6080
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x483e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21e0
leaq 0xb973(%rip), %rdi      # 0x101b8
movq %rbx, %rsi
callq 0x575e
movq %r14, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x485f
jmp 0x487b
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x487e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x487e
movq %rax, %rbx
movl $0xe0, %esi
movq %r14, %rdi
callq 0x21e0
movq %rbx, %rdi
callq 0x22e0