// File: /workspace/github_c_makefile_star2_O3/tomcatzh[P]RealityBenchmark/aes_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;
  char mode[4];
  mode[0] = '\0';

  int index;
  int c;
  opterr = 0;

  while ((c = getopt(argc, argv, "r:t:vfu:k:c:")) != -1) {
    switch (c) {
    case 'r':
      timeout.tv_sec = atoi(optarg);
      break;
    case 't':
      threads = atoi(optarg);
      break;
    case 'u':
      randomSize = parseHumanSize(optarg);
      break;
    case 'v':
      verbose = 1;
      break;
    case 'f':
      formated = 1;
      break;
    case 'k':
      keyLength = atoi(optarg);
      break;
    case 'c':
      strncpy(mode, optarg, sizeof(mode));
      mode[3] = '\0';
      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;
  }

  switch (keyLength) {
  case 128:
  case 0:
    keyLength = keyLength128Bit;
    break;
  case 192:
    keyLength = keyLength192Bit;
    break;
  case 256:
    keyLength = keyLength256Bit;
    break;
  default:
    printUsage();
    goto END;
  }

  if (mode[0] == '\0' || strcmp(mode, "CBC") == 0) {
    cipherMode = cipherModeCBC;
  } else if (strcmp(mode, "CFB") == 0) {
    cipherMode = cipherModeCFB;
  } else if (strcmp(mode, "OFB") == 0) {
    cipherMode = cipherModeOFB;
  } else if (strcmp(mode, "CTR") == 0) {
    cipherMode = cipherModeCTR;
  } else if (strcmp(mode, "GCM") == 0) {
    cipherMode = cipherModeGCM;
    ivLength = 12;
    tagLength = 16;
  } else if (strcmp(mode, "CCM") == 0) {
    cipherMode = cipherModeCCM;
    ivLength = 7;
    tagLength = 12;
  } else {
    printUsage();
    goto END;
  }

  init();

  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, &encryptContent);
  testAddRun(t, &decryptContent);
  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)
