#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 */
struct stat {
  int st_mode;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ b64e(unsigned char *);
int /*<<< orphan*/ eprintf(char *, char const *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
scalar_t__ fstat(int /*<<< orphan*/, struct stat *);
int /*<<< orphan*/ fwrite(unsigned int *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, char const *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdout;
void uuencodeb64(FILE *fp, const char *name, const char *s) {
  struct stat st;
  ssize_t n, m = 0;
  unsigned char buf[45], *pb;
  unsigned int out[sizeof(buf) / 3 + 1], *po;
  if (fstat(fileno(fp), &st) < 0)
    eprintf("fstat %s:", s);
  printf("begin-base64 %o %s\n", st.st_mode & 0777, name);
  while ((n = fread(buf, 1, sizeof(buf), fp))) {
    if (n != sizeof(buf) && (m = n % 3) != 0) {
      buf[n] = '\0';
      if (m == 1)
        buf[n + 1] = '\0';
    }
    for (pb = buf, po = out; pb < buf + n; pb += 3)
      *po++ = b64e(pb);
    if (m != 0) {
      unsigned int mask = 0xffffffff, dest = 0x3d3d3d3d;
      mask >>= ((3 - m) << 3);
      po[-1] = (po[-1] & mask) | (dest & ~mask);
    }
    *po++ = '\n';
    fwrite(out, 1, (po - out) * sizeof(unsigned int) - 3, stdout);
  }
  if (ferror(fp))
    eprintf("'%s' read error:", s);
  puts("====");
}


x86 assembly (clang, -O0):
<uuencodeb64>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <fileno@plt>
mov    %eax,%edi
lea    -0x20(%rbp),%rsi
call   10b0 <fstat@plt>
cmp    $0x0,%rax
jge    11dc <uuencodeb64+0x4c>
mov    -0x18(%rbp),%rsi
lea    0xe29(%rip),%rdi
call   1090 <eprintf@plt>
mov    -0x20(%rbp),%esi
and    $0x1ff,%esi
mov    -0x10(%rbp),%rdx
lea    0xe1a(%rip),%rdi
call   1070 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x2d,%edx
call   1060 <fread@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
je     1380 <uuencodeb64+0x1f0>
movslq -0x24(%rbp),%rax
cmp    $0x2d,%rax
je     1262 <uuencodeb64+0xd2>
mov    -0x24(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
cmp    $0x0,%edx
je     1262 <uuencodeb64+0xd2>
movslq -0x24(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
cmpl   $0x1,-0x28(%rbp)
jne    125d <uuencodeb64+0xcd>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x60(%rbp,%rax,1)
jmp    1262 <uuencodeb64+0xd2>
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0xb0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x68(%rbp),%rax
lea    -0x60(%rbp),%rcx
movslq -0x24(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    12c3 <uuencodeb64+0x133>
mov    -0x68(%rbp),%rdi
call   1030 <b64e@plt>
mov    %eax,%ecx
mov    -0xb8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0xb8(%rbp)
mov    %ecx,(%rax)
mov    -0x68(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x68(%rbp)
jmp    1278 <uuencodeb64+0xe8>
cmpl   $0x0,-0x28(%rbp)
je     1327 <uuencodeb64+0x197>
movl   $0xffffffff,-0xbc(%rbp)
ff ff ff
movl   $0x3d3d3d3d,-0xc0(%rbp)
3d 3d 3d
mov    $0x3,%ecx
sub    -0x28(%rbp),%ecx
shl    $0x3,%ecx
mov    -0xbc(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0xbc(%rbp)
mov    -0xb8(%rbp),%rax
mov    -0x4(%rax),%ecx
and    -0xbc(%rbp),%ecx
mov    -0xc0(%rbp),%eax
mov    -0xbc(%rbp),%edx
xor    $0xffffffff,%edx
and    %edx,%eax
or     %eax,%ecx
mov    -0xb8(%rbp),%rax
mov    %ecx,-0x4(%rax)
mov    -0xb8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0xb8(%rbp)
movl   $0xa,(%rax)
lea    -0xb0(%rbp),%rdi
mov    -0xb8(%rbp),%rax
lea    -0xb0(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
shl    $0x2,%rax
sub    $0x3,%rax
mov    %eax,%edx
mov    0x2c71(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   10a0 <fwrite@plt>
jmp    11f5 <uuencodeb64+0x65>
mov    -0x8(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%rax
je     13a3 <uuencodeb64+0x213>
mov    -0x18(%rbp),%rsi
lea    0xc80(%rip),%rdi
call   1090 <eprintf@plt>
lea    0xc85(%rip),%rdi
call   1040 <puts@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uuencodeb64>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r12
call   1080 <fileno@plt>
mov    %rsp,%rsi
mov    %eax,%edi
call   10b0 <fstat@plt>
test   %rax,%rax
jns    11cd <uuencodeb64+0x3d>
lea    0xe3b(%rip),%rdi
mov    %rbx,%rsi
call   1090 <eprintf@plt>
mov    %rbx,0x8(%rsp)
mov    $0x1ff,%esi
and    (%rsp),%esi
lea    0xe29(%rip),%rdi
mov    %r14,%rdx
call   1070 <printf@plt>
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x2d,%edx
mov    %r12,%rcx
call   1060 <fread@plt>
test   %eax,%eax
je     1308 <uuencodeb64+0x178>
xor    %r14d,%r14d
lea    0x40(%rsp),%r13
jmp    1285 <uuencodeb64+0xf5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x0(,%r14,8),%eax
mov    $0x18,%cl
sub    %al,%cl
mov    -0x4(%rbx),%eax
mov    $0x3d3d3d3d,%edx
xor    %edx,%eax
shl    %cl,%eax
shr    %cl,%eax
xor    $0x3d3d3d3d,%eax
mov    %eax,-0x4(%rbx)
movl   $0xa,(%rbx)
sub    %r13d,%ebx
add    $0x1,%ebx
mov    0x2d8b(%rip),%rax
mov    (%rax),%ecx
mov    %r13,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   10a0 <fwrite@plt>
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x2d,%edx
mov    %r12,%rcx
call   1060 <fread@plt>
test   %eax,%eax
je     1308 <uuencodeb64+0x178>
movslq %eax,%rcx
cmp    $0x2d,%ecx
je     12c8 <uuencodeb64+0x138>
imul   $0x55555556,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
shr    $0x20,%rdx
add    %esi,%edx
lea    (%rdx,%rdx,2),%edx
mov    %ecx,%r14d
sub    %edx,%r14d
je     12c1 <uuencodeb64+0x131>
movb   $0x0,0x10(%rsp,%rcx,1)
cmp    $0x1,%r14d
jne    12c1 <uuencodeb64+0x131>
lea    0x10(%rsp),%rdx
movb   $0x0,0x1(%rcx,%rdx,1)
mov    %r13,%rbx
test   %eax,%eax
jle    12f7 <uuencodeb64+0x167>
lea    (%rsp,%rcx,1),%r15
add    $0x10,%r15
lea    0x10(%rsp),%rbp
mov    %r13,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1030 <b64e@plt>
mov    %eax,(%rbx)
add    $0x4,%rbx
add    $0x3,%rbp
cmp    %r15,%rbp
jb     12e0 <uuencodeb64+0x150>
test   %r14d,%r14d
jne    1220 <uuencodeb64+0x90>
xor    %r14d,%r14d
jmp    1242 <uuencodeb64+0xb2>
mov    %r12,%rdi
call   1050 <ferror@plt>
test   %rax,%rax
je     1326 <uuencodeb64+0x196>
lea    0xd02(%rip),%rdi
mov    0x8(%rsp),%rsi
call   1090 <eprintf@plt>
lea    0xd02(%rip),%rdi
call   1040 <puts@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [10 x i8] c"fstat %s:\00"
@.str.1 = [20 x i8] c"begin-base64 %o %s\0A\00"
@stdout = global i32 0
@.str.2 = [17 x i8] c"'%s' read error:\00"
@.str.3 = [5 x i8] c"====\00"
define void @uuencodeb64(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct.stat
%8 = alloca i32
%9 = alloca i32
%10 = alloca [45 x i8]
%11 = alloca i8*
%12 = alloca [16 x i32]
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %9
%16 = load i32*, i32** %4
%17 = call i32 @fileno(i32* %16)
%18 = call i64 @fstat(i32 %17, %struct.stat* %7)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %3
%21 = load i8*, i8** %6
%22 = call i32 @eprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20, %3
%24 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%25 = load i32, i32* %24
%26 = and i32 %25, 511
%27 = load i8*, i8** %5
%28 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %26, i8* %27)
br label %29
29: ; preds = %93, %23
%30 = getelementptr inbounds [45 x i8], [45 x i8]* %10, i64 0, i64 0
%31 = load i32*, i32** %4
%32 = call i32 @fread(i8* %30, i32 1, i32 45, i32* %31)
store i32 %32, i32* %8
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %108
34: ; preds = %29
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = icmp ne i64 %36, 45
br i1 %37, label %38, label %54
38: ; preds = %34
%39 = load i32, i32* %8
%40 = srem i32 %39, 3
store i32 %40, i32* %9
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %54
42: ; preds = %38
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [45 x i8], [45 x i8]* %10, i64 0, i64 %44
store i8 0, i8* %45
%46 = load i32, i32* %9
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %53
48: ; preds = %42
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [45 x i8], [45 x i8]* %10, i64 0, i64 %51
store i8 0, i8* %52
br label %53
53: ; preds = %48, %42
br label %54
54: ; preds = %53, %38, %34
%55 = getelementptr inbounds [45 x i8], [45 x i8]* %10, i64 0, i64 0
store i8* %55, i8** %11
%56 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 0
store i32* %56, i32** %13
br label %57
57: ; preds = %69, %54
%58 = load i8*, i8** %11
%59 = getelementptr inbounds [45 x i8], [45 x i8]* %10, i64 0, i64 0
%60 = load i32, i32* %8
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = icmp ult i8* %58, %62
br i1 %63, label %64, label %72
64: ; preds = %57
%65 = load i8*, i8** %11
%66 = call i32 @b64e(i8* %65)
%67 = load i32*, i32** %13
%68 = getelementptr inbounds i32, i32* %67, i32 1
store i32* %68, i32** %13
store i32 %66, i32* %67
br label %69
69: ; preds = %64
%70 = load i8*, i8** %11
%71 = getelementptr inbounds i8, i8* %70, i64 3
store i8* %71, i8** %11
br label %57
72: ; preds = %57
%73 = load i32, i32* %9
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %93
75: ; preds = %72
store i32 -1, i32* %14
store i32 1027423549, i32* %15
%76 = load i32, i32* %9
%77 = sub nsw i32 3, %76
%78 = shl i32 %77, 3
%79 = load i32, i32* %14
%80 = lshr i32 %79, %78
store i32 %80, i32* %14
%81 = load i32*, i32** %13
%82 = getelementptr inbounds i32, i32* %81, i64 -1
%83 = load i32, i32* %82
%84 = load i32, i32* %14
%85 = and i32 %83, %84
%86 = load i32, i32* %15
%87 = load i32, i32* %14
%88 = xor i32 %87, -1
%89 = and i32 %86, %88
%90 = or i32 %85, %89
%91 = load i32*, i32** %13
%92 = getelementptr inbounds i32, i32* %91, i64 -1
store i32 %90, i32* %92
br label %93
93: ; preds = %75, %72
%94 = load i32*, i32** %13
%95 = getelementptr inbounds i32, i32* %94, i32 1
store i32* %95, i32** %13
store i32 10, i32* %94
%96 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 0
%97 = load i32*, i32** %13
%98 = getelementptr inbounds [16 x i32], [16 x i32]* %12, i64 0, i64 0
%99 = ptrtoint i32* %97 to i64
%100 = ptrtoint i32* %98 to i64
%101 = sub i64 %99, %100
%102 = sdiv exact i64 %101, 4
%103 = mul i64 %102, 4
%104 = sub i64 %103, 3
%105 = trunc i64 %104 to i32
%106 = load i32, i32* @stdout
%107 = call i32 @fwrite(i32* %96, i32 1, i32 %105, i32 %106)
br label %29
108: ; preds = %29
%109 = load i32*, i32** %4
%110 = call i64 @ferror(i32* %109)
%111 = icmp ne i64 %110, 0
br i1 %111, label %112, label %115
112: ; preds = %108
%113 = load i8*, i8** %6
%114 = call i32 @eprintf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %113)
br label %115
115: ; preds = %112, %108
%116 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [10 x i8] c"fstat %s:\00"
@.str.1 = [20 x i8] c"begin-base64 %o %s\0A\00"
@stdout = global i32 0
@.str.2 = [17 x i8] c"'%s' read error:\00"
@.str.3 = [5 x i8] c"====\00"
define void @uuencodeb64(i32* nocapture %0, i8* %1, i8* %2) {
%4 = alloca %struct.stat
%5 = alloca [45 x i8]
%6 = alloca [16 x i32]
%7 = bitcast %struct.stat* %4 to i8*
%8 = getelementptr inbounds [45 x i8], [45 x i8]* %5, i64 0, i64 0
%9 = bitcast [16 x i32]* %6 to i8*
%10 = tail call i32 @fileno(i32* %0)
%11 = call i64 @fstat(i32 %10, %struct.stat* %4)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = tail call i32 @eprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %15
15: ; preds = %13, %3
%16 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%17 = load i32, i32* %16
%18 = and i32 %17, 511
%19 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %1)
%20 = call i32 @fread(i8* %8, i32 1, i32 45, i32* %0)
%21 = icmp eq i32 %20, 0
br i1 %21, label %77, label %22
22: ; preds = %15
%23 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%24 = ptrtoint [16 x i32]* %6 to i64
br label %25
25: ; preds = %22, %66
%26 = phi i32 [ %20, %22 ], [ %75, %66 ]
%27 = phi i32 [ 0, %22 ], [ %67, %66 ]
%28 = sext i32 %26 to i64
%29 = icmp eq i32 %26, 45
br i1 %29, label %42, label %30
30: ; preds = %25
%31 = srem i32 %26, 3
%32 = icmp eq i32 %31, 0
br i1 %32, label %40, label %33
33: ; preds = %30
%34 = getelementptr inbounds [45 x i8], [45 x i8]* %5, i64 0, i64 %28
store i8 0, i8* %34
%35 = icmp eq i32 %31, 1
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = add nsw i32 %26, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [45 x i8], [45 x i8]* %5, i64 0, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %33, %36, %30
%41 = icmp sgt i32 %26, 0
br i1 %41, label %42, label %52
42: ; preds = %25, %40
%43 = phi i32 [ %31, %40 ], [ %27, %25 ]
%44 = getelementptr inbounds [45 x i8], [45 x i8]* %5, i64 0, i64 %28
br label %45
45: ; preds = %42, %45
%46 = phi i8* [ %50, %45 ], [ %8, %42 ]
%47 = phi i32* [ %49, %45 ], [ %23, %42 ]
%48 = call i32 @b64e(i8* %46)
%49 = getelementptr inbounds i32, i32* %47, i64 1
store i32 %48, i32* %47
%50 = getelementptr inbounds i8, i8* %46, i64 3
%51 = icmp ult i8* %50, %44
br i1 %51, label %45, label %52
52: ; preds = %45, %40
%53 = phi i32 [ %31, %40 ], [ %43, %45 ]
%54 = phi i32* [ %23, %40 ], [ %49, %45 ]
%55 = icmp eq i32 %53, 0
br i1 %55, label %66, label %56
56: ; preds = %52
%57 = mul i32 %53, -8
%58 = add i32 %57, 24
%59 = lshr i32 -1, %58
%60 = getelementptr inbounds i32, i32* %54, i64 -1
%61 = load i32, i32* %60
%62 = and i32 %61, %59
%63 = and i32 %59, 1027423549
%64 = xor i32 %63, 1027423549
%65 = or i32 %62, %64
store i32 %65, i32* %60
br label %66
66: ; preds = %56, %52
%67 = phi i32 [ %53, %56 ], [ 0, %52 ]
%68 = getelementptr inbounds i32, i32* %54, i64 1
store i32 10, i32* %54
%69 = ptrtoint i32* %68 to i64
%70 = sub i64 %69, %24
%71 = trunc i64 %70 to i32
%72 = add i32 %71, -3
%73 = load i32, i32* @stdout
%74 = call i32 @fwrite(i32* %23, i32 1, i32 %72, i32 %73)
%75 = call i32 @fread(i8* %8, i32 1, i32 45, i32* %0)
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %25
77: ; preds = %66, %15
%78 = call i64 @ferror(i32* %0)
%79 = icmp eq i64 %78, 0
br i1 %79, label %82, label %80
80: ; preds = %77
%81 = call i32 @eprintf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %82
82: ; preds = %80, %77
%83 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
ret void
}