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

/* Variables and functions */
int __base64_value_char(int const);
void __base64_decode_block(const uint8_t *in, uint8_t *out, int max) {
  if (max)
    out[0] =
        (__base64_value_char(in[0]) << 2) | (__base64_value_char(in[1]) >> 4);
  if (max > 1)
    out[1] =
        (__base64_value_char(in[1]) << 4) | (__base64_value_char(in[2]) >> 2);
  if (max > 2)
    out[2] =
        ((__base64_value_char(in[2]) << 6) & 0xc0) | __base64_value_char(in[3]);
}


x86 assembly (clang, -O0):
<__base64_decode_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1158 <__base64_decode_block+0x48>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <__base64_value_char@plt>
shl    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <__base64_value_char@plt>
mov    -0x18(%rbp),%ecx
sar    $0x4,%eax
or     %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x1,-0x14(%rbp)
jle    118f <__base64_decode_block+0x7f>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <__base64_value_char@plt>
shl    $0x4,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
call   1030 <__base64_value_char@plt>
mov    -0x1c(%rbp),%ecx
sar    $0x2,%eax
or     %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
cmpl   $0x2,-0x14(%rbp)
jle    11c8 <__base64_decode_block+0xb8>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
call   1030 <__base64_value_char@plt>
shl    $0x6,%eax
and    $0xc0,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%edi
call   1030 <__base64_value_char@plt>
mov    -0x20(%rbp),%ecx
or     %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__base64_decode_block>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edx,%edx
je     1188 <__base64_decode_block+0x78>
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%edi
call   1030 <__base64_value_char@plt>
mov    %eax,%ebx
shl    $0x2,%ebx
mov    0x4(%r15),%edi
call   1030 <__base64_value_char@plt>
sar    $0x4,%eax
or     %ebx,%eax
mov    %eax,(%r14)
cmp    $0x2,%ebp
jl     1188 <__base64_decode_block+0x78>
mov    0x4(%r15),%edi
call   1030 <__base64_value_char@plt>
mov    %eax,%ebx
shl    $0x4,%ebx
mov    0x8(%r15),%edi
call   1030 <__base64_value_char@plt>
sar    $0x2,%eax
or     %ebx,%eax
mov    %eax,0x4(%r14)
cmp    $0x2,%ebp
je     1188 <__base64_decode_block+0x78>
mov    0x8(%r15),%edi
call   1030 <__base64_value_char@plt>
shl    $0x6,%eax
movzbl %al,%ebx
mov    0xc(%r15),%edi
call   1030 <__base64_value_char@plt>
or     %ebx,%eax
mov    %eax,0x8(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @__base64_decode_block(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %23
9: ; preds = %3
%10 = load i32*, i32** %4
%11 = getelementptr inbounds i32, i32* %10, i64 0
%12 = load i32, i32* %11
%13 = call i32 @__base64_value_char(i32 %12)
%14 = shl i32 %13, 2
%15 = load i32*, i32** %4
%16 = getelementptr inbounds i32, i32* %15, i64 1
%17 = load i32, i32* %16
%18 = call i32 @__base64_value_char(i32 %17)
%19 = ashr i32 %18, 4
%20 = or i32 %14, %19
%21 = load i32*, i32** %5
%22 = getelementptr inbounds i32, i32* %21, i64 0
store i32 %20, i32* %22
br label %23
23: ; preds = %9, %3
%24 = load i32, i32* %6
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %40
26: ; preds = %23
%27 = load i32*, i32** %4
%28 = getelementptr inbounds i32, i32* %27, i64 1
%29 = load i32, i32* %28
%30 = call i32 @__base64_value_char(i32 %29)
%31 = shl i32 %30, 4
%32 = load i32*, i32** %4
%33 = getelementptr inbounds i32, i32* %32, i64 2
%34 = load i32, i32* %33
%35 = call i32 @__base64_value_char(i32 %34)
%36 = ashr i32 %35, 2
%37 = or i32 %31, %36
%38 = load i32*, i32** %5
%39 = getelementptr inbounds i32, i32* %38, i64 1
store i32 %37, i32* %39
br label %40
40: ; preds = %26, %23
%41 = load i32, i32* %6
%42 = icmp sgt i32 %41, 2
br i1 %42, label %43, label %57
43: ; preds = %40
%44 = load i32*, i32** %4
%45 = getelementptr inbounds i32, i32* %44, i64 2
%46 = load i32, i32* %45
%47 = call i32 @__base64_value_char(i32 %46)
%48 = shl i32 %47, 6
%49 = and i32 %48, 192
%50 = load i32*, i32** %4
%51 = getelementptr inbounds i32, i32* %50, i64 3
%52 = load i32, i32* %51
%53 = call i32 @__base64_value_char(i32 %52)
%54 = or i32 %49, %53
%55 = load i32*, i32** %5
%56 = getelementptr inbounds i32, i32* %55, i64 2
store i32 %54, i32* %56
br label %57
57: ; preds = %43, %40
ret void
}

LLVM IR (-O2):
define void @__base64_decode_block(i32* nocapture %0, i32* nocapture writeonly %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %36, label %5
5: ; preds = %3
%6 = load i32, i32* %0
%7 = tail call i32 @__base64_value_char(i32 %6)
%8 = shl i32 %7, 2
%9 = getelementptr inbounds i32, i32* %0, i64 1
%10 = load i32, i32* %9
%11 = tail call i32 @__base64_value_char(i32 %10)
%12 = ashr i32 %11, 4
%13 = or i32 %12, %8
store i32 %13, i32* %1
%14 = icmp sgt i32 %2, 1
br i1 %14, label %15, label %36
15: ; preds = %5
%16 = load i32, i32* %9
%17 = tail call i32 @__base64_value_char(i32 %16)
%18 = shl i32 %17, 4
%19 = getelementptr inbounds i32, i32* %0, i64 2
%20 = load i32, i32* %19
%21 = tail call i32 @__base64_value_char(i32 %20)
%22 = ashr i32 %21, 2
%23 = or i32 %22, %18
%24 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %23, i32* %24
%25 = icmp eq i32 %2, 2
br i1 %25, label %36, label %26
26: ; preds = %15
%27 = load i32, i32* %19
%28 = tail call i32 @__base64_value_char(i32 %27)
%29 = shl i32 %28, 6
%30 = and i32 %29, 192
%31 = getelementptr inbounds i32, i32* %0, i64 3
%32 = load i32, i32* %31
%33 = tail call i32 @__base64_value_char(i32 %32)
%34 = or i32 %30, %33
%35 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %34, i32* %35
br label %36
36: ; preds = %3, %5, %26, %15
ret void
}