// File: /workspace/github_c_makefile_star2_O0/felipelouza[P]egap/./blocks.h
// Function: readBlock
static solidBlock *readBlock(solidBlockFile *sf) 
{
  if(sf->fin==NULL) return NULL;
  // read size of block
  customInt buffer[SIZE_OF_ALPHABET+MAX_NUMBER_OF_BWTS];
  int e = fread(buffer,sizeof(customInt),2,sf->fin);
  if(e==0) return NULL; // no more blocks
  if(e!=2) die("tmp file read error in readBlock (1)");
  // ----- get solid block from s->solidList or malloc
  solidBlock *newB = get_block(sf);  
  newB->beginsAt = buffer[0];
  newB->endsAt = buffer[1];
  // printf("Reading [%ld %ld]\n",newB->beginsAt,newB->endsAt); //!!!!!!
  // --- get and init occ/smallOcc array
  if (newB->endsAt - newB->beginsAt <= SMALLSOLID_LIMIT) {
    // small solid block
    newB->smallOcc = get_smallocc(sf);
    e = fread(newB->smallOcc,sizeof(smallSolidInt),sf->occ_size,sf->fin);
    if(e!=sf->occ_size) die("tmp file read error in readBlock (2)");
  }
  else { // large solid block 
    newB->occ = get_occ(sf);
    memset(newB->occ,0,sf->occ_size*sizeof(customInt));// zero all values
    uint8_t *byteBuffer = (uint8_t *) buffer; // transform to an uint8_t buffer
    e = fread(byteBuffer,POS_SIZE,sf->occ_size,sf->fin); // read POS_SIZE bytes for customInt
    if(e!=sf->occ_size) die("tmp file read error in readBlock (3)");
    // fill newB->occ using five bytes for entry
    for(int j=0;j<sf->occ_size;j++) {
      for(int i=0;i<POS_SIZE;i++) 
        newB->occ[j] |= ((customInt) byteBuffer[j*POS_SIZE+i]) << (8*i);  
    }
  }
  newB->nextBlock=NULL;
  return newB;
}

// Assembly:
subq $0x1038, %rsp           # imm = 0x1038
movq %rdi, 0x1028(%rsp)
movq 0x1028(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x1067e
movq $0x0, 0x1030(%rsp)
jmp 0x1089a
leaq 0x20(%rsp), %rdi
movq 0x1028(%rsp), %rax
movq (%rax), %rcx
movl $0x8, %esi
movl $0x2, %edx
callq 0x2090
movl %eax, 0x1c(%rsp)
cmpl $0x0, 0x1c(%rsp)
jne 0x106b9
movq $0x0, 0x1030(%rsp)
jmp 0x1089a
cmpl $0x2, 0x1c(%rsp)
je 0x106cc
leaq 0x5a2f(%rip), %rdi      # 0x160f6
callq 0x3ce0
movq 0x1028(%rsp), %rdi
callq 0x87c0
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rcx
movq 0x10(%rsp), %rax
movq %rcx, (%rax)
movq 0x28(%rsp), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rsp), %rcx
subq (%rcx), %rax
cmpq $0xffff, %rax           # imm = 0xFFFF
ja 0x1077b
movq 0x1028(%rsp), %rdi
callq 0x88a0
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x1028(%rsp), %rax
movslq 0x10(%rax), %rdx
movq 0x1028(%rsp), %rax
movq (%rax), %rcx
movl $0x2, %esi
callq 0x2090
movl %eax, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movq 0x1028(%rsp), %rcx
cmpl 0x10(%rcx), %eax
je 0x10776
leaq 0x59aa(%rip), %rdi      # 0x1611b
callq 0x3ce0
jmp 0x10880
movq 0x1028(%rsp), %rdi
callq 0x8830
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x1028(%rsp), %rax
movslq 0x10(%rax), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x2140
leaq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rdi
movq 0x1028(%rsp), %rax
movslq 0x10(%rax), %rdx
movq 0x1028(%rsp), %rax
movq (%rax), %rcx
movl $0x5, %esi
callq 0x2090
movl %eax, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movq 0x1028(%rsp), %rcx
cmpl 0x10(%rcx), %eax
je 0x10805
leaq 0x5940(%rip), %rdi      # 0x16140
callq 0x3ce0
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
movq 0x1028(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x1087e
movl $0x0, (%rsp)
cmpl $0x5, (%rsp)
jge 0x1086f
movq 0x8(%rsp), %rax
imull $0x5, 0x4(%rsp), %ecx
addl (%rsp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %edx
movl (%rsp), %eax
shll $0x3, %eax
movl %eax, %eax
movl %eax, %ecx
shlq %cl, %rdx
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x4(%rsp), %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl (%rsp), %eax
addl $0x1, %eax
movl %eax, (%rsp)
jmp 0x10825
jmp 0x10871
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x1080d
jmp 0x10880
movq 0x10(%rsp), %rax
movq $0x0, 0x18(%rax)
movq 0x10(%rsp), %rax
movq %rax, 0x1030(%rsp)
movq 0x1030(%rsp), %rax
addq $0x1038, %rsp           # imm = 0x1038
retq
nopw (%rax,%rax)