// File: /workspace/github_cpp_makefile_star2_O2/wwdatabase[P]database/./rcdmana/rm_filescan.h
// Function: RM_FileScan::getNextRec(RM_Record&)
RC RM_FileScan::getNextRec(RM_Record &rec) {
    cout << "Get record" << endl;
  char data[this->fh->recordSize];
  bool isSelected = false;
  bool rid_error = false;
  do {
    if (this->recordScanNum >= this->fh->recordNumForAllPages) {
        cout << "File EOF" << endl;
        this->record.clean();
        break;
    }

    while (this->fh->getRec(rid, this->record) == 108) {
        cout << "Unused record, ignore it." << endl;
        incRID();
    }

    char *td = data;
    this->record.getData(td);
    char comValue[this->attrLength];
    strncpy(comValue, data+this->attrOffset, this->attrLength);
    if (attrType == ATTRINT) {
      int *intValue = (int*)(comValue);
      // int c = 40100200;
      // int *intValue = &c;
      int *cmpValue = (int*)(value);
      cout << *intValue << " : " << *cmpValue << endl;
      switch (this->compOp) {
          case EQ_OP:
              if ((*intValue) == (*cmpValue))
                  isSelected = true;
              cout << isSelected << endl;
              break;
          case LT_OP:
              if (*intValue < *cmpValue)
                  isSelected = true;
              break;
          case GT_OP:
              if (*intValue > *cmpValue)
                  isSelected = true;
              break;
          case LE_OP:
              if (*intValue <= *cmpValue)
                  isSelected = true;
              break;
          case GE_OP:
              if (*intValue >= *cmpValue)
                  isSelected = true;
              break;
          case NE_OP:
              if (*intValue != *cmpValue)
                  isSelected = true;
              break;
          case NO_OP:
              /* No comparision (when value is a null pointer) */
              isSelected = true;
              break;
          default:
              cout << "compOp Error at compare INT" << endl;
              break;
      }
    }
    else if (attrType == ATTRFLOAT) {
      float *floatValue = (float*)(comValue);
      float *cmpValue = (float*)(value);
      switch (this->compOp) {
          case EQ_OP:
              if (*floatValue == *cmpValue)
                  isSelected = true;
              break;
          case LT_OP:
              if (*floatValue < *cmpValue)
                  isSelected = true;
              break;
          case GT_OP:
              if (*floatValue > *cmpValue)
                  isSelected = true;
              break;
          case LE_OP:
              if (*floatValue <= *cmpValue)
                  isSelected = true;
              break;
          case GE_OP:
              if (*floatValue >= *cmpValue)
                  isSelected = true;
              break;
          case NE_OP:
              if (*floatValue != *cmpValue)
                  isSelected = true;
              break;
          case NO_OP:
              /* No comparision (when value is a null pointer) */
              isSelected = true;
              break;
          default:
              cout << "Compop error at compare FLOAT" << endl;
              break;
      }
    }
    else if (attrType == ATTRSTRING) {
      isSelected = true;
      char *strValue = (char*)(comValue);
      char* cmpValue = (char*)(value);
      switch (this->compOp) {
          case EQ_OP:
              if (strncmp(strValue, cmpValue, this->attrLength) == 0)
                  isSelected = true;
              break;
          case LT_OP:
              if (strncmp(strValue, cmpValue, this->attrLength) < 0)
                  isSelected = true;
              break;
          case GT_OP:
              if (strncmp(strValue, cmpValue, this->attrLength) > 0)
                  isSelected = true;
              break;
          case LE_OP:
              if (strncmp(strValue, cmpValue, this->attrLength) <= 0)
                  isSelected = true;
              break;
          case GE_OP:
              if (strncmp(strValue, cmpValue, this->attrLength) >= 0)
                  isSelected = true;
              break;
          case NE_OP:
              if (strncmp(strValue, cmpValue, this->attrLength) != 0)
                  isSelected = true;
              break;
          case NO_OP:
              /* No comparision (when value is a null pointer) */
              isSelected = true;
              break;
          default:
              cout << "Compop error at compare FLOAT" << endl;
              break;
      }
    }

    incRID();
    ++recordScanNum;
  } while ((value != NULL) && !isSelected);

  rec = this->record;
  // rec.setData(this->record.data);
  // rec.rid = this->record.rid;
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, -0x40(%rbp)
movq %rdi, %r14
movq 0x4c29(%rip), %r15      # 0x7fd8
leaq 0x1ee5(%rip), %rsi      # 0x529b
movq %r15, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20b0
movq (%r14), %rax
movl 0xc(%rax), %eax
movq %rsp, %rcx
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x48(%rbp)
movq %rcx, %rsp
leaq 0x34(%r14), %rbx
leaq 0x20(%r14), %r12
movl $0x0, -0x2c(%rbp)
leaq 0x1eb8(%rip), %r13      # 0x52af
movl 0x30(%r14), %eax
movq (%r14), %rdi
cmpl 0x68(%rdi), %eax
jl 0x3426
jmp 0x36c1
movq %r15, %rdi
movq %r13, %rsi
callq 0x2170
movq %rax, %rdi
callq 0x20b0
movq %r14, %rdi
callq 0x3702
movq (%r14), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x255c
cmpl $0x6c, %eax
je 0x3408
movq %r12, %rdi
movq -0x48(%rbp), %r13
movq %r13, %rsi
callq 0x3ca4
movq %rsp, -0x50(%rbp)
movl 0xc(%r14), %eax
movq %rsp, %r15
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movslq 0x10(%r14), %rsi
addq %r13, %rsi
movslq 0xc(%r14), %rdx
movq %r15, %rdi
callq 0x20c0
movl 0x8(%r14), %eax
cmpl $0x3, %eax
je 0x356c
cmpl $0x2, %eax
je 0x3522
cmpl $0x1, %eax
leaq 0x1e1e(%rip), %r13      # 0x52af
jne 0x3697
movq 0x18(%r14), %rax
movq %rax, -0x38(%rbp)
movl (%r15), %esi
movq 0x4b2f(%rip), %rdi      # 0x7fd8
callq 0x2260
movq %rax, %rdi
leaq 0x1cfe(%rip), %rsi      # 0x51b6
callq 0x2170
movq -0x38(%rbp), %rcx
movl (%rcx), %esi
movq %rax, %rdi
callq 0x2260
movq %rax, %rdi
callq 0x20b0
movl 0x14(%r14), %eax
decl %eax
cmpl $0x6, %eax
ja 0x363a
leaq 0x1b4b(%rip), %rcx      # 0x5034
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movl -0x2c(%rbp), %esi
movzbl %sil, %esi
jmpq *%rax
movl (%r15), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
pushq $0x1
popq %rax
cmovel %eax, %esi
movl %esi, -0x2c(%rbp)
andl $0x1, %esi
movq 0x4ac3(%rip), %r15      # 0x7fd8
movq %r15, %rdi
callq 0x2250
jmp 0x3650
movl 0x14(%r14), %ecx
decl %ecx
cmpl $0x6, %ecx
leaq 0x1d7d(%rip), %r13      # 0x52af
ja 0x35f2
movq 0x18(%r14), %rax
leaq 0x1ad5(%rip), %rdx      # 0x5018
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movss (%r15), %xmm0
ucomiss (%rax), %xmm0
movq 0x4a7d(%rip), %r15      # 0x7fd8
jne 0x369e
jnp 0x366d
jmp 0x369e
movl 0x14(%r14), %eax
decl %eax
movb $0x1, %cl
movl %ecx, -0x2c(%rbp)
movq 0x4a5a(%rip), %r15      # 0x7fd8
cmpl $0x7, %eax
jb 0x359a
movq %r15, %rdi
leaq 0x1d58(%rip), %rsi      # 0x52e5
callq 0x2170
movq %rax, %rdi
callq 0x20b0
leaq 0x1d0e(%rip), %r13      # 0x52af
jmp 0x369e
movb $0x1, %al
movl %eax, -0x2c(%rbp)
jmp 0x3697
movss (%r15), %xmm0
ucomiss (%rax), %xmm0
jmp 0x35e0
movl (%r15), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
pushq $0x1
popq %rax
cmovlel %eax, %esi
jmp 0x3694
movss (%r15), %xmm0
ucomiss (%rax), %xmm0
jmp 0x361e
movss (%rax), %xmm0
ucomiss (%r15), %xmm0
movq 0x49f1(%rip), %r15      # 0x7fd8
jae 0x366d
jmp 0x369e
movq 0x49df(%rip), %r15      # 0x7fd8
movq %r15, %rdi
leaq 0x1ce2(%rip), %rsi      # 0x52e5
jmp 0x364b
movl (%r15), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
pushq $0x1
popq %rax
cmovll %eax, %esi
jmp 0x3694
movss (%rax), %xmm0
ucomiss (%r15), %xmm0
movq 0x49b3(%rip), %r15      # 0x7fd8
ja 0x366d
jmp 0x369e
movl (%r15), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
pushq $0x1
popq %rax
cmovgl %eax, %esi
jmp 0x3694
movq 0x4997(%rip), %r15      # 0x7fd8
movq %r15, %rdi
leaq 0x1c7e(%rip), %rsi      # 0x52c9
callq 0x2170
movq %rax, %rdi
callq 0x20b0
jmp 0x369e
movss (%r15), %xmm0
ucomiss (%rax), %xmm0
movq 0x496f(%rip), %r15      # 0x7fd8
jne 0x366d
jnp 0x369e
movb $0x1, %al
movl %eax, -0x2c(%rbp)
jmp 0x369e
movl (%r15), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
pushq $0x1
popq %rax
cmovgel %eax, %esi
jmp 0x3694
movl (%r15), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
pushq $0x1
popq %rax
cmovnel %eax, %esi
movl %esi, -0x2c(%rbp)
movq 0x493a(%rip), %r15      # 0x7fd8
movq %r14, %rdi
callq 0x3702
incl 0x30(%r14)
movq -0x50(%rbp), %rsp
cmpq $0x0, 0x18(%r14)
je 0x36e4
testb $0x1, -0x2c(%rbp)
je 0x33f7
jmp 0x36e4
movq 0x4910(%rip), %rdi      # 0x7fd8
leaq 0x1bd7(%rip), %rsi      # 0x52a6
callq 0x2170
movq %rax, %rdi
callq 0x20b0
movq %r12, %rdi
callq 0x3fc2
movq -0x40(%rbp), %rdi
movq %r12, %rsi
callq 0x3fe6
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop