// File: /workspace/github_c_makefile_star2_O0/zhou-lab[P]tbmate/view.c
// Function: main_view
int main_view(int argc, char *argv[]) {

  view_conf_t conf = {0};
  conf.precision = 3;
  conf.print_all = 0;
  conf.print_all_units = 0;
  conf.column_name = 0;
  conf.na_for_negative = 0;
  conf.show_unaddressed = 0;
  conf.chunk_read = 0;
  conf.n_chunk_index = 1000000;
  conf.n_chunk_data = 1000000;
  conf.max_pval = -1.0;
  conf.min_coverage = -1;
  conf.full_path_as_colname = 0;
  conf.na_token = strdup("NA");
  
  int c;
  if (argc<2) return usage(&conf);

  char *regions_fname = NULL;
  char *region = NULL;
  FILE *out_fh = stdout;
  char *idx_fname = NULL;
  char *tbk_fname_list = NULL;
  while ((c = getopt(argc, argv, "i:l:o:R:N:m:n:p:g:s:t:ckabduFh"))>=0) {
    switch (c) {
    case 'i': idx_fname = strdup(optarg); break;
    case 'l': tbk_fname_list = strdup(optarg); break;
    case 'o': out_fh = fopen(optarg, "w"); break;
    case 'R': regions_fname = optarg; break;
    case 'N': conf.na_token = strdup(optarg); break;
    case 'm': conf.n_chunk_index = atoi(optarg); break;
    case 'n': conf.n_chunk_data = atoi(optarg); break;
    case 'g': region = strdup(optarg); break;
    case 's': conf.min_coverage = atoi(optarg); break;
    case 't': conf.max_pval = atof(optarg); break;
    case 'p': conf.precision = atoi(optarg); break;
    case 'c': conf.column_name = 1; break;
    case 'k': conf.chunk_read = 1; break;
    case 'a': conf.print_all = 1; break;
    case 'b': conf.print_all_units = 1; break;
    case 'd': conf.na_for_negative = 1; break;
    case 'u': conf.show_unaddressed = 1; break;
    case 'F': conf.full_path_as_colname = 1; break;
    case 'h': return usage(&conf); break;
    default: usage(&conf); wzfatal("Unrecognized option: %c.\n", c);
    }
  }

  if (optind > argc && !tbk_fname_list) {
    usage(&conf); 
    wzfatal("Please supply tbk file.\n"); 
  }

  int nregs = 0;
  char **regs = NULL;

  int n_tbks = 0; tbk_t *tbks = NULL;
  int n_tbfs = 0; tbf_t *tbfs = NULL;
  parse_tbf_from_argument(argc, argv, optind, &tbfs, &n_tbfs);
  parse_tbf_fname_list(tbk_fname_list, &tbfs, &n_tbfs);
  int i;
  for (i=0; i<n_tbfs; ++i) {
    parse_tbk_from_tbf(&tbfs[i], &tbks, &n_tbks);
  }
  
  infer_idx(tbks, n_tbks, &idx_fname);
  
  regs = parse_regions(regions_fname, region, &nregs);
  int ret;
  if (conf.chunk_read)
    ret = chunk_query_region(idx_fname, regs, nregs, tbks, n_tbks, &conf, out_fh);
  else
    ret = query_regions(idx_fname, regs, nregs, tbks, n_tbks, &conf, out_fh);

  if (n_tbfs > 0) {for (i=0; i<n_tbfs; ++i) tbf_close(&tbfs[i]); free(tbfs);}
  if (n_tbks > 0) {for (i=0; i<n_tbks; ++i) free(tbks[i].sname); free(tbks);}
  if (idx_fname) free(idx_fname);
  free(conf.na_token);
  if (region) free(region);
  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x3090
movl $0x3, -0x50(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0xf4240, -0x28(%rbp)   # imm = 0xF4240
movl $0xf4240, -0x24(%rbp)   # imm = 0xF4240
movss 0x70963(%rip), %xmm0    # 0x7537c
movss %xmm0, -0x20(%rbp)
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x18(%rbp)
leaq 0x709aa(%rip), %rdi     # 0x753dd
callq 0x35f0
movq %rax, -0x38(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x4a53
leaq -0x50(%rbp), %rdi
callq 0x4ee0
movl %eax, -0x4(%rbp)
jmp 0x4ec6
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq 0x8058e(%rip), %rax     # 0x84ff8
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x70951(%rip), %rdx     # 0x753e0
callq 0x3210
movl %eax, -0x54(%rbp)
cmpl $0x0, %eax
jl 0x4c43
movl -0x54(%rbp), %eax
addl $-0x46, %eax
movl %eax, %ecx
movq %rcx, -0xc0(%rbp)
subl $0x2f, %eax
ja 0x4c24
movq -0xc0(%rbp), %rax
leaq 0x707f2(%rip), %rcx     # 0x752b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8050a(%rip), %rax     # 0x84fe0
movq (%rax), %rdi
callq 0x35f0
movq %rax, -0x78(%rbp)
jmp 0x4c3e
movq 0x804f2(%rip), %rax     # 0x84fe0
movq (%rax), %rdi
callq 0x35f0
movq %rax, -0x80(%rbp)
jmp 0x4c3e
movq 0x804da(%rip), %rax     # 0x84fe0
movq (%rax), %rdi
leaq 0x705a8(%rip), %rsi     # 0x750b8
callq 0x3260
movq %rax, -0x70(%rbp)
jmp 0x4c3e
movq 0x804bb(%rip), %rax     # 0x84fe0
movq (%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x4c3e
movq 0x804a8(%rip), %rax     # 0x84fe0
movq (%rax), %rdi
callq 0x35f0
movq %rax, -0x38(%rbp)
jmp 0x4c3e
movq 0x80490(%rip), %rax     # 0x84fe0
movq (%rax), %rdi
callq 0x3550
movl %eax, -0x28(%rbp)
jmp 0x4c3e
movq 0x80479(%rip), %rax     # 0x84fe0
movq (%rax), %rdi
callq 0x3550
movl %eax, -0x24(%rbp)
jmp 0x4c3e
movq 0x80462(%rip), %rax     # 0x84fe0
movq (%rax), %rdi
callq 0x35f0
movq %rax, -0x68(%rbp)
jmp 0x4c3e
movq 0x8044a(%rip), %rax     # 0x84fe0
movq (%rax), %rdi
callq 0x3550
movl %eax, -0x1c(%rbp)
jmp 0x4c3e
movq 0x80433(%rip), %rax     # 0x84fe0
movq (%rax), %rdi
callq 0x3300
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x20(%rbp)
jmp 0x4c3e
movq 0x80419(%rip), %rax     # 0x84fe0
movq (%rax), %rdi
callq 0x3550
movl %eax, -0x50(%rbp)
jmp 0x4c3e
movl $0x1, -0x4c(%rbp)
jmp 0x4c3e
movl $0x1, -0x2c(%rbp)
jmp 0x4c3e
movl $0x1, -0x48(%rbp)
jmp 0x4c3e
movl $0x1, -0x44(%rbp)
jmp 0x4c3e
movl $0x1, -0x40(%rbp)
jmp 0x4c3e
movl $0x1, -0x30(%rbp)
jmp 0x4c3e
movl $0x1, -0x18(%rbp)
jmp 0x4c3e
leaq -0x50(%rbp), %rdi
callq 0x4ee0
movl %eax, -0x4(%rbp)
jmp 0x4ec6
leaq -0x50(%rbp), %rdi
callq 0x4ee0
movl -0x54(%rbp), %esi
leaq 0x707c8(%rip), %rdi     # 0x753ff
movb $0x0, %al
callq 0x4270
jmp 0x4a81
movq 0x80376(%rip), %rax     # 0x84fc0
movl (%rax), %eax
cmpl -0x8(%rbp), %eax
jle 0x4c6f
cmpq $0x0, -0x80(%rbp)
jne 0x4c6f
leaq -0x50(%rbp), %rdi
callq 0x4ee0
leaq 0x707b1(%rip), %rdi     # 0x75419
movb $0x0, %al
callq 0x4270
movl $0x0, -0x84(%rbp)
movq $0x0, -0x90(%rbp)
movl $0x0, -0x94(%rbp)
movq $0x0, -0xa0(%rbp)
movl $0x0, -0xa4(%rbp)
movq $0x0, -0xb0(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movq 0x80304(%rip), %rax     # 0x84fc0
movl (%rax), %edx
leaq -0xb0(%rbp), %rcx
leaq -0xa4(%rbp), %r8
callq 0x51a0
movq -0x80(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
leaq -0xa4(%rbp), %rdx
callq 0x53a0
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0xa4(%rbp), %eax
jge 0x4d39
movq -0xb0(%rbp), %rdi
movslq -0xb4(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
leaq -0xa0(%rbp), %rsi
leaq -0x94(%rbp), %rdx
callq 0x4650
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x4cf2
movq -0xa0(%rbp), %rdi
movl -0x94(%rbp), %esi
leaq -0x78(%rbp), %rdx
callq 0x54b0
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
leaq -0x84(%rbp), %rdx
callq 0x5640
movq %rax, -0x90(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x4da8
movq -0x78(%rbp), %rdi
movq -0x90(%rbp), %rsi
movl -0x84(%rbp), %edx
movq -0xa0(%rbp), %rcx
movl -0x94(%rbp), %r8d
movq -0x70(%rbp), %rax
leaq -0x50(%rbp), %r9
movq %rax, (%rsp)
callq 0x7470
movl %eax, -0xb8(%rbp)
jmp 0x4dde
movq -0x78(%rbp), %rdi
movq -0x90(%rbp), %rsi
movl -0x84(%rbp), %edx
movq -0xa0(%rbp), %rcx
movl -0x94(%rbp), %r8d
movq -0x70(%rbp), %rax
leaq -0x50(%rbp), %r9
movq %rax, (%rsp)
callq 0x58d0
movl %eax, -0xb8(%rbp)
cmpl $0x0, -0xa4(%rbp)
jle 0x4e36
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0xa4(%rbp), %eax
jge 0x4e2a
movq -0xb0(%rbp), %rdi
movslq -0xb4(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0x5c80
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x4df1
movq -0xb0(%rbp), %rdi
callq 0x3370
cmpl $0x0, -0x94(%rbp)
jle 0x4e94
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x4e88
movq -0xa0(%rbp), %rax
movslq -0xb4(%rbp), %rcx
imulq $0x2028, %rcx, %rcx     # imm = 0x2028
addq %rcx, %rax
movq (%rax), %rdi
callq 0x3370
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x4e49
movq -0xa0(%rbp), %rdi
callq 0x3370
cmpq $0x0, -0x78(%rbp)
je 0x4ea4
movq -0x78(%rbp), %rdi
callq 0x3370
movq -0x38(%rbp), %rdi
callq 0x3370
cmpq $0x0, -0x68(%rbp)
je 0x4ebd
movq -0x68(%rbp), %rdi
callq 0x3370
movl -0xb8(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)