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

/* Variables and functions */
int firetalk_debase64_char(char const);
int strlen(char const *const);
const char *firetalk_debase64(const char *const str) {
  static unsigned char out[256];
  int s, o, len = strlen(str);
  for (o = s = 0; (s <= (len - 3)) && (o < (sizeof(out) - 3)); s += 4, o += 3) {
    out[o] = (firetalk_debase64_char(str[s]) << 2) |
             (firetalk_debase64_char(str[s + 1]) >> 4);
    out[o + 1] = (firetalk_debase64_char(str[s + 1]) << 4) |
                 (firetalk_debase64_char(str[s + 2]) >> 2);
    out[o + 2] = (firetalk_debase64_char(str[s + 2]) << 6) |
                 firetalk_debase64_char(str[s + 3]);
  }
  out[o] = 0;
  return ((char *)out);
}


x86 assembly (clang, -O0):
<firetalk_debase64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x14(%rbp),%edx
sub    $0x3,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x15(%rbp)
jg     116c <firetalk_debase64+0x4c>
movslq -0x10(%rbp),%rax
cmp    $0xfd,%rax
setb   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    117c <firetalk_debase64+0x5c>
jmp    1279 <firetalk_debase64+0x159>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <firetalk_debase64_char@plt>
shl    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <firetalk_debase64_char@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
sar    $0x4,%ecx
or     %ecx,%eax
mov    %al,%dl
movslq -0x10(%rbp),%rcx
lea    0x2e80(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <firetalk_debase64_char@plt>
shl    $0x4,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <firetalk_debase64_char@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sar    $0x2,%ecx
or     %ecx,%eax
mov    %al,%dl
mov    -0x10(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2e2f(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <firetalk_debase64_char@plt>
shl    $0x6,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <firetalk_debase64_char@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
or     %ecx,%eax
mov    %al,%dl
mov    -0x10(%rbp),%eax
add    $0x2,%eax
movslq %eax,%rcx
lea    0x2de1(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x10(%rbp)
jmp    1146 <firetalk_debase64+0x26>
movslq -0x10(%rbp),%rcx
lea    0x2dbc(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2db1(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<firetalk_debase64>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
call   1030 <strlen@plt>
cmp    $0x3,%eax
jl     11eb <firetalk_debase64+0xcb>
mov    %eax,%r14d
add    $0xfffffffd,%r14d
mov    $0x4,%ebx
xor    %r13d,%r13d
lea    0x2eee(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl -0x4(%r15,%rbx,1),%edi
call   1040 <firetalk_debase64_char@plt>
mov    %eax,%ebp
shl    $0x2,%ebp
movsbl -0x3(%r15,%rbx,1),%edi
call   1040 <firetalk_debase64_char@plt>
shr    $0x4,%eax
or     %ebp,%eax
mov    %al,0x0(%r13,%r12,1)
movsbl -0x3(%r15,%rbx,1),%edi
call   1040 <firetalk_debase64_char@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl -0x2(%r15,%rbx,1),%edi
call   1040 <firetalk_debase64_char@plt>
shr    $0x2,%eax
or     %ebp,%eax
mov    %al,0x1(%r13,%r12,1)
movsbl -0x2(%r15,%rbx,1),%edi
call   1040 <firetalk_debase64_char@plt>
mov    %eax,%ebp
shl    $0x6,%ebp
movsbl -0x1(%r15,%rbx,1),%edi
call   1040 <firetalk_debase64_char@plt>
or     %ebp,%eax
mov    %al,0x2(%r13,%r12,1)
lea    0x3(%r13),%rcx
cmp    %r14,%rbx
ja     11ed <firetalk_debase64+0xcd>
add    $0x4,%rbx
cmp    $0xfa,%r13
mov    %rcx,%r13
jb     1160 <firetalk_debase64+0x40>
jmp    11ed <firetalk_debase64+0xcd>
xor    %ecx,%ecx
lea    0x2e4c(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@firetalk_debase64.out = internal global [256 x i8] zeroinitializer
define i8* @firetalk_debase64(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %5
store i32 0, i32* %3
store i32 0, i32* %4
br label %8
8: ; preds = %83, %1
%9 = load i32, i32* %3
%10 = load i32, i32* %5
%11 = sub nsw i32 %10, 3
%12 = icmp sle i32 %9, %11
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = icmp ult i64 %15, 253
br label %17
17: ; preds = %13, %8
%18 = phi i1 [ false, %8 ], [ %16, %13 ]
br i1 %18, label %19, label %88
19: ; preds = %17
%20 = load i8*, i8** %2
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = call i32 @firetalk_debase64_char(i8 signext %24)
%26 = shl i32 %25, 2
%27 = load i8*, i8** %2
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
%32 = load i8, i8* %31
%33 = call i32 @firetalk_debase64_char(i8 signext %32)
%34 = ashr i32 %33, 4
%35 = or i32 %26, %34
%36 = trunc i32 %35 to i8
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [256 x i8], [256 x i8]* @firetalk_debase64.out, i64 0, i64 %38
store i8 %36, i8* %39
%40 = load i8*, i8** %2
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %40, i64 %43
%45 = load i8, i8* %44
%46 = call i32 @firetalk_debase64_char(i8 signext %45)
%47 = shl i32 %46, 4
%48 = load i8*, i8** %2
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 2
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %48, i64 %51
%53 = load i8, i8* %52
%54 = call i32 @firetalk_debase64_char(i8 signext %53)
%55 = ashr i32 %54, 2
%56 = or i32 %47, %55
%57 = trunc i32 %56 to i8
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [256 x i8], [256 x i8]* @firetalk_debase64.out, i64 0, i64 %60
store i8 %57, i8* %61
%62 = load i8*, i8** %2
%63 = load i32, i32* %3
%64 = add nsw i32 %63, 2
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %62, i64 %65
%67 = load i8, i8* %66
%68 = call i32 @firetalk_debase64_char(i8 signext %67)
%69 = shl i32 %68, 6
%70 = load i8*, i8** %2
%71 = load i32, i32* %3
%72 = add nsw i32 %71, 3
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %70, i64 %73
%75 = load i8, i8* %74
%76 = call i32 @firetalk_debase64_char(i8 signext %75)
%77 = or i32 %69, %76
%78 = trunc i32 %77 to i8
%79 = load i32, i32* %4
%80 = add nsw i32 %79, 2
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [256 x i8], [256 x i8]* @firetalk_debase64.out, i64 0, i64 %81
store i8 %78, i8* %82
br label %83
83: ; preds = %19
%84 = load i32, i32* %3
%85 = add nsw i32 %84, 4
store i32 %85, i32* %3
%86 = load i32, i32* %4
%87 = add nsw i32 %86, 3
store i32 %87, i32* %4
br label %8
88: ; preds = %17
%89 = load i32, i32* %4
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [256 x i8], [256 x i8]* @firetalk_debase64.out, i64 0, i64 %90
store i8 0, i8* %91
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @firetalk_debase64.out, i64 0, i64 0)
}

LLVM IR (-O2):
@firetalk_debase64.out = internal global [256 x i8] zeroinitializer
define i8* @firetalk_debase64(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 2
br i1 %3, label %4, label %50
4: ; preds = %1
%5 = add nsw i32 %2, -3
%6 = zext i32 %5 to i64
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %46, %7 ]
%9 = phi i64 [ 0, %4 ], [ %45, %7 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = tail call i32 @firetalk_debase64_char(i8 signext %11)
%13 = shl i32 %12, 2
%14 = or i64 %9, 1
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = tail call i32 @firetalk_debase64_char(i8 signext %16)
%18 = lshr i32 %17, 4
%19 = or i32 %18, %13
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds [256 x i8], [256 x i8]* @firetalk_debase64.out, i64 0, i64 %8
store i8 %20, i8* %21
%22 = load i8, i8* %15
%23 = tail call i32 @firetalk_debase64_char(i8 signext %22)
%24 = shl i32 %23, 4
%25 = or i64 %9, 2
%26 = getelementptr inbounds i8, i8* %0, i64 %25
%27 = load i8, i8* %26
%28 = tail call i32 @firetalk_debase64_char(i8 signext %27)
%29 = lshr i32 %28, 2
%30 = or i32 %29, %24
%31 = trunc i32 %30 to i8
%32 = add nuw nsw i64 %8, 1
%33 = getelementptr inbounds [256 x i8], [256 x i8]* @firetalk_debase64.out, i64 0, i64 %32
store i8 %31, i8* %33
%34 = load i8, i8* %26
%35 = tail call i32 @firetalk_debase64_char(i8 signext %34)
%36 = shl i32 %35, 6
%37 = or i64 %9, 3
%38 = getelementptr inbounds i8, i8* %0, i64 %37
%39 = load i8, i8* %38
%40 = tail call i32 @firetalk_debase64_char(i8 signext %39)
%41 = or i32 %40, %36
%42 = trunc i32 %41 to i8
%43 = add nuw nsw i64 %8, 2
%44 = getelementptr inbounds [256 x i8], [256 x i8]* @firetalk_debase64.out, i64 0, i64 %43
store i8 %42, i8* %44
%45 = add nuw nsw i64 %9, 4
%46 = add nuw nsw i64 %8, 3
%47 = icmp ule i64 %45, %6
%48 = icmp ult i64 %8, 250
%49 = select i1 %47, i1 %48, i1 false
br i1 %49, label %7, label %50
50: ; preds = %7, %1
%51 = phi i64 [ 0, %1 ], [ %46, %7 ]
%52 = getelementptr inbounds [256 x i8], [256 x i8]* @firetalk_debase64.out, i64 0, i64 %51
store i8 0, i8* %52
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @firetalk_debase64.out, i64 0, i64 0)
}