// File: 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
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq 0x19a5b(%rip), %rdi     # 0x1ffc8
leaq 0xfd6c(%rip), %rsi      # 0x162e0
callq 0x3280
movq %rax, %rdi
movq -0x8(%rbp), %rsi
callq 0x3250
movq %rax, %rdi
leaq 0xfd6a(%rip), %rsi      # 0x162f9
callq 0x3280
movq -0x8(%rbp), %rdi
callq 0x6940
testb $0x1, %al
jne 0x65a3
jmp 0x65d6
movq 0x19a1e(%rip), %rdi     # 0x1ffc8
leaq 0xfd4c(%rip), %rsi      # 0x162fd
callq 0x3280
movq %rax, %rdi
movq -0x8(%rbp), %rsi
callq 0x3250
movq %rax, %rdi
leaq 0xfd46(%rip), %rsi      # 0x16312
callq 0x3280
jmp 0x692e
movq -0x10(%rbp), %rdi
leaq 0xfd43(%rip), %rsi      # 0x16324
callq 0x54f0
testb $0x1, %al
jne 0x6689
movq -0x10(%rbp), %rdi
leaq 0xfd33(%rip), %rsi      # 0x1632c
callq 0x54f0
testb $0x1, %al
jne 0x6689
movq -0x10(%rbp), %rdi
leaq 0xfd23(%rip), %rsi      # 0x16334
callq 0x54f0
testb $0x1, %al
jne 0x6689
movq -0x10(%rbp), %rdi
leaq 0xfd13(%rip), %rsi      # 0x16338
callq 0x54f0
testb $0x1, %al
jne 0x6689
movq -0x10(%rbp), %rdi
leaq 0xfd06(%rip), %rsi      # 0x1633f
callq 0x54f0
testb $0x1, %al
jne 0x6689
movq -0x10(%rbp), %rdi
leaq 0xfcf9(%rip), %rsi      # 0x16346
callq 0x54f0
testb $0x1, %al
jne 0x6689
movq 0x1996b(%rip), %rdi     # 0x1ffc8
leaq 0xfce6(%rip), %rsi      # 0x1634a
callq 0x3280
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x3250
movq %rax, %rdi
leaq 0xfce1(%rip), %rsi      # 0x16360
callq 0x3280
jmp 0x692e
cmpl $0x1f4, -0x14(%rbp)     # imm = 0x1F4
jle 0x66aa
movq 0x1992f(%rip), %rdi     # 0x1ffc8
leaq 0xfccf(%rip), %rsi      # 0x1636f
callq 0x3280
jmp 0x692e
movq -0x10(%rbp), %rdi
leaq 0xfc6f(%rip), %rsi      # 0x16324
callq 0x54f0
testb $0x1, %al
jne 0x66eb
movq -0x10(%rbp), %rdi
leaq 0xfc63(%rip), %rsi      # 0x1632c
callq 0x54f0
testb $0x1, %al
jne 0x66eb
movq -0x10(%rbp), %rdi
leaq 0xfc57(%rip), %rsi      # 0x16334
callq 0x54f0
testb $0x1, %al
jne 0x66eb
jmp 0x67e5
movl $0xe0, %edi
callq 0x3290
movq %rax, -0xa0(%rbp)
movb $0x1, -0x55(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x3420
movq -0x90(%rbp), %rdx
leaq 0xfbfb(%rip), %rsi      # 0x16324
leaq -0x40(%rbp), %rdi
callq 0x3810
jmp 0x6734
movq -0x98(%rbp), %rsi
movq -0xa0(%rbp), %rdi
movl -0x14(%rbp), %ecx
leaq -0x40(%rbp), %rdx
callq 0xa1f0
jmp 0x6750
movb $0x0, -0x55(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3190
leaq -0x41(%rbp), %rdi
callq 0x32f0
movq -0xa0(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x8(%rbp), %rsi
leaq 0x19ae9(%rip), %rdi     # 0x20270
callq 0x7770
movq -0xa8(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x692e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x67be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3190
leaq -0x41(%rbp), %rdi
callq 0x32f0
testb $0x1, -0x55(%rbp)
jne 0x67cf
jmp 0x67e0
movq -0xa0(%rbp), %rdi
movl $0xe0, %esi
callq 0x32a0
jmp 0x6937
movq -0x10(%rbp), %rdi
leaq 0xfb48(%rip), %rsi      # 0x16338
callq 0x54f0
testb $0x1, %al
jne 0x6826
movq -0x10(%rbp), %rdi
leaq 0xfb3b(%rip), %rsi      # 0x1633f
callq 0x54f0
testb $0x1, %al
jne 0x6826
movq -0x10(%rbp), %rdi
leaq 0xfb2e(%rip), %rsi      # 0x16346
callq 0x54f0
testb $0x1, %al
jne 0x6826
jmp 0x692c
movl $0xe0, %edi
callq 0x3290
movq %rax, -0xc0(%rbp)
movb $0x1, -0x82(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x3420
movq -0xb0(%rbp), %rdx
leaq 0xface(%rip), %rsi      # 0x16338
leaq -0x80(%rbp), %rdi
callq 0x3810
jmp 0x6875
movq -0xb8(%rbp), %rsi
movq -0xc0(%rbp), %rdi
movl -0x14(%rbp), %ecx
leaq -0x80(%rbp), %rdx
callq 0xabb0
jmp 0x6891
movb $0x0, -0x82(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x3190
leaq -0x81(%rbp), %rdi
callq 0x32f0
movq -0xc0(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x8(%rbp), %rsi
leaq 0x199d2(%rip), %rdi     # 0x202a0
callq 0x7850
movq -0xc8(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x692c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x6902
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x3190
leaq -0x81(%rbp), %rdi
callq 0x32f0
testb $0x1, -0x82(%rbp)
jne 0x6919
jmp 0x692a
movq -0xc0(%rbp), %rdi
movl $0xe0, %esi
callq 0x32a0
jmp 0x6937
jmp 0x692e
addq $0xd0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x3410