#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*/ assert(unsigned char const *);
int /*<<< orphan*/ creat_array(unsigned char *);
int decode_string(unsigned char const *, unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memset(unsigned char *, int, int);
void base64_decode(const unsigned char *src, unsigned char *dest) {
  assert(src);
  unsigned char array[124];
  memset(array, 0x00, 124);
  creat_array(array);
  int index = 0;
  while (*src) {
    int step = decode_string(src, dest, array, index);
    index += step;
    src += 4;
  }
  *(dest + index) = '\0';
}


x86 assembly (clang, -O0):
<base64_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <assert@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x7c,%edx
call   1040 <memset@plt>
lea    -0x90(%rbp),%rdi
call   1030 <creat_array@plt>
movl   $0x0,-0x94(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11d5 <base64_decode+0x95>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x90(%rbp),%rdx
mov    -0x94(%rbp),%ecx
call   1060 <decode_string@plt>
mov    %eax,-0x98(%rbp)
mov    -0x98(%rbp),%eax
add    -0x94(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    1185 <base64_decode+0x45>
mov    -0x10(%rbp),%rax
movslq -0x94(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<base64_decode>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <assert@plt>
mov    %rsp,%r12
xor    %ebx,%ebx
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x7c,%edx
call   1040 <memset@plt>
mov    %r12,%rdi
call   1030 <creat_array@plt>
cmpb   $0x0,(%r15)
je     11a4 <base64_decode+0x64>
mov    %rsp,%r12
nop
mov    %ebx,%ebp
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    %ebx,%ecx
call   1060 <decode_string@plt>
mov    %eax,%ebx
add    %ebp,%ebx
cmpb   $0x0,0x4(%r15)
lea    0x4(%r15),%r15
jne    1180 <base64_decode+0x40>
movslq %ebx,%rbx
movb   $0x0,(%r14,%rbx,1)
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @base64_decode(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [124 x i8]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32 @assert(i8* %8)
%10 = getelementptr inbounds [124 x i8], [124 x i8]* %5, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i32 124)
%12 = getelementptr inbounds [124 x i8], [124 x i8]* %5, i64 0, i64 0
%13 = call i32 @creat_array(i8* %12)
store i32 0, i32* %6
br label %14
14: ; preds = %18, %2
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = load i8*, i8** %3
%20 = load i8*, i8** %4
%21 = getelementptr inbounds [124 x i8], [124 x i8]* %5, i64 0, i64 0
%22 = load i32, i32* %6
%23 = call i32 @decode_string(i8* %19, i8* %20, i8* %21, i32 %22)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = load i32, i32* %6
%26 = add nsw i32 %25, %24
store i32 %26, i32* %6
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 4
store i8* %28, i8** %3
br label %14
29: ; preds = %14
%30 = load i8*, i8** %4
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 0, i8* %33
ret void
}

LLVM IR (-O2):
define void @base64_decode(i8* %0, i8* %1) {
%3 = alloca [124 x i8]
%4 = tail call i32 @assert(i8* %0)
%5 = getelementptr inbounds [124 x i8], [124 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 124)
%7 = call i32 @creat_array(i8* %5)
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %2, %10
%11 = phi i8* [ %15, %10 ], [ %0, %2 ]
%12 = phi i32 [ %14, %10 ], [ 0, %2 ]
%13 = call i32 @decode_string(i8* %11, i8* %1, i8* %5, i32 %12)
%14 = add nsw i32 %13, %12
%15 = getelementptr inbounds i8, i8* %11, i64 4
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %10
18: ; preds = %10
%19 = sext i32 %14 to i64
br label %20
20: ; preds = %18, %2
%21 = phi i64 [ 0, %2 ], [ %19, %18 ]
%22 = getelementptr inbounds i8, i8* %1, i64 %21
store i8 0, i8* %22
ret void
}