#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 */
scalar_t__ AES_BLOCK_SIZE;
int /*<<< orphan*/ AES_encrypt(unsigned char *, unsigned char *,
                               int /*<<< orphan*/ *);
scalar_t__ AES_set_encrypt_key(unsigned char *, int, int /*<<< orphan*/ *);
int my_aes_encrypt(char *key, char *in, int inlen, char *out) {
  int i, en_len = 0;
  if (!in || !key || !out)
    return 0;
  AES_KEY aes;
  if (AES_set_encrypt_key((unsigned char *)key, 128, &aes) < 0) {
    return 0;
  }
  while (en_len < inlen) {
    AES_encrypt((unsigned char *)in, (unsigned char *)out, &aes);
    in += AES_BLOCK_SIZE;
    out += AES_BLOCK_SIZE;
    en_len += AES_BLOCK_SIZE;
  }
  return 1;
}


x86 assembly (clang, -O0):
<my_aes_encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     115f <my_aes_encrypt+0x3f>
cmpq   $0x0,-0x10(%rbp)
je     115f <my_aes_encrypt+0x3f>
cmpq   $0x0,-0x28(%rbp)
jne    116b <my_aes_encrypt+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    11f9 <my_aes_encrypt+0xd9>
mov    -0x10(%rbp),%rdi
mov    $0x80,%esi
lea    -0x34(%rbp),%rdx
call   1030 <AES_set_encrypt_key@plt>
cmp    $0x0,%rax
jge    1193 <my_aes_encrypt+0x73>
movl   $0x0,-0x4(%rbp)
jmp    11f9 <my_aes_encrypt+0xd9>
jmp    1198 <my_aes_encrypt+0x78>
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11f2 <my_aes_encrypt+0xd2>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   1040 <AES_encrypt@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e1a(%rip),%rax
mov    (%rax),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e08(%rip),%rax
mov    (%rax),%rcx
movslq -0x30(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x30(%rbp)
jmp    1198 <my_aes_encrypt+0x78>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_aes_encrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
test   %rdi,%rdi
je     11a7 <my_aes_encrypt+0x87>
mov    %rsi,%rbp
test   %rsi,%rsi
je     11a7 <my_aes_encrypt+0x87>
mov    %rcx,%r13
test   %rcx,%rcx
je     11a7 <my_aes_encrypt+0x87>
mov    %edx,%r15d
lea    0x4(%rsp),%rdx
mov    $0x80,%esi
call   1030 <AES_set_encrypt_key@plt>
test   %rax,%rax
js     11a5 <my_aes_encrypt+0x85>
mov    $0x1,%eax
test   %r15d,%r15d
jle    11a7 <my_aes_encrypt+0x87>
xor    %ebx,%ebx
lea    0x4(%rsp),%r12
mov    0x2e77(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1040 <AES_encrypt@plt>
mov    (%r14),%rax
add    %rax,%rbp
add    %rax,%r13
add    %eax,%ebx
cmp    %r15d,%ebx
jl     1180 <my_aes_encrypt+0x60>
mov    $0x1,%eax
jmp    11a7 <my_aes_encrypt+0x87>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@AES_BLOCK_SIZE = global i64 0
define i32 @my_aes_encrypt(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 0, i32* %11
%13 = load i8*, i8** %7
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %21
15: ; preds = %4
%16 = load i8*, i8** %6
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i8*, i8** %9
%20 = icmp ne i8* %19, null
br i1 %20, label %22, label %21
21: ; preds = %18, %15, %4
store i32 0, i32* %5
br label %48
22: ; preds = %18
%23 = load i8*, i8** %6
%24 = call i64 @AES_set_encrypt_key(i8* %23, i32 128, i32* %12)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 0, i32* %5
br label %48
27: ; preds = %22
br label %28
28: ; preds = %32, %27
%29 = load i32, i32* %11
%30 = load i32, i32* %8
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %47
32: ; preds = %28
%33 = load i8*, i8** %7
%34 = load i8*, i8** %9
%35 = call i32 @AES_encrypt(i8* %33, i8* %34, i32* %12)
%36 = load i64, i64* @AES_BLOCK_SIZE
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i64 %36
store i8* %38, i8** %7
%39 = load i64, i64* @AES_BLOCK_SIZE
%40 = load i8*, i8** %9
%41 = getelementptr inbounds i8, i8* %40, i64 %39
store i8* %41, i8** %9
%42 = load i64, i64* @AES_BLOCK_SIZE
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = add nsw i64 %44, %42
%46 = trunc i64 %45 to i32
store i32 %46, i32* %11
br label %28
47: ; preds = %28
store i32 1, i32* %5
br label %48
48: ; preds = %47, %26, %21
%49 = load i32, i32* %5
ret i32 %49
}

LLVM IR (-O2):
@AES_BLOCK_SIZE = global i64 0
define i32 @my_aes_encrypt(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = icmp ne i8* %1, null
%7 = icmp ne i8* %0, null
%8 = and i1 %7, %6
%9 = icmp ne i8* %3, null
%10 = and i1 %8, %9
br i1 %10, label %11, label %30
11: ; preds = %4
%12 = bitcast i32* %5 to i8*
%13 = call i64 @AES_set_encrypt_key(i8* %0, i32 128, i32* %5)
%14 = icmp slt i64 %13, 0
br i1 %14, label %28, label %15
15: ; preds = %11
%16 = icmp sgt i32 %2, 0
br i1 %16, label %17, label %28
17: ; preds = %15, %17
%18 = phi i32 [ %26, %17 ], [ 0, %15 ]
%19 = phi i8* [ %24, %17 ], [ %3, %15 ]
%20 = phi i8* [ %23, %17 ], [ %1, %15 ]
%21 = call i32 @AES_encrypt(i8* %20, i8* %19, i32* %5)
%22 = load i64, i64* @AES_BLOCK_SIZE
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = getelementptr inbounds i8, i8* %19, i64 %22
%25 = trunc i64 %22 to i32
%26 = add i32 %18, %25
%27 = icmp slt i32 %26, %2
br i1 %27, label %17, label %28
28: ; preds = %17, %15, %11
%29 = phi i32 [ 0, %11 ], [ 1, %15 ], [ 1, %17 ]
br label %30
30: ; preds = %4, %28
%31 = phi i32 [ %29, %28 ], [ 0, %4 ]
ret i32 %31
}