#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 /*<<< orphan*/ memcpy(char *, void *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
char strlen(char *);
int /*<<< orphan*/ uu_encode_word24(char *, char *);
char uu_encode_line(char *dest_uu, void *src, uint8_t bytes) {
  char tmp[64];
  uint8_t i;
  uint8_t j;
  char *dest = (char *)dest_uu;
  memset(tmp, 0, 64);
  memcpy(tmp, src, bytes);
  dest[0] = (bytes & 0x3F) + ' ';
  j = 1;
  for (i = 0; i < bytes; i += 3) {
    uu_encode_word24(&dest[j], &tmp[i]);
    j += 4;
  }
  dest[j] = '\r';
  dest[j + 1] = '\n';
  dest[j + 2] = 0;
  return strlen(dest);
}


x86 assembly (clang, -O0):
<uu_encode_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <memcpy@plt>
mov    -0x14(%rbp),%eax
and    $0x3f,%eax
add    $0x20,%eax
mov    %al,%cl
mov    -0x70(%rbp),%rax
mov    %cl,(%rax)
movl   $0x1,-0x68(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d8 <uu_encode_line+0x98>
mov    -0x70(%rbp),%rdi
movslq -0x68(%rbp),%rax
add    %rax,%rdi
movslq -0x64(%rbp),%rax
lea    -0x60(%rbp),%rsi
add    %rax,%rsi
call   1030 <uu_encode_word24@plt>
mov    -0x68(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x68(%rbp)
mov    -0x64(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x64(%rbp)
jmp    119a <uu_encode_line+0x5a>
mov    -0x70(%rbp),%rax
movslq -0x68(%rbp),%rcx
movb   $0xd,(%rax,%rcx,1)
mov    -0x70(%rbp),%rax
mov    -0x68(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0xa,(%rax,%rcx,1)
mov    -0x70(%rbp),%rax
mov    -0x68(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
movsbl %al,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uu_encode_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edx,%r13d
mov    %rsi,%r14
mov    %rdi,%r12
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
call   1060 <memcpy@plt>
mov    %r13d,%eax
and    $0x3f,%al
add    $0x20,%al
mov    %al,(%r12)
test   %r13d,%r13d
jle    11ac <uu_encode_line+0x6c>
mov    $0x1,%ebx
xor    %ebp,%ebp
xchg   %ax,%ax
lea    (%r12,%rbx,1),%rdi
lea    (%rsp,%rbp,1),%rsi
call   1030 <uu_encode_word24@plt>
add    $0x4,%rbx
add    $0x3,%rbp
cmp    %r13d,%ebp
jl     1190 <uu_encode_line+0x50>
jmp    11b1 <uu_encode_line+0x71>
mov    $0x1,%ebx
mov    %ebx,%eax
movw   $0xa0d,(%r12,%rax,1)
movb   $0x0,0x2(%r12,%rax,1)
mov    %r12,%rdi
call   1040 <strlen@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @uu_encode_line(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [64 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i8*, i8** %4
store i8* %11, i8** %10
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i32 0, i32 64)
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%15 = load i8*, i8** %5
%16 = load i32, i32* %6
%17 = call i32 @memcpy(i8* %14, i8* %15, i32 %16)
%18 = load i32, i32* %6
%19 = and i32 %18, 63
%20 = add nsw i32 %19, 32
%21 = trunc i32 %20 to i8
%22 = load i8*, i8** %10
%23 = getelementptr inbounds i8, i8* %22, i64 0
store i8 %21, i8* %23
store i32 1, i32* %9
store i32 0, i32* %8
br label %24
24: ; preds = %39, %3
%25 = load i32, i32* %8
%26 = load i32, i32* %6
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %42
28: ; preds = %24
%29 = load i8*, i8** %10
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 %34
%36 = call i32 @uu_encode_word24(i8* %32, i8* %35)
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 4
store i32 %38, i32* %9
br label %39
39: ; preds = %28
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 3
store i32 %41, i32* %8
br label %24
42: ; preds = %24
%43 = load i8*, i8** %10
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8 13, i8* %46
%47 = load i8*, i8** %10
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %47, i64 %50
store i8 10, i8* %51
%52 = load i8*, i8** %10
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 2
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %52, i64 %55
store i8 0, i8* %56
%57 = load i8*, i8** %10
%58 = call signext i8 @strlen(i8* %57)
ret i8 %58
}

LLVM IR (-O2):
define signext i8 @uu_encode_line(i8* %0, i8* %1, i32 %2) {
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 64)
%7 = call i32 @memcpy(i8* %5, i8* %1, i32 %2)
%8 = trunc i32 %2 to i8
%9 = and i8 %8, 63
%10 = add nuw nsw i8 %9, 32
store i8 %10, i8* %0
%11 = icmp sgt i32 %2, 0
br i1 %11, label %12, label %24
12: ; preds = %3, %12
%13 = phi i64 [ %18, %12 ], [ 1, %3 ]
%14 = phi i64 [ %19, %12 ], [ 0, %3 ]
%15 = getelementptr inbounds i8, i8* %0, i64 %13
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 %14
%17 = call i32 @uu_encode_word24(i8* %15, i8* %16)
%18 = add nuw i64 %13, 4
%19 = add nuw i64 %14, 3
%20 = trunc i64 %19 to i32
%21 = icmp slt i32 %20, %2
br i1 %21, label %12, label %22
22: ; preds = %12
%23 = trunc i64 %18 to i32
br label %24
24: ; preds = %22, %3
%25 = phi i32 [ 1, %3 ], [ %23, %22 ]
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %0, i64 %26
store i8 13, i8* %27
%28 = add nuw nsw i32 %25, 1
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %0, i64 %29
store i8 10, i8* %30
%31 = add nuw nsw i32 %25, 2
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %0, i64 %32
store i8 0, i8* %33
%34 = call signext i8 @strlen(i8* %0)
ret i8 %34
}