// File: /workspace/github_cpp_makefile_star2_O1/wwdatabase[P]database/testrcdmana.cpp
// Function: main
int main() {
    RecordManager *prm = RecordManager::getInstance();
    const char *fileName = "database.txt";
    vector<int> attrType, attrLength, isNull;
    for (int i = 0; i < 3; ++i) {
        attrType.push_back(1);
        attrLength.push_back(4);
        isNull.push_back(1);
    }
    prm->createFile(fileName, 12, attrType, attrLength, isNull, 1);

    RM_FileHandle fileHandle(prm->pfm, prm->bpm);
    prm->openFile(fileName, fileHandle);
    RID rid;
    /*prm->fileHandle->insertRec("123451345512", rid);
    cout << rid << endl;
    prm->fileHandle->insertRec("123451345512", rid);
    cout << rid << endl;
    prm->fileHandle->insertRec("This is one ", rid);
    prm->fileHandle->insertRec("123451345512", rid);
    prm->fileHandle->insertRec("123451345512", rid);
*/
    RM_Record rec;
    /*prm->fileHandle->getRec(rid, rec);
    cout << string(rec.data) << endl;

    rec.setData("this is another case");
    prm->fileHandle->updateRec(rec);

    prm->fileHandle->getRec(rid, rec);
    cout << string(rec.data) << endl;

    prm->fileHandle->deleteRec(rid);
    prm->fileHandle->insertRec("33333333333333333333", rid);
*/
    int b = 40100200;
    char data[12];
    strcpy(data, "abcd");
    for (int i = 0; i < 4; ++i) {
        char t = *((char*)(&b)+i);
        cout << t << " ddd" << endl;
        strcat(data, &t);
        cout << data << " ddd " << strlen(data) << endl;
    }
    strcat(data, "1234");
    cout << "size : " << strlen(data) << endl;
    fileHandle.insertRec(data, rid);
    b = 20; 
    strcpy(data, "1111");
    for (int i = 0; i < 4; ++i) {
        strcat(data, (char*)(&b)+i);
    }
    strcat(data, "3333");
    fileHandle.insertRec(data, rid);
    // a = {'a', 'b', 'c', 'd'}; 
    b = 345; 
    // c = {'a', 'b', 'c', 'd'};
    strcpy(data, "2222");
    for (int i = 0; i < 4; ++i) {
        strcat(data, (char*)(&b)+i);
    }
    strcat(data, "6666");
    fileHandle.insertRec(data, rid);

    RM_FileScan fs;
    b = 40100200;
    void* value = (void*)(&b);
    fs.openScan(fileHandle,
                ATTRINT,
                4,
                4,
                GT_OP,
                value);
    fs.getNextRec(rec);
    if (!rec.empty()) {
        cout << string(rec.data) << " , " << rec.rid << endl;
    }
    fs.closeScan();

    prm->closeFile(fileHandle);

    prm->destroyFile(fileName);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
callq 0x4976
movq %rax, -0xd8(%rbp)
xorl %eax, %eax
leaq -0xb0(%rbp), %r14
movq %rax, 0x10(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
leaq -0x90(%rbp), %r15
movq %rax, 0x10(%r15)
movaps %xmm0, (%r15)
leaq -0x70(%rbp), %r12
movq %rax, 0x10(%r12)
movaps %xmm0, (%r12)
movl $0x3, %ebx
leaq -0x1c0(%rbp), %r13
movl $0x1, -0x1c0(%rbp)
movq -0xa8(%rbp), %rsi
cmpq -0xa0(%rbp), %rsi
je 0x3f3a
movl $0x1, (%rsi)
addq $0x4, %rsi
movq %rsi, -0xa8(%rbp)
jmp 0x3f45
movq %r14, %rdi
movq %r13, %rdx
callq 0x531a
movl $0x4, -0x1c0(%rbp)
movq -0x88(%rbp), %rsi
cmpq -0x80(%rbp), %rsi
je 0x3f6f
movl $0x4, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x88(%rbp)
jmp 0x3f7a
movq %r15, %rdi
movq %r13, %rdx
callq 0x531a
movl $0x1, -0x1c0(%rbp)
movq -0x68(%rbp), %rsi
cmpq -0x60(%rbp), %rsi
je 0x3f9e
movl $0x1, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x68(%rbp)
jmp 0x3fa9
movq %r12, %rdi
movq %r13, %rdx
callq 0x531a
decl %ebx
jne 0x3f0d
leaq -0x120(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x49c8
leaq -0x108(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x49c8
leaq -0xf0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x49c8
movl $0x1, (%rsp)
leaq 0x230e(%rip), %rsi      # 0x6303
leaq -0x120(%rbp), %rcx
leaq -0x108(%rbp), %r8
leaq -0xf0(%rbp), %r9
movq -0xd8(%rbp), %rbx
movq %rbx, %rdi
movl $0xc, %edx
callq 0x2d7e
movq -0xf0(%rbp), %rdi
testq %rdi, %rdi
je 0x4039
movq -0xe0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2160
movq -0x108(%rbp), %rdi
testq %rdi, %rdi
je 0x4054
movq -0xf8(%rbp), %rsi
subq %rdi, %rsi
callq 0x2160
movq -0x120(%rbp), %rdi
testq %rdi, %rdi
je 0x406f
movq -0x110(%rbp), %rsi
subq %rdi, %rsi
callq 0x2160
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
xorl %edx, %edx
movq %rdx, -0x140(%rbp)
movq %rdx, -0x150(%rbp)
movl %edx, -0x148(%rbp)
movl %edx, -0x138(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x1b0(%rbp)
movaps %xmm0, -0x1a0(%rbp)
movaps %xmm0, -0x1c0(%rbp)
movaps %xmm0, -0x190(%rbp)
movaps %xmm0, -0x180(%rbp)
movaps %xmm0, -0x170(%rbp)
movq -0x1a8(%rbp), %rdx
cmpq %rdx, -0x1a0(%rbp)
je 0x40d6
movq %rdx, -0x1a0(%rbp)
movq -0x190(%rbp), %rdx
cmpq %rdx, -0x188(%rbp)
je 0x40ed
movq %rdx, -0x188(%rbp)
movq -0x178(%rbp), %rdx
cmpq %rdx, -0x170(%rbp)
je 0x4104
movq %rdx, -0x170(%rbp)
leaq -0x1c0(%rbp), %rdx
movaps %xmm0, 0x60(%rdx)
movq %rax, 0x90(%rdx)
movq %rcx, 0x98(%rdx)
leaq 0x21df(%rip), %rsi      # 0x6303
movq %rbx, %rdi
callq 0x31d4
movq $0x0, -0x58(%rbp)
movl $0x263e168, -0x2c(%rbp) # imm = 0x263E168
leaq -0x38(%rbp), %rbx
movb $0x0, 0x4(%rbx)
movl $0x64636261, (%rbx)     # imm = 0x64636261
xorl %r13d, %r13d
movq 0x4e85(%rip), %r14      # 0x8fd8
leaq 0x21c0(%rip), %r15      # 0x631a
movb -0x2c(%rbp,%r13), %al
movb %al, -0xd0(%rbp)
movb %al, -0x200(%rbp)
movl $0x1, %edx
movq %r14, %rdi
leaq -0x200(%rbp), %rsi
callq 0x2170
movq %rax, %r12
movl $0x4, %edx
movq %rax, %rdi
leaq 0x2184(%rip), %rsi      # 0x6315
callq 0x2170
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
movq %rbx, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x2070
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2170
movl $0x5, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2170
movq %rbx, %rdi
callq 0x2070
movq %r14, %rdi
movq %rax, %rsi
callq 0x20b0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
incq %r13
cmpq $0x4, %r13
jne 0x415a
leaq -0x38(%rbp), %rdi
callq 0x2070
movl $0x34333231, -0x38(%rbp,%rax) # imm = 0x34333231
movb $0x0, -0x34(%rbp,%rax)
movq 0x4d7e(%rip), %rdi      # 0x8fd8
leaq 0x1f0f(%rip), %rsi      # 0x6170
movl $0x7, %edx
callq 0x2170
leaq -0x38(%rbp), %rdi
callq 0x2070
movq 0x4d5d(%rip), %rdi      # 0x8fd8
movq %rax, %rsi
callq 0x20b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
leaq -0x1c0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x44(%rbp), %rdx
callq 0x25fa
movl $0x14, -0x2c(%rbp)
leaq -0x38(%rbp), %rbx
movl $0x31313131, (%rbx)     # imm = 0x31313131
movb $0x0, 0x4(%rbx)
xorl %r14d, %r14d
leaq (%r14,%rbp), %rsi
addq $-0x2c, %rsi
movq %rbx, %rdi
callq 0x2210
incq %r14
cmpq $0x4, %r14
jne 0x42d9
leaq -0x38(%rbp), %rbx
movq %rbx, %rdi
callq 0x2070
movl $0x33333333, -0x38(%rbp,%rax) # imm = 0x33333333
movb $0x0, -0x34(%rbp,%rax)
leaq -0x1c0(%rbp), %rdi
leaq -0x44(%rbp), %rdx
movq %rbx, %rsi
callq 0x25fa
movl $0x159, -0x2c(%rbp)     # imm = 0x159
movl $0x32323232, (%rbx)     # imm = 0x32323232
movb $0x0, 0x4(%rbx)
xorl %r14d, %r14d
leaq (%r14,%rbp), %rsi
addq $-0x2c, %rsi
movq %rbx, %rdi
callq 0x2210
incq %r14
cmpq $0x4, %r14
jne 0x4332
leaq -0x38(%rbp), %rbx
movq %rbx, %rdi
callq 0x2070
movl $0x36363636, -0x38(%rbp,%rax) # imm = 0x36363636
movb $0x0, -0x34(%rbp,%rax)
leaq -0x1c0(%rbp), %rdi
leaq -0x44(%rbp), %rdx
movq %rbx, %rsi
callq 0x25fa
leaq -0x200(%rbp), %rdi
movq $0x0, 0x20(%rdi)
leaq -0x2c(%rbp), %rax
movl $0x263e168, (%rax)      # imm = 0x263E168
movq %rax, (%rsp)
leaq -0x1c0(%rbp), %rsi
movl $0x1, %edx
movl $0x4, %ecx
movl $0x4, %r8d
movl $0x3, %r9d
callq 0x3924
leaq -0x200(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x39f0
movq -0x58(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
leaq -0x39(%rbp), %rdx
callq 0x467e
movq -0xd0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
movq 0x4be9(%rip), %rdi      # 0x8fd8
callq 0x2170
movq %rax, %rbx
leaq 0x1f3b(%rip), %rsi      # 0x6339
movl $0x3, %edx
movq %rax, %rdi
callq 0x2170
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x23ac
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
movq -0xd0(%rbp), %rdi
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x2160
movq %rax, %rbx
leaq -0xc0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x447d
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x447d
jmp 0x447a
movq %rax, %rbx
movq -0x1e0(%rbp), %rdi
testq %rdi, %rdi
je 0x4495
callq 0x2190
jmp 0x4495
jmp 0x4492
movq %rax, %rbx
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x44a8
callq 0x2190
jmp 0x44a8
movq %rax, %rbx
leaq -0x1c0(%rbp), %rdi
callq 0x24c0
jmp 0x451f
movq %rax, %rbx
movq -0xf0(%rbp), %rdi
testq %rdi, %rdi
je 0x44d9
movq -0xe0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2160
jmp 0x44d9
movq %rax, %rbx
movq -0x108(%rbp), %rdi
testq %rdi, %rdi
je 0x44f9
movq -0xf8(%rbp), %rsi
subq %rdi, %rsi
callq 0x2160
jmp 0x44f9
movq %rax, %rbx
movq -0x120(%rbp), %rdi
testq %rdi, %rdi
je 0x451f
movq -0x110(%rbp), %rsi
subq %rdi, %rsi
callq 0x2160
jmp 0x451f
jmp 0x451c
jmp 0x451c
jmp 0x451c
movq %rax, %rbx
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x4534
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x2160
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x454c
movq -0x80(%rbp), %rsi
subq %rdi, %rsi
callq 0x2160
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x4567
movq -0xa0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2160
movq %rbx, %rdi
callq 0x2200
nop