// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movq %rsi, %r15
movl %edi, %r12d
movq $0x0, 0x20(%rsp)
movq 0x8b70(%rip), %rax      # 0xafe0
movl $0x0, (%rax)
xorl %ebp, %ebp
leaq 0x4bb1(%rip), %rbx      # 0x7030
leaq 0x4b7e(%rip), %r13      # 0x7004
movq 0x8b1b(%rip), %r14      # 0xafa8
movl $0x0, 0x4(%rsp)
movq $0x0, 0x10(%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0xc(%rsp)
movl %r12d, %edi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x2080
cmpl $0x6b, %eax
jle 0x24e3
addl $-0x6c, %eax
cmpl $0xa, %eax
ja 0x24ae
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movq (%r14), %rdi
callq 0x2270
movl %eax, 0x8c8f(%rip)      # 0xb170
jmp 0x24ae
cmpl $-0x1, %eax
je 0x2538
cmpl $0x66, %eax
je 0x252b
cmpl $0x3f, %eax
jne 0x24ae
jmp 0x2653
movq (%r14), %rdi
callq 0x2270
movslq %eax, %rbp
jmp 0x24ae
movq (%r14), %rdi
callq 0x2270
movl %eax, 0xc(%rsp)
jmp 0x24ae
movl $0x1, 0x8(%rsp)
jmp 0x24ae
movq (%r14), %rdi
callq 0x305c
movq %rax, 0x10(%rsp)
jmp 0x24ae
movl $0x1, 0x4(%rsp)
jmp 0x24ae
testq %rbp, %rbp
movl $0x3, %eax
cmovneq %rbp, %rax
movq %rax, 0x18(%rsp)
movl 0xc(%rsp), %ebp
testl %ebp, %ebp
jne 0x2565
movl $0x54, %edi
callq 0x2100
testl %eax, %eax
movl $0x2, %ebp
cmovnel %eax, %ebp
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2579
callq 0x2aa8
movq %rax, %rbx
jmp 0x25ac
movq 0x8a50(%rip), %rax      # 0xafd0
movslq (%rax), %rax
cmpl %r12d, %eax
jge 0x265a
movq (%r15,%rax,8), %rdi
callq 0x2b99
testq %rax, %rax
je 0x2661
movq %rax, %rbx
cmpq $0x0, 0x8(%rax)
je 0x266e
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x312c
movq %rax, %r12
movq %rax, %rdi
movl %ebp, %esi
callq 0x3169
leaq 0x18(%rsp), %rsi
movq %r12, %rdi
callq 0x3162
leaq 0xc3(%rip), %rsi        # 0x269a
movq %r12, %rdi
callq 0x316d
leaq 0x2bd(%rip), %rsi       # 0x28a3
movq %r12, %rdi
callq 0x316d
movq %r12, %rdi
movq %rbx, %rsi
callq 0x31cb
movq %r12, %rdi
movq %rbx, %rsi
callq 0x31c6
movq %r12, %rdi
callq 0x322d
testq %rax, %rax
je 0x267b
movq %rax, %r14
movq %rax, %rdi
movl 0x8(%rsp), %esi
movl 0x4(%rsp), %edx
callq 0x3585
movq %r14, %rdi
callq 0x31d1
testq %rbx, %rbx
je 0x2641
movq %rbx, %rdi
callq 0x2d65
movq %rbx, %rdi
callq 0x22c8
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x22e0
jmp 0x2666
callq 0x22fe
jmp 0x2666
callq 0x2338
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x2641
callq 0x231c
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x2631
leaq 0x4b9d(%rip), %rdi      # 0x721f
leaq 0x49db(%rip), %rsi      # 0x7064
leaq 0x49e1(%rip), %rcx      # 0x7071
movl $0xc3, %edx
callq 0x2110