// File: /workspace/github_c_makefile_star2_O2/thegenemyers[P]DASCRUBBER/DB.c
// Function: Fetch_Block_Range
int Fetch_Block_Range(char *path, int trim, int n, int *first, int *last)
{ FILE *dbfile;
  char  buffer[2*MAX_NAME+100];
  int   nfiles;
  int   nblocks;
  int64 size;
  int   all, cutoff;
  int   tfirst, tlast;
  int   ufirst, ulast;
  int   i;

  dbfile = Fopen(path,"r");
  if (dbfile == NULL)
    EXIT(1);
  if (fscanf(dbfile,DB_NFILE,&nfiles) != 1)
    goto stub_error;
  for (i = 0; i < nfiles; i++)
    if (fgets(buffer,2*MAX_NAME+100,dbfile) == NULL)
      goto stub_error;
  if (fscanf(dbfile,DB_NBLOCK,&nblocks) != 1)
    goto stub_error;

  if (n < 0 || n >= nblocks)
    { *first = *last = -1;
      return (0);
    }

  if (fscanf(dbfile,DB_PARAMS,&size,&cutoff,&all) != 3)
    goto stub_error;
  for (i = 1; i <= n; i++)
    if (fscanf(dbfile,DB_BDATA,&ufirst,&tfirst) != 2)
      goto stub_error;
  if (fscanf(dbfile,DB_BDATA,&ulast,&tlast) != 2)
    goto stub_error;

  fclose(dbfile);

  if (trim)
    { *first = tfirst;
      *last  = tlast;
    }
  else
    { *first = ufirst;
      *last  = ulast;
    }

  return (0);

stub_error:
  fclose(dbfile);
  EPRINTF(EPLACE,"%s: Stub file %s is junk\n",Prog_Name,path);
  EXIT(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4ec8, %rsp           # imm = 0x4EC8
movq %r8, 0x10(%rsp)
movq %rcx, %r15
movl %edx, %r13d
movl %esi, 0x4(%rsp)
leaq 0x7486(%rip), %rsi      # 0x9d51
movq %rdi, 0x18(%rsp)
callq 0x1ccb
testq %rax, %rax
je 0x29db
movq %rax, %r12
leaq 0x6b11(%rip), %rsi      # 0x93f9
leaq 0xc(%rsp), %rdx
movq %rax, %rdi
xorl %eax, %eax
callq 0x1090
cmpl $0x1, %eax
jne 0x29af
pushq $-0x1
popq %rbp
leaq 0x40(%rsp), %rbx
incl %ebp
cmpl 0xc(%rsp), %ebp
jge 0x292a
movq %rbx, %rdi
movl $0x4e84, %esi           # imm = 0x4E84
movq %r12, %rdx
callq 0x1180
testq %rax, %rax
jne 0x2908
jmp 0x29af
leaq 0x6afc(%rip), %rsi      # 0x942d
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0x1090
cmpl $0x1, %eax
jne 0x29af
testl %r13d, %r13d
js 0x29e3
cmpl %r13d, 0x8(%rsp)
jle 0x29e3
leaq 0x6adb(%rip), %rsi      # 0x943b
leaq 0x38(%rsp), %rdx
leaq 0x30(%rsp), %rcx
leaq 0x34(%rsp), %r8
movq %r12, %rdi
xorl %eax, %eax
callq 0x1090
cmpl $0x3, %eax
jne 0x29af
incl %r13d
leaq 0x6ad9(%rip), %r14      # 0x9461
leaq 0x24(%rsp), %rbp
leaq 0x2c(%rsp), %rbx
decl %r13d
je 0x29f1
movq %r12, %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1090
cmpl $0x2, %eax
je 0x2992
movq %r12, %rdi
callq 0x10c0
movq 0xb63a(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xdf20(%rip), %rdx      # 0x108e8
leaq 0x6a9c(%rip), %rsi      # 0x946b
movq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0x11a0
pushq $0x1
popq %rdi
callq 0x1270
movq 0x10(%rsp), %rax
orl $-0x1, (%rax)
orl $-0x1, (%r15)
jmp 0x2a3c
leaq 0x6a69(%rip), %rsi      # 0x9461
leaq 0x20(%rsp), %r14
leaq 0x28(%rsp), %r13
movq %r12, %rdi
movq %r14, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x1090
cmpl $0x2, %eax
jne 0x29af
movq %r12, %rdi
callq 0x10c0
cmpl $0x0, 0x4(%rsp)
cmoveq %rbp, %rbx
movl (%rbx), %eax
movl %eax, (%r15)
cmoveq %r14, %r13
movl (%r13), %eax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
xorl %eax, %eax
addq $0x4ec8, %rsp           # imm = 0x4EC8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq