#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 /*<<< orphan*/ Base64decode(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ replace_nl(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncpy(char *, char *, int);
int decode_base64(char *str) {
  char tmp[2048];
  strncpy(tmp, str + 2, 2048);
  if (tmp[2048 - 1] != '\0') {
    fprintf(stderr, "Value Truncated: %s, Increase MAX_VAL_LEN\n", str);
    tmp[2048 - 1] = '\0';
  }
  Base64decode(str, tmp);
  replace_nl(str);
  return 0;
}


x86 assembly (clang, -O0):
<decode_base64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x810(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x2,%rsi
mov    $0x800,%edx
call   1030 <strncpy@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     1192 <decode_base64+0x52>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe77(%rip),%rsi
call   1060 <fprintf@plt>
movb   $0x0,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1040 <Base64decode@plt>
mov    -0x8(%rbp),%rdi
call   1050 <replace_nl@plt>
xor    %eax,%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_base64>:
push   %rbx
sub    $0x800,%rsp
mov    %rdi,%rbx
lea    0x2(%rdi),%rsi
mov    %rsp,%rdi
mov    $0x800,%edx
call   1030 <strncpy@plt>
cmpb   $0x0,0x7ff(%rsp)
je     1186 <decode_base64+0x46>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
movb   $0x0,0x7ff(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <Base64decode@plt>
mov    %rbx,%rdi
call   1050 <replace_nl@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"Value Truncated: %s, Increase MAX_VAL_LEN\0A\00"
define i32 @decode_base64(i8* %0) {
%2 = alloca i8*
%3 = alloca [2048 x i8]
store i8* %0, i8** %2
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 2
%7 = call i32 @strncpy(i8* %4, i8* %6, i32 2048)
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 2047
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %2
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 2047
store i8 0, i8* %16
br label %17
17: ; preds = %12, %1
%18 = load i8*, i8** %2
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%20 = call i32 @Base64decode(i8* %18, i8* %19)
%21 = load i8*, i8** %2
%22 = call i32 @replace_nl(i8* %21)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"Value Truncated: %s, Increase MAX_VAL_LEN\0A\00"
define i32 @decode_base64(i8* %0) {
%2 = alloca [2048 x i8]
%3 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds i8, i8* %0, i64 2
%5 = call i32 @strncpy(i8* %3, i8* %4, i32 2048)
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 2047
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %0)
store i8 0, i8* %6
br label %12
12: ; preds = %9, %1
%13 = call i32 @Base64decode(i8* %0, i8* %3)
%14 = call i32 @replace_nl(i8* %0)
ret i32 0
}