#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ block128_f;
typedef int /*<<< orphan*/ AES_KEY;

/* Variables and functions */
scalar_t__ AES_decrypt;
scalar_t__ AES_encrypt;
int /*<<< orphan*/ CRYPTO_cbc128_decrypt(unsigned char const *, unsigned char *,
                                         size_t, int /*<<< orphan*/ const *,
                                         unsigned char *, int /*<<< orphan*/);
int /*<<< orphan*/ CRYPTO_cbc128_encrypt(unsigned char const *, unsigned char *,
                                         size_t, int /*<<< orphan*/ const *,
                                         unsigned char *, int /*<<< orphan*/);
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,
                     const AES_KEY *key, unsigned char *ivec, const int enc) {
  if (enc)
    CRYPTO_cbc128_encrypt(in, out, len, key, ivec, (block128_f)AES_encrypt);
  else
    CRYPTO_cbc128_decrypt(in, out, len, key, ivec, (block128_f)AES_decrypt);
}


x86 assembly (clang, -O0):
<AES_cbc_encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1175 <AES_cbc_encrypt+0x55>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    0x2e7b(%rip),%rax
mov    (%rax),%rax
mov    %eax,%r9d
call   1030 <CRYPTO_cbc128_encrypt@plt>
jmp    119b <AES_cbc_encrypt+0x7b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    0x2e58(%rip),%rax
mov    (%rax),%rax
mov    %eax,%r9d
call   1040 <CRYPTO_cbc128_decrypt@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AES_cbc_encrypt>:
test   %r9d,%r9d
je     1134 <AES_cbc_encrypt+0x14>
mov    0x2eb4(%rip),%rax
mov    (%rax),%r9d
jmp    1030 <CRYPTO_cbc128_encrypt@plt>
mov    0x2ead(%rip),%rax
mov    (%rax),%r9d
jmp    1040 <CRYPTO_cbc128_decrypt@plt>

LLVM IR (-O0):
@AES_encrypt = global i64 0
@AES_decrypt = global i64 0
define void @AES_cbc_encrypt(i8* %0, i8* %1, i64 %2, i32* %3, i8* %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i64 %2, i64* %9
store i32* %3, i32** %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%13 = load i32, i32* %12
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %6
%16 = load i8*, i8** %7
%17 = load i8*, i8** %8
%18 = load i64, i64* %9
%19 = load i32*, i32** %10
%20 = load i8*, i8** %11
%21 = load i64, i64* @AES_encrypt
%22 = trunc i64 %21 to i32
%23 = call i32 @CRYPTO_cbc128_encrypt(i8* %16, i8* %17, i64 %18, i32* %19, i8* %20, i32 %22)
br label %33
24: ; preds = %6
%25 = load i8*, i8** %7
%26 = load i8*, i8** %8
%27 = load i64, i64* %9
%28 = load i32*, i32** %10
%29 = load i8*, i8** %11
%30 = load i64, i64* @AES_decrypt
%31 = trunc i64 %30 to i32
%32 = call i32 @CRYPTO_cbc128_decrypt(i8* %25, i8* %26, i64 %27, i32* %28, i8* %29, i32 %31)
br label %33
33: ; preds = %24, %15
ret void
}

LLVM IR (-O2):
@AES_encrypt = global i64 0
@AES_decrypt = global i64 0
define void @AES_cbc_encrypt(i8* %0, i8* %1, i64 %2, i32* %3, i8* %4, i32 %5) {
%7 = icmp eq i32 %5, 0
br i1 %7, label %12, label %8
8: ; preds = %6
%9 = load i64, i64* @AES_encrypt
%10 = trunc i64 %9 to i32
%11 = tail call i32 @CRYPTO_cbc128_encrypt(i8* %0, i8* %1, i64 %2, i32* %3, i8* %4, i32 %10)
br label %16
12: ; preds = %6
%13 = load i64, i64* @AES_decrypt
%14 = trunc i64 %13 to i32
%15 = tail call i32 @CRYPTO_cbc128_decrypt(i8* %0, i8* %1, i64 %2, i32* %3, i8* %4, i32 %14)
br label %16
16: ; preds = %12, %8
ret void
}