// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq $0x0, -0x48(%rbp)
movb $0x0, -0x4c(%rbp)
movq 0xda20(%rip), %rax      # 0xffe0
movl $0x0, (%rax)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x9c10(%rip), %rdx      # 0xc1e4
callq 0x20a0
movl %eax, -0x54(%rbp)
cmpl $-0x1, %eax
je 0x26a4
movl -0x54(%rbp), %eax
addl $-0x3f, %eax
movl %eax, %ecx
movq %rcx, -0x70(%rbp)
subl $0x37, %eax
ja 0x269f
movq -0x70(%rbp), %rax
leaq 0x99ff(%rip), %rcx      # 0xc004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0xd993(%rip), %rax      # 0xffa8
movq (%rax), %rdi
callq 0x2390
cltq
movq %rax, -0x30(%rbp)
jmp 0x269f
movq 0xd97c(%rip), %rax      # 0xffa8
movq (%rax), %rdi
callq 0x2390
movl %eax, -0x34(%rbp)
jmp 0x269f
movq 0xd968(%rip), %rax      # 0xffa8
movq (%rax), %rdi
callq 0x4760
movq %rax, -0x48(%rbp)
jmp 0x269f
movl $0x1, -0x38(%rbp)
jmp 0x269f
movl $0x1, -0x3c(%rbp)
jmp 0x269f
movq 0xd941(%rip), %rax      # 0xffa8
movq (%rax), %rdi
callq 0x2390
movl %eax, 0xdbfb(%rip)      # 0x10270
jmp 0x269f
leaq -0x4c(%rbp), %rdi
movq 0xd926(%rip), %rax      # 0xffa8
movq (%rax), %rsi
movl $0x4, %edx
callq 0x2110
movb $0x0, -0x49(%rbp)
jmp 0x269f
callq 0x3d30
jmp 0x299d
jmp 0x25c6
cmpq $0x0, -0x30(%rbp)
jne 0x26b3
movq $0x3, -0x30(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x26d5
movl $0x54, %edi
callq 0x2190
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x26d3
movl $0x2, -0x34(%rbp)
jmp 0x26d5
movl 0xdb95(%rip), %eax      # 0x10270
movl %eax, -0x74(%rbp)
testl %eax, %eax
je 0x2708
jmp 0x26e4
movl -0x74(%rbp), %eax
subl $0x80, %eax
je 0x2708
jmp 0x26f0
movl -0x74(%rbp), %eax
subl $0xc0, %eax
je 0x2714
jmp 0x26fc
movl -0x74(%rbp), %eax
subl $0x100, %eax            # imm = 0x100
je 0x2720
jmp 0x272c
movl $0x10, 0xdb5e(%rip)     # 0x10270
jmp 0x2736
movl $0x18, 0xdb52(%rip)     # 0x10270
jmp 0x2736
movl $0x20, 0xdb46(%rip)     # 0x10270
jmp 0x2736
callq 0x3d30
jmp 0x299d
movsbl -0x4c(%rbp), %eax
cmpl $0x0, %eax
je 0x2754
leaq -0x4c(%rbp), %rdi
leaq 0x9aa7(%rip), %rsi      # 0xc1f1
callq 0x2320
cmpl $0x0, %eax
jne 0x2763
movl $0x1, 0xdb16(%rip)      # 0x10274
jmp 0x284a
leaq -0x4c(%rbp), %rdi
leaq 0x9a87(%rip), %rsi      # 0xc1f5
callq 0x2320
cmpl $0x0, %eax
jne 0x2787
movl $0x2, 0xdaf2(%rip)      # 0x10274
jmp 0x2848
leaq -0x4c(%rbp), %rdi
leaq 0x9a67(%rip), %rsi      # 0xc1f9
callq 0x2320
cmpl $0x0, %eax
jne 0x27ab
movl $0x4, 0xdace(%rip)      # 0x10274
jmp 0x2846
leaq -0x4c(%rbp), %rdi
leaq 0x9a47(%rip), %rsi      # 0xc1fd
callq 0x2320
cmpl $0x0, %eax
jne 0x27cc
movl $0x8, 0xdaaa(%rip)      # 0x10274
jmp 0x2844
leaq -0x4c(%rbp), %rdi
leaq 0x9a2a(%rip), %rsi      # 0xc201
callq 0x2320
cmpl $0x0, %eax
jne 0x2801
movl $0x10, 0xda89(%rip)     # 0x10274
movl $0xc, 0xda43(%rip)      # 0x10238
movl $0x10, 0xda3d(%rip)     # 0x1023c
jmp 0x2842
leaq -0x4c(%rbp), %rdi
leaq 0x99f9(%rip), %rsi      # 0xc205
callq 0x2320
cmpl $0x0, %eax
jne 0x2836
movl $0x20, 0xda54(%rip)     # 0x10274
movl $0x7, 0xda0e(%rip)      # 0x10238
movl $0xc, 0xda08(%rip)      # 0x1023c
jmp 0x2840
callq 0x3d30
jmp 0x299d
jmp 0x2842
jmp 0x2844
jmp 0x2846
jmp 0x2848
jmp 0x284a
callq 0x3d50
cmpq $0x0, -0x48(%rbp)
je 0x2868
movq -0x48(%rbp), %rdi
callq 0x3e80
movq %rax, -0x20(%rbp)
jmp 0x28eb
movq 0xd761(%rip), %rax      # 0xffd0
movl (%rax), %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x8(%rbp), %eax
jl 0x2886
callq 0x3d30
jmp 0x299d
movq -0x10(%rbp), %rax
movslq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3fb0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x28bf
movq 0xd71f(%rip), %rax      # 0xffc8
movq (%rax), %rdi
leaq 0x9956(%rip), %rsi      # 0xc209
movb $0x0, %al
callq 0x2330
jmp 0x299d
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x28e7
movq 0xd6f7(%rip), %rax      # 0xffc8
movq (%rax), %rdi
leaq 0x9941(%rip), %rsi      # 0xc21c
movb $0x0, %al
callq 0x2330
jmp 0x299d
jmp 0x28e9
jmp 0x28eb
movb $0x0, %al
callq 0x48a0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x4920
movq -0x60(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x48f0
movq -0x60(%rbp), %rdi
leaq 0xb6(%rip), %rsi        # 0x29d0
callq 0x4940
movq -0x60(%rbp), %rdi
leaq 0xa16(%rip), %rsi       # 0x3340
callq 0x4940
movq -0x60(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x49f0
movq -0x60(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x49d0
movq -0x60(%rbp), %rdi
callq 0x4ac0
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x295f
jmp 0x297e
leaq 0x9c5b(%rip), %rdi      # 0xc5c1
leaq 0x98c5(%rip), %rsi      # 0xc232
movl $0x1f5, %edx            # imm = 0x1F5
leaq 0x98c5(%rip), %rcx      # 0xc23e
callq 0x21a0
movq -0x68(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x3c(%rbp), %edx
callq 0x4f00
movq -0x68(%rbp), %rdi
callq 0x4a20
movl $0x0, -0x14(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x29be
movq -0x20(%rbp), %rdi
callq 0x4220
movq -0x20(%rbp), %rdi
callq 0x2458
movq $0x0, -0x20(%rbp)
movl -0x14(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)