// File: /workspace/github_c_makefile_star2_O3/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 0x3515
movq %rax, %rbx
movq 0x8(%r14), %r15
movl 0x922b(%rip), %eax      # 0xc254
leal -0x1(%rax), %ecx
cmpl $0x7, %ecx
ja 0x306c
leaq 0x501c(%rip), %rax      # 0x8054
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl 0x9209(%rip), %eax      # 0xc250
cmpl $0x20, %eax
je 0x31fa
cmpl $0x18, %eax
je 0x31f3
cmpl $0x10, %eax
jne 0x3223
callq 0x2120
jmp 0x31ff
cmpl $0x10, %eax
je 0x312a
cmpl $0x20, %eax
jne 0x3433
movl 0x91cc(%rip), %eax      # 0xc250
cmpl $0x20, %eax
je 0x3348
cmpl $0x18, %eax
je 0x3341
cmpl $0x10, %eax
jne 0x35ee
callq 0x2390
jmp 0x334d
movl 0x91a1(%rip), %eax      # 0xc250
cmpl $0x20, %eax
je 0x315c
cmpl $0x18, %eax
je 0x3155
cmpl $0x10, %eax
jne 0x3185
callq 0x2240
jmp 0x3161
movl 0x9176(%rip), %eax      # 0xc250
cmpl $0x20, %eax
je 0x31ab
cmpl $0x18, %eax
je 0x31a4
cmpl $0x10, %eax
jne 0x31d4
callq 0x2330
jmp 0x31b0
movl 0x914b(%rip), %eax      # 0xc250
cmpl $0x20, %eax
je 0x3249
cmpl $0x18, %eax
je 0x3242
cmpl $0x10, %eax
jne 0x3272
callq 0x2060
jmp 0x324e
movl 0x9120(%rip), %eax      # 0xc250
cmpl $0x20, %eax
je 0x3298
cmpl $0x18, %eax
je 0x3291
cmpl $0x10, %eax
jne 0x35cf
callq 0x21e0
jmp 0x329d
callq 0x2140
jmp 0x3161
callq 0x22e0
leaq 0x90f8(%rip), %rcx      # 0xc260
leaq 0x9111(%rip), %r8       # 0xc280
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
je 0x3433
leaq 0x515e(%rip), %rdi      # 0x82ea
leaq 0x4f43(%rip), %rsi      # 0x80d6
leaq 0x5159(%rip), %rcx      # 0x82f3
movl $0x7a, %edx
callq 0x2190
callq 0x2370
jmp 0x31b0
callq 0x2200
leaq 0x90a9(%rip), %rcx      # 0xc260
leaq 0x90c2(%rip), %r8       # 0xc280
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
je 0x3433
leaq 0x510f(%rip), %rdi      # 0x82ea
leaq 0x4ef4(%rip), %rsi      # 0x80d6
leaq 0x510a(%rip), %rcx      # 0x82f3
movl $0x5e, %edx
callq 0x2190
callq 0x23e0
jmp 0x31ff
callq 0x2160
leaq 0x905a(%rip), %rcx      # 0xc260
leaq 0x9073(%rip), %r8       # 0xc280
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
je 0x3433
leaq 0x50c0(%rip), %rdi      # 0x82ea
leaq 0x4ea5(%rip), %rsi      # 0x80d6
leaq 0x50bb(%rip), %rcx      # 0x82f3
movl $0x50, %edx
callq 0x2190
callq 0x23b0
jmp 0x324e
callq 0x23c0
leaq 0x900b(%rip), %rcx      # 0xc260
leaq 0x9024(%rip), %r8       # 0xc280
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
je 0x3433
leaq 0x5071(%rip), %rdi      # 0x82ea
leaq 0x4e56(%rip), %rsi      # 0x80d6
leaq 0x506c(%rip), %rcx      # 0x82f3
movl $0x6c, %edx
callq 0x2190
callq 0x23f0
jmp 0x329d
callq 0x2360
movq %rax, %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2090
cmpl $0x1, %eax
jne 0x35cf
movzbl 0x8f9c(%rip), %r12d     # 0xc25c
movzbl 0x8f91(%rip), %eax      # 0xc258
leal (%rax,%rax,4), %edx
addl $0x7, %edx
movq %rbx, %rdi
movl $0x9, %esi
xorl %ecx, %ecx
callq 0x2310
cmpl $0x1, %eax
jne 0x360d
leaq 0x8f74(%rip), %rcx      # 0xc260
leaq 0x8f8d(%rip), %r8       # 0xc280
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
jne 0x364b
leaq 0x8f81(%rip), %rcx      # 0xc290
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
movl $0x20, %r8d
callq 0x2150
cmpl $0x1, %eax
jne 0x3689
xorl $0x1, %r12d
shll $0x2, %r12d
orq $-0x10, %r12
addq %r12, %r15
jmp 0x3433
callq 0x2290
jmp 0x334d
callq 0x22a0
movq %rax, %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2090
cmpl $0x1, %eax
jne 0x35ee
movzbl 0x8eec(%rip), %r12d     # 0xc25c
movzbl 0x8ee1(%rip), %eax      # 0xc258
leal (%rax,%rax,4), %edx
addl $0x7, %edx
movq %rbx, %rdi
movl $0x9, %esi
xorl %ecx, %ecx
callq 0x2310
cmpl $0x1, %eax
jne 0x362c
xorl $0x1, %r12d
shll $0x2, %r12d
orq $-0x10, %r12
addq %r12, %r15
movzbl 0x8eb1(%rip), %eax      # 0xc25c
leal 0xc(,%rax,4), %edx
movq (%r14), %rcx
addq %r15, %rcx
movq %rbx, %rdi
movl $0x11, %esi
callq 0x2310
cmpl $0x1, %eax
jne 0x366a
leaq 0x8e8b(%rip), %rcx      # 0xc260
leaq 0x8ea4(%rip), %r8       # 0xc280
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
jne 0x36a8
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
movl %r15d, %r8d
callq 0x2150
cmpl $0x1, %eax
jne 0x36c7
leaq 0x8e7b(%rip), %rcx      # 0xc290
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
movl $0x20, %r8d
callq 0x2150
cmpl $0x1, %eax
jne 0x36e6
movl $0x1, %edi
movl $0x10, %esi
callq 0x21a0
testq %rax, %rax
je 0x3534
movq %rax, %r12
movq %r15, %rdi
callq 0x2430
movq %rax, (%r12)
testq %rax, %rax
je 0x3553
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 0x3572
movslq 0x4(%rsp), %rbp
movq %rbp, 0x8(%r12)
movl 0x8dbf(%rip), %eax      # 0xc254
cmpl $0x10, %eax
jne 0x34ca
movzbl 0x8dbb(%rip), %eax      # 0xc25c
leal 0xc(,%rax,4), %edx
addq (%r14), %r15
movq %rbx, %rdi
movl $0x11, %esi
movq %r15, %rcx
callq 0x2310
cmpl $0x1, %eax
jne 0x3591
movl 0x8d8a(%rip), %eax      # 0xc254
cmpl $0x20, %eax
je 0x34fb
leaq 0x4(%rsp), %rdx
movslq (%rdx), %rax
addq %rax, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x20c0
cmpl $0x1, %eax
jne 0x35b0
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 0x4d9f(%rip), %rdi      # 0x82bb
leaq 0x4bb3(%rip), %rsi      # 0x80d6
leaq 0x4dc9(%rip), %rcx      # 0x82f3
movl $0x3c, %edx
callq 0x2190
leaq 0x4db4(%rip), %rdi      # 0x82ef
leaq 0x4b94(%rip), %rsi      # 0x80d6
leaq 0x4daa(%rip), %rcx      # 0x82f3
movl $0xba, %edx
callq 0x2190
leaq 0x4dc4(%rip), %rdi      # 0x831e
leaq 0x4b75(%rip), %rsi      # 0x80d6
leaq 0x4d8b(%rip), %rcx      # 0x82f3
movl $0xbc, %edx
callq 0x2190
leaq 0x4d71(%rip), %rdi      # 0x82ea
leaq 0x4b56(%rip), %rsi      # 0x80d6
leaq 0x4d6c(%rip), %rcx      # 0x82f3
movl $0xbf, %edx
callq 0x2190
leaq 0x4d52(%rip), %rdi      # 0x82ea
leaq 0x4b37(%rip), %rsi      # 0x80d6
leaq 0x4d4d(%rip), %rcx      # 0x82f3
movl $0xc4, %edx
callq 0x2190
leaq 0x4d33(%rip), %rdi      # 0x82ea
leaq 0x4b18(%rip), %rsi      # 0x80d6
leaq 0x4d2e(%rip), %rcx      # 0x82f3
movl $0xc9, %edx
callq 0x2190
leaq 0x4d14(%rip), %rdi      # 0x82ea
leaq 0x4af9(%rip), %rsi      # 0x80d6
leaq 0x4d0f(%rip), %rcx      # 0x82f3
movl $0x88, %edx
callq 0x2190
leaq 0x4cf5(%rip), %rdi      # 0x82ea
leaq 0x4ada(%rip), %rsi      # 0x80d6
leaq 0x4cf0(%rip), %rcx      # 0x82f3
movl $0xa2, %edx
callq 0x2190
leaq 0x4cd6(%rip), %rdi      # 0x82ea
leaq 0x4abb(%rip), %rsi      # 0x80d6
leaq 0x4cd1(%rip), %rcx      # 0x82f3
movl $0x8d, %edx
callq 0x2190
leaq 0x4cb7(%rip), %rdi      # 0x82ea
leaq 0x4a9c(%rip), %rsi      # 0x80d6
leaq 0x4cb2(%rip), %rcx      # 0x82f3
movl $0xa7, %edx
callq 0x2190
leaq 0x4c98(%rip), %rdi      # 0x82ea
leaq 0x4a7d(%rip), %rsi      # 0x80d6
leaq 0x4c93(%rip), %rcx      # 0x82f3
movl $0x90, %edx
callq 0x2190
leaq 0x4c79(%rip), %rdi      # 0x82ea
leaq 0x4a5e(%rip), %rsi      # 0x80d6
leaq 0x4c74(%rip), %rcx      # 0x82f3
movl $0xaa, %edx
callq 0x2190
leaq 0x4c5a(%rip), %rdi      # 0x82ea
leaq 0x4a3f(%rip), %rsi      # 0x80d6
leaq 0x4c55(%rip), %rcx      # 0x82f3
movl $0x93, %edx
callq 0x2190
leaq 0x4c3b(%rip), %rdi      # 0x82ea
leaq 0x4a20(%rip), %rsi      # 0x80d6
leaq 0x4c36(%rip), %rcx      # 0x82f3
movl $0xad, %edx
callq 0x2190
leaq 0x4c1c(%rip), %rdi      # 0x82ea
leaq 0x4a01(%rip), %rsi      # 0x80d6
leaq 0x4c17(%rip), %rcx      # 0x82f3
movl $0xb0, %edx
callq 0x2190
leaq 0x4bfd(%rip), %rdi      # 0x82ea
leaq 0x49e2(%rip), %rsi      # 0x80d6
leaq 0x4bf8(%rip), %rcx      # 0x82f3
movl $0xb3, %edx
callq 0x2190
nopl (%rax)