// File: /workspace/github_c_makefile_star2_O1/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 0x3523
movq %rax, %rbx
movq 0x8(%r14), %r15
movl 0x9219(%rip), %eax      # 0xc254
leal -0x1(%rax), %ecx
cmpl $0x7, %ecx
ja 0x307e
leaq 0x500a(%rip), %rax      # 0x8054
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl 0x91f7(%rip), %eax      # 0xc250
cmpl $0x20, %eax
je 0x320c
cmpl $0x18, %eax
je 0x3205
cmpl $0x10, %eax
jne 0x3235
callq 0x2120
jmp 0x3211
cmpl $0x10, %eax
je 0x313c
cmpl $0x20, %eax
jne 0x3445
movl 0x91ba(%rip), %eax      # 0xc250
cmpl $0x20, %eax
je 0x335a
cmpl $0x18, %eax
je 0x3353
cmpl $0x10, %eax
jne 0x35fc
callq 0x23a0
jmp 0x335f
movl 0x918f(%rip), %eax      # 0xc250
cmpl $0x20, %eax
je 0x316e
cmpl $0x18, %eax
je 0x3167
cmpl $0x10, %eax
jne 0x3197
callq 0x2250
jmp 0x3173
movl 0x9164(%rip), %eax      # 0xc250
cmpl $0x20, %eax
je 0x31bd
cmpl $0x18, %eax
je 0x31b6
cmpl $0x10, %eax
jne 0x31e6
callq 0x2340
jmp 0x31c2
movl 0x9139(%rip), %eax      # 0xc250
cmpl $0x20, %eax
je 0x325b
cmpl $0x18, %eax
je 0x3254
cmpl $0x10, %eax
jne 0x3284
callq 0x2060
jmp 0x3260
movl 0x910e(%rip), %eax      # 0xc250
cmpl $0x20, %eax
je 0x32aa
cmpl $0x18, %eax
je 0x32a3
cmpl $0x10, %eax
jne 0x35dd
callq 0x21f0
jmp 0x32af
callq 0x2140
jmp 0x3173
callq 0x22f0
leaq 0x90e6(%rip), %rcx      # 0xc260
leaq 0x90ff(%rip), %r8       # 0xc280
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
je 0x3445
leaq 0x514c(%rip), %rdi      # 0x82ea
leaq 0x4f31(%rip), %rsi      # 0x80d6
leaq 0x5147(%rip), %rcx      # 0x82f3
movl $0x7a, %edx
callq 0x2190
callq 0x2380
jmp 0x31c2
callq 0x2210
leaq 0x9097(%rip), %rcx      # 0xc260
leaq 0x90b0(%rip), %r8       # 0xc280
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
je 0x3445
leaq 0x50fd(%rip), %rdi      # 0x82ea
leaq 0x4ee2(%rip), %rsi      # 0x80d6
leaq 0x50f8(%rip), %rcx      # 0x82f3
movl $0x5e, %edx
callq 0x2190
callq 0x23f0
jmp 0x3211
callq 0x2160
leaq 0x9048(%rip), %rcx      # 0xc260
leaq 0x9061(%rip), %r8       # 0xc280
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
je 0x3445
leaq 0x50ae(%rip), %rdi      # 0x82ea
leaq 0x4e93(%rip), %rsi      # 0x80d6
leaq 0x50a9(%rip), %rcx      # 0x82f3
movl $0x50, %edx
callq 0x2190
callq 0x23c0
jmp 0x3260
callq 0x23d0
leaq 0x8ff9(%rip), %rcx      # 0xc260
leaq 0x9012(%rip), %r8       # 0xc280
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
je 0x3445
leaq 0x505f(%rip), %rdi      # 0x82ea
leaq 0x4e44(%rip), %rsi      # 0x80d6
leaq 0x505a(%rip), %rcx      # 0x82f3
movl $0x6c, %edx
callq 0x2190
callq 0x2400
jmp 0x32af
callq 0x2370
movq %rax, %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2090
cmpl $0x1, %eax
jne 0x35dd
movzbl 0x8f8a(%rip), %r12d     # 0xc25c
movzbl 0x8f7f(%rip), %eax      # 0xc258
leal (%rax,%rax,4), %edx
addl $0x7, %edx
movq %rbx, %rdi
movl $0x9, %esi
xorl %ecx, %ecx
callq 0x2320
cmpl $0x1, %eax
jne 0x361b
leaq 0x8f62(%rip), %rcx      # 0xc260
leaq 0x8f7b(%rip), %r8       # 0xc280
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
jne 0x3659
leaq 0x8f6f(%rip), %rcx      # 0xc290
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
movl $0x20, %r8d
callq 0x2150
cmpl $0x1, %eax
jne 0x3697
xorl $0x1, %r12d
shll $0x2, %r12d
orq $-0x10, %r12
addq %r12, %r15
jmp 0x3445
callq 0x22a0
jmp 0x335f
callq 0x22b0
movq %rax, %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2090
cmpl $0x1, %eax
jne 0x35fc
movzbl 0x8eda(%rip), %r12d     # 0xc25c
movzbl 0x8ecf(%rip), %eax      # 0xc258
leal (%rax,%rax,4), %edx
addl $0x7, %edx
movq %rbx, %rdi
movl $0x9, %esi
xorl %ecx, %ecx
callq 0x2320
cmpl $0x1, %eax
jne 0x363a
xorl $0x1, %r12d
shll $0x2, %r12d
orq $-0x10, %r12
addq %r12, %r15
movzbl 0x8e9f(%rip), %eax      # 0xc25c
leal 0xc(,%rax,4), %edx
movq (%r14), %rcx
addq %r15, %rcx
movq %rbx, %rdi
movl $0x11, %esi
callq 0x2320
cmpl $0x1, %eax
jne 0x3678
leaq 0x8e79(%rip), %rcx      # 0xc260
leaq 0x8e92(%rip), %r8       # 0xc280
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2090
cmpl $0x1, %eax
jne 0x36b6
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
movl %r15d, %r8d
callq 0x2150
cmpl $0x1, %eax
jne 0x36d5
leaq 0x8e69(%rip), %rcx      # 0xc290
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
movl $0x20, %r8d
callq 0x2150
cmpl $0x1, %eax
jne 0x36f4
movl $0x1, %edi
movl $0x10, %esi
callq 0x21a0
testq %rax, %rax
je 0x3542
movq %rax, %r12
movq %r15, %rdi
callq 0x2440
movq %rax, (%r12)
testq %rax, %rax
je 0x3561
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 0x3580
movslq 0x4(%rsp), %rbp
movq %rbp, 0x8(%r12)
cmpl $0x10, 0x8dac(%rip)     # 0xc254
jne 0x34d4
movzbl 0x8dab(%rip), %eax      # 0xc25c
leal 0xc(,%rax,4), %edx
addq (%r14), %r15
movq %rbx, %rdi
movl $0x11, %esi
movq %r15, %rcx
callq 0x2320
cmpl $0x1, %eax
jne 0x359f
cmpl $0x20, 0x8d79(%rip)     # 0xc254
je 0x3509
leaq 0x4(%rsp), %rdx
movslq (%rdx), %rax
addq %rax, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x20c0
cmpl $0x1, %eax
jne 0x35be
movslq 0x4(%rsp), %rax
addq %rbp, %rax
movq %rax, 0x8(%r12)
movq %rbx, %rdi
callq 0x2260
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4d91(%rip), %rdi      # 0x82bb
leaq 0x4ba5(%rip), %rsi      # 0x80d6
leaq 0x4dbb(%rip), %rcx      # 0x82f3
movl $0x3c, %edx
callq 0x2190
leaq 0x4da6(%rip), %rdi      # 0x82ef
leaq 0x4b86(%rip), %rsi      # 0x80d6
leaq 0x4d9c(%rip), %rcx      # 0x82f3
movl $0xba, %edx
callq 0x2190
leaq 0x4db6(%rip), %rdi      # 0x831e
leaq 0x4b67(%rip), %rsi      # 0x80d6
leaq 0x4d7d(%rip), %rcx      # 0x82f3
movl $0xbc, %edx
callq 0x2190
leaq 0x4d63(%rip), %rdi      # 0x82ea
leaq 0x4b48(%rip), %rsi      # 0x80d6
leaq 0x4d5e(%rip), %rcx      # 0x82f3
movl $0xbf, %edx
callq 0x2190
leaq 0x4d44(%rip), %rdi      # 0x82ea
leaq 0x4b29(%rip), %rsi      # 0x80d6
leaq 0x4d3f(%rip), %rcx      # 0x82f3
movl $0xc4, %edx
callq 0x2190
leaq 0x4d25(%rip), %rdi      # 0x82ea
leaq 0x4b0a(%rip), %rsi      # 0x80d6
leaq 0x4d20(%rip), %rcx      # 0x82f3
movl $0xc9, %edx
callq 0x2190
leaq 0x4d06(%rip), %rdi      # 0x82ea
leaq 0x4aeb(%rip), %rsi      # 0x80d6
leaq 0x4d01(%rip), %rcx      # 0x82f3
movl $0x88, %edx
callq 0x2190
leaq 0x4ce7(%rip), %rdi      # 0x82ea
leaq 0x4acc(%rip), %rsi      # 0x80d6
leaq 0x4ce2(%rip), %rcx      # 0x82f3
movl $0xa2, %edx
callq 0x2190
leaq 0x4cc8(%rip), %rdi      # 0x82ea
leaq 0x4aad(%rip), %rsi      # 0x80d6
leaq 0x4cc3(%rip), %rcx      # 0x82f3
movl $0x8d, %edx
callq 0x2190
leaq 0x4ca9(%rip), %rdi      # 0x82ea
leaq 0x4a8e(%rip), %rsi      # 0x80d6
leaq 0x4ca4(%rip), %rcx      # 0x82f3
movl $0xa7, %edx
callq 0x2190
leaq 0x4c8a(%rip), %rdi      # 0x82ea
leaq 0x4a6f(%rip), %rsi      # 0x80d6
leaq 0x4c85(%rip), %rcx      # 0x82f3
movl $0x90, %edx
callq 0x2190
leaq 0x4c6b(%rip), %rdi      # 0x82ea
leaq 0x4a50(%rip), %rsi      # 0x80d6
leaq 0x4c66(%rip), %rcx      # 0x82f3
movl $0xaa, %edx
callq 0x2190
leaq 0x4c4c(%rip), %rdi      # 0x82ea
leaq 0x4a31(%rip), %rsi      # 0x80d6
leaq 0x4c47(%rip), %rcx      # 0x82f3
movl $0x93, %edx
callq 0x2190
leaq 0x4c2d(%rip), %rdi      # 0x82ea
leaq 0x4a12(%rip), %rsi      # 0x80d6
leaq 0x4c28(%rip), %rcx      # 0x82f3
movl $0xad, %edx
callq 0x2190
leaq 0x4c0e(%rip), %rdi      # 0x82ea
leaq 0x49f3(%rip), %rsi      # 0x80d6
leaq 0x4c09(%rip), %rcx      # 0x82f3
movl $0xb0, %edx
callq 0x2190
leaq 0x4bef(%rip), %rdi      # 0x82ea
leaq 0x49d4(%rip), %rsi      # 0x80d6
leaq 0x4bea(%rip), %rcx      # 0x82f3
movl $0xb3, %edx
callq 0x2190
nop