#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*/ AES_ENCRYPT;
int /*<<< orphan*/ AES_cbc_encrypt(unsigned char *, unsigned char *, int,
                                   int /*<<< orphan*/ *, unsigned char *,
                                   int /*<<< orphan*/);
int /*<<< orphan*/ AES_set_encrypt_key(unsigned char *, int,
                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *str2hex(char *);
void encrpyt_buf(char *raw_buf, char **encrpy_buf, int len) {
  AES_KEY aes;
  unsigned char *key = str2hex("8cc72b05705d5c46f412af8cbed55aad");
  unsigned char *iv = str2hex("667b02a85c61c786def4521b060265e8");
  AES_set_encrypt_key(key, 128, &aes);
  unsigned char *pbuf = (unsigned char *)(*encrpy_buf);
  unsigned char *praw = (unsigned char *)raw_buf;
  AES_cbc_encrypt(praw, pbuf, len, &aes, iv, AES_ENCRYPT);
  free(key);
  free(iv);
}


x86 assembly (clang, -O0):
<encrpyt_buf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xea6(%rip),%rdi
call   1060 <str2hex@plt>
mov    %rax,-0x20(%rbp)
lea    0xeb7(%rip),%rdi
call   1060 <str2hex@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x80,%esi
lea    -0x18(%rbp),%rdx
call   1040 <AES_set_encrypt_key@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x28(%rbp),%r8
mov    0x2e32(%rip),%rax
mov    (%rax),%r9d
lea    -0x18(%rbp),%rcx
call   1050 <AES_cbc_encrypt@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encrpyt_buf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r12
mov    %rdi,%r15
lea    0xea5(%rip),%rdi
call   1060 <str2hex@plt>
mov    %rax,%rbp
lea    0xeb7(%rip),%rdi
call   1060 <str2hex@plt>
mov    %rax,%rbx
lea    0x4(%rsp),%r13
mov    %rbp,%rdi
mov    $0x80,%esi
mov    %r13,%rdx
call   1040 <AES_set_encrypt_key@plt>
mov    (%r12),%rsi
mov    0x2e4e(%rip),%rax
mov    (%rax),%r9d
mov    %r15,%rdi
mov    %r14d,%edx
mov    %r13,%rcx
mov    %rbx,%r8
call   1050 <AES_cbc_encrypt@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"8cc72b05705d5c46f412af8cbed55aad\00"
@.str.1 = [33 x i8] c"667b02a85c61c786def4521b060265e8\00"
@AES_ENCRYPT = global i32 0
define void @encrpyt_buf(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%12 = call i8* @str2hex(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %8
%13 = call i8* @str2hex(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i8* %13, i8** %9
%14 = load i8*, i8** %8
%15 = call i32 @AES_set_encrypt_key(i8* %14, i32 128, i32* %7)
%16 = load i8**, i8*** %5
%17 = load i8*, i8** %16
store i8* %17, i8** %10
%18 = load i8*, i8** %4
store i8* %18, i8** %11
%19 = load i8*, i8** %11
%20 = load i8*, i8** %10
%21 = load i32, i32* %6
%22 = load i8*, i8** %9
%23 = load i32, i32* @AES_ENCRYPT
%24 = call i32 @AES_cbc_encrypt(i8* %19, i8* %20, i32 %21, i32* %7, i8* %22, i32 %23)
%25 = load i8*, i8** %8
%26 = call i32 @free(i8* %25)
%27 = load i8*, i8** %9
%28 = call i32 @free(i8* %27)
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"8cc72b05705d5c46f412af8cbed55aad\00"
@.str.1 = [33 x i8] c"667b02a85c61c786def4521b060265e8\00"
@AES_ENCRYPT = global i32 0
define void @encrpyt_buf(i8* %0, i8** nocapture %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = tail call i8* @str2hex(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%7 = tail call i8* @str2hex(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @AES_set_encrypt_key(i8* %6, i32 128, i32* %4)
%9 = load i8*, i8** %1
%10 = load i32, i32* @AES_ENCRYPT
%11 = call i32 @AES_cbc_encrypt(i8* %0, i8* %9, i32 %2, i32* %4, i8* %7, i32 %10)
%12 = call i32 @free(i8* %6)
%13 = call i32 @free(i8* %7)
ret void
}