#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*/ AES_KEY;

/* Variables and functions */
int /*<<< orphan*/ JTR_AES_cbc_encrypt(unsigned char *, unsigned char *, size_t,
                                       int /*<<< orphan*/ *, unsigned char *,
                                       int);
int /*<<< orphan*/ aes_key_mgmt(int /*<<< orphan*/ *, unsigned char *,
                                unsigned int, int);
void aes_cbc(unsigned char *in, unsigned char *out, unsigned char *key,
             size_t num_blocks, unsigned char *iv, unsigned int key_length,
             int direction) {
  AES_KEY akey;
  aes_key_mgmt(&akey, key, key_length, direction);
  JTR_AES_cbc_encrypt(in, out, num_blocks * 16, &akey, iv, direction);
}


x86 assembly (clang, -O0):
<aes_cbc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
mov    0x10(%rbp),%ecx
lea    -0x30(%rbp),%rdi
call   1040 <aes_key_mgmt@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
shl    $0x4,%rdx
mov    -0x28(%rbp),%r8
mov    0x10(%rbp),%r9d
lea    -0x30(%rbp),%rcx
call   1030 <JTR_AES_cbc_encrypt@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aes_cbc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rsi,%r15
mov    %rdi,%r12
mov    0x40(%rsp),%r13d
lea    0x4(%rsp),%rbp
mov    %rbp,%rdi
mov    %rdx,%rsi
mov    %r9d,%edx
mov    %r13d,%ecx
call   1040 <aes_key_mgmt@plt>
shl    $0x4,%rbx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %r14,%r8
mov    %r13d,%r9d
call   1030 <JTR_AES_cbc_encrypt@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @aes_cbc(i8* %0, i8* %1, i8* %2, i64 %3, i8* %4, i32 %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i64 %3, i64* %11
store i8* %4, i8** %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%16 = load i8*, i8** %10
%17 = load i32, i32* %13
%18 = load i32, i32* %14
%19 = call i32 @aes_key_mgmt(i32* %15, i8* %16, i32 %17, i32 %18)
%20 = load i8*, i8** %8
%21 = load i8*, i8** %9
%22 = load i64, i64* %11
%23 = mul i64 %22, 16
%24 = load i8*, i8** %12
%25 = load i32, i32* %14
%26 = call i32 @JTR_AES_cbc_encrypt(i8* %20, i8* %21, i64 %23, i32* %15, i8* %24, i32 %25)
ret void
}

LLVM IR (-O2):
define void @aes_cbc(i8* %0, i8* %1, i8* %2, i64 %3, i8* %4, i32 %5, i32 %6) {
%8 = alloca i32
%9 = bitcast i32* %8 to i8*
%10 = call i32 @aes_key_mgmt(i32* %8, i8* %2, i32 %5, i32 %6)
%11 = shl i64 %3, 4
%12 = call i32 @JTR_AES_cbc_encrypt(i8* %0, i8* %1, i64 %11, i32* %8, i8* %4, i32 %6)
ret void
}