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

/* Variables and functions */
int AMCBase64Decode(char *, unsigned char *, unsigned long *);
int /*<<< orphan*/ errPrintf(char *);
int /*<<< orphan*/ printData(unsigned char *, unsigned long);
int /*<<< orphan*/ printf(char *);
int _testDecodeMain(int argc, char *argv[]) {
  char inputStr[] = "JCgvdXNyL3NiaW4vdGVsbmV0ZCk";
  unsigned char outputStr[sizeof(inputStr)];
  int callStat;
  unsigned long outputLen;
  callStat = AMCBase64Decode(inputStr, outputStr, &outputLen);
  if (callStat < 0) {
    errPrintf("Failed to decode Base64.\n");
  } else {
    printf("Decoding result:\n");
    printData(outputStr, outputLen);
  }
  return callStat;
}


x86 assembly (clang, -O0):
<_testDecodeMain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea2(%rip),%eax
mov    %eax,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1040 <AMCBase64Decode@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    11a8 <_testDecodeMain+0x68>
lea    0xe7e(%rip),%rdi
call   1030 <errPrintf@plt>
jmp    11c1 <_testDecodeMain+0x81>
lea    0xe87(%rip),%rdi
call   1050 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   1060 <printData@plt>
mov    -0x54(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_testDecodeMain>:
push   %rbx
sub    $0x50,%rsp
movups 0xec0(%rip),%xmm0
movups %xmm0,0x1c(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0x30(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <AMCBase64Decode@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1194 <_testDecodeMain+0x54>
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%rsi
lea    0x30(%rsp),%rdi
call   1060 <printData@plt>
jmp    11a0 <_testDecodeMain+0x60>
lea    0xe81(%rip),%rdi
call   1030 <errPrintf@plt>
mov    %ebx,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const._testDecodeMain.inputStr = [28 x i8] c"JCgvdXNyL3NiaW4vdGVsbmV0ZCk\00"
@.str = [26 x i8] c"Failed to decode Base64.\0A\00"
@.str.1 = [18 x i8] c"Decoding result:\0A\00"
define i32 @_testDecodeMain(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [28 x i8]
%6 = alloca [28 x i8]
%7 = alloca i32
%8 = alloca i64
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = bitcast [28 x i8]* %5 to i8*
%10 = getelementptr inbounds [28 x i8], [28 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [28 x i8], [28 x i8]* %6, i64 0, i64 0
%12 = call i32 @AMCBase64Decode(i8* %10, i8* %11, i64* %8)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @errPrintf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %22
17: ; preds = %2
%18 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%19 = getelementptr inbounds [28 x i8], [28 x i8]* %6, i64 0, i64 0
%20 = load i64, i64* %8
%21 = call i32 @printData(i8* %19, i64 %20)
br label %22
22: ; preds = %17, %15
%23 = load i32, i32* %7
ret i32 %23
}

LLVM IR (-O2):
@__const._testDecodeMain.inputStr = [28 x i8] c"JCgvdXNyL3NiaW4vdGVsbmV0ZCk\00"
@.str = [26 x i8] c"Failed to decode Base64.\0A\00"
@str = [17 x i8] c"Decoding result:\00"
define i32 @_testDecodeMain(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [28 x i8]
%4 = alloca [28 x i8]
%5 = alloca i64
%6 = getelementptr inbounds [28 x i8], [28 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [28 x i8], [28 x i8]* %4, i64 0, i64 0
%8 = bitcast i64* %5 to i8*
%9 = call i32 @AMCBase64Decode(i8* %6, i8* %7, i64* %5)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @errPrintf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %17
13: ; preds = %2
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%15 = load i64, i64* %5
%16 = call i32 @printData(i8* %7, i64 %15)
br label %17
17: ; preds = %13, %11
ret i32 %9
}