// File: /workspace/github_cpp_makefile_star2_O1/lagoproject[P]arti/analysis/analysis.cc
// Function: ReadBlock(double*, int)
int ReadBlock(double *block, int type) {
  int read_line_error = 0, check = 0, read_no_error=1;
  bad_block=0;
  for (int row=0; row<block_rows; row++) {
    if (fgets(line,250,fi)!=NULL) {
      do {
        check=sscanf(
          line, "%le %le %le %le %le %le %le\n", 
          &block[block_cols * row + 0], 
          &block[block_cols * row + 1], 
          &block[block_cols * row + 2], 
          &block[block_cols * row + 3], 
          &block[block_cols * row + 4], 
          &block[block_cols * row + 5], 
          &block[block_cols * row + 6]
        );
      } while (check != block_cols && read_line_error++ < read_tries);
      lines++;
      if (read_line_error) {
        cerr << "Error: Bad block (missing elements) at block "<< type << ", row " << row+1 << endl;
        read_no_error=0;
        break;
      }
    }
    else { 
      cerr << "Error: EOF while reading block " << type << " at line " << row+1 << endl;
      read_no_error=0;
      break;
    }
  }
  if (block[0] != chk_block[type]) {
    // if we read the last event, then while we are trying to read the next event header we are actually reading the run_footer, so...
    if (type == 2 && block[0] == chk_block[4]) {
      events=false;
      for (int i=0; i<block_size; i++) 
        run_footer[i] = block[i];
    }
    else {  
      bad_block = 1;
      fprintf(stderr, "Error: Bad block error (unformated) at block %d. First element should be %.5E, and it is %.5E\n", type, chk_block[type], block[0]);
    }
  }
  return read_no_error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, 0x4(%rsp)
movq %rdi, %r12
movl $0x0, 0x678e(%rip)      # 0x7ca0
xorl %r14d, %r14d
movq %rdi, 0x8(%rsp)
movq 0x3c57(%rip), %rdx      # 0x5178
leaq 0x67c8(%rip), %rdi      # 0x7cf0
movl $0xfa, %esi
callq 0x11c0
testq %rax, %rax
je 0x15f3
movq %r14, 0x10(%rsp)
imulq $0x38, %r14, %rax
leaq (%r12,%rax), %rcx
movq %rcx, 0x20(%rsp)
leaq (%r12,%rax), %rcx
addq $0x8, %rcx
movq %rcx, 0x18(%rsp)
leaq 0x10(%r12,%rax), %rbx
leaq 0x18(%r12,%rax), %r14
leaq (%r12,%rax), %r15
addq $0x20, %r15
leaq (%r12,%rax), %r13
addq $0x28, %r13
leaq (%r12,%rax), %rbp
addq $0x30, %rbp
xorl %r12d, %r12d
subq $0x8, %rsp
leaq 0x6766(%rip), %rdi      # 0x7cf0
leaq 0x1b2c(%rip), %rsi      # 0x30bd
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq %rbx, %r8
movq %r14, %r9
xorl %eax, %eax
pushq %rbp
pushq %r13
pushq %r15
callq 0x1100
addq $0x20, %rsp
cmpl $0x7, %eax
je 0x15c5
incl %r12d
cmpl $0xb, %r12d
jne 0x157f
movl $0x1, %r12d
incq 0x66bc(%rip)            # 0x7c88
testl %r12d, %r12d
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %r14
jne 0x162b
incq %r14
cmpq $0x27, %r14
jne 0x151a
movl $0x1, %r14d
jmp 0x16a4
movq 0x39f6(%rip), %rbx      # 0x4ff0
leaq 0x1b0e(%rip), %rsi      # 0x310f
movl $0x1f, %edx
movq %rbx, %rdi
callq 0x1140
movq %rbx, %rdi
movl 0x4(%rsp), %esi
callq 0x11e0
movq %rax, %rbx
leaq 0x1b0b(%rip), %rsi      # 0x312f
movl $0x9, %edx
jmp 0x1661
movq 0x39be(%rip), %rbx      # 0x4ff0
leaq 0x1aa1(%rip), %rsi      # 0x30da
movl $0x2d, %edx
movq %rbx, %rdi
callq 0x1140
movq %rbx, %rdi
movl 0x4(%rsp), %esi
callq 0x11e0
movq %rax, %rbx
leaq 0x1aac(%rip), %rsi      # 0x3108
movl $0x6, %edx
movq %rax, %rdi
callq 0x1140
incl %r14d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x11e0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10b0
xorl %r14d, %r14d
movsd (%r12), %xmm1
movl 0x4(%rsp), %edx
movslq %edx, %rax
leaq 0x3a68(%rip), %rcx      # 0x5120
movsd (%rcx,%rax,8), %xmm0
ucomisd %xmm0, %xmm1
jne 0x16c5
jnp 0x16fd
cmpl $0x2, %edx
jne 0x170f
ucomisd 0x3a6e(%rip), %xmm1     # 0x5140
jne 0x170f
jp 0x170f
movb $0x0, 0x3a6b(%rip)      # 0x5148
xorl %eax, %eax
leaq 0x5cea(%rip), %rcx      # 0x73d0
movsd (%r12,%rax), %xmm0
movsd %xmm0, (%rax,%rcx)
addq $0x8, %rax
cmpq $0x888, %rax            # imm = 0x888
jne 0x16e6
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, 0x6587(%rip)      # 0x7ca0
movq 0x38b0(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
leaq 0x1a0f(%rip), %rsi      # 0x3139
movb $0x2, %al
callq 0x11a0
jmp 0x16fd