// File: /workspace/github_c_makefile_star2_O1/thegenemyers[P]DASCRUBBER/DB.c
// Function: parse_block_arg
static Block_Looper *parse_block_arg(char *arg, int isDB)
{ _Block_Looper *parse;
  char *pwd, *root;
  char *ppnt, *cpnt;
  int   first, last;

  parse = (_Block_Looper *) Malloc(sizeof(_Block_Looper),"Allocating parse node");
  pwd   = PathTo(arg);
  if (isDB)
    { int len = strlen(arg);
      if (strcmp(arg+(len-4),".dam") == 0)
        { root = Root(arg,".dam");
          isDB = 2;
        }
      else
        root = Root(arg,".db");
    }
  else
    root  = Root(arg,".las");
  if (parse == NULL || pwd == NULL || root == NULL)
    goto error;

  ppnt = index(root,BLOCK_SYMBOL);
  if (ppnt == NULL)
    first = last = -1;
  else
    { if (index(ppnt+1,BLOCK_SYMBOL) != NULL)
        { EPRINTF(EPLACE,"%s: Two or more occurrences of %c-sign in source name '%s'\n",
                         Prog_Name,BLOCK_SYMBOL,root);
          goto error;
        }
      *ppnt++ = '\0';
      first = strtol(ppnt,&cpnt,10);
      if (cpnt == ppnt)
        { first = 1;
          last  = INT_MAX;
        }
      else
        { if (first < 1)
            { EPRINTF(EPLACE,
                      "%s: Integer following %c-sigan is less than 1 in source name '%s'\n",
                      Prog_Name,BLOCK_SYMBOL,root);
              goto error;
            }
          if (*cpnt == '-')
            { ppnt = cpnt+1;
              last = strtol(ppnt,&cpnt,10);
              if (cpnt == ppnt)
                { EPRINTF(EPLACE,"%s: Second integer must follow - in source name '%s'\n",
                                 Prog_Name,root);
                  goto error;
                }
              if (last < first)
                { EPRINTF(EPLACE,
                          "%s: 2nd integer is less than 1st integer in source name '%s'\n",
                          Prog_Name,root);
                  goto error;
                }
              ppnt = cpnt;
            }
          else
            { last = INT_MAX;
              ppnt = cpnt;
            }
        }
    }

  parse->pwd   = pwd;
  parse->root  = root;
  parse->ppnt  = ppnt;
  parse->first = first;
  parse->last  = last;
  parse->next  = first-1;
  parse->slice = NULL;
  parse->isDB  = isDB;

  if (isDB && first >= 0 && last == INT_MAX)
    { char  buffer[2*MAX_NAME+100];
      char *dbname;
      FILE *dbfile;
      int   i, nfiles, nblocks;

      dbname = MyCatenate(pwd,"/",root,"db"); 
      dbfile = fopen(dbname,"r");
      if (dbfile == NULL)
        { dbname = MyCatenate(pwd,"/",root,"dam"); 
          dbfile = fopen(dbname,"r");
          if (dbfile == NULL)
            { EPRINTF(EPLACE,"%s: Cannot open database %s[db|dam]\n",Prog_Name,root);
              goto error;
            }
        }

      if (fscanf(dbfile,DB_NFILE,&nfiles) != 1)
        SYSTEM_READ_ERROR
      for (i = 0; i < nfiles; i++)
        if (fgets(buffer,2*MAX_NAME+100,dbfile) == NULL)
          SYSTEM_READ_ERROR
      if (fscanf(dbfile,DB_NBLOCK,&nblocks) != 1)
        SYSTEM_READ_ERROR
      fclose(dbfile);

      parse->last = nblocks;
    }

  return ((Block_Looper *) parse);

error:
  free(parse);
  free(root);
  free(pwd);
  EXIT(NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4ea8, %rsp           # imm = 0x4EA8
movl %esi, %r13d
movq %rdi, %r15
leaq 0x48b3(%rip), %rsi      # 0xbe5c
movl $0x38, %edi
callq 0x2b85
movq %rax, %rbx
movq %r15, %rdi
callq 0x2cfe
movq %rax, %r14
testl %r13d, %r13d
je 0x7603
movq %r15, %rdi
callq 0x10e0
addl $-0x4, %eax
movslq %eax, %rdi
addq %r15, %rdi
movq %r14, %r12
leaq 0x3ea4(%rip), %r14      # 0xb485
movq %r14, %rsi
callq 0x1190
xorl %ebp, %ebp
testl %eax, %eax
sete %bpl
leaq 0x3e92(%rip), %rsi      # 0xb48a
cmoveq %r14, %rsi
movq %r12, %r14
incl %ebp
jmp 0x760c
xorl %ebp, %ebp
leaq 0x479d(%rip), %rsi      # 0xbda9
movq %r15, %rdi
callq 0x2d58
movq %rax, %r15
testq %rbx, %rbx
je 0x7856
testq %r14, %r14
je 0x7856
testq %r15, %r15
je 0x7856
movl %r13d, 0x10(%rsp)
movq %r14, (%rsp)
movq %r15, %rdi
movl $0x40, %esi
callq 0x1140
testq %rax, %rax
je 0x76e1
movq %rax, %r14
leaq 0x1(%rax), %r13
movq %r13, %rdi
movl $0x40, %esi
callq 0x1140
testq %rax, %rax
jne 0x7836
movb $0x0, (%r14)
leaq 0x18(%rsp), %r14
movq %r13, %rdi
movq %r14, %rsi
movl $0xa, %edx
callq 0x11d0
movq %rax, %r12
movq (%r14), %r14
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %r13, %r14
je 0x76f1
testl %r12d, %r12d
jle 0x7840
cmpb $0x2d, (%r14)
jne 0x76f9
incq %r14
leaq 0x18(%rsp), %r13
movq %r14, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x11d0
movq (%r13), %r13
cmpq %r14, %r13
je 0x784a
cmpl %r12d, %eax
movq (%rsp), %r14
jge 0x7700
movq %r15, %rdi
callq 0x1eea
jmp 0x7856
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %r13d, %r13d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x76fc
movl $0x1, %r12d
jmp 0x76fc
movq %r14, %r13
movq (%rsp), %r14
leal -0x1(%r12), %ecx
movq %r14, 0x18(%rbx)
movq %r15, 0x10(%rbx)
movq %r13, 0x20(%rbx)
movl %r12d, (%rbx)
movl %eax, 0x4(%rbx)
movl %ecx, 0x8(%rbx)
movq $0x0, 0x30(%rbx)
movl %ebp, 0x28(%rbx)
cmpl $0x0, 0x10(%rsp)
je 0x7821
testl %r12d, %r12d
js 0x7821
cmpl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
jne 0x7821
leaq 0x3d43(%rip), %rsi      # 0xb48e
leaq 0x3d39(%rip), %rcx      # 0xb48b
movq %r14, %rdi
movq %r15, %rdx
callq 0x4215
leaq 0x45ed(%rip), %rsi      # 0xbd51
movq %rax, %rdi
callq 0x1240
testq %rax, %rax
jne 0x77a2
leaq 0x3d16(%rip), %rsi      # 0xb48e
leaq 0x3d07(%rip), %rcx      # 0xb486
movq %r14, %rdi
movq %r15, %rdx
callq 0x4215
leaq 0x45c0(%rip), %rsi      # 0xbd51
movq %rax, %rdi
callq 0x1240
testq %rax, %rax
je 0x7878
movq %rax, %r12
leaq 0x3c4d(%rip), %rsi      # 0xb3f9
leaq 0xc(%rsp), %rdx
movq %rax, %rdi
xorl %eax, %eax
callq 0x1090
cmpl $0x1, %eax
jne 0x78a1
cmpl $0x0, 0xc(%rsp)
jle 0x77f3
xorl %ebp, %ebp
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl $0x4e84, %esi           # imm = 0x4E84
movq %r12, %rdx
callq 0x1180
testq %rax, %rax
je 0x789c
incl %ebp
cmpl 0xc(%rsp), %ebp
jl 0x77d2
leaq 0x3c33(%rip), %rsi      # 0xb42d
leaq 0x14(%rsp), %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0x1090
cmpl $0x1, %eax
jne 0x78a6
movq %r12, %rdi
callq 0x10c0
movl 0x14(%rsp), %eax
movl %eax, 0x4(%rbx)
movq %rbx, %rax
addq $0x4ea8, %rsp           # imm = 0x4EA8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x1ec5
jmp 0x7852
movq %r15, %rdi
callq 0x1f2e
jmp 0x7852
movq %r15, %rdi
callq 0x1f0c
movq (%rsp), %r14
movq %rbx, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
movl $0x1, %edi
callq 0x1270
movq 0x8779(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq 0xb05f(%rip), %rdx      # 0x128e8
leaq 0x46d5(%rip), %rsi      # 0xbf65
movq %r15, %rcx
xorl %eax, %eax
callq 0x11a0
jmp 0x7856
callq 0x1fa3
callq 0x1f53
callq 0x1f7b