// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DASCRUBBER/DB.c
// Function: Read_DB_Stub
DAZZ_STUB *Read_DB_Stub(char *path, int what)
{ FILE      *dbfile;
  DAZZ_STUB *stub;

  char  buf1[MAX_NAME+100];
  char  buf2[MAX_NAME+100];
  int   nread;

  int   i;
  int   nfiles;
  int   nblocks;
  int64 size;
  int   all, cutoff;

  dbfile = Fopen(path,"r");
  if (dbfile == NULL)
    EXIT(NULL);

  stub = Malloc(sizeof(DAZZ_STUB),"Allocating DB stub record");
  if (stub == NULL)
    { fclose(dbfile);
      EXIT(NULL);
    }

  stub->nreads  = NULL;
  stub->fname   = NULL;
  stub->prolog  = NULL;
  stub->ublocks = NULL;
  stub->tblocks = NULL;

  if (fscanf(dbfile,DB_NFILE,&nfiles) != 1)
    goto stub_trash;

  if (what & DB_STUB_NREADS)
    { stub->nreads = (int *) Malloc(sizeof(int)*(nfiles+1),"Allocating DB stub record");
      if (stub->nreads == NULL)
        goto stub_error;
      stub->nreads += 1;
    }

  if (what & DB_STUB_FILES)
    { stub->fname = (char **) Malloc(sizeof(char *)*(nfiles+1),"Allocating DB stub record");
      if (stub->fname == NULL)
        goto stub_error;
      stub->fname += 1;

      stub->nfiles  = nfiles;
      for (i = 0; i < nfiles; i++)
        stub->fname[i] = NULL;
    }

  if (what & DB_STUB_PROLOGS)
    { stub->prolog = (char **) Malloc(sizeof(char *)*(nfiles+1),"Allocating DB stub record");
      if (stub->prolog == NULL)
        goto stub_error;
      stub->prolog += 1;

      for (i = 0; i < nfiles; i++)
        stub->prolog[i] = NULL;
    }

  for (i = 0; i < nfiles; i++)
    { if (fscanf(dbfile,DB_FDATA,&nread,buf1,buf2) != 3)
        goto stub_trash;
      if (what & DB_STUB_NREADS)
        stub->nreads[i] = nread;
      if (what & DB_STUB_FILES)
        { stub->fname[i]   = Strdup(buf1,"Alloacting DB stub record");
          if (stub->fname[i] == NULL)
            goto stub_error;
        }
      if (what & DB_STUB_PROLOGS)
        { stub->prolog[i] = Strdup(buf2,"Alloacting DB stub record");
          if (stub->prolog[i] == NULL)
            goto stub_error;
        }
    }

  if (fscanf(dbfile,DB_NBLOCK,&nblocks) != 1)
    goto stub_trash;

  if (fscanf(dbfile,DB_PARAMS,&size,&cutoff,&all) != 3)
    goto stub_trash;

  if (what & DB_STUB_BLOCKS)
    { stub->ublocks  = (int *) Malloc(sizeof(int)*(nblocks+1),"Allocating DB stub record");
      stub->tblocks  = (int *) Malloc(sizeof(int)*(nblocks+1),"Allocating DB stub record");
      if (stub->ublocks == NULL || stub->tblocks == NULL)
        goto stub_error;

      for (i = 0; i <= nblocks; i++)
        if (fscanf(dbfile,DB_BDATA,stub->ublocks+i,stub->tblocks+i) != 2)
          goto stub_trash;
    }

  fclose(dbfile);

  stub->nfiles  = nfiles;
  stub->all     = all;
  stub->cutoff  = cutoff;
  stub->bsize   = size;
  stub->nblocks = nblocks;
  return (stub);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4f40, %rsp           # imm = 0x4F40
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
leaq 0xbb57(%rip), %rsi      # 0xed54
callq 0x2480
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x3217
movl $0x1, %edi
callq 0x1260
movl $0x48, %edi
leaq 0xb1bc(%rip), %rsi      # 0xe3df
callq 0x22c0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x3246
movq -0x18(%rbp), %rdi
callq 0x10b0
movl $0x1, %edi
callq 0x1260
movq -0x20(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x18(%rbp), %rdi
leaq 0xb16c(%rip), %rsi      # 0xe3f9
leaq -0x4f2c(%rbp), %rdx
movb $0x0, %al
callq 0x1080
cmpl $0x1, %eax
je 0x32a5
jmp 0x36f1
movl -0xc(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x32f7
movl -0x4f2c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
leaq 0xb118(%rip), %rsi      # 0xe3df
callq 0x22c0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x32e7
jmp 0x3714
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x4, %rcx
movq %rcx, 0x8(%rax)
movl -0xc(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x339b
movl -0x4f2c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
leaq 0xb0c2(%rip), %rsi      # 0xe3df
callq 0x22c0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x333d
jmp 0x3714
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x8, %rcx
movq %rcx, 0x10(%rax)
movl -0x4f2c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x4f28(%rbp)
movl -0x4f28(%rbp), %eax
cmpl -0x4f2c(%rbp), %eax
jge 0x3399
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x4f28(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x4f28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4f28(%rbp)
jmp 0x3363
jmp 0x339b
movl -0xc(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x3433
movl -0x4f2c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
leaq 0xb01e(%rip), %rsi      # 0xe3df
callq 0x22c0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x33e1
jmp 0x3714
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rcx
addq $0x8, %rcx
movq %rcx, 0x18(%rax)
movl $0x0, -0x4f28(%rbp)
movl -0x4f28(%rbp), %eax
cmpl -0x4f2c(%rbp), %eax
jge 0x3431
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x4f28(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x4f28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4f28(%rbp)
jmp 0x33fb
jmp 0x3433
movl $0x0, -0x4f28(%rbp)
movl -0x4f28(%rbp), %eax
cmpl -0x4f2c(%rbp), %eax
jge 0x355b
movq -0x18(%rbp), %rdi
leaq -0x27a0(%rbp), %rcx
leaq -0x4f20(%rbp), %r8
leaq 0xaf9e(%rip), %rsi      # 0xe406
leaq -0x4f24(%rbp), %rdx
movb $0x0, %al
callq 0x1080
cmpl $0x3, %eax
je 0x3480
jmp 0x36f1
movl -0xc(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x34a3
movl -0x4f24(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x4f28(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0xc(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x34f4
leaq -0x27a0(%rbp), %rdi
leaq 0xaf57(%rip), %rsi      # 0xe413
callq 0x23e0
movq %rax, %rdx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x4f28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x4f28(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x34f2
jmp 0x3714
jmp 0x34f4
movl -0xc(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x3545
leaq -0x4f20(%rbp), %rdi
leaq 0xaf06(%rip), %rsi      # 0xe413
callq 0x23e0
movq %rax, %rdx
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x4f28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x4f28(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x3543
jmp 0x3714
jmp 0x3545
jmp 0x3547
movl -0x4f28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4f28(%rbp)
jmp 0x343d
movq -0x18(%rbp), %rdi
leaq 0xaec7(%rip), %rsi      # 0xe42d
leaq -0x4f30(%rbp), %rdx
movb $0x0, %al
callq 0x1080
cmpl $0x1, %eax
je 0x357e
jmp 0x36f1
movq -0x18(%rbp), %rdi
leaq 0xaeb2(%rip), %rsi      # 0xe43b
leaq -0x4f38(%rbp), %rdx
leaq -0x4f40(%rbp), %rcx
leaq -0x4f3c(%rbp), %r8
movb $0x0, %al
callq 0x1080
cmpl $0x3, %eax
je 0x35af
jmp 0x36f1
movl -0xc(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x3699
movl -0x4f30(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
leaq 0xae0a(%rip), %rsi      # 0xe3df
callq 0x22c0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x38(%rax)
movl -0x4f30(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
leaq 0xade3(%rip), %rsi      # 0xe3df
callq 0x22c0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x3622
movq -0x20(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x3627
jmp 0x3714
movl $0x0, -0x4f28(%rbp)
movl -0x4f28(%rbp), %eax
cmpl -0x4f30(%rbp), %eax
jg 0x3697
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rdx
movslq -0x4f28(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdx
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rcx
movslq -0x4f28(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rcx
leaq 0xadeb(%rip), %rsi      # 0xe461
movb $0x0, %al
callq 0x1080
cmpl $0x2, %eax
je 0x3684
jmp 0x36f1
jmp 0x3686
movl -0x4f28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4f28(%rbp)
jmp 0x3631
jmp 0x3699
movq -0x18(%rbp), %rdi
callq 0x10b0
movl -0x4f2c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x4f3c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x20(%rax)
movl -0x4f40(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x4f38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movl -0x4f30(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x20(%rbp), %rax
addq $0x4f40, %rsp           # imm = 0x4F40
popq %rbp
retq
movq 0xe900(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0x11386(%rip), %rdx     # 0x14a88
movq -0x8(%rbp), %rcx
leaq 0xad5e(%rip), %rsi      # 0xe46b
movb $0x0, %al
callq 0x1180
movq -0x20(%rbp), %rdi
callq 0x3730
movq -0x18(%rbp), %rdi
callq 0x10b0
movl $0x1, %edi
callq 0x1260