// File: /workspace/github_c_makefile_star2_O3/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 0x4520(%rip), %rsi      # 0xbebc
movl $0x38, %edi
callq 0x2af5
movq %rax, %rbx
movq %r15, %rdi
callq 0x2c75
movq %rax, %r14
testl %r13d, %r13d
je 0x79f6
movq %r15, %rdi
callq 0x10e0
addl $-0x4, %eax
movslq %eax, %rdi
addq %r15, %rdi
movq %r14, %r12
leaq 0x3b11(%rip), %r14      # 0xb4e5
movq %r14, %rsi
callq 0x1190
xorl %ebp, %ebp
testl %eax, %eax
sete %bpl
leaq 0x3aff(%rip), %rsi      # 0xb4ea
cmoveq %r14, %rsi
movq %r12, %r14
incl %ebp
jmp 0x79ff
xorl %ebp, %ebp
leaq 0x440a(%rip), %rsi      # 0xbe09
movq %r15, %rdi
callq 0x2ccf
movq %rax, %r15
testq %rbx, %rbx
je 0x7c49
testq %r14, %r14
je 0x7c49
testq %r15, %r15
je 0x7c49
movl %r13d, 0x10(%rsp)
movq %r14, (%rsp)
movq %r15, %rdi
movl $0x40, %esi
callq 0x1140
testq %rax, %rax
je 0x7ad4
movq %rax, %r14
leaq 0x1(%rax), %r13
movq %r13, %rdi
movl $0x40, %esi
callq 0x1140
testq %rax, %rax
jne 0x7c29
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 0x7ae4
testl %r12d, %r12d
jle 0x7c33
cmpb $0x2d, (%r14)
jne 0x7aec
incq %r14
leaq 0x18(%rsp), %r13
movq %r14, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x11d0
movq (%r13), %r13
cmpq %r14, %r13
je 0x7c3d
cmpl %r12d, %eax
movq (%rsp), %r14
jge 0x7af3
movq %r15, %rdi
callq 0x1e72
jmp 0x7c49
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %r13d, %r13d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x7aef
movl $0x1, %r12d
jmp 0x7aef
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 0x7c14
testl %r12d, %r12d
js 0x7c14
cmpl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
jne 0x7c14
leaq 0x39b0(%rip), %rsi      # 0xb4ee
leaq 0x39a6(%rip), %rcx      # 0xb4eb
movq %r14, %rdi
movq %r15, %rdx
callq 0x427d
leaq 0x425a(%rip), %rsi      # 0xbdb1
movq %rax, %rdi
callq 0x1240
testq %rax, %rax
jne 0x7b95
leaq 0x3983(%rip), %rsi      # 0xb4ee
leaq 0x3974(%rip), %rcx      # 0xb4e6
movq %r14, %rdi
movq %r15, %rdx
callq 0x427d
leaq 0x422d(%rip), %rsi      # 0xbdb1
movq %rax, %rdi
callq 0x1240
testq %rax, %rax
je 0x7c6b
movq %rax, %r12
leaq 0x38ba(%rip), %rsi      # 0xb459
leaq 0xc(%rsp), %rdx
movq %rax, %rdi
xorl %eax, %eax
callq 0x1090
cmpl $0x1, %eax
jne 0x7c94
cmpl $0x0, 0xc(%rsp)
jle 0x7be6
xorl %ebp, %ebp
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl $0x4e84, %esi           # imm = 0x4E84
movq %r12, %rdx
callq 0x1180
testq %rax, %rax
je 0x7c8f
incl %ebp
cmpl 0xc(%rsp), %ebp
jl 0x7bc5
leaq 0x38a0(%rip), %rsi      # 0xb48d
leaq 0x14(%rsp), %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0x1090
cmpl $0x1, %eax
jne 0x7c99
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 0x1e4d
jmp 0x7c45
movq %r15, %rdi
callq 0x1eb6
jmp 0x7c45
movq %r15, %rdi
callq 0x1e94
movq (%rsp), %r14
movq %rbx, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
movl $0x1, %edi
callq 0x1270
movq 0x8386(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq 0xac6c(%rip), %rdx      # 0x128e8
leaq 0x4342(%rip), %rsi      # 0xbfc5
movq %r15, %rcx
xorl %eax, %eax
callq 0x11a0
jmp 0x7c49
callq 0x1f2b
callq 0x1edb
callq 0x1f03