// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x4ef0, %rsp           # imm = 0x4EF0
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xb4fc(%rip), %rsi      # 0xed54
callq 0x2480
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x3872
movl $0x1, %edi
callq 0x1260
movq -0x30(%rbp), %rdi
leaq 0xab7c(%rip), %rsi      # 0xe3f9
leaq -0x4ec4(%rbp), %rdx
movb $0x0, %al
callq 0x1080
cmpl $0x1, %eax
je 0x3895
jmp 0x3a28
movl $0x0, -0x4eec(%rbp)
movl -0x4eec(%rbp), %eax
cmpl -0x4ec4(%rbp), %eax
jge 0x38e0
leaq -0x4ec0(%rbp), %rdi
movq -0x30(%rbp), %rdx
movl $0x4e84, %esi           # imm = 0x4E84
callq 0x1160
cmpq $0x0, %rax
jne 0x38cd
jmp 0x3a28
jmp 0x38cf
movl -0x4eec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4eec(%rbp)
jmp 0x389f
movq -0x30(%rbp), %rdi
leaq 0xab42(%rip), %rsi      # 0xe42d
leaq -0x4ec8(%rbp), %rdx
movb $0x0, %al
callq 0x1080
cmpl $0x1, %eax
je 0x3903
jmp 0x3a28
cmpl $0x0, -0x18(%rbp)
jl 0x3914
movl -0x18(%rbp), %eax
cmpl -0x4ec8(%rbp), %eax
jl 0x3934
movq -0x28(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl $0x0, -0x4(%rbp)
jmp 0x3a5e
movq -0x30(%rbp), %rdi
leaq 0xaafc(%rip), %rsi      # 0xe43b
leaq -0x4ed0(%rbp), %rdx
leaq -0x4ed8(%rbp), %rcx
leaq -0x4ed4(%rbp), %r8
movb $0x0, %al
callq 0x1080
cmpl $0x3, %eax
je 0x3965
jmp 0x3a28
movl $0x1, -0x4eec(%rbp)
movl -0x4eec(%rbp), %eax
cmpl -0x18(%rbp), %eax
jg 0x39b7
movq -0x30(%rbp), %rdi
leaq 0xaadc(%rip), %rsi      # 0xe461
leaq -0x4ee4(%rbp), %rdx
leaq -0x4edc(%rbp), %rcx
movb $0x0, %al
callq 0x1080
cmpl $0x2, %eax
je 0x39a4
jmp 0x3a28
jmp 0x39a6
movl -0x4eec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4eec(%rbp)
jmp 0x396f
movq -0x30(%rbp), %rdi
leaq 0xaa9f(%rip), %rsi      # 0xe461
leaq -0x4ee8(%rbp), %rdx
leaq -0x4ee0(%rbp), %rcx
movb $0x0, %al
callq 0x1080
cmpl $0x2, %eax
je 0x39de
jmp 0x3a28
movq -0x30(%rbp), %rdi
callq 0x10b0
cmpl $0x0, -0x14(%rbp)
je 0x3a07
movl -0x4edc(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x4ee0(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x3a1f
movl -0x4ee4(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x4ee8(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x3a5e
movq -0x30(%rbp), %rdi
callq 0x10b0
movq 0xe5c0(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0x11046(%rip), %rdx     # 0x14a88
movq -0x10(%rbp), %rcx
leaq 0xaa1e(%rip), %rsi      # 0xe46b
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
movl -0x4(%rbp), %eax
addq $0x4ef0, %rsp           # imm = 0x4EF0
popq %rbp
retq
nopw (%rax,%rax)