// File: /workspace/github_cpp_makefile_star2_O2/4n6ist[P]usn_analytics/src/main.cpp
// Function: main
int main(int argc, char **argv) {
    
  char *ifname = NULL;
  char *odname = NULL;
  timer measure_time;

  int opt;
  int longindex;
  
  struct option longopts[] = {
    {"help", no_argument, NULL, 'h'},
    {"output", required_argument, NULL, 'o'},
    {"raw", no_argument, NULL, 'r'}, 
    {"utc", no_argument, NULL, 'u'}, 
    {0, 0, 0, 0},
  };

  while((opt = getopt_long(argc, argv, "ho:ru", longopts, &longindex)) != -1) {
    switch(opt) {     
      case 'h':
        usage();
        exit(EXIT_FAILURE);
      case 'o':
        odname = optarg;
        break;
      case 'r':
        raw = true;
        break;
      case 'u':
        lt = false;
        break;
    }
  }
  for (int i = optind; i < argc; i++)
    ifname = argv[i];

  if (!ifname || !odname) {
    usage();
    exit(EXIT_FAILURE);
  }
  
  struct stat st;
  if (is_empty_dir(odname) == false) {
    if (stat(odname, &st) == 0) {
      std::cout << odname << " already exist" << std::endl;
      std::cout << "Please specify a empty directory or new directory" << std::endl;
      exit(EXIT_FAILURE);
    }
    int dresult;
    // try to create directory
#ifdef _WIN32
    dresult = _mkdir(odname);
#else
    dresult = mkdir(odname, 0775);
#endif

    if(dresult != 0) {
      std::cout << "unable to create " << odname << std::endl;
      std::cout << "Please check existence of parent directory and/or permissions" << std::endl;
      exit(EXIT_FAILURE);
    }
  } 

  process(ifname, odname);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %r14
movl %edi, %ebp
leaq 0x10(%rsp), %rdi
callq 0xa5d8
leaq 0x6153(%rip), %rsi      # 0x11d00
leaq 0xb0(%rsp), %r15
movl $0xa0, %edx
movq %r15, %rdi
callq 0x31e0
xorl %ebx, %ebx
leaq 0xddd(%rip), %r12       # 0xc9a8
leaq 0xc(%rsp), %r13
movl %ebp, %edi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
movq %r13, %r8
callq 0x3460
cmpl $0x72, %eax
je 0xbc0a
cmpl $0x75, %eax
je 0xbc01
cmpl $-0x1, %eax
je 0xbc1f
cmpl $0x6f, %eax
je 0xbc13
cmpl $0x68, %eax
jne 0xbbd0
jmp 0xbc9e
movb $0x0, 0x6690(%rip)      # 0x12298
jmp 0xbbd0
movb $0x1, 0x668e(%rip)      # 0x1229f
jmp 0xbbd0
movq 0x639e(%rip), %rax      # 0x11fb8
movq (%rax), %rbx
jmp 0xbbd0
movq 0x63aa(%rip), %rax      # 0x11fd0
movslq (%rax), %rax
movslq %ebp, %rcx
xorl %r15d, %r15d
cmpq %rcx, %rax
jge 0xbc3d
movq (%r14,%rax,8), %r15
incq %rax
jmp 0xbc2f
testq %r15, %r15
je 0xbc9e
testq %rbx, %rbx
je 0xbc9e
movq %rbx, %rdi
callq 0xa644
testb %al, %al
jne 0xbc75
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x3220
testl %eax, %eax
je 0xbcab
movq %rbx, %rdi
movl $0x1fd, %esi            # imm = 0x1FD
callq 0x3110
testl %eax, %eax
jne 0xbcee
movq %r15, %rdi
movq %rbx, %rsi
callq 0xba62
leaq 0x10(%rsp), %rdi
callq 0xa5f2
xorl %eax, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xba18
pushq $0x1
popq %rdi
callq 0x3310
movq 0x6316(%rip), %rdi      # 0x11fc8
movq %rbx, %rsi
callq 0x3240
leaq 0xced(%rip), %rsi       # 0xc9ae
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3120
movq 0x62f0(%rip), %rdi      # 0x11fc8
leaq 0xcde(%rip), %rsi       # 0xc9bd
callq 0x3240
movq %rax, %rdi
callq 0x3120
jmp 0xbca3
movq 0x62d3(%rip), %rdi      # 0x11fc8
leaq 0xcf3(%rip), %rsi       # 0xc9ef
callq 0x3240
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3240
movq %rax, %rdi
callq 0x3120
movq 0x62ad(%rip), %rdi      # 0x11fc8
leaq 0xcdf(%rip), %rsi       # 0xca01
callq 0x3240
movq %rax, %rdi
callq 0x3120
jmp 0xbca3
jmp 0xbd36
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xa5f2
movq %rbx, %rdi
callq 0x3480