// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, 0x20(%rsp)
movq 0x8bf3(%rip), %rax      # 0xafe0
andl $0x0, (%rax)
xorl %ebp, %ebp
leaq 0x4c37(%rip), %rbx      # 0x7030
leaq 0x4c04(%rip), %r13      # 0x7004
movq 0x8ba1(%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
leal -0x6c(%rax), %ecx
cmpl $0xa, %ecx
ja 0x2458
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movq (%r14), %rdi
callq 0x2270
movl %eax, 0x8d1a(%rip)      # 0xb170
jmp 0x2428
cmpl $-0x1, %eax
je 0x24a7
cmpl $0x3f, %eax
je 0x25b0
cmpl $0x66, %eax
jne 0x2428
pushq $0x1
popq %rax
movl %eax, 0x4(%rsp)
jmp 0x2428
pushq $0x1
popq %rax
movl %eax, 0x8(%rsp)
jmp 0x2428
movq (%r14), %rdi
callq 0x2f16
movq %rax, 0x10(%rsp)
jmp 0x2428
movq (%r14), %rdi
callq 0x2270
movslq %eax, %rbp
jmp 0x2428
movq (%r14), %rdi
callq 0x2270
movl %eax, 0xc(%rsp)
jmp 0x2428
testq %rbp, %rbp
pushq $0x3
popq %rax
cmovneq %rbp, %rax
movq %rax, 0x18(%rsp)
movl 0xc(%rsp), %ebp
testl %ebp, %ebp
jne 0x24ce
pushq $0x54
popq %rdi
callq 0x2100
testl %eax, %eax
pushq $0x2
popq %rbp
cmovnel %eax, %ebp
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x24e2
callq 0x2a00
movq %rax, %rbx
jmp 0x2515
movq 0x8ae7(%rip), %rax      # 0xafd0
movslq (%rax), %rax
cmpl %r12d, %eax
jge 0x25b0
movq (%r15,%rax,8), %rdi
callq 0x2ad9
testq %rax, %rax
je 0x25cb
movq %rax, %rbx
cmpq $0x0, 0x8(%rax)
je 0x25e9
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x2fd0
movq %rax, %r12
movq %rax, %rdi
movl %ebp, %esi
callq 0x3007
leaq 0x18(%rsp), %rsi
movq %r12, %rdi
callq 0x3000
leaq 0xea(%rip), %rsi        # 0x262a
movq %r12, %rdi
callq 0x300b
leaq 0x2bb(%rip), %rsi       # 0x280a
movq %r12, %rdi
callq 0x300b
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3067
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3062
movq %r12, %rdi
callq 0x30c0
testq %rax, %rax
je 0x260b
movq %rax, %r14
movq %rax, %rdi
movl 0x8(%rsp), %esi
movl 0x4(%rsp), %edx
callq 0x33dd
movq %r14, %rdi
callq 0x306d
testq %rbx, %rbx
je 0x25b9
movq %rbx, %rdi
callq 0x2c7e
movq %rbx, %rdi
callq 0x22c8
jmp 0x25b9
callq 0x29e1
pushq $-0x1
popq %r15
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x89f6(%rip), %rax      # 0xafc8
movq (%rax), %rcx
leaq 0x4a5f(%rip), %rdi      # 0x703b
pushq $0x12
popq %rsi
pushq $0x1
popq %rdx
callq 0x22a0
jmp 0x25b5
movq 0x89d8(%rip), %rax      # 0xafc8
movq (%rax), %rcx
leaq 0x4a54(%rip), %rdi      # 0x704e
pushq $0x15
popq %rsi
pushq $0x1
popq %rdx
callq 0x22a0
pushq $-0x1
popq %r15
jmp 0x259e
leaq 0x4c0d(%rip), %rdi      # 0x721f
leaq 0x4a4b(%rip), %rsi      # 0x7064
leaq 0x4a51(%rip), %rcx      # 0x7071
movl $0xc3, %edx
callq 0x2110