#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*/ _error(char *, int);
char *malloc(size_t);
size_t strlen(char const *);
char *_hash_base64(char const *password) {
  char *ret;
  char *r;
  const char conv[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                      "abcdefghijklmnopqrstuvwxyz0123456789+/";
  size_t len;
  size_t i;
  size_t j;
  unsigned char bufi[3];
  len = strlen(password);
  if ((ret = malloc(len * 4 / 3 + 4)) == NULL) {
    _error("malloc", 1);
    return NULL;
  }
  r = ret;
  for (i = 0; i < len;) {
    for (j = 0; j < 3; i++, j++)
      bufi[j] = (i < len) ? password[i] : '\0';
    *(r++) = conv[bufi[0] >> 2];
    *(r++) = conv[(bufi[0] & 0x3) << 4 | (bufi[1] >> 4)];
    *(r++) = (i - 2 < len) ? conv[(bufi[1] & 0xf) << 2 | (bufi[2] >> 6)] : '=';
    *(r++) = (i - 1 < len) ? conv[bufi[2] & 0x3f] : '=';
  }
  *(r++) = '\0';
  return ret;
}


x86 assembly (clang, -O0):
<_hash_base64>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x41,%edx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
shl    $0x2,%rax
mov    $0x3,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdi
add    $0x4,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11bb <_hash_base64+0x7b>
lea    0xe9d(%rip),%rdi
mov    $0x1,%esi
call   1060 <_error@plt>
movq   $0x0,-0x8(%rbp)
jmp    138a <_hash_base64+0x24a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x80(%rbp)
mov    -0x80(%rbp),%rax
cmp    -0x78(%rbp),%rax
jae    1370 <_hash_base64+0x230>
movq   $0x0,-0x88(%rbp)
cmpq   $0x3,-0x88(%rbp)
03
jae    125d <_hash_base64+0x11d>
mov    -0x80(%rbp),%rax
cmp    -0x78(%rbp),%rax
jae    1217 <_hash_base64+0xd7>
mov    -0x10(%rbp),%rax
mov    -0x80(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x90(%rbp)
jmp    1224 <_hash_base64+0xe4>
xor    %eax,%eax
mov    %eax,-0x90(%rbp)
jmp    1224 <_hash_base64+0xe4>
mov    -0x90(%rbp),%eax
mov    %al,%cl
mov    -0x88(%rbp),%rax
mov    %cl,-0x8b(%rbp,%rax,1)
mov    -0x80(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x80(%rbp)
mov    -0x88(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x88(%rbp)
jmp    11e4 <_hash_base64+0xa4>
movzbl -0x8b(%rbp),%eax
sar    $0x2,%eax
cltq
mov    -0x70(%rbp,%rax,1),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
movzbl -0x8b(%rbp),%eax
and    $0x3,%eax
shl    $0x4,%eax
movzbl -0x8a(%rbp),%ecx
sar    $0x4,%ecx
or     %ecx,%eax
cltq
mov    -0x70(%rbp,%rax,1),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x80(%rbp),%rax
sub    $0x2,%rax
cmp    -0x78(%rbp),%rax
jae    12eb <_hash_base64+0x1ab>
movzbl -0x8a(%rbp),%eax
and    $0xf,%eax
shl    $0x2,%eax
movzbl -0x89(%rbp),%ecx
sar    $0x6,%ecx
or     %ecx,%eax
cltq
movsbl -0x70(%rbp,%rax,1),%eax
mov    %eax,-0x94(%rbp)
jmp    12fb <_hash_base64+0x1bb>
mov    $0x3d,%eax
mov    %eax,-0x94(%rbp)
jmp    12fb <_hash_base64+0x1bb>
mov    -0x94(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x80(%rbp),%rax
sub    $0x1,%rax
cmp    -0x78(%rbp),%rax
jae    1342 <_hash_base64+0x202>
movzbl -0x89(%rbp),%eax
and    $0x3f,%eax
cltq
movsbl -0x70(%rbp,%rax,1),%eax
mov    %eax,-0x98(%rbp)
jmp    1352 <_hash_base64+0x212>
mov    $0x3d,%eax
mov    %eax,-0x98(%rbp)
jmp    1352 <_hash_base64+0x212>
mov    -0x98(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    11cb <_hash_base64+0x8b>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_hash_base64>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %rax,%r12
lea    0x0(,%rax,4),%rax
movabs $0xaaaaaaaaaaaaaaab,%rcx
aa aa aa
mul    %rcx
shr    %rdx
lea    0x4(%rdx),%rdi
call   1040 <malloc@plt>
mov    %rax,%r14
test   %rax,%rax
je     124d <_hash_base64+0x11d>
mov    %r14,%rdi
test   %r12,%r12
je     1248 <_hash_base64+0x118>
mov    $0x2,%edx
lea    0xe78(%rip),%r8
mov    %r14,%rdi
jmp    11ab <_hash_base64+0x7b>
nopl   (%rax)
mov    %bl,0x3(%rdi)
add    $0x4,%rdi
lea    0x3(%rdx),%rax
add    $0x1,%rdx
cmp    %r12,%rdx
mov    %rax,%rdx
jae    1248 <_hash_base64+0x118>
lea    -0x1(%rdx),%r10
cmp    %r12,%r10
jae    11d0 <_hash_base64+0xa0>
movzbl -0x1(%r15,%rdx,1),%esi
cmp    %r12,%rdx
jb     11d7 <_hash_base64+0xa7>
xor    %r9d,%r9d
jmp    11dc <_hash_base64+0xac>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %esi,%esi
cmp    %r12,%rdx
jae    11bf <_hash_base64+0x8f>
movzbl (%r15,%rdx,1),%r9d
movzbl -0x2(%r15,%rdx,1),%ecx
mov    %rcx,%rbx
shr    $0x2,%rbx
mov    %esi,%eax
shr    $0x4,%al
shl    $0x4,%cl
or     %al,%cl
and    $0x3f,%cl
movzbl (%rbx,%r8,1),%eax
mov    %al,(%rdi)
movzbl %cl,%eax
movzbl (%rax,%r8,1),%eax
mov    %al,0x1(%rdi)
mov    $0x3d,%bl
mov    $0x3d,%cl
cmp    %r12,%r10
jae    122b <_hash_base64+0xfb>
mov    %r9d,%eax
shr    $0x6,%al
shl    $0x2,%sil
or     %al,%sil
and    $0x3f,%sil
movzbl %sil,%eax
movzbl (%rax,%r8,1),%ecx
mov    %cl,0x2(%rdi)
cmp    %r12,%rdx
jae    1190 <_hash_base64+0x60>
movzbl %r9b,%eax
and    $0x3f,%eax
movzbl (%rax,%r8,1),%ebx
jmp    1190 <_hash_base64+0x60>
movb   $0x0,(%rdi)
jmp    125e <_hash_base64+0x12e>
lea    0xded(%rip),%rdi
mov    $0x1,%esi
call   1050 <_error@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const._hash_base64.conv = [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\00"
@.str = [7 x i8] c"malloc\00"
define i8* @_hash_base64(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [65 x i8]
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca [3 x i8]
store i8* %0, i8** %3
%11 = bitcast [65 x i8]* %6 to i8*
%12 = load i8*, i8** %3
%13 = call i64 @strlen(i8* %12)
store i64 %13, i64* %7
%14 = load i64, i64* %7
%15 = mul i64 %14, 4
%16 = udiv i64 %15, 3
%17 = add i64 %16, 4
%18 = call i8* @malloc(i64 %17)
store i8* %18, i8** %4
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %1
%21 = call i32 @_error(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 1)
store i8* null, i8** %2
br label %126
22: ; preds = %1
%23 = load i8*, i8** %4
store i8* %23, i8** %5
store i64 0, i64* %8
br label %24
24: ; preds = %117, %22
%25 = load i64, i64* %8
%26 = load i64, i64* %7
%27 = icmp ult i64 %25, %26
br i1 %27, label %28, label %122
28: ; preds = %24
store i64 0, i64* %9
br label %29
29: ; preds = %48, %28
%30 = load i64, i64* %9
%31 = icmp ult i64 %30, 3
br i1 %31, label %32, label %53
32: ; preds = %29
%33 = load i64, i64* %8
%34 = load i64, i64* %7
%35 = icmp ult i64 %33, %34
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i8*, i8** %3
%38 = load i64, i64* %8
%39 = getelementptr inbounds i8, i8* %37, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
br label %43
42: ; preds = %32
br label %43
43: ; preds = %42, %36
%44 = phi i32 [ %41, %36 ], [ 0, %42 ]
%45 = trunc i32 %44 to i8
%46 = load i64, i64* %9
%47 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 %46
store i8 %45, i8* %47
br label %48
48: ; preds = %43
%49 = load i64, i64* %8
%50 = add i64 %49, 1
store i64 %50, i64* %8
%51 = load i64, i64* %9
%52 = add i64 %51, 1
store i64 %52, i64* %9
br label %29
53: ; preds = %29
%54 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 0
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = ashr i32 %56, 2
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = load i8*, i8** %5
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %5
store i8 %60, i8* %61
%63 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 0
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = and i32 %65, 3
%67 = shl i32 %66, 4
%68 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 1
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = ashr i32 %70, 4
%72 = or i32 %67, %71
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 %73
%75 = load i8, i8* %74
%76 = load i8*, i8** %5
%77 = getelementptr inbounds i8, i8* %76, i32 1
store i8* %77, i8** %5
store i8 %75, i8* %76
%78 = load i64, i64* %8
%79 = sub i64 %78, 2
%80 = load i64, i64* %7
%81 = icmp ult i64 %79, %80
br i1 %81, label %82, label %97
82: ; preds = %53
%83 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 1
%84 = load i8, i8* %83
%85 = zext i8 %84 to i32
%86 = and i32 %85, 15
%87 = shl i32 %86, 2
%88 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 2
%89 = load i8, i8* %88
%90 = zext i8 %89 to i32
%91 = ashr i32 %90, 6
%92 = or i32 %87, %91
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 %93
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
br label %98
97: ; preds = %53
br label %98
98: ; preds = %97, %82
%99 = phi i32 [ %96, %82 ], [ 61, %97 ]
%100 = trunc i32 %99 to i8
%101 = load i8*, i8** %5
%102 = getelementptr inbounds i8, i8* %101, i32 1
store i8* %102, i8** %5
store i8 %100, i8* %101
%103 = load i64, i64* %8
%104 = sub i64 %103, 1
%105 = load i64, i64* %7
%106 = icmp ult i64 %104, %105
br i1 %106, label %107, label %116
107: ; preds = %98
%108 = getelementptr inbounds [3 x i8], [3 x i8]* %10, i64 0, i64 2
%109 = load i8, i8* %108
%110 = zext i8 %109 to i32
%111 = and i32 %110, 63
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 %112
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
br label %117
116: ; preds = %98
br label %117
117: ; preds = %116, %107
%118 = phi i32 [ %115, %107 ], [ 61, %116 ]
%119 = trunc i32 %118 to i8
%120 = load i8*, i8** %5
%121 = getelementptr inbounds i8, i8* %120, i32 1
store i8* %121, i8** %5
store i8 %119, i8* %120
br label %24
122: ; preds = %24
%123 = load i8*, i8** %5
%124 = getelementptr inbounds i8, i8* %123, i32 1
store i8* %124, i8** %5
store i8 0, i8* %123
%125 = load i8*, i8** %4
store i8* %125, i8** %2
br label %126
126: ; preds = %122, %20
%127 = load i8*, i8** %2
ret i8* %127
}

LLVM IR (-O2):
@__const._hash_base64.conv = [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\00"
@.str = [7 x i8] c"malloc\00"
define noalias i8* @_hash_base64(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = shl i64 %2, 2
%4 = udiv i64 %3, 3
%5 = add nuw nsw i64 %4, 4
%6 = tail call i8* @malloc(i64 %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = icmp eq i64 %2, 0
br i1 %9, label %65, label %12
10: ; preds = %1
%11 = tail call i32 @_error(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 1)
br label %67
12: ; preds = %8, %61
%13 = phi i64 [ %31, %61 ], [ 0, %8 ]
%14 = phi i8* [ %63, %61 ], [ %6, %8 ]
%15 = getelementptr inbounds i8, i8* %0, i64 %13
%16 = load i8, i8* %15
%17 = add nuw i64 %13, 1
%18 = icmp ult i64 %17, %2
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = getelementptr inbounds i8, i8* %0, i64 %17
%21 = load i8, i8* %20
br label %22
22: ; preds = %19, %12
%23 = phi i8 [ %21, %19 ], [ 0, %12 ]
%24 = add i64 %13, 2
%25 = icmp ult i64 %24, %2
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = getelementptr inbounds i8, i8* %0, i64 %24
%28 = load i8, i8* %27
br label %29
29: ; preds = %26, %22
%30 = phi i8 [ %28, %26 ], [ 0, %22 ]
%31 = add i64 %13, 3
%32 = lshr i8 %16, 2
%33 = zext i8 %32 to i64
%34 = getelementptr inbounds [65 x i8], [65 x i8]* @__const._hash_base64.conv, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = getelementptr inbounds i8, i8* %14, i64 1
store i8 %35, i8* %14
%37 = shl i8 %16, 4
%38 = and i8 %37, 48
%39 = lshr i8 %23, 4
%40 = or i8 %39, %38
%41 = zext i8 %40 to i64
%42 = getelementptr inbounds [65 x i8], [65 x i8]* @__const._hash_base64.conv, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = getelementptr inbounds i8, i8* %14, i64 2
store i8 %43, i8* %36
br i1 %18, label %45, label %53
45: ; preds = %29
%46 = shl i8 %23, 2
%47 = and i8 %46, 60
%48 = lshr i8 %30, 6
%49 = or i8 %48, %47
%50 = zext i8 %49 to i64
%51 = getelementptr inbounds [65 x i8], [65 x i8]* @__const._hash_base64.conv, i64 0, i64 %50
%52 = load i8, i8* %51
br label %53
53: ; preds = %29, %45
%54 = phi i8 [ %52, %45 ], [ 61, %29 ]
%55 = getelementptr inbounds i8, i8* %14, i64 3
store i8 %54, i8* %44
br i1 %25, label %56, label %61
56: ; preds = %53
%57 = and i8 %30, 63
%58 = zext i8 %57 to i64
%59 = getelementptr inbounds [65 x i8], [65 x i8]* @__const._hash_base64.conv, i64 0, i64 %58
%60 = load i8, i8* %59
br label %61
61: ; preds = %53, %56
%62 = phi i8 [ %60, %56 ], [ 61, %53 ]
%63 = getelementptr inbounds i8, i8* %14, i64 4
store i8 %62, i8* %55
%64 = icmp ult i64 %31, %2
br i1 %64, label %12, label %65
65: ; preds = %61, %8
%66 = phi i8* [ %6, %8 ], [ %63, %61 ]
store i8 0, i8* %66
br label %67
67: ; preds = %65, %10
ret i8* %6
}