#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 AES_BLOCK_SIZE;
int /*<<< orphan*/ AES_decrypt(unsigned char *, unsigned char *,
                               int /*<<< orphan*/ *);
scalar_t__ AES_set_decrypt_key(unsigned char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int my_aes_decrypt(char *key, char *in, int inlen, char *out) {
  if (!in || !key || !out)
    return 0;
  AES_KEY aes;
  if (AES_set_decrypt_key((unsigned char *)key, 128, &aes) < 0) {
    return 0;
  }
  int en_len = 0;
  while (en_len < inlen) {
    AES_decrypt((unsigned char *)in, (unsigned char *)out, &aes);
    in += AES_BLOCK_SIZE;
    printf("AES_BLOCK_SIZE:%d\n", AES_BLOCK_SIZE);
    out += AES_BLOCK_SIZE;
    en_len += AES_BLOCK_SIZE;
  }
  return 1;
}


x86 assembly (clang, -O0):
<my_aes_decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1168 <my_aes_decrypt+0x38>
cmpq   $0x0,-0x10(%rbp)
je     1168 <my_aes_decrypt+0x38>
cmpq   $0x0,-0x28(%rbp)
jne    1174 <my_aes_decrypt+0x44>
movl   $0x0,-0x4(%rbp)
jmp    121e <my_aes_decrypt+0xee>
mov    -0x10(%rbp),%rdi
mov    $0x80,%esi
lea    -0x2c(%rbp),%rdx
call   1040 <AES_set_decrypt_key@plt>
cmp    $0x0,%rax
jge    119c <my_aes_decrypt+0x6c>
movl   $0x0,-0x4(%rbp)
jmp    121e <my_aes_decrypt+0xee>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1217 <my_aes_decrypt+0xe7>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   1050 <AES_decrypt@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    11a3 <my_aes_decrypt+0x73>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_aes_decrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
test   %rdi,%rdi
je     11c7 <my_aes_decrypt+0x97>
mov    %rsi,%rbp
test   %rsi,%rsi
je     11c7 <my_aes_decrypt+0x97>
mov    %rcx,%rbx
test   %rcx,%rcx
je     11c7 <my_aes_decrypt+0x97>
mov    %edx,%r15d
lea    0x4(%rsp),%rdx
mov    $0x80,%esi
call   1040 <AES_set_decrypt_key@plt>
test   %rax,%rax
js     11c5 <my_aes_decrypt+0x95>
mov    $0x1,%eax
test   %r15d,%r15d
jle    11c7 <my_aes_decrypt+0x97>
xor    %r14d,%r14d
mov    0x2e67(%rip),%r12
lea    0xe78(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
lea    0x4(%rsp),%rdx
call   1050 <AES_decrypt@plt>
movslq (%r12),%rsi
add    %rsi,%rbp
mov    %r13,%rdi
call   1030 <printf@plt>
movslq (%r12),%rax
add    %rax,%rbx
add    %eax,%r14d
cmp    %r15d,%r14d
jl     1190 <my_aes_decrypt+0x60>
mov    $0x1,%eax
jmp    11c7 <my_aes_decrypt+0x97>
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 i32 0
@.str = [19 x i8] c"AES_BLOCK_SIZE:%d\0A\00"
define i32 @my_aes_decrypt(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
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %20
14: ; preds = %4
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i8*, i8** %9
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %17, %14, %4
store i32 0, i32* %5
br label %49
21: ; preds = %17
%22 = load i8*, i8** %6
%23 = call i64 @AES_set_decrypt_key(i8* %22, i32 128, i32* %10)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 0, i32* %5
br label %49
26: ; preds = %21
store i32 0, i32* %11
br label %27
27: ; preds = %31, %26
%28 = load i32, i32* %11
%29 = load i32, i32* %8
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %48
31: ; preds = %27
%32 = load i8*, i8** %7
%33 = load i8*, i8** %9
%34 = call i32 @AES_decrypt(i8* %32, i8* %33, i32* %10)
%35 = load i32, i32* @AES_BLOCK_SIZE
%36 = load i8*, i8** %7
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds i8, i8* %36, i64 %37
store i8* %38, i8** %7
%39 = load i32, i32* @AES_BLOCK_SIZE
%40 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = load i32, i32* @AES_BLOCK_SIZE
%42 = load i8*, i8** %9
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds i8, i8* %42, i64 %43
store i8* %44, i8** %9
%45 = load i32, i32* @AES_BLOCK_SIZE
%46 = load i32, i32* %11
%47 = add nsw i32 %46, %45
store i32 %47, i32* %11
br label %27
48: ; preds = %27
store i32 1, i32* %5
br label %49
49: ; preds = %48, %25, %20
%50 = load i32, i32* %5
ret i32 %50
}

LLVM IR (-O2):
@AES_BLOCK_SIZE = global i32 0
@.str = [19 x i8] c"AES_BLOCK_SIZE:%d\0A\00"
define i32 @my_aes_decrypt(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 %33
11: ; preds = %4
%12 = bitcast i32* %5 to i8*
%13 = call i64 @AES_set_decrypt_key(i8* %0, i32 128, i32* %5)
%14 = icmp slt i64 %13, 0
br i1 %14, label %31, label %15
15: ; preds = %11
%16 = icmp sgt i32 %2, 0
br i1 %16, label %17, label %31
17: ; preds = %15, %17
%18 = phi i32 [ %29, %17 ], [ 0, %15 ]
%19 = phi i8* [ %28, %17 ], [ %3, %15 ]
%20 = phi i8* [ %24, %17 ], [ %1, %15 ]
%21 = call i32 @AES_decrypt(i8* %20, i8* %19, i32* %5)
%22 = load i32, i32* @AES_BLOCK_SIZE
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %22)
%26 = load i32, i32* @AES_BLOCK_SIZE
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %19, i64 %27
%29 = add nsw i32 %26, %18
%30 = icmp slt i32 %29, %2
br i1 %30, label %17, label %31
31: ; preds = %17, %15, %11
%32 = phi i32 [ 0, %11 ], [ 1, %15 ], [ 1, %17 ]
br label %33
33: ; preds = %4, %31
%34 = phi i32 [ %32, %31 ], [ 0, %4 ]
ret i32 %34
}