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

/* Variables and functions */
int _base64Decode(unsigned char *, unsigned int, unsigned char *,
                  unsigned int *);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *malloc(unsigned int);
int /*<<< orphan*/ printf(char *);
int base64Decode(unsigned char *in, unsigned int inLength,
                 unsigned char **out) {
  unsigned int outLength = 0;
  *out = malloc(inLength * 3.0f / 4.0f + 1);
  if (*out) {
    int ret = _base64Decode(in, inLength, *out, &outLength);
    if (ret > 0) {
      printf("Base64Utils: error decoding");
      free(*out);
      *out = NULL;
      outLength = 0;
    }
  }
  return outLength;
}


x86 assembly (clang, -O0):
<base64Decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
cvtsi2ss %rax,%xmm0
movss  0xe96(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe8e(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe86(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11fd <base64Decode+0xbd>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    -0x1c(%rbp),%rcx
call   1050 <_base64Decode@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    11f8 <base64Decode+0xb8>
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x1c(%rbp)
jmp    11fd <base64Decode+0xbd>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<base64Decode>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r15
movl   $0x0,0x4(%rsp)
mov    %esi,%eax
cvtsi2ss %rax,%xmm0
mulss  0xe9a(%rip),%xmm0
mulss  0xe96(%rip),%xmm0
addss  0xe92(%rip),%xmm0
cvttss2si %xmm0,%rdi
call   1060 <malloc@plt>
mov    %rax,(%rbx)
xor    %r14d,%r14d
test   %rax,%rax
je     11c3 <base64Decode+0x83>
lea    0x4(%rsp),%rcx
mov    %r15,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
call   1050 <_base64Decode@plt>
test   %eax,%eax
jle    11be <base64Decode+0x7e>
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
mov    (%rbx),%rdi
call   1030 <free@plt>
movq   $0x0,(%rbx)
jmp    11c3 <base64Decode+0x83>
mov    0x4(%rsp),%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Base64Utils: error decoding\00"
define i32 @base64Decode(i8* %0, i32 %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
store i32 0, i32* %7
%9 = load i32, i32* %5
%10 = uitofp i32 %9 to float
%11 = fmul float %10, 3.000000e+00
%12 = fdiv float %11, 4.000000e+00
%13 = fadd float %12, 1.000000e+00
%14 = fptoui float %13 to i32
%15 = call i8* @malloc(i32 %14)
%16 = load i8**, i8*** %6
store i8* %15, i8** %16
%17 = load i8**, i8*** %6
%18 = load i8*, i8** %17
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %35
20: ; preds = %3
%21 = load i8*, i8** %4
%22 = load i32, i32* %5
%23 = load i8**, i8*** %6
%24 = load i8*, i8** %23
%25 = call i32 @_base64Decode(i8* %21, i32 %22, i8* %24, i32* %7)
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %20
%29 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%30 = load i8**, i8*** %6
%31 = load i8*, i8** %30
%32 = call i32 @free(i8* %31)
%33 = load i8**, i8*** %6
store i8* null, i8** %33
store i32 0, i32* %7
br label %34
34: ; preds = %28, %20
br label %35
35: ; preds = %34, %3
%36 = load i32, i32* %7
ret i32 %36
}

LLVM IR (-O2):
@.str = [28 x i8] c"Base64Utils: error decoding\00"
define i32 @base64Decode(i8* %0, i32 %1, i8** nocapture %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%6 = uitofp i32 %1 to float
%7 = fmul float %6, 3.000000e+00
%8 = fmul float %7, 2.500000e-01
%9 = fadd float %8, 1.000000e+00
%10 = fptoui float %9 to i32
%11 = tail call i8* @malloc(i32 %10)
store i8* %11, i8** %2
%12 = icmp eq i8* %11, null
br i1 %12, label %22, label %13
13: ; preds = %3
%14 = call i32 @_base64Decode(i8* %0, i32 %1, i8* %11, i32* %4)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = load i32, i32* %4
br label %22
18: ; preds = %13
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%20 = load i8*, i8** %2
%21 = call i32 @free(i8* %20)
store i8* null, i8** %2
br label %22
22: ; preds = %16, %18, %3
%23 = phi i32 [ %17, %16 ], [ 0, %18 ], [ 0, %3 ]
ret i32 %23
}