// File: /workspace/github_c_makefile_star2_O2/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 0x3ac7(%rip), %rsi      # 0x9e5c
pushq $0x38
popq %rdi
callq 0x1bad
movq %rax, %rbx
movq %r15, %rdi
callq 0x1d2b
movq %rax, %r14
testl %r13d, %r13d
je 0x63ed
movq %r15, %rdi
callq 0x10e0
addl $-0x4, %eax
movslq %eax, %rdi
addq %r15, %rdi
movq %r14, %r12
leaq 0x30ba(%rip), %r14      # 0x9485
movq %r14, %rsi
callq 0x1190
xorl %ebp, %ebp
testl %eax, %eax
sete %bpl
leaq 0x30a8(%rip), %rsi      # 0x948a
cmoveq %r14, %rsi
movq %r12, %r14
incl %ebp
jmp 0x63f6
xorl %ebp, %ebp
leaq 0x39b3(%rip), %rsi      # 0x9da9
movq %r15, %rdi
callq 0x1d83
movq %rax, %r15
testq %rbx, %rbx
je 0x66be
testq %r14, %r14
je 0x66be
testq %r15, %r15
je 0x66be
movl %r13d, 0xc(%rsp)
movq %r14, (%rsp)
pushq $0x40
popq %rsi
movq %r15, %rdi
callq 0x1140
testq %rax, %rax
je 0x64d3
movq %rax, %r14
leaq 0x1(%rax), %r13
pushq $0x40
popq %rsi
movq %r13, %rdi
callq 0x1140
testq %rax, %rax
jne 0x6633
movb $0x0, (%r14)
leaq 0x18(%rsp), %r14
pushq $0xa
popq %rdx
movq %r13, %rdi
movq %r14, %rsi
callq 0x11d0
movq %rax, %r12
movq (%r14), %r14
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %r13, %r14
je 0x64df
testl %r12d, %r12d
jle 0x664d
cmpb $0x2d, (%r14)
jne 0x64e5
incq %r14
leaq 0x18(%rsp), %r13
pushq $0xa
popq %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x11d0
movq (%r13), %r13
cmpq %r14, %r13
je 0x6678
cmpl %r12d, %eax
movq (%rsp), %r14
jge 0x64ec
movq 0x7b3b(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xa421(%rip), %rdx      # 0x108e8
leaq 0x3a59(%rip), %rsi      # 0x9f27
jmp 0x66b4
pushq $-0x1
popq %r12
xorl %r13d, %r13d
movl %r12d, %eax
jmp 0x64e8
pushq $0x1
popq %r12
jmp 0x64e8
movq %r14, %r13
movq (%rsp), %r14
leal -0x1(%r12), %ecx
andq $0x0, 0x30(%rbx)
movq %r14, 0x18(%rbx)
movq %r15, 0x10(%rbx)
movq %r13, 0x20(%rbx)
movl %r12d, (%rbx)
movl %eax, 0x4(%rbx)
movl %ecx, 0x8(%rbx)
movl %ebp, 0x28(%rbx)
cmpl $0x0, 0xc(%rsp)
je 0x661e
testl %r12d, %r12d
js 0x661e
cmpl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
jne 0x661e
leaq 0x2f5a(%rip), %rsi      # 0x948e
leaq 0x2f50(%rip), %rcx      # 0x948b
movq %r14, %rdi
movq %r15, %rdx
callq 0x31cf
leaq 0x3804(%rip), %rsi      # 0x9d51
movq %rax, %rdi
callq 0x1240
testq %rax, %rax
jne 0x658b
leaq 0x2f2d(%rip), %rsi      # 0x948e
leaq 0x2f1e(%rip), %rcx      # 0x9486
movq %r14, %rdi
movq %r15, %rdx
callq 0x31cf
leaq 0x37d7(%rip), %rsi      # 0x9d51
movq %rax, %rdi
callq 0x1240
testq %rax, %rax
je 0x669c
movq %rax, %r12
leaq 0x2e64(%rip), %rsi      # 0x93f9
leaq 0x14(%rsp), %rdx
movq %rax, %rdi
xorl %eax, %eax
callq 0x1090
cmpl $0x1, %eax
jne 0x65ce
pushq $-0x1
popq %rbp
leaq 0x20(%rsp), %r14
incl %ebp
cmpl 0x14(%rsp), %ebp
jge 0x65f4
movq %r14, %rdi
movl $0x4e84, %esi           # imm = 0x4E84
movq %r12, %rdx
callq 0x1180
testq %rax, %rax
jne 0x65b1
movq 0x7a23(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xa309(%rip), %rdx      # 0x108e8
leaq 0x2a37(%rip), %rsi      # 0x901d
xorl %eax, %eax
callq 0x11a0
pushq $0x2
jmp 0x66d8
leaq 0x2e32(%rip), %rsi      # 0x942d
leaq 0x10(%rsp), %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0x1090
cmpl $0x1, %eax
jne 0x65ce
movq %r12, %rdi
callq 0x10c0
movl 0x10(%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 0x79be(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xa2a4(%rip), %rdx      # 0x108e8
leaq 0x3827(%rip), %rsi      # 0x9e72
jmp 0x6665
movq 0x79a4(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xa28a(%rip), %rdx      # 0x108e8
leaq 0x3849(%rip), %rsi      # 0x9eae
pushq $0x40
popq %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x11a0
movq (%rsp), %r14
jmp 0x66be
movq 0x7979(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xa25f(%rip), %rdx      # 0x108e8
leaq 0x3861(%rip), %rsi      # 0x9ef1
movq %r15, %rcx
xorl %eax, %eax
callq 0x11a0
jmp 0x6672
movq 0x7955(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xa23b(%rip), %rdx      # 0x108e8
leaq 0x38b1(%rip), %rsi      # 0x9f65
movq %r15, %rcx
xorl %eax, %eax
callq 0x11a0
movq %rbx, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
pushq $0x1
popq %rdi
callq 0x1270