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

/* Variables and functions */
char *cipher_aes_decrypt(unsigned char *, int, int *,
                         int /*<<< orphan*/ const *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
unsigned char *unbase64(char const *, int, int *);
char *cipher_aes_b64_decrypt(const unsigned char *in, int inlen, int *outlen,
                             const uint8_t *key) {
  *outlen = 0;
  if (!in || inlen == 0) {
    return NULL;
  }
  int ub64len;
  unsigned char *ub64 = unbase64((const char *)in, inlen, &ub64len);
  if (!ub64) {
    return NULL;
  }
  if ((ub64len % (4 * 4)) || ub64len < (4 * 4)) {
    memset(ub64, 0, ub64len);
    free(ub64);
    return NULL;
  }
  char *ret = cipher_aes_decrypt(ub64, ub64len, outlen, key);
  memset(ub64, 0, ub64len);
  free(ub64);
  return ret;
}


x86 assembly (clang, -O0):
<cipher_aes_b64_decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
cmpq   $0x0,-0x10(%rbp)
je     1176 <cipher_aes_b64_decrypt+0x36>
cmpl   $0x0,-0x14(%rbp)
jne    1183 <cipher_aes_b64_decrypt+0x43>
movq   $0x0,-0x8(%rbp)
jmp    1228 <cipher_aes_b64_decrypt+0xe8>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x2c(%rbp),%rdx
call   1040 <unbase64@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11af <cipher_aes_b64_decrypt+0x6f>
movq   $0x0,-0x8(%rbp)
jmp    1228 <cipher_aes_b64_decrypt+0xe8>
mov    -0x2c(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11cd <cipher_aes_b64_decrypt+0x8d>
cmpl   $0x10,-0x2c(%rbp)
jge    11f1 <cipher_aes_b64_decrypt+0xb1>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1228 <cipher_aes_b64_decrypt+0xe8>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <cipher_aes_decrypt@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cipher_aes_b64_decrypt>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x0,(%rdx)
xor    %r12d,%r12d
test   %rdi,%rdi
je     11b3 <cipher_aes_b64_decrypt+0x73>
test   %esi,%esi
je     11b3 <cipher_aes_b64_decrypt+0x73>
mov    %rcx,%r15
mov    %rdx,%rbx
lea    0x4(%rsp),%rdx
call   1040 <unbase64@plt>
test   %rax,%rax
je     11b0 <cipher_aes_b64_decrypt+0x70>
mov    %rax,%r14
mov    0x4(%rsp),%edx
xor    %r12d,%r12d
cmp    $0x10,%edx
jl     119c <cipher_aes_b64_decrypt+0x5c>
mov    %edx,%eax
and    $0xf,%eax
jne    119c <cipher_aes_b64_decrypt+0x5c>
mov    %r14,%rdi
mov    %edx,%esi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1050 <cipher_aes_decrypt@plt>
mov    %rax,%r12
mov    0x4(%rsp),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    11b3 <cipher_aes_b64_decrypt+0x73>
xor    %r12d,%r12d
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @cipher_aes_b64_decrypt(i8* %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i32* %3, i32** %9
%13 = load i32*, i32** %8
store i32 0, i32* %13
%14 = load i8*, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %4
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16, %4
store i8* null, i8** %5
br label %52
20: ; preds = %16
%21 = load i8*, i8** %6
%22 = load i32, i32* %7
%23 = call i8* @unbase64(i8* %21, i32 %22, i32* %10)
store i8* %23, i8** %11
%24 = load i8*, i8** %11
%25 = icmp ne i8* %24, null
br i1 %25, label %27, label %26
26: ; preds = %20
store i8* null, i8** %5
br label %52
27: ; preds = %20
%28 = load i32, i32* %10
%29 = srem i32 %28, 16
%30 = icmp ne i32 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %27
%32 = load i32, i32* %10
%33 = icmp slt i32 %32, 16
br i1 %33, label %34, label %40
34: ; preds = %31, %27
%35 = load i8*, i8** %11
%36 = load i32, i32* %10
%37 = call i32 @memset(i8* %35, i32 0, i32 %36)
%38 = load i8*, i8** %11
%39 = call i32 @free(i8* %38)
store i8* null, i8** %5
br label %52
40: ; preds = %31
%41 = load i8*, i8** %11
%42 = load i32, i32* %10
%43 = load i32*, i32** %8
%44 = load i32*, i32** %9
%45 = call i8* @cipher_aes_decrypt(i8* %41, i32 %42, i32* %43, i32* %44)
store i8* %45, i8** %12
%46 = load i8*, i8** %11
%47 = load i32, i32* %10
%48 = call i32 @memset(i8* %46, i32 0, i32 %47)
%49 = load i8*, i8** %11
%50 = call i32 @free(i8* %49)
%51 = load i8*, i8** %12
store i8* %51, i8** %5
br label %52
52: ; preds = %40, %34, %26, %19
%53 = load i8*, i8** %5
ret i8* %53
}

LLVM IR (-O2):
define i8* @cipher_aes_b64_decrypt(i8* %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca i32
store i32 0, i32* %2
%6 = icmp eq i8* %0, null
%7 = icmp eq i32 %1, 0
%8 = or i1 %6, %7
br i1 %8, label %29, label %9
9: ; preds = %4
%10 = bitcast i32* %5 to i8*
%11 = call i8* @unbase64(i8* %0, i32 %1, i32* %5)
%12 = icmp eq i8* %11, null
br i1 %12, label %27, label %13
13: ; preds = %9
%14 = load i32, i32* %5
%15 = and i32 %14, 15
%16 = icmp ne i32 %15, 0
%17 = icmp slt i32 %14, 16
%18 = or i1 %17, %16
br i1 %18, label %22, label %19
19: ; preds = %13
%20 = call i8* @cipher_aes_decrypt(i8* %11, i32 %14, i32* %2, i32* %3)
%21 = load i32, i32* %5
br label %22
22: ; preds = %13, %19
%23 = phi i32 [ %21, %19 ], [ %14, %13 ]
%24 = phi i8* [ %20, %19 ], [ null, %13 ]
%25 = call i32 @memset(i8* %11, i32 0, i32 %23)
%26 = call i32 @free(i8* %11)
br label %27
27: ; preds = %22, %9
%28 = phi i8* [ null, %9 ], [ %24, %22 ]
br label %29
29: ; preds = %4, %27
%30 = phi i8* [ %28, %27 ], [ null, %4 ]
ret i8* %30
}