// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %rsi, -0x50(%rbp)
movq %rdi, %r14
movq 0x55c9(%rip), %r15      # 0x8fd8
leaq 0x2885(%rip), %rsi      # 0x629b
movl $0xa, %edx
movq %r15, %rdi
callq 0x2170
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
movq (%r14), %rax
movl 0xc(%rax), %eax
movq %rsp, %rcx
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x60(%rbp)
movq %rcx, %rsp
leaq 0x34(%r14), %r13
leaq 0x20(%r14), %rbx
movl $0x0, -0x2c(%rbp)
leaq 0x2834(%rip), %r12      # 0x62af
movq %rbx, -0x38(%rbp)
movl 0x30(%r14), %eax
movq (%r14), %rcx
cmpl 0x68(%rcx), %eax
jl 0x3adf
jmp 0x3e14
movl $0x19, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x2170
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
movl 0x38(%r14), %eax
incl %eax
movq (%r14), %rcx
cmpl 0x64(%rcx), %eax
jl 0x3adb
incl (%r13)
xorl %eax, %eax
movl %eax, 0x38(%r14)
movq (%r14), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x2534
cmpl $0x6c, %eax
je 0x3a90
movq %rbx, %rdi
movq -0x60(%rbp), %rbx
movq %rbx, %rsi
callq 0x46bc
movq %rsp, -0x40(%rbp)
movl 0xc(%r14), %eax
movq %rsp, %r12
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movslq 0x10(%r14), %rsi
addq %rbx, %rsi
movslq 0xc(%r14), %rdx
movq %r12, %rdi
callq 0x2080
movl 0x8(%r14), %eax
cmpl $0x3, %eax
je 0x3c5d
cmpl $0x2, %eax
je 0x3c15
cmpl $0x1, %eax
jne 0x3dd3
movq 0x18(%r14), %rbx
movl (%r12), %esi
movq %r15, %rdi
callq 0x21f0
movq %rax, -0x58(%rbp)
movl $0x3, %edx
movq %rax, %rdi
leaq 0x2647(%rip), %rsi      # 0x61b6
callq 0x2170
movq %rbx, -0x48(%rbp)
movl (%rbx), %esi
movq -0x58(%rbp), %rdi
callq 0x21f0
movq %rax, %rbx
movq (%rax), %rcx
movq -0x18(%rcx), %rdi
addq %rax, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
movl 0x14(%r14), %eax
decl %eax
cmpl $0x6, %eax
ja 0x3d67
leaq 0x2471(%rip), %rcx      # 0x6034
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl (%r12), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
movl -0x2c(%rbp), %esi
movzbl %sil, %esi
movl $0x1, %eax
cmovel %eax, %esi
movl %esi, -0x2c(%rbp)
andl $0x1, %esi
movq %r15, %rdi
callq 0x21d0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r12, %rdi
jmp 0x3c9f
movl 0x14(%r14), %ecx
decl %ecx
cmpl $0x6, %ecx
ja 0x3c71
movq 0x18(%r14), %rax
leaq 0x23ed(%rip), %rdx      # 0x6018
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movss (%r12), %xmm0
ucomiss (%rax), %xmm0
movq -0x38(%rbp), %rbx
leaq 0x2667(%rip), %r12      # 0x62af
movq -0x40(%rbp), %rdx
jne 0x3de2
jnp 0x3d97
jmp 0x3de2
movl 0x14(%r14), %eax
decl %eax
movb $0x1, %cl
movl %ecx, -0x2c(%rbp)
cmpl $0x7, %eax
jb 0x3dd3
movl $0x1d, %edx
movq %r15, %rdi
leaq 0x2665(%rip), %rsi      # 0x62e5
callq 0x2170
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
jmp 0x3dd3
movb $0x1, %al
movl %eax, -0x2c(%rbp)
jmp 0x3dd3
movss (%r12), %xmm0
ucomiss (%rax), %xmm0
jmp 0x3cf7
movl (%r12), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
movl -0x2c(%rbp), %ecx
movzbl %cl, %ecx
movl $0x1, %eax
cmovlel %eax, %ecx
jmp 0x3dd0
movss (%r12), %xmm0
ucomiss (%rax), %xmm0
jmp 0x3d37
movss (%rax), %xmm0
ucomiss (%r12), %xmm0
movq -0x38(%rbp), %rbx
leaq 0x25ad(%rip), %r12      # 0x62af
movq -0x40(%rbp), %rdx
jae 0x3d97
jmp 0x3de2
movl (%r12), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
movl -0x2c(%rbp), %ecx
movzbl %cl, %ecx
movl $0x1, %eax
cmovll %eax, %ecx
jmp 0x3dd0
movss (%rax), %xmm0
ucomiss (%r12), %xmm0
movq -0x38(%rbp), %rbx
leaq 0x256d(%rip), %r12      # 0x62af
movq -0x40(%rbp), %rdx
ja 0x3d97
jmp 0x3de2
movl (%r12), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
movl -0x2c(%rbp), %ecx
movzbl %cl, %ecx
movl $0x1, %eax
cmovgl %eax, %ecx
jmp 0x3dd0
movl $0x1b, %edx
movq %r15, %rdi
leaq 0x2553(%rip), %rsi      # 0x62c9
jmp 0x3c80
movss (%r12), %xmm0
ucomiss (%rax), %xmm0
movq -0x38(%rbp), %rbx
leaq 0x2520(%rip), %r12      # 0x62af
movq -0x40(%rbp), %rdx
jne 0x3d97
jnp 0x3de2
movb $0x1, %al
movl %eax, -0x2c(%rbp)
jmp 0x3de2
movl (%r12), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
movl -0x2c(%rbp), %ecx
movzbl %cl, %ecx
movl $0x1, %eax
cmovgel %eax, %ecx
jmp 0x3dd0
movl (%r12), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
movl -0x2c(%rbp), %ecx
movzbl %cl, %ecx
movl $0x1, %eax
cmovnel %eax, %ecx
movl %ecx, -0x2c(%rbp)
movq -0x38(%rbp), %rbx
leaq 0x24d1(%rip), %r12      # 0x62af
movq -0x40(%rbp), %rdx
movl 0x38(%r14), %eax
incl %eax
movq (%r14), %rcx
cmpl 0x64(%rcx), %eax
jl 0x3df6
incl (%r13)
xorl %eax, %eax
movq %rdx, %rsp
movl %eax, 0x38(%r14)
incl 0x30(%r14)
cmpq $0x0, 0x18(%r14)
je 0x3e65
testb $0x1, -0x2c(%rbp)
je 0x3a7f
jmp 0x3e65
leaq 0x248b(%rip), %rsi      # 0x62a6
movl $0x8, %edx
movq %r15, %rdi
callq 0x2170
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0x3e65
callq 0x2190
movq $0x0, 0x20(%r14)
movq 0x20(%r14), %rsi
movq -0x50(%rbp), %rbx
movq %rbx, %rdi
callq 0x45e2
movq 0x28(%r14), %rax
movq %rax, 0x8(%rbx)
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq