#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*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int PATH_MAX;
int /*<<< orphan*/ appendbinaryattach(char *, char *, char *);
int /*<<< orphan*/ copyfile(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ unlink(char *);
scalar_t__ uudecode(int /*<<< orphan*/ *, char *);
int attachuu2bin(char *filename) {
  FILE *fr, *fw;
  char tofile[PATH_MAX + 1], *attachfile, *ptr, buf[512], tmpattach[512];
  int hast = 0;
  tofile[PATH_MAX] = 0;
  if (strlen(filename) > PATH_MAX - 1)
    return -1;
  strncpy(tofile, filename, PATH_MAX - 1);
  strcat(tofile, "b");
  fr = fopen(filename, "r");
  if (NULL == fr)
    return -2;
  fw = fopen(tofile, "w");
  if (NULL == fw) {
    fclose(fr);
    return -3;
  }
  while (fgets(buf, sizeof(buf), fr) != NULL) {
    if (!strncmp(buf, "begin 644 ", 10)) {
      attachfile = buf + 10;
      ptr = strchr(attachfile, '\r');
      if (ptr)
        *ptr = 0;
      ptr = strchr(attachfile, '\n');
      if (ptr)
        *ptr = 0;
      strcpy(tmpattach, "/home/bbs"
                        "/bbstmpfs/userattach"
                        "/lepton/");
      strcat(tmpattach, attachfile);
      if (uudecode(fr, tmpattach)) {
        printf("error: %s\n", filename);
        continue;
      }
      fclose(fw);
      appendbinaryattach(tofile, "lepton", attachfile);
      hast = 1;
      fw = fopen(tofile, "a");
      if (NULL == fw) {
        fclose(fr);
        unlink(tofile);
        return -4;
      }
    } else if (!strncmp(buf, "beginbinaryattach ", 18)) {
      char ch;
      fread(&ch, 1, 1, fr);
      if (ch != 0) {
        ungetc(ch, fr);
        fprintf(fw, "%s", buf);
        continue;
      }
      fclose(fr);
      fclose(fw);
      unlink(tofile);
      return -5;
    } else
      fprintf(fw, "%s", buf);
  }
  if (hast) {
    fclose(fr);
    fclose(fw);
    copyfile(tofile, filename);
    unlink(tofile);
    return -6;
  } else {
    fclose(fr);
    fclose(fw);
    unlink(tofile);
    return 0;
  }
}


x86 assembly (clang, -O0):
<attachuu2bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2dca(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x28(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x458(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x30(%rbp)
movl   $0x0,-0x444(%rbp)
mov    0x2d8c(%rip),%rcx
movslq (%rcx),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   10a0 <strlen@plt>
mov    0x2d75(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    129e <attachuu2bin+0x8e>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x448(%rbp)
jmp    15fb <attachuu2bin+0x3eb>
mov    -0x458(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2d40(%rip),%rax
mov    (%rax),%edx
sub    $0x1,%edx
call   1040 <strncpy@plt>
mov    -0x458(%rbp),%rdi
lea    0xd38(%rip),%rsi
call   1120 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    0xd2a(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1303 <attachuu2bin+0xf3>
movl   $0xfffffffe,-0x4(%rbp)
movl   $0x1,-0x448(%rbp)
jmp    15fb <attachuu2bin+0x3eb>
mov    -0x458(%rbp),%rdi
lea    0xcf3(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    1345 <attachuu2bin+0x135>
mov    -0x18(%rbp),%rdi
call   1080 <fclose@plt>
movl   $0xfffffffd,-0x4(%rbp)
movl   $0x1,-0x448(%rbp)
jmp    15fb <attachuu2bin+0x3eb>
jmp    134a <attachuu2bin+0x13a>
lea    -0x240(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x200,%esi
call   10d0 <fgets@plt>
cmp    $0x0,%rax
je     157b <attachuu2bin+0x36b>
lea    -0x240(%rbp),%rdi
lea    0xc8f(%rip),%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    14b0 <attachuu2bin+0x2a0>
lea    -0x240(%rbp),%rax
add    $0xa,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    $0xd,%esi
call   10b0 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     13bd <attachuu2bin+0x1ad>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x38(%rbp),%rdi
mov    $0xa,%esi
call   10b0 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     13e1 <attachuu2bin+0x1d1>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x440(%rbp),%rdi
lea    0xc22(%rip),%rsi
call   1060 <strcpy@plt>
lea    -0x440(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1120 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    -0x440(%rbp),%rsi
call   1090 <uudecode@plt>
cmp    $0x0,%rax
je     1433 <attachuu2bin+0x223>
mov    -0x10(%rbp),%rsi
lea    0xc0e(%rip),%rdi
call   10c0 <printf@plt>
jmp    134a <attachuu2bin+0x13a>
mov    -0x20(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x458(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xbf4(%rip),%rsi
call   10f0 <appendbinaryattach@plt>
mov    -0x458(%rbp),%rdi
movl   $0x1,-0x444(%rbp)
lea    0xbde(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    14ab <attachuu2bin+0x29b>
mov    -0x18(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x458(%rbp),%rdi
call   1030 <unlink@plt>
movl   $0xfffffffc,-0x4(%rbp)
movl   $0x1,-0x448(%rbp)
jmp    15fb <attachuu2bin+0x3eb>
jmp    1576 <attachuu2bin+0x366>
lea    -0x240(%rbp),%rdi
lea    0xb8d(%rip),%rsi
mov    $0x12,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    155a <attachuu2bin+0x34a>
mov    -0x18(%rbp),%rcx
lea    -0x449(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1070 <fread@plt>
movsbl -0x449(%rbp),%eax
cmp    $0x0,%eax
je     1526 <attachuu2bin+0x316>
mov    -0x449(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1100 <ungetc@plt>
mov    -0x20(%rbp),%rdi
lea    -0x240(%rbp),%rdx
lea    0xb42(%rip),%rsi
call   10e0 <fprintf@plt>
jmp    134a <attachuu2bin+0x13a>
mov    -0x18(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x458(%rbp),%rdi
call   1030 <unlink@plt>
movl   $0xfffffffb,-0x4(%rbp)
movl   $0x1,-0x448(%rbp)
jmp    15fb <attachuu2bin+0x3eb>
mov    -0x20(%rbp),%rdi
lea    -0x240(%rbp),%rdx
lea    0xaf2(%rip),%rsi
call   10e0 <fprintf@plt>
jmp    1576 <attachuu2bin+0x366>
jmp    134a <attachuu2bin+0x13a>
cmpl   $0x0,-0x444(%rbp)
je     15cc <attachuu2bin+0x3bc>
mov    -0x18(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x458(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1130 <copyfile@plt>
mov    -0x458(%rbp),%rdi
call   1030 <unlink@plt>
movl   $0xfffffffa,-0x4(%rbp)
movl   $0x1,-0x448(%rbp)
jmp    15fb <attachuu2bin+0x3eb>
mov    -0x18(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x458(%rbp),%rdi
call   1030 <unlink@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x448(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<attachuu2bin>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rdi,%r14
mov    0x2dc2(%rip),%rbx
movslq (%rbx),%rax
lea    0x1(%rax),%ecx
mov    %rsp,%r15
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r15
mov    %r15,%rsp
movb   $0x0,(%rax,%r15,1)
call   10a0 <strlen@plt>
mov    %eax,%ecx
mov    (%rbx),%edx
mov    $0xffffffff,%eax
cmp    %edx,%ecx
jge    14c7 <attachuu2bin+0x2b7>
add    $0xffffffff,%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strncpy@plt>
lea    0xd8b(%rip),%rsi
mov    %r15,%rdi
call   1120 <strcat@plt>
lea    0xd7e(%rip),%rsi
mov    %r14,%rdi
call   1110 <fopen@plt>
test   %rax,%rax
je     1447 <attachuu2bin+0x237>
mov    %rax,%rbx
lea    0xd65(%rip),%rsi
mov    %r15,%rdi
call   1110 <fopen@plt>
test   %rax,%rax
je     144e <attachuu2bin+0x23e>
mov    %rax,%r12
lea    -0x240(%rbp),%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   10e0 <fgets@plt>
test   %rax,%rax
je     148e <attachuu2bin+0x27e>
mov    %r14,-0x38(%rbp)
movl   $0x0,-0x30(%rbp)
lea    -0x240(%rbp),%r13
jmp    131f <attachuu2bin+0x10f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
mov    %rbx,%rsi
call   1100 <ungetc@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   10d0 <fputs@plt>
mov    %r13,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   10e0 <fgets@plt>
test   %rax,%rax
je     145d <attachuu2bin+0x24d>
mov    %r13,%rdi
lea    0xcdd(%rip),%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
je     1380 <attachuu2bin+0x170>
mov    %r13,%rdi
lea    0xd0a(%rip),%rsi
mov    $0x12,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
jne    12fb <attachuu2bin+0xeb>
lea    -0x29(%rbp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fread@plt>
movzbl -0x29(%rbp),%eax
test   %al,%al
jne    12f0 <attachuu2bin+0xe0>
jmp    14aa <attachuu2bin+0x29a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x236(%rbp),%rdi
mov    $0xd,%esi
call   10b0 <strchr@plt>
test   %rax,%rax
je     1399 <attachuu2bin+0x189>
movb   $0x0,(%rax)
mov    %r12,%r14
lea    -0x236(%rbp),%rdi
mov    $0xa,%esi
call   10b0 <strchr@plt>
test   %rax,%rax
je     13b5 <attachuu2bin+0x1a5>
movb   $0x0,(%rax)
lea    -0x440(%rbp),%r12
mov    %r12,%rdi
lea    0xc4b(%rip),%rsi
call   1060 <strcpy@plt>
mov    %r12,%rdi
lea    -0x236(%rbp),%rsi
call   1120 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <uudecode@plt>
test   %rax,%rax
je     1402 <attachuu2bin+0x1f2>
lea    0xc46(%rip),%rdi
mov    -0x38(%rbp),%rsi
call   10c0 <printf@plt>
mov    %r14,%r12
jmp    1306 <attachuu2bin+0xf6>
mov    %r14,%rdi
call   1080 <fclose@plt>
mov    %r15,%rdi
lea    0xc2e(%rip),%rsi
lea    -0x236(%rbp),%rdx
call   10f0 <appendbinaryattach@plt>
mov    %r15,%rdi
lea    0xc1f(%rip),%rsi
call   1110 <fopen@plt>
test   %rax,%rax
je     14d6 <attachuu2bin+0x2c6>
mov    %rax,%r12
movl   $0x1,-0x30(%rbp)
jmp    1306 <attachuu2bin+0xf6>
mov    $0xfffffffe,%eax
jmp    14c7 <attachuu2bin+0x2b7>
mov    %rbx,%rdi
call   1080 <fclose@plt>
mov    $0xfffffffd,%eax
jmp    14c7 <attachuu2bin+0x2b7>
cmpl   $0x0,-0x30(%rbp)
je     148e <attachuu2bin+0x27e>
mov    %rbx,%rdi
call   1080 <fclose@plt>
mov    %r12,%rdi
call   1080 <fclose@plt>
mov    %r15,%rdi
mov    -0x38(%rbp),%rsi
call   1130 <copyfile@plt>
mov    %r15,%rdi
call   1030 <unlink@plt>
mov    $0xfffffffa,%eax
jmp    14c7 <attachuu2bin+0x2b7>
mov    %rbx,%rdi
call   1080 <fclose@plt>
mov    %r12,%rdi
call   1080 <fclose@plt>
mov    %r15,%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
jmp    14c7 <attachuu2bin+0x2b7>
mov    %rbx,%rdi
call   1080 <fclose@plt>
mov    %r12,%rdi
call   1080 <fclose@plt>
mov    %r15,%rdi
call   1030 <unlink@plt>
mov    $0xfffffffb,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1080 <fclose@plt>
mov    %r15,%rdi
call   1030 <unlink@plt>
mov    $0xfffffffc,%eax
jmp    14c7 <attachuu2bin+0x2b7>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [2 x i8] c"b\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [11 x i8] c"begin 644 \00"
@.str.4 = [38 x i8] c"/home/bbs/bbstmpfs/userattach/lepton/\00"
@.str.5 = [11 x i8] c"error: %s\0A\00"
@.str.6 = [7 x i8] c"lepton\00"
@.str.7 = [2 x i8] c"a\00"
@.str.8 = [19 x i8] c"beginbinaryattach \00"
@.str.9 = [3 x i8] c"%s\00"
define i32 @attachuu2bin(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [512 x i8]
%11 = alloca [512 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8
store i8* %0, i8** %3
%15 = load i32, i32* @PATH_MAX
%16 = add nsw i32 %15, 1
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %6
%19 = alloca i8, i64 %17
store i64 %17, i64* %7
store i32 0, i32* %12
%20 = load i32, i32* @PATH_MAX
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 0, i8* %22
%23 = load i8*, i8** %3
%24 = call i32 @strlen(i8* %23)
%25 = load i32, i32* @PATH_MAX
%26 = sub nsw i32 %25, 1
%27 = icmp sgt i32 %24, %26
br i1 %27, label %28, label %29
28: ; preds = %1
store i32 -1, i32* %2
store i32 1, i32* %13
br label %145
29: ; preds = %1
%30 = load i8*, i8** %3
%31 = load i32, i32* @PATH_MAX
%32 = sub nsw i32 %31, 1
%33 = call i32 @strncpy(i8* %19, i8* %30, i32 %32)
%34 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%35 = load i8*, i8** %3
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %36, i32** %4
%37 = load i32*, i32** %4
%38 = icmp eq i32* null, %37
br i1 %38, label %39, label %40
39: ; preds = %29
store i32 -2, i32* %2
store i32 1, i32* %13
br label %145
40: ; preds = %29
%41 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %41, i32** %5
%42 = load i32*, i32** %5
%43 = icmp eq i32* null, %42
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i32*, i32** %4
%46 = call i32 @fclose(i32* %45)
store i32 -3, i32* %2
store i32 1, i32* %13
br label %145
47: ; preds = %40
br label %48
48: ; preds = %127, %109, %83, %47
%49 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%50 = load i32*, i32** %4
%51 = call i32* @fgets(i8* %49, i32 512, i32* %50)
%52 = icmp ne i32* %51, null
br i1 %52, label %53, label %128
53: ; preds = %48
%54 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%55 = call i32 @strncmp(i8* %54, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 10)
%56 = icmp ne i32 %55, 0
br i1 %56, label %99, label %57
57: ; preds = %53
%58 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%59 = getelementptr inbounds i8, i8* %58, i64 10
store i8* %59, i8** %8
%60 = load i8*, i8** %8
%61 = call i8* @strchr(i8* %60, i8 signext 13)
store i8* %61, i8** %9
%62 = load i8*, i8** %9
%63 = icmp ne i8* %62, null
br i1 %63, label %64, label %66
64: ; preds = %57
%65 = load i8*, i8** %9
store i8 0, i8* %65
br label %66
66: ; preds = %64, %57
%67 = load i8*, i8** %8
%68 = call i8* @strchr(i8* %67, i8 signext 10)
store i8* %68, i8** %9
%69 = load i8*, i8** %9
%70 = icmp ne i8* %69, null
br i1 %70, label %71, label %73
71: ; preds = %66
%72 = load i8*, i8** %9
store i8 0, i8* %72
br label %73
73: ; preds = %71, %66
%74 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%75 = call i32 @strcpy(i8* %74, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%76 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%77 = load i8*, i8** %8
%78 = call i32 @strcat(i8* %76, i8* %77)
%79 = load i32*, i32** %4
%80 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%81 = call i64 @uudecode(i32* %79, i8* %80)
%82 = icmp ne i64 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %73
%84 = load i8*, i8** %3
%85 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %84)
br label %48
86: ; preds = %73
%87 = load i32*, i32** %5
%88 = call i32 @fclose(i32* %87)
%89 = load i8*, i8** %8
%90 = call i32 @appendbinaryattach(i8* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %89)
store i32 1, i32* %12
%91 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %91, i32** %5
%92 = load i32*, i32** %5
%93 = icmp eq i32* null, %92
br i1 %93, label %94, label %98
94: ; preds = %86
%95 = load i32*, i32** %4
%96 = call i32 @fclose(i32* %95)
%97 = call i32 @unlink(i8* %19)
store i32 -4, i32* %2
store i32 1, i32* %13
br label %145
98: ; preds = %86
br label %127
99: ; preds = %53
%100 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%101 = call i32 @strncmp(i8* %100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 18)
%102 = icmp ne i32 %101, 0
br i1 %102, label %122, label %103
103: ; preds = %99
%104 = load i32*, i32** %4
%105 = call i32 @fread(i8* %14, i32 1, i32 1, i32* %104)
%106 = load i8, i8* %14
%107 = sext i8 %106 to i32
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %116
109: ; preds = %103
%110 = load i8, i8* %14
%111 = load i32*, i32** %4
%112 = call i32 @ungetc(i8 signext %110, i32* %111)
%113 = load i32*, i32** %5
%114 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%115 = call i32 @fprintf(i32* %113, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %114)
br label %48
116: ; preds = %103
%117 = load i32*, i32** %4
%118 = call i32 @fclose(i32* %117)
%119 = load i32*, i32** %5
%120 = call i32 @fclose(i32* %119)
%121 = call i32 @unlink(i8* %19)
store i32 -5, i32* %2
store i32 1, i32* %13
br label %145
122: ; preds = %99
%123 = load i32*, i32** %5
%124 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%125 = call i32 @fprintf(i32* %123, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %124)
br label %126
126: ; preds = %122
br label %127
127: ; preds = %126, %98
br label %48
128: ; preds = %48
%129 = load i32, i32* %12
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %139
131: ; preds = %128
%132 = load i32*, i32** %4
%133 = call i32 @fclose(i32* %132)
%134 = load i32*, i32** %5
%135 = call i32 @fclose(i32* %134)
%136 = load i8*, i8** %3
%137 = call i32 @copyfile(i8* %19, i8* %136)
%138 = call i32 @unlink(i8* %19)
store i32 -6, i32* %2
store i32 1, i32* %13
br label %145
139: ; preds = %128
%140 = load i32*, i32** %4
%141 = call i32 @fclose(i32* %140)
%142 = load i32*, i32** %5
%143 = call i32 @fclose(i32* %142)
%144 = call i32 @unlink(i8* %19)
store i32 0, i32* %2
store i32 1, i32* %13
br label %145
145: ; preds = %139, %131, %116, %94, %44, %39, %28
%146 = load i8*, i8** %6
%147 = load i32, i32* %2
ret i32 %147
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [2 x i8] c"b\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [11 x i8] c"begin 644 \00"
@.str.4 = [38 x i8] c"/home/bbs/bbstmpfs/userattach/lepton/\00"
@.str.5 = [11 x i8] c"error: %s\0A\00"
@.str.6 = [7 x i8] c"lepton\00"
@.str.7 = [2 x i8] c"a\00"
@.str.8 = [19 x i8] c"beginbinaryattach \00"
define i32 @attachuu2bin(i8* %0) {
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = alloca i8
%5 = load i32, i32* @PATH_MAX
%6 = add nsw i32 %5, 1
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%11 = sext i32 %5 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
store i8 0, i8* %12
%13 = tail call i32 @strlen(i8* %0)
%14 = load i32, i32* @PATH_MAX
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %99
16: ; preds = %1
%17 = add nsw i32 %14, -1
%18 = call i32 @strncpy(i8* %8, i8* %0, i32 %17)
%19 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %99, label %22
22: ; preds = %16
%23 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %30, label %25
25: ; preds = %22
%26 = call i32* @fgets(i8* %9, i32 512, i32* %20)
%27 = icmp eq i32* %26, null
br i1 %27, label %94, label %28
28: ; preds = %25
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 10
br label %82
30: ; preds = %22
%31 = call i32 @fclose(i32* %20)
br label %99
32: ; preds = %82, %50
%33 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 10)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %61
35: ; preds = %32
%36 = call i8* @strchr(i8* %29, i8 signext 13)
%37 = icmp eq i8* %36, null
br i1 %37, label %39, label %38
38: ; preds = %35
store i8 0, i8* %36
br label %39
39: ; preds = %38, %35
%40 = call i8* @strchr(i8* %29, i8 signext 10)
%41 = icmp eq i8* %40, null
br i1 %41, label %43, label %42
42: ; preds = %39
store i8 0, i8* %40
br label %43
43: ; preds = %42, %39
%44 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%45 = call i32 @strcat(i8* %10, i8* %29)
%46 = call i64 @uudecode(i32* %20, i8* %10)
%47 = icmp eq i64 %46, 0
br i1 %47, label %53, label %48
48: ; preds = %43
%49 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %0)
br label %50
50: ; preds = %48, %72
%51 = call i32* @fgets(i8* %9, i32 512, i32* %20)
%52 = icmp eq i32* %51, null
br i1 %52, label %85, label %32
53: ; preds = %43
%54 = call i32 @fclose(i32* %84)
%55 = call i32 @appendbinaryattach(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %29)
%56 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %77
58: ; preds = %53
%59 = call i32 @fclose(i32* %20)
%60 = call i32 @unlink(i8* %8)
br label %99
61: ; preds = %32
%62 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 18)
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %75
64: ; preds = %61
%65 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %20)
%66 = load i8, i8* %4
%67 = icmp eq i8 %66, 0
br i1 %67, label %68, label %72
68: ; preds = %64
%69 = call i32 @fclose(i32* %20)
%70 = call i32 @fclose(i32* %84)
%71 = call i32 @unlink(i8* %8)
br label %99
72: ; preds = %64
%73 = call i32 @ungetc(i8 signext %66, i32* %20)
%74 = call i32 @fputs(i8* %9, i32* %84)
br label %50
75: ; preds = %61
%76 = call i32 @fputs(i8* %9, i32* %84)
br label %77
77: ; preds = %53, %75
%78 = phi i32* [ %84, %75 ], [ %56, %53 ]
%79 = phi i32 [ %83, %75 ], [ 1, %53 ]
%80 = call i32* @fgets(i8* %9, i32 512, i32* %20)
%81 = icmp eq i32* %80, null
br i1 %81, label %85, label %82
82: ; preds = %28, %77
%83 = phi i32 [ 0, %28 ], [ %79, %77 ]
%84 = phi i32* [ %23, %28 ], [ %78, %77 ]
br label %32
85: ; preds = %77, %50
%86 = phi i32* [ %84, %50 ], [ %78, %77 ]
%87 = phi i32 [ %83, %50 ], [ %79, %77 ]
%88 = icmp eq i32 %87, 0
br i1 %88, label %94, label %89
89: ; preds = %85
%90 = call i32 @fclose(i32* %20)
%91 = call i32 @fclose(i32* %86)
%92 = call i32 @copyfile(i8* %8, i8* %0)
%93 = call i32 @unlink(i8* %8)
br label %99
94: ; preds = %25, %85
%95 = phi i32* [ %86, %85 ], [ %23, %25 ]
%96 = call i32 @fclose(i32* %20)
%97 = call i32 @fclose(i32* %95)
%98 = call i32 @unlink(i8* %8)
br label %99
99: ; preds = %68, %16, %1, %94, %89, %58, %30
%100 = phi i32 [ -3, %30 ], [ -4, %58 ], [ -6, %89 ], [ 0, %94 ], [ -1, %1 ], [ -2, %16 ], [ -5, %68 ]
ret i32 %100
}