// File: /workspace/github_c_makefile_star2_O1/tomcatzh[P]RealityBenchmark/zlib_bench.c
// Function: main
int main(int argc, char **argv) {
  int ret = -1;
  CONTENTS *contents = NULL;

  struct timeval timeout;
  timeout.tv_sec = 0;
  timeout.tv_usec = 0;
  unsigned int threads = 0;
  int verbose = 0;
  int formated = 0;
  size_t randomSize = 0;

  int index;
  int c;
  opterr = 0;

  while ((c = getopt(argc, argv, "r:t:l:vfu:")) != -1) {
    switch (c) {
    case 'r':
      timeout.tv_sec = atoi(optarg);
      break;
    case 't':
      threads = atoi(optarg);
      break;
    case 'l':
      level = atoi(optarg);
      break;
    case 'u':
      randomSize = parseHumanSize(optarg);
      break;
    case 'v':
      verbose = 1;
      break;
    case 'f':
      formated = 1;
      break;
    case '?':
      printUsage();
      goto END;
    }
  }

  if (timeout.tv_sec == 0) {
    timeout.tv_sec = 3;
  }

  if (threads == 0) {
    threads = sysconf(_SC_NPROCESSORS_ONLN);
    if (threads == 0) 
      threads = 2;
  }

  if (randomSize) {
    contents = randomContents(randomSize);
  } else {
    index = optind;
    if (index >= argc) {
      printUsage();
      goto END;
    }

    contents = getContents(argv[index]);

    if (contents == NULL) {
      fprintf(stderr, "Get content error\n");
      goto END;
    } else if (contents->size == 0) {
      fprintf(stderr, "Empty content to zip\n");
      goto END;
    }
  }
  

  TEST *t = testNew();
  testSetThreads(t, threads);
  testSetTimeout(t, &timeout);
  testAddRun(t, &deflateContent);
  testAddRun(t, &inflateContent);
  testSetInput(t, contents);
  testSetTesting(t, contents);

  RESULT *r = testRun(t);
  assert(r);

  printResult(r, verbose, formated);

  resultDestory(r);
  
  ret = 0;

END:
  if (contents) {
    destroyContents(contents);
    free(contents);
    contents = NULL;
  }
  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r15
movl %edi, %r12d
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x8b61(%rip), %rax      # 0xafe0
movl $0x0, (%rax)
movq $0x0, 0x10(%rsp)
leaq 0x4b9b(%rip), %rbx      # 0x7030
leaq 0x4b68(%rip), %rbp      # 0x7004
movq 0x8b05(%rip), %r13      # 0xafa8
movq $0x0, 0x18(%rsp)
movl $0x0, 0xc(%rsp)
xorl %r14d, %r14d
movl %r12d, %edi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x2080
cmpl $0x6b, %eax
jle 0x24ff
addl $-0x6c, %eax
cmpl $0xa, %eax
ja 0x24b7
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movq (%r13), %rdi
callq 0x2280
movl %eax, 0x8c8d(%rip)      # 0xb178
jmp 0x24b7
movq (%r13), %rdi
callq 0x2280
cltq
movq %rax, 0x20(%rsp)
jmp 0x24b7
cmpl $-0x1, %eax
je 0x254d
cmpl $0x66, %eax
je 0x253e
cmpl $0x3f, %eax
jne 0x24b7
jmp 0x266a
movl $0x1, 0xc(%rsp)
jmp 0x24b7
movq (%r13), %rdi
callq 0x3061
movq %rax, 0x18(%rsp)
jmp 0x24b7
movq (%r13), %rdi
callq 0x2280
movl %eax, %r14d
jmp 0x24b7
movl $0x1, %eax
movq %rax, 0x10(%rsp)
jmp 0x24b7
cmpq $0x0, 0x20(%rsp)
jne 0x255e
movq $0x3, 0x20(%rsp)
testl %r14d, %r14d
movq 0x18(%rsp), %rbx
jne 0x257e
movl $0x54, %edi
callq 0x2100
testl %eax, %eax
movl $0x2, %r14d
cmovnel %eax, %r14d
testq %rbx, %rbx
je 0x2590
movq %rbx, %rdi
callq 0x2ab0
movq %rax, %r15
jmp 0x25c3
movq 0x8a39(%rip), %rax      # 0xafd0
movslq (%rax), %rax
cmpl %r12d, %eax
jge 0x2671
movq (%r15,%rax,8), %rdi
callq 0x2ba1
testq %rax, %rax
je 0x2678
movq %rax, %r15
cmpq $0x0, 0x8(%rax)
je 0x2687
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x3148
movq %rax, %r12
movq %rax, %rdi
movl %r14d, %esi
callq 0x318d
leaq 0x20(%rsp), %rsi
movq %r12, %rdi
callq 0x317e
leaq 0xc4(%rip), %rsi        # 0x26b2
movq %r12, %rdi
callq 0x3191
leaq 0x2b2(%rip), %rsi       # 0x28af
movq %r12, %rdi
callq 0x3191
movq %r12, %rdi
movq %r15, %rsi
callq 0x31ef
movq %r12, %rdi
movq %r15, %rsi
callq 0x31ea
movq %r12, %rdi
callq 0x3251
testq %rax, %rax
je 0x2693
movq %rax, %r14
movq %rax, %rdi
movl 0xc(%rsp), %esi
movq 0x10(%rsp), %rdx
callq 0x3590
movq %r14, %rdi
callq 0x31f5
testq %r15, %r15
je 0x2659
movq %r15, %rdi
callq 0x2d6d
movq %r15, %rdi
callq 0x22d8
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x22f0
jmp 0x267d
callq 0x230e
jmp 0x267d
callq 0x2348
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %r15d, %r15d
jmp 0x2644
callq 0x232c
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x2644
leaq 0x4b85(%rip), %rdi      # 0x721f
leaq 0x49c3(%rip), %rsi      # 0x7064
leaq 0x49c9(%rip), %rcx      # 0x7071
movl $0xc3, %edx
callq 0x2110