#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 */
void *uuchar(unsigned int);
void uuencode(char *str, const unsigned char *data, int num) {
  int i, n;
  *str++ = uuchar(num);
  n = (num + 2) / 3;
  for (i = 0; i < n; i++) {
    unsigned int val = ((data[0] & 0xFF) << 16) | ((data[1] & 0xFF) << 8) |
                       ((data[2] & 0xFF) << 0);
    *str++ = uuchar(val >> 18);
    *str++ = uuchar(val >> 12);
    *str++ = uuchar(val >> 6);
    *str++ = uuchar(val >> 0);
    data += 3;
  }
  *str = '\0';
}


x86 assembly (clang, -O0):
<uuencode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <uuchar@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    122c <uuencode+0x11c>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
and    $0xff,%eax
shl    $0x10,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
and    $0xff,%ecx
shl    $0x0,%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
shr    $0x12,%edi
call   1030 <uuchar@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%edi
shr    $0xc,%edi
call   1030 <uuchar@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%edi
shr    $0x6,%edi
call   1030 <uuchar@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%edi
shr    $0x0,%edi
call   1030 <uuchar@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1156 <uuencode+0x46>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uuencode>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%edi
call   1030 <uuchar@plt>
mov    %al,(%r15)
add    $0x1,%r15
test   %ebp,%ebp
jle    11aa <uuencode+0x9a>
add    $0x2,%ebp
mov    $0xaaaaaaab,%r12d
imul   %rbp,%r12
shr    $0x21,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%r14),%edi
mov    %edi,%eax
shl    $0x10,%eax
movzbl 0x1(%r14),%ebx
shl    $0x8,%ebx
or     %eax,%ebx
movzbl 0x2(%r14),%ebp
or     %ebx,%ebp
shr    $0x2,%edi
call   1030 <uuchar@plt>
mov    %al,(%r15)
shr    $0xc,%ebx
mov    %ebx,%edi
call   1030 <uuchar@plt>
mov    %al,0x1(%r15)
mov    %ebp,%edi
shr    $0x6,%edi
call   1030 <uuchar@plt>
mov    %al,0x2(%r15)
mov    %ebp,%edi
call   1030 <uuchar@plt>
mov    %al,0x3(%r15)
add    $0x4,%r15
add    $0x3,%r14
add    $0xffffffff,%r12d
jne    1150 <uuencode+0x40>
movb   $0x0,(%r15)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @uuencode(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = call i8* @uuchar(i32 %10)
%12 = ptrtoint i8* %11 to i8
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %4
store i8 %12, i8* %13
%15 = load i32, i32* %6
%16 = add nsw i32 %15, 2
%17 = sdiv i32 %16, 3
store i32 %17, i32* %8
store i32 0, i32* %7
br label %18
18: ; preds = %69, %3
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %72
22: ; preds = %18
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = and i32 %26, 255
%28 = shl i32 %27, 16
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = and i32 %32, 255
%34 = shl i32 %33, 8
%35 = or i32 %28, %34
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i64 2
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = and i32 %39, 255
%41 = shl i32 %40, 0
%42 = or i32 %35, %41
store i32 %42, i32* %9
%43 = load i32, i32* %9
%44 = lshr i32 %43, 18
%45 = call i8* @uuchar(i32 %44)
%46 = ptrtoint i8* %45 to i8
%47 = load i8*, i8** %4
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %4
store i8 %46, i8* %47
%49 = load i32, i32* %9
%50 = lshr i32 %49, 12
%51 = call i8* @uuchar(i32 %50)
%52 = ptrtoint i8* %51 to i8
%53 = load i8*, i8** %4
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %4
store i8 %52, i8* %53
%55 = load i32, i32* %9
%56 = lshr i32 %55, 6
%57 = call i8* @uuchar(i32 %56)
%58 = ptrtoint i8* %57 to i8
%59 = load i8*, i8** %4
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %4
store i8 %58, i8* %59
%61 = load i32, i32* %9
%62 = lshr i32 %61, 0
%63 = call i8* @uuchar(i32 %62)
%64 = ptrtoint i8* %63 to i8
%65 = load i8*, i8** %4
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %4
store i8 %64, i8* %65
%67 = load i8*, i8** %5
%68 = getelementptr inbounds i8, i8* %67, i64 3
store i8* %68, i8** %5
br label %69
69: ; preds = %22
%70 = load i32, i32* %7
%71 = add nsw i32 %70, 1
store i32 %71, i32* %7
br label %18
72: ; preds = %18
%73 = load i8*, i8** %4
store i8 0, i8* %73
ret void
}

LLVM IR (-O2):
define void @uuencode(i8* nocapture writeonly %0, i8* nocapture %1, i32 %2) {
%4 = tail call i8* @uuchar(i32 %2)
%5 = ptrtoint i8* %4 to i64
%6 = trunc i64 %5 to i8
%7 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %6, i8* %0
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %50
9: ; preds = %3
%10 = add nuw nsw i32 %2, 2
%11 = udiv i32 %10, 3
br label %12
12: ; preds = %9, %12
%13 = phi i8* [ %46, %12 ], [ %7, %9 ]
%14 = phi i8* [ %47, %12 ], [ %1, %9 ]
%15 = phi i32 [ %48, %12 ], [ 0, %9 ]
%16 = load i8, i8* %14
%17 = zext i8 %16 to i32
%18 = shl nuw nsw i32 %17, 16
%19 = getelementptr inbounds i8, i8* %14, i64 1
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = shl nuw nsw i32 %21, 8
%23 = or i32 %22, %18
%24 = getelementptr inbounds i8, i8* %14, i64 2
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = or i32 %23, %26
%28 = lshr i32 %17, 2
%29 = tail call i8* @uuchar(i32 %28)
%30 = ptrtoint i8* %29 to i64
%31 = trunc i64 %30 to i8
%32 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %31, i8* %13
%33 = lshr i32 %23, 12
%34 = tail call i8* @uuchar(i32 %33)
%35 = ptrtoint i8* %34 to i64
%36 = trunc i64 %35 to i8
%37 = getelementptr inbounds i8, i8* %13, i64 2
store i8 %36, i8* %32
%38 = lshr i32 %27, 6
%39 = tail call i8* @uuchar(i32 %38)
%40 = ptrtoint i8* %39 to i64
%41 = trunc i64 %40 to i8
%42 = getelementptr inbounds i8, i8* %13, i64 3
store i8 %41, i8* %37
%43 = tail call i8* @uuchar(i32 %27)
%44 = ptrtoint i8* %43 to i64
%45 = trunc i64 %44 to i8
%46 = getelementptr inbounds i8, i8* %13, i64 4
store i8 %45, i8* %42
%47 = getelementptr inbounds i8, i8* %14, i64 3
%48 = add nuw nsw i32 %15, 1
%49 = icmp eq i32 %48, %11
br i1 %49, label %50, label %12
50: ; preds = %12, %3
%51 = phi i8* [ %7, %3 ], [ %46, %12 ]
store i8 0, i8* %51
ret void
}