// File: /workspace/github_c_makefile_star2_O2/tomcatzh[P]RealityBenchmark/aes_bench.c
// Function: decryptContent
static CONTENTS* decryptContent(const CONTENTS* data) {
  EVP_CIPHER_CTX *ctx;

  ctx = EVP_CIPHER_CTX_new();
  assert(ctx);

  int i = 0;

  int len;
  size_t dataLength = data->size;

  switch (cipherMode) {
  case cipherModeCBC:
    switch (keyLength) {
      case keyLength128Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv);
        break;
      case keyLength192Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_192_cbc(), NULL, key, iv);
        break;
      case keyLength256Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key, iv);
        break;
    }
    assert(i==1);
    break;
  case cipherModeCFB:
    switch (keyLength) {
      case keyLength128Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_128_cfb(), NULL, key, iv);
        break;
      case keyLength192Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_192_cfb(), NULL, key, iv);
        break;
      case keyLength256Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_256_cfb(), NULL, key, iv);
        break;
    }
    assert(i==1);
    break;
  case cipherModeOFB:
    switch (keyLength) {
      case keyLength128Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_128_ofb(), NULL, key, iv);
        break;
      case keyLength192Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_192_ofb(), NULL, key, iv);
        break;
      case keyLength256Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_256_ofb(), NULL, key, iv);
        break;
    }
    assert(i==1);
    break;
  case cipherModeCTR:
    switch (keyLength) {
      case keyLength128Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_128_ctr(), NULL, key, iv);
        break;
      case keyLength192Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_192_ctr(), NULL, key, iv);
        break;
      case keyLength256Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_256_ctr(), NULL, key, iv);
        break;
    }
    assert(i==1);
    break;
  case cipherModeGCM:
    switch (keyLength) {
      case keyLength128Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_128_gcm(), NULL, NULL, NULL);
        break;
      case keyLength192Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_192_gcm(), NULL, NULL, NULL);
        break;
      case keyLength256Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, NULL, NULL);
        break;
    }
    assert(i==1);

    dataLength -= tagLength;

    i = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, ivLength, NULL);
    assert(i==1);

    i = EVP_DecryptInit_ex(ctx, NULL, NULL, key, iv);
    assert(i==1);

    i = EVP_DecryptUpdate(ctx, NULL, &len, aad, sizeof(aad));
    assert(i==1);

    break;
  case cipherModeCCM:
    switch (keyLength) {
      case keyLength128Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_128_ccm(), NULL, NULL, NULL);
        break;
      case keyLength192Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_192_ccm(), NULL, NULL, NULL);
        break;
      case keyLength256Bit:
        i = EVP_DecryptInit_ex(ctx, EVP_aes_256_ccm(), NULL, NULL, NULL);
        break;
    }
    assert(i==1);

    dataLength -= tagLength;

    i = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_IVLEN, ivLength, NULL);
    assert(i==1);

    i = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_TAG, tagLength, data->body + dataLength);
    assert(i==1);

    i = EVP_DecryptInit_ex(ctx, NULL, NULL, key, iv);
    assert(i==1);

    i = EVP_DecryptUpdate(ctx, NULL, &len, NULL, dataLength);
    assert(i==1);

    i = EVP_DecryptUpdate(ctx, NULL, &len, aad, sizeof(aad));
    assert(i==1);

    break;
  }

  CONTENTS* ret = NULL;
  ret = calloc(1, sizeof(CONTENTS));
  assert(ret);
  ret->body = (unsigned char*)malloc(dataLength);
  assert(ret->body);

  i = EVP_DecryptUpdate(ctx, ret->body, &len, data->body, dataLength);
  assert(i==1);
  ret->size = len;

  if (cipherMode == cipherModeGCM) {
    i = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, tagLength, data->body + dataLength);
    assert(i==1);
  }

  if (cipherMode != cipherModeCCM) {
    i = EVP_DecryptFinal_ex(ctx, ret->body + len, &len);
    assert(i==1);
    ret->size += len;
  }

  EVP_CIPHER_CTX_free(ctx);

  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
