// File: /workspace/github_c_makefile_star2_O1/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 0x9999(%rip), %rax      # 0xbfe0
movl $0x0, (%rax)
movq $0x0, 0x10(%rsp)
leaq 0x5a2b(%rip), %rbp      # 0x8088
movq 0x9944(%rip), %r14      # 0xbfa8
leaq 0x5999(%rip), %r13      # 0x8004
movq $0x0, 0x18(%rsp)
movl $0x0, 0xc(%rsp)
xorl %ebx, %ebx
movl %r12d, %edi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x20a0
cmpl $0x65, %eax
jle 0x26b3
leal -0x6b(%rax), %ecx
cmpl $0xb, %ecx
ja 0x26d1
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movq (%r14), %rdi
callq 0x2360
movl %eax, 0x9b9f(%rip)      # 0xc250
jmp 0x267e
cmpl $0x63, %eax
jne 0x26e2
movq (%r14), %rsi
movl $0x4, %edx
leaq 0x8(%rsp), %rdi
callq 0x2110
movb $0x0, 0xb(%rsp)
jmp 0x267e
cmpl $0x66, %eax
jne 0x267e
movl $0x1, %eax
movq %rax, 0x10(%rsp)
jmp 0x267e
cmpl $-0x1, %eax
je 0x2730
cmpl $0x3f, %eax
jne 0x267e
jmp 0x298c
movl $0x1, 0xc(%rsp)
jmp 0x267e
movq (%r14), %rdi
callq 0x2360
movl %eax, %ebx
jmp 0x267e
movq (%r14), %rdi
callq 0x3cc5
movq %rax, 0x18(%rsp)
jmp 0x267e
movq (%r14), %rdi
callq 0x2360
cltq
movq %rax, 0x20(%rsp)
jmp 0x267e
cmpq $0x0, 0x20(%rsp)
jne 0x2741
movq $0x3, 0x20(%rsp)
movl %ebx, %r14d
testl %ebx, %ebx
jne 0x275e
movl $0x54, %edi
callq 0x2180
testl %eax, %eax
movl $0x2, %r14d
cmovnel %eax, %r14d
movl 0x9aec(%rip), %eax      # 0xc250
roll $0x1a, %eax
cmpl $0x5, %eax
jae 0x2976
movl $0x1d, %ecx
btl %eax, %ecx
jae 0x2976
movl %eax, %eax
leaq 0x58ed(%rip), %rcx      # 0x8074
movl (%rcx,%rax,4), %eax
movl %eax, 0x9ac0(%rip)      # 0xc250
cmpb $0x0, 0x8(%rsp)
je 0x2801
cmpl $0x434243, 0x8(%rsp)    # imm = 0x434243
je 0x2801
cmpl $0x424643, 0x8(%rsp)    # imm = 0x424643
je 0x2967
cmpl $0x42464f, 0x8(%rsp)    # imm = 0x42464F
je 0x297d
cmpl $0x525443, 0x8(%rsp)    # imm = 0x525443
je 0x2993
cmpl $0x4d4347, 0x8(%rsp)    # imm = 0x4D4347
je 0x29a2
cmpl $0x4d4343, 0x8(%rsp)    # imm = 0x4D4343
jne 0x2a04
movl $0x20, 0x9a63(%rip)     # 0xc254
xorl %eax, %eax
movb %al, 0x9a5f(%rip)       # 0xc258
movb %al, 0x9a5d(%rip)       # 0xc25c
jmp 0x280b
movl $0x1, 0x9a49(%rip)      # 0xc254
leaq 0x5a52(%rip), %rdi      # 0x8264
xorl %esi, %esi
xorl %eax, %eax
callq 0x21b0
testl %eax, %eax
js 0x2a0b
movl %eax, %ebx
movl 0x9a25(%rip), %edx      # 0xc250
leaq 0x9a2e(%rip), %rsi      # 0xc260
movl %eax, %edi
callq 0x2310
movl 0x9a11(%rip), %ecx      # 0xc250
cmpq %rcx, %rax
jne 0x2a2a
leaq 0x9a31(%rip), %rsi      # 0xc280
movl $0x10, %edx
movl %ebx, %edi
callq 0x2310
cmpq $0x10, %rax
jne 0x2a49
movl 0x99e9(%rip), %eax      # 0xc254
cmpl $0x20, %eax
je 0x2875
cmpl $0x10, %eax
jne 0x2892
leaq 0x9a14(%rip), %rsi      # 0xc290
movl $0x20, %edx
movl %ebx, %edi
callq 0x2310
cmpq $0x20, %rax
jne 0x2a87
movl %ebx, %edi
callq 0x2420
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x28ad
callq 0x3714
movq %rax, %rbx
jmp 0x28e0
movq 0x971c(%rip), %rax      # 0xbfd0
movslq (%rax), %rax
cmpl %r12d, %eax
jge 0x29bf
movq (%r15,%rax,8), %rdi
callq 0x3805
testq %rax, %rax
je 0x29c6
movq %rax, %rbx
cmpq $0x0, 0x8(%rax)
je 0x29f8
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x3dac
movq %rax, %r15
movq %rax, %rdi
movl %r14d, %esi
callq 0x3df1
leaq 0x20(%rsp), %rsi
movq %r15, %rdi
callq 0x3de2
leaq 0x19b(%rip), %rsi       # 0x2aa6
movq %r15, %rdi
callq 0x3df5
leaq 0x6f8(%rip), %rsi       # 0x3012
movq %r15, %rdi
callq 0x3df5
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3e53
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3e4e
movq %r15, %rdi
callq 0x3eb5
testq %rax, %rax
je 0x2a68
movq %rax, %r14
movq %rax, %rdi
movl 0xc(%rsp), %esi
movq 0x10(%rsp), %rdx
callq 0x41f4
movq %r14, %rdi
callq 0x3e59
jmp 0x29d2
movl $0x2, 0x98e3(%rip)      # 0xc254
jmp 0x280b
callq 0x2474
jmp 0x29cb
movl $0x4, 0x98cd(%rip)      # 0xc254
jmp 0x280b
callq 0x2450
jmp 0x29cb
movl $0x8, 0x98b7(%rip)      # 0xc254
jmp 0x280b
movl $0x10, 0x98a8(%rip)     # 0xc254
movb $0x1, %al
movb %al, 0x98a4(%rip)       # 0xc258
movb %al, 0x98a2(%rip)       # 0xc25c
jmp 0x280b
callq 0x24bc
jmp 0x29cb
callq 0x2502
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x29e7
movq %rbx, %rdi
callq 0x39d1
movq %rbx, %rdi
callq 0x2438
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x24e0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x29d2
callq 0x2498
jmp 0x29cb
leaq 0x585f(%rip), %rdi      # 0x8271
leaq 0x56bd(%rip), %rsi      # 0x80d6
leaq 0x5859(%rip), %rcx      # 0x8279
movl $0x26, %edx
callq 0x2190
leaq 0x5854(%rip), %rdi      # 0x8285
leaq 0x569e(%rip), %rsi      # 0x80d6
leaq 0x583a(%rip), %rcx      # 0x8279
movl $0x2b, %edx
callq 0x2190
leaq 0x5846(%rip), %rdi      # 0x8296
leaq 0x567f(%rip), %rsi      # 0x80d6
leaq 0x581b(%rip), %rcx      # 0x8279
movl $0x2e, %edx
callq 0x2190
leaq 0x59f6(%rip), %rdi      # 0x8465
leaq 0x5660(%rip), %rsi      # 0x80d6
leaq 0x5665(%rip), %rcx      # 0x80e2
movl $0x1f5, %edx            # imm = 0x1F5
callq 0x2190
leaq 0x581a(%rip), %rdi      # 0x82a8
leaq 0x5641(%rip), %rsi      # 0x80d6
leaq 0x57dd(%rip), %rcx      # 0x8279
movl $0x32, %edx
callq 0x2190