#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_decrypt(unsigned char *, unsigned char *,
                               int /*<<< orphan*/ *);
int /*<<< orphan*/ AES_set_decrypt_key(unsigned char *, int,
                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memset(unsigned char *, char, int);
int strlen(unsigned char *);
int decrypt(unsigned char *in, unsigned char *out, unsigned char *key) {
  do {
  } while (0);
  if (strlen(key) < 0)
    return 0;
  unsigned char cleartext[(128 / 8)];
  unsigned char ciphertext[(128 / 8)];
  int round;
  round = strlen(in) / (128 / 8);
  AES_KEY aes_key;
  AES_set_decrypt_key(key, 128, &aes_key);
  int idx = 0;
  while (idx < round) {
    memset(ciphertext, '\0', (128 / 8));
    memcpy(ciphertext, in + idx * (128 / 8), (128 / 8));
    do {
    } while (0);
    AES_decrypt(ciphertext, cleartext, &aes_key);
    do {
    } while (0);
    memcpy(out + idx * (128 / 8), cleartext, (128 / 8));
    idx++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
jmp    1169 <decrypt+0x19>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jge    1187 <decrypt+0x37>
movl   $0x0,-0x4(%rbp)
jmp    123a <decrypt+0xea>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x80,%esi
lea    -0x48(%rbp),%rdx
call   1060 <AES_set_decrypt_key@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1233 <decrypt+0xe3>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x4c(%rbp),%eax
shl    $0x4,%eax
cltq
add    %rax,%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
jmp    11f2 <decrypt+0xa2>
lea    -0x40(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1070 <AES_decrypt@plt>
jmp    1208 <decrypt+0xb8>
mov    -0x18(%rbp),%rdi
mov    -0x4c(%rbp),%eax
shl    $0x4,%eax
cltq
add    %rax,%rdi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11b4 <decrypt+0x64>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%rbp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rdx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
js     1202 <decrypt+0xb2>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r15d
lea    0xc(%rsp),%rdx
mov    %rbp,%rdi
mov    $0x80,%esi
call   1060 <AES_set_decrypt_key@plt>
cmp    $0x10,%r15d
jl     11fb <decrypt+0xab>
shr    $0x4,%r15d
lea    0x10(%rsp),%r12
lea    0x20(%rsp),%r13
lea    0xc(%rsp),%rbp
nopl   (%rax)
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1070 <AES_decrypt@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
add    $0x10,%r14
add    $0x10,%rbx
add    $0xffffffffffffffff,%r15
jne    11b0 <decrypt+0x60>
mov    $0x1,%eax
jmp    1204 <decrypt+0xb4>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @decrypt(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [16 x i8]
%9 = alloca [16 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
br label %13
13: ; preds = %3
br label %14
14: ; preds = %13
%15 = load i8*, i8** %7
%16 = call i32 @strlen(i8* %15)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 0, i32* %4
br label %56
19: ; preds = %14
%20 = load i8*, i8** %5
%21 = call i32 @strlen(i8* %20)
%22 = sdiv i32 %21, 16
store i32 %22, i32* %10
%23 = load i8*, i8** %7
%24 = call i32 @AES_set_decrypt_key(i8* %23, i32 128, i32* %11)
store i32 0, i32* %12
br label %25
25: ; preds = %45, %19
%26 = load i32, i32* %12
%27 = load i32, i32* %10
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %55
29: ; preds = %25
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%31 = call i32 @memset(i8* %30, i8 signext 0, i32 16)
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%33 = load i8*, i8** %5
%34 = load i32, i32* %12
%35 = mul nsw i32 %34, 16
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
%38 = call i32 @memcpy(i8* %32, i8* %37, i32 16)
br label %39
39: ; preds = %29
br label %40
40: ; preds = %39
%41 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%42 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%43 = call i32 @AES_decrypt(i8* %41, i8* %42, i32* %11)
br label %44
44: ; preds = %40
br label %45
45: ; preds = %44
%46 = load i8*, i8** %6
%47 = load i32, i32* %12
%48 = mul nsw i32 %47, 16
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %46, i64 %49
%51 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%52 = call i32 @memcpy(i8* %50, i8* %51, i32 16)
%53 = load i32, i32* %12
%54 = add nsw i32 %53, 1
store i32 %54, i32* %12
br label %25
55: ; preds = %25
store i32 1, i32* %4
br label %56
56: ; preds = %55, %18
%57 = load i32, i32* %4
ret i32 %57
}

LLVM IR (-O2):
define i32 @decrypt(i8* %0, i8* %1, i8* %2) {
%4 = alloca [16 x i8]
%5 = alloca [16 x i8]
%6 = alloca i32
%7 = tail call i32 @strlen(i8* %2)
%8 = icmp slt i32 %7, 0
br i1 %8, label %31, label %9
9: ; preds = %3
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%12 = tail call i32 @strlen(i8* %0)
%13 = bitcast i32* %6 to i8*
%14 = call i32 @AES_set_decrypt_key(i8* %2, i32 128, i32* %6)
%15 = icmp sgt i32 %12, 15
br i1 %15, label %16, label %30
16: ; preds = %9
%17 = lshr i32 %12, 4
%18 = zext i32 %17 to i64
br label %19
19: ; preds = %16, %19
%20 = phi i64 [ 0, %16 ], [ %28, %19 ]
%21 = call i32 @memset(i8* %11, i8 signext 0, i32 16)
%22 = shl nsw i64 %20, 4
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = call i32 @memcpy(i8* %11, i8* %23, i32 16)
%25 = call i32 @AES_decrypt(i8* %11, i8* %10, i32* %6)
%26 = getelementptr inbounds i8, i8* %1, i64 %22
%27 = call i32 @memcpy(i8* %26, i8* %10, i32 16)
%28 = add nuw nsw i64 %20, 1
%29 = icmp eq i64 %28, %18
br i1 %29, label %30, label %19
30: ; preds = %19, %9
br label %31
31: ; preds = %3, %30
%32 = phi i32 [ 1, %30 ], [ 0, %3 ]
ret i32 %32
}