callq 0x2170
testq %rax, %rax
je 0x33ef
movq %rax, %rbx
movq 0x8(%r14), %r15
movl 0x8335(%rip), %eax      # 0xb254
leal -0x1(%rax), %ecx
cmpl $0x7, %ecx
ja 0x2f62
leaq 0x4126(%rip), %rax      # 0x7054
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl 0x8313(%rip), %eax      # 0xb250
cmpl $0x20, %eax
je 0x30ea
cmpl $0x18, %eax
je 0x30e3
cmpl $0x10, %eax
jne 0x3113
callq 0x2120
jmp 0x30ef
cmpl $0x10, %eax
je 0x3020
cmpl $0x20, %eax
jne 0x3313
movl 0x82d6(%rip), %eax      # 0xb250
cmpl $0x20, %eax
je 0x322e
cmpl $0x18, %eax
je 0x3227
cmpl $0x10, %eax
jne 0x34c6
callq 0x2390
jmp 0x3233
movl 0x82ab(%rip), %eax      # 0xb250
cmpl $0x20, %eax
je 0x3052
cmpl $0x18, %eax
je 0x304b
cmpl $0x10, %eax
jne 0x307b
callq 0x2240
jmp 0x3057
movl 0x8280(%rip), %eax      # 0xb250
cmpl $0x20, %eax
je 0x309e
cmpl $0x18, %eax
je 0x3097
cmpl $0x10, %eax
jne 0x30c7
callq 0x2330
jmp 0x30a3
movl 0x8255(%rip), %eax      # 0xb250
cmpl $0x20, %eax
je 0x3136
cmpl $0x18, %eax
je 0x312f
cmpl $0x10, %eax
jne 0x315f
callq 0x2060
jmp 0x313b
movl 0x822a(%rip), %eax      # 0xb250
cmpl $0x20, %eax
je 0x3182
cmpl $0x18, %eax
je 0x317b
cmpl $0x10, %eax
jne 0x34a7
callq 0x21e0
jmp 0x3187
callq 0x2140
jmp 0x3057
callq 0x22e0
leaq 0x8202(%rip), %rcx      # 0xb260
leaq 0x821b(%rip), %r8       # 0xb280
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
je 0x3313
leaq 0x4268(%rip), %rdi      # 0x72ea
leaq 0x404d(%rip), %rsi      # 0x70d6
leaq 0x4263(%rip), %rcx      # 0x72f3
pushq $0x7a
jmp 0x3406
callq 0x2370
jmp 0x30a3
callq 0x2200
leaq 0x81b6(%rip), %rcx      # 0xb260
leaq 0x81cf(%rip), %r8       # 0xb280
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
je 0x3313
leaq 0x421c(%rip), %rdi      # 0x72ea
leaq 0x4001(%rip), %rsi      # 0x70d6
leaq 0x4217(%rip), %rcx      # 0x72f3
pushq $0x5e
jmp 0x3406
callq 0x23e0
jmp 0x30ef
callq 0x2160
leaq 0x816a(%rip), %rcx      # 0xb260
leaq 0x8183(%rip), %r8       # 0xb280
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
je 0x3313
leaq 0x41d0(%rip), %rdi      # 0x72ea
leaq 0x3fb5(%rip), %rsi      # 0x70d6
leaq 0x41cb(%rip), %rcx      # 0x72f3
pushq $0x50
jmp 0x3406
callq 0x23b0
jmp 0x313b
callq 0x23c0
leaq 0x811e(%rip), %rcx      # 0xb260
leaq 0x8137(%rip), %r8       # 0xb280
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
je 0x3313
leaq 0x4184(%rip), %rdi      # 0x72ea
leaq 0x3f69(%rip), %rsi      # 0x70d6
leaq 0x417f(%rip), %rcx      # 0x72f3
pushq $0x6c
jmp 0x3406
callq 0x23f0
jmp 0x3187
callq 0x2360
movq %rax, %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2090
cmpl $0x1, %eax
jne 0x34a7
movzbl 0x80b2(%rip), %r12d     # 0xb25c
movzbl 0x80a7(%rip), %eax      # 0xb258
leal (%rax,%rax,4), %edx
addl $0x7, %edx
pushq $0x9
popq %rsi
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x2310
cmpl $0x1, %eax
jne 0x34e5
leaq 0x808c(%rip), %rcx      # 0xb260
leaq 0x80a5(%rip), %r8       # 0xb280
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
jne 0x3523
leaq 0x8099(%rip), %rcx      # 0xb290
leaq 0x4(%rsp), %rdx
pushq $0x20
popq %r8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2150
cmpl $0x1, %eax
jne 0x3561
xorl $0x1, %r12d
shll $0x2, %r12d
orq $-0x10, %r12
addq %r12, %r15
jmp 0x3313
callq 0x2290
jmp 0x3233
callq 0x22a0
movq %rax, %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2090
cmpl $0x1, %eax
jne 0x34c6
movzbl 0x8006(%rip), %r12d     # 0xb25c
movzbl 0x7ffb(%rip), %eax      # 0xb258
leal (%rax,%rax,4), %edx
addl $0x7, %edx
pushq $0x9
popq %rsi
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x2310
cmpl $0x1, %eax
jne 0x3504
xorl $0x1, %r12d
shll $0x2, %r12d
orq $-0x10, %r12
addq %r12, %r15
movzbl 0x7fcd(%rip), %eax      # 0xb25c
leal 0xc(,%rax,4), %edx
movq (%r14), %rcx
addq %r15, %rcx
pushq $0x11
popq %rsi
movq %rbx, %rdi
callq 0x2310
cmpl $0x1, %eax
jne 0x3542
leaq 0x7fa9(%rip), %rcx      # 0xb260
leaq 0x7fc2(%rip), %r8       # 0xb280
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
jne 0x3580
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
movl %r15d, %r8d
callq 0x2150
cmpl $0x1, %eax
jne 0x359f
leaq 0x7f99(%rip), %rcx      # 0xb290
leaq 0x4(%rsp), %rdx
pushq $0x20
popq %r8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2150
cmpl $0x1, %eax
jne 0x35be
pushq $0x1
popq %rdi
pushq $0x10
popq %rsi
callq 0x21a0
testq %rax, %rax
je 0x340c
movq %rax, %r12
movq %r15, %rdi
callq 0x2430
movq %rax, (%r12)
testq %rax, %rax
je 0x342b
movq %rax, %r13
movq (%r14), %rcx
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
movq %rax, %rsi
movl %r15d, %r8d
callq 0x2150
cmpl $0x1, %eax
jne 0x344a
movslq 0x4(%rsp), %rbp
movq %rbp, 0x8(%r12)
movl 0x7ee3(%rip), %eax      # 0xb254
cmpl $0x10, %eax
jne 0x33a4
movzbl 0x7edf(%rip), %eax      # 0xb25c
leal 0xc(,%rax,4), %edx
addq (%r14), %r15
pushq $0x11
popq %rsi
movq %rbx, %rdi
movq %r15, %rcx
callq 0x2310
cmpl $0x1, %eax
jne 0x3469
movl 0x7eb0(%rip), %eax      # 0xb254
cmpl $0x20, %eax
je 0x33d5
leaq 0x4(%rsp), %rdx
movslq (%rdx), %rax
addq %rax, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x20c0
cmpl $0x1, %eax
jne 0x3488
movslq 0x4(%rsp), %rax
addq %rbp, %rax
movq %rax, 0x8(%r12)
movq %rbx, %rdi
callq 0x2250
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3ec5(%rip), %rdi      # 0x72bb
leaq 0x3cd9(%rip), %rsi      # 0x70d6
leaq 0x3eef(%rip), %rcx      # 0x72f3
pushq $0x3c
popq %rdx
callq 0x2190
leaq 0x3edc(%rip), %rdi      # 0x72ef
leaq 0x3cbc(%rip), %rsi      # 0x70d6
leaq 0x3ed2(%rip), %rcx      # 0x72f3
movl $0xba, %edx
callq 0x2190
leaq 0x3eec(%rip), %rdi      # 0x731e
leaq 0x3c9d(%rip), %rsi      # 0x70d6
leaq 0x3eb3(%rip), %rcx      # 0x72f3
movl $0xbc, %edx
callq 0x2190
leaq 0x3e99(%rip), %rdi      # 0x72ea
leaq 0x3c7e(%rip), %rsi      # 0x70d6
leaq 0x3e94(%rip), %rcx      # 0x72f3
movl $0xbf, %edx
callq 0x2190
leaq 0x3e7a(%rip), %rdi      # 0x72ea
leaq 0x3c5f(%rip), %rsi      # 0x70d6
leaq 0x3e75(%rip), %rcx      # 0x72f3
movl $0xc4, %edx
callq 0x2190
leaq 0x3e5b(%rip), %rdi      # 0x72ea
leaq 0x3c40(%rip), %rsi      # 0x70d6
leaq 0x3e56(%rip), %rcx      # 0x72f3
movl $0xc9, %edx
callq 0x2190
leaq 0x3e3c(%rip), %rdi      # 0x72ea
leaq 0x3c21(%rip), %rsi      # 0x70d6
leaq 0x3e37(%rip), %rcx      # 0x72f3
movl $0x88, %edx
callq 0x2190
leaq 0x3e1d(%rip), %rdi      # 0x72ea
leaq 0x3c02(%rip), %rsi      # 0x70d6
leaq 0x3e18(%rip), %rcx      # 0x72f3
movl $0xa2, %edx
callq 0x2190
leaq 0x3dfe(%rip), %rdi      # 0x72ea
leaq 0x3be3(%rip), %rsi      # 0x70d6
leaq 0x3df9(%rip), %rcx      # 0x72f3
movl $0x8d, %edx
callq 0x2190
leaq 0x3ddf(%rip), %rdi      # 0x72ea
leaq 0x3bc4(%rip), %rsi      # 0x70d6
leaq 0x3dda(%rip), %rcx      # 0x72f3
movl $0xa7, %edx
callq 0x2190
leaq 0x3dc0(%rip), %rdi      # 0x72ea
leaq 0x3ba5(%rip), %rsi      # 0x70d6
leaq 0x3dbb(%rip), %rcx      # 0x72f3
movl $0x90, %edx
callq 0x2190
leaq 0x3da1(%rip), %rdi      # 0x72ea
leaq 0x3b86(%rip), %rsi      # 0x70d6
leaq 0x3d9c(%rip), %rcx      # 0x72f3
movl $0xaa, %edx
callq 0x2190
leaq 0x3d82(%rip), %rdi      # 0x72ea
leaq 0x3b67(%rip), %rsi      # 0x70d6
leaq 0x3d7d(%rip), %rcx      # 0x72f3
movl $0x93, %edx
callq 0x2190
leaq 0x3d63(%rip), %rdi      # 0x72ea
leaq 0x3b48(%rip), %rsi      # 0x70d6
leaq 0x3d5e(%rip), %rcx      # 0x72f3
movl $0xad, %edx
callq 0x2190
leaq 0x3d44(%rip), %rdi      # 0x72ea
leaq 0x3b29(%rip), %rsi      # 0x70d6
leaq 0x3d3f(%rip), %rcx      # 0x72f3
movl $0xb0, %edx
callq 0x2190
leaq 0x3d25(%rip), %rdi      # 0x72ea
leaq 0x3b0a(%rip), %rsi      # 0x70d6
leaq 0x3d20(%rip), %rcx      # 0x72f3
movl $0xb3, %edx
callq 0x2190