leaq 0x8(%rsp), %rax
movb $0x0, (%rax)
movq 0x99a9(%rip), %rax      # 0xbfe0
movl $0x0, (%rax)
xorl %ebx, %ebx
leaq 0x5a42(%rip), %rbp      # 0x8088
movq 0x995b(%rip), %r14      # 0xbfa8
leaq 0x59b0(%rip), %r13      # 0x8004
movl $0x0, 0xc(%rsp)
movq $0x0, 0x18(%rsp)
movl $0x0, 0x10(%rsp)
movl $0x0, 0x14(%rsp)
movl %r12d, %edi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x20a0
cmpl $0x65, %eax
jle 0x26aa
leal -0x6b(%rax), %ecx
cmpl $0xb, %ecx
ja 0x26c8
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movq (%r14), %rdi
callq 0x2350
movl %eax, 0x9ba8(%rip)      # 0xc250
jmp 0x2675
cmpl $0x63, %eax
jne 0x26d7
movq (%r14), %rsi
movl $0x4, %edx
leaq 0x8(%rsp), %rdi
callq 0x2110
movb $0x0, 0xb(%rsp)
jmp 0x2675
cmpl $0x66, %eax
jne 0x2675
movl $0x1, 0xc(%rsp)
jmp 0x2675
cmpl $-0x1, %eax
je 0x2728
cmpl $0x3f, %eax
jne 0x2675
jmp 0x2998
movl $0x1, 0x10(%rsp)
jmp 0x2675
movq (%r14), %rdi
callq 0x2350
movl %eax, 0x14(%rsp)
jmp 0x2675
movq (%r14), %rdi
callq 0x3cbc
movq %rax, 0x18(%rsp)
jmp 0x2675
movq (%r14), %rdi
callq 0x2350
movslq %eax, %rbx
movq %rbx, 0x20(%rsp)
jmp 0x2675
testq %rbx, %rbx
jne 0x2736
movq $0x3, 0x20(%rsp)
movl 0x14(%rsp), %r14d
testl %r14d, %r14d
jne 0x2756
movl $0x54, %edi
callq 0x2180
testl %eax, %eax
movl $0x2, %r14d
cmovnel %eax, %r14d
movl 0x9af4(%rip), %eax      # 0xc250
roll $0x1a, %eax
cmpl $0x5, %eax
jae 0x2982
movl $0x1d, %ecx
btl %eax, %ecx
jae 0x2982
movl %eax, %eax
leaq 0x58f5(%rip), %rcx      # 0x8074
movl (%rcx,%rax,4), %eax
movl %eax, 0x9ac8(%rip)      # 0xc250
cmpb $0x0, 0x8(%rsp)
je 0x27f9
cmpl $0x434243, 0x8(%rsp)    # imm = 0x434243
je 0x27f9
cmpl $0x424643, 0x8(%rsp)    # imm = 0x424643
je 0x2973
cmpl $0x42464f, 0x8(%rsp)    # imm = 0x42464F
je 0x2989
cmpl $0x525443, 0x8(%rsp)    # imm = 0x525443
je 0x299f
cmpl $0x4d4347, 0x8(%rsp)    # imm = 0x4D4347
je 0x29ae
cmpl $0x4d4343, 0x8(%rsp)    # imm = 0x4D4343
jne 0x29fc
movl $0x20, 0x9a6b(%rip)     # 0xc254
xorl %eax, %eax
movb %al, 0x9a67(%rip)       # 0xc258
movb %al, 0x9a65(%rip)       # 0xc25c
jmp 0x2803
movl $0x1, 0x9a51(%rip)      # 0xc254
leaq 0x5a5a(%rip), %rdi      # 0x8264
xorl %esi, %esi
xorl %eax, %eax
callq 0x21b0
testl %eax, %eax
js 0x2a03
movl %eax, %ebx
movl 0x9a2d(%rip), %edx      # 0xc250
leaq 0x9a36(%rip), %rsi      # 0xc260
movl %eax, %edi
callq 0x2300
movl 0x9a19(%rip), %ecx      # 0xc250
cmpq %rcx, %rax
jne 0x2a22
leaq 0x9a39(%rip), %rsi      # 0xc280
movl $0x10, %edx
movl %ebx, %edi
callq 0x2300
cmpq $0x10, %rax
jne 0x2a41
movl 0x99f1(%rip), %eax      # 0xc254
cmpl $0x20, %eax
je 0x286d
cmpl $0x10, %eax
jne 0x288a
leaq 0x9a1c(%rip), %rsi      # 0xc290
movl $0x20, %edx
movl %ebx, %edi
callq 0x2300
cmpq $0x20, %rax
jne 0x2a7f
movl %ebx, %edi
callq 0x2410
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x28a5
callq 0x3708
movq %rax, %rbx
jmp 0x28d8
movq 0x9724(%rip), %rax      # 0xbfd0
movslq (%rax), %rax
cmpl %r12d, %eax
jge 0x29cb
movq (%r15,%rax,8), %rdi
callq 0x37f9
testq %rax, %rax
je 0x29d2
movq %rax, %rbx
cmpq $0x0, 0x8(%rax)
je 0x29ed
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x3d8c
movq %rax, %r15
movq %rax, %rdi
movl %r14d, %esi
callq 0x3dc9
leaq 0x20(%rsp), %rsi
movq %r15, %rdi
callq 0x3dc2
leaq 0x19b(%rip), %rsi       # 0x2a9e
movq %r15, %rdi
callq 0x3dcd
leaq 0x6ee(%rip), %rsi       # 0x3000
movq %r15, %rdi
callq 0x3dcd
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3e2b
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3e26
movq %r15, %rdi
callq 0x3e8d
testq %rax, %rax
je 0x2a60
movq %rax, %r14
movq %rax, %rdi
movl 0x10(%rsp), %esi
movl 0xc(%rsp), %edx
callq 0x41e5
movq %r14, %rdi
callq 0x3e31
testq %rbx, %rbx
je 0x29dc
movq %rbx, %rdi
callq 0x39c5
movq %rbx, %rdi
callq 0x2428
jmp 0x29dc
movl $0x2, 0x98d7(%rip)      # 0xc254
jmp 0x2803
callq 0x2464
jmp 0x29d7
movl $0x4, 0x98c1(%rip)      # 0xc254
jmp 0x2803
callq 0x2440
jmp 0x29d7
movl $0x8, 0x98ab(%rip)      # 0xc254
jmp 0x2803
movl $0x10, 0x989c(%rip)     # 0xc254
movb $0x1, %al
movb %al, 0x9898(%rip)       # 0xc258
movb %al, 0x9896(%rip)       # 0xc25c
jmp 0x2803
callq 0x24ac
jmp 0x29d7
callq 0x24f2
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x24d0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x2961
callq 0x2488
jmp 0x29d7
leaq 0x5867(%rip), %rdi      # 0x8271
leaq 0x56c5(%rip), %rsi      # 0x80d6
leaq 0x5861(%rip), %rcx      # 0x8279
movl $0x26, %edx
callq 0x2190
leaq 0x585c(%rip), %rdi      # 0x8285
leaq 0x56a6(%rip), %rsi      # 0x80d6
leaq 0x5842(%rip), %rcx      # 0x8279
movl $0x2b, %edx
callq 0x2190
leaq 0x584e(%rip), %rdi      # 0x8296
leaq 0x5687(%rip), %rsi      # 0x80d6
leaq 0x5823(%rip), %rcx      # 0x8279
movl $0x2e, %edx
callq 0x2190
leaq 0x59fe(%rip), %rdi      # 0x8465
leaq 0x5668(%rip), %rsi      # 0x80d6
leaq 0x566d(%rip), %rcx      # 0x80e2
movl $0x1f5, %edx            # imm = 0x1F5
callq 0x2190
leaq 0x5822(%rip), %rdi      # 0x82a8
leaq 0x5649(%rip), %rsi      # 0x80d6
leaq 0x57e5(%rip), %rcx      # 0x8279
movl $0x32, %edx
callq 0x2190