// File: /workspace/github_cpp_makefile_star2_O2/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 0x400c
movq %rax, -0x60(%rbp)
xorps %xmm0, %xmm0
leaq -0x100(%rbp), %r14
movaps %xmm0, (%r14)
andq $0x0, 0x10(%r14)
leaq -0xe0(%rbp), %r15
andq $0x0, 0x10(%r15)
leaq -0xc0(%rbp), %r12
andq $0x0, 0x10(%r12)
movaps %xmm0, (%r15)
movaps %xmm0, (%r12)
pushq $0x3
popq %rbx
leaq -0x200(%rbp), %r13
subl $0x1, %ebx
jb 0x37c6
movl $0x1, -0x200(%rbp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x4c98
movl $0x4, -0x200(%rbp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x4c98
movl $0x1, -0x200(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x4c98
jmp 0x3780
leaq -0xa8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x4058
leaq -0x90(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x4058
leaq -0x78(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x4058
movl $0x1, (%rsp)
leaq 0x1af9(%rip), %rsi      # 0x5303
pushq $0xc
popq %rdx
leaq -0xa8(%rbp), %rcx
leaq -0x90(%rbp), %r8
leaq -0x78(%rbp), %r9
movq -0x60(%rbp), %rbx
movq %rbx, %rdi
callq 0x2b98
leaq -0x78(%rbp), %rdi
callq 0x4950
leaq -0x90(%rbp), %rdi
callq 0x4950
leaq -0xa8(%rbp), %rdi
callq 0x4950
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq -0x200(%rbp), %r14
movq %r14, %rdi
callq 0x2472
leaq 0x1a9a(%rip), %rsi      # 0x5303
movq %rbx, %rdi
movq %r14, %rdx
callq 0x2e22
andq $0x0, -0x58(%rbp)
movl $0x263e168, -0x2c(%rbp) # imm = 0x263E168
leaq -0x38(%rbp), %rbx
movb $0x0, 0x4(%rbx)
movl $0x64636261, (%rbx)     # imm = 0x64636261
xorl %r12d, %r12d
movq 0x4740(%rip), %r14      # 0x7fd8
leaq 0x1a7b(%rip), %r13      # 0x531a
cmpq $0x4, %r12
je 0x3919
movsbl -0x2c(%rbp,%r12), %esi
movb %sil, -0x160(%rbp)
movq %r14, %rdi
callq 0x21b0
movq %rax, %rdi
leaq 0x1a51(%rip), %rsi      # 0x5315
callq 0x2170
movq %rax, %rdi
callq 0x20b0
movq %rbx, %rdi
leaq -0x160(%rbp), %rsi
callq 0x2280
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2170
movq %rax, %rdi
movq %r13, %rsi
callq 0x2170
movq %rax, %r15
movq %rbx, %rdi
callq 0x2090
movq %r15, %rdi
movq %rax, %rsi
callq 0x20e0
movq %rax, %rdi
callq 0x20b0
incq %r12
jmp 0x389f
leaq -0x38(%rbp), %rdi
callq 0x2090
movl $0x34333231, -0x38(%rbp,%rax) # imm = 0x34333231
movb $0x0, -0x34(%rbp,%rax)
movq 0x46a2(%rip), %rdi      # 0x7fd8
leaq 0x1833(%rip), %rsi      # 0x5170
callq 0x2170
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x2090
movq %rbx, %rdi
movq %rax, %rsi
callq 0x20e0
movq %rax, %rdi
callq 0x20b0
leaq -0x200(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x44(%rbp), %rdx
callq 0x261c
movl $0x14, -0x2c(%rbp)
leaq -0x38(%rbp), %rbx
movl $0x31313131, (%rbx)     # imm = 0x31313131
movb $0x0, 0x4(%rbx)
xorl %r14d, %r14d
cmpq $0x4, %r14
je 0x39a8
leaq (%r14,%rbp), %rsi
addq $-0x2c, %rsi
movq %rbx, %rdi
callq 0x2280
incq %r14
jmp 0x398d
leaq -0x38(%rbp), %rbx
movq %rbx, %rdi
callq 0x2090
movl $0x33333333, -0x38(%rbp,%rax) # imm = 0x33333333
movb $0x0, -0x34(%rbp,%rax)
leaq -0x200(%rbp), %rdi
leaq -0x44(%rbp), %rdx
movq %rbx, %rsi
callq 0x261c
movl $0x159, -0x2c(%rbp)     # imm = 0x159
movl $0x32323232, (%rbx)     # imm = 0x32323232
movb $0x0, 0x4(%rbx)
xorl %r14d, %r14d
cmpq $0x4, %r14
je 0x3a03
leaq (%r14,%rbp), %rsi
addq $-0x2c, %rsi
movq %rbx, %rdi
callq 0x2280
incq %r14
jmp 0x39e8
leaq -0x38(%rbp), %rbx
movq %rbx, %rdi
callq 0x2090
movl $0x36363636, -0x38(%rbp,%rax) # imm = 0x36363636
movb $0x0, -0x34(%rbp,%rax)
leaq -0x200(%rbp), %rdi
leaq -0x44(%rbp), %rdx
movq %rbx, %rsi
callq 0x261c
leaq -0x160(%rbp), %rdi
andq $0x0, 0x20(%rdi)
leaq -0x2c(%rbp), %rax
movl $0x263e168, (%rax)      # imm = 0x263E168
movq %rax, (%rsp)
leaq -0x200(%rbp), %rsi
pushq $0x1
popq %rdx
pushq $0x4
popq %rcx
pushq $0x3
popq %r9
movl %ecx, %r8d
callq 0x3318
leaq -0x160(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3390
movq -0x58(%rbp), %rsi
leaq -0x120(%rbp), %rdi
leaq -0x39(%rbp), %rdx
callq 0x3c68
movq 0x454b(%rip), %rdi      # 0x7fd8
leaq -0x120(%rbp), %rsi
callq 0x2150
leaq 0x1899(%rip), %rsi      # 0x5339
movq %rax, %rdi
callq 0x2170
movq %rax, %rbx
leaq -0x50(%rbp), %rsi
movq %rax, %rdi
callq 0x241c
movq %rbx, %rdi
callq 0x20b0
leaq -0x120(%rbp), %rdi
callq 0x20a0
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x20a0
jmp 0x3ae1
jmp 0x3ade
movq %rax, %rbx
leaq -0x140(%rbp), %rdi
callq 0x3fae
jmp 0x3af4
jmp 0x3af1
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x3fae
jmp 0x3b02
movq %rax, %rbx
leaq -0x200(%rbp), %rdi
callq 0x2516
jmp 0x3b49
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x4950
jmp 0x3b21
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x4950
jmp 0x3b32
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x4950
jmp 0x3b49
jmp 0x3b46
jmp 0x3b46
jmp 0x3b46
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x4950
leaq -0xe0(%rbp), %rdi
callq 0x4950
leaq -0x100(%rbp), %rdi
callq 0x4950
movq %rbx, %rdi
callq 0x2270
nop