#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ decode(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, int *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
scalar_t__ strcmp(char *, char *);
scalar_t__ strncmp(char *, char *, int);
void main(int argc, char **argv) {
  FILE *in, *out;
  int mode;
  char dest[128];
  char buf[80];
  if (argc > 1) {
    if ((in = fopen(argv[1], "r")) == 0) {
      perror(argv[1]);
      exit(1);
    }
    argv++;
    argc--;
  } else
    in = stdin;
  if (argc != 1) {
    printf("Usage: uudecode [infile]\n");
    exit(2);
  }
  for (;;) {
    if (fgets(buf, sizeof buf, in) == 0) {
      fprintf(stderr, "No begin line\n");
      exit(3);
    }
    if (strncmp(buf, "begin ", 6) == 0)
      break;
  }
  (void)sscanf(buf, "begin %o %s", &mode, dest);
  out = fopen(dest, "wb");
  if (out == 0) {
    perror(dest);
    exit(4);
  }
  decode(in, out);
  if (fgets(buf, sizeof buf, in) == 0 || strcmp(buf, "end\n")) {
    fprintf(stderr, "No end line\n");
    exit(5);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    120f <main+0x6f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe35(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11f5 <main+0x55>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    121d <main+0x7d>
mov    0x2dd2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     123d <main+0x9d>
lea    0xdd4(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
call   10c0 <exit@plt>
jmp    1242 <main+0xa2>
lea    -0x100(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x50,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    1280 <main+0xe0>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
lea    0xdab(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x3,%edi
call   10c0 <exit@plt>
lea    -0x100(%rbp),%rdi
lea    0xd9d(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12a7 <main+0x107>
jmp    12ac <main+0x10c>
jmp    1242 <main+0xa2>
lea    -0x100(%rbp),%rdi
lea    -0xb0(%rbp),%rcx
lea    0xd71(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1080 <sscanf@plt>
lea    -0xb0(%rbp),%rdi
lea    0xd66(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1302 <main+0x162>
lea    -0xb0(%rbp),%rdi
call   10b0 <perror@plt>
mov    $0x4,%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <decode@plt>
lea    -0x100(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x50,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     134b <main+0x1ab>
lea    -0x100(%rbp),%rdi
lea    0xd05(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     136a <main+0x1ca>
mov    0x2c86(%rip),%rax
mov    (%rax),%edi
lea    0xceb(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x5,%edi
call   10c0 <exit@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xe0,%rsp
mov    %edi,%ebp
cmp    $0x2,%edi
jl     11e1 <main+0x41>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe40(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
jne    1274 <main+0xd4>
mov    0x8(%rbx),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%r14
cmp    $0x1,%ebp
jne    1283 <main+0xe3>
lea    0x10(%rsp),%rbp
lea    0xe11(%rip),%rbx
mov    %rbp,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1299 <main+0xf9>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1200 <main+0x60>
lea    0xde3(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
lea    0x60(%rsp),%rbx
mov    %rbx,%rcx
call   1080 <sscanf@plt>
lea    0xdd1(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
jne    12b8 <main+0x118>
lea    0x60(%rsp),%rdi
call   10b0 <perror@plt>
mov    $0x4,%edi
call   10c0 <exit@plt>
mov    %rax,%r14
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
je     11f4 <main+0x54>
lea    0xdaf(%rip),%rdi
call   1040 <puts@plt>
mov    $0x2,%edi
call   10c0 <exit@plt>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
lea    0xd59(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x3,%edi
call   10c0 <exit@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1090 <decode@plt>
lea    0x10(%rsp),%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     12f7 <main+0x157>
lea    0xd46(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    12f7 <main+0x157>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
lea    0xd25(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x5,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stdin = global i32* null
@.str.1 = [26 x i8] c"Usage: uudecode [infile]\0A\00"
@stderr = global i32 0
@.str.2 = [15 x i8] c"No begin line\0A\00"
@.str.3 = [7 x i8] c"begin \00"
@.str.4 = [12 x i8] c"begin %o %s\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [5 x i8] c"end\0A\00"
@.str.7 = [13 x i8] c"No end line\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [128 x i8]
%9 = alloca [80 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %29
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %5
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %24
18: ; preds = %12
%19 = load i8**, i8*** %4
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @perror(i8* %21)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %12
%25 = load i8**, i8*** %4
%26 = getelementptr inbounds i8*, i8** %25, i32 1
store i8** %26, i8*** %4
%27 = load i32, i32* %3
%28 = add nsw i32 %27, -1
store i32 %28, i32* %3
br label %31
29: ; preds = %2
%30 = load i32*, i32** @stdin
store i32* %30, i32** %5
br label %31
31: ; preds = %29, %24
%32 = load i32, i32* %3
%33 = icmp ne i32 %32, 1
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 @exit(i32 2)
unreachable
37: ; preds = %31
br label %38
38: ; preds = %52, %37
%39 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%40 = load i32*, i32** %5
%41 = call i64 @fgets(i8* %39, i32 80, i32* %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%46 = call i32 @exit(i32 3)
unreachable
47: ; preds = %38
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%49 = call i64 @strncmp(i8* %48, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %47
br label %53
52: ; preds = %47
br label %38
53: ; preds = %51
%54 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%55 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%56 = call i32 @sscanf(i8* %54, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32* %7, i8* %55)
%57 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%58 = call i32* @fopen(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %58, i32** %6
%59 = load i32*, i32** %6
%60 = icmp eq i32* %59, null
br i1 %60, label %61, label %65
61: ; preds = %53
%62 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%63 = call i32 @perror(i8* %62)
%64 = call i32 @exit(i32 4)
unreachable
65: ; preds = %53
%66 = load i32*, i32** %5
%67 = load i32*, i32** %6
%68 = call i32 @decode(i32* %66, i32* %67)
%69 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%70 = load i32*, i32** %5
%71 = call i64 @fgets(i8* %69, i32 80, i32* %70)
%72 = icmp eq i64 %71, 0
br i1 %72, label %77, label %73
73: ; preds = %65
%74 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%75 = call i64 @strcmp(i8* %74, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%76 = icmp ne i64 %75, 0
br i1 %76, label %77, label %81
77: ; preds = %73, %65
%78 = load i32, i32* @stderr
%79 = call i32 @fprintf(i32 %78, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%80 = call i32 @exit(i32 5)
unreachable
81: ; preds = %73
%82 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stdin = global i32* null
@stderr = global i32 0
@.str.2 = [15 x i8] c"No begin line\0A\00"
@.str.3 = [7 x i8] c"begin \00"
@.str.4 = [12 x i8] c"begin %o %s\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [5 x i8] c"end\0A\00"
@.str.7 = [13 x i8] c"No end line\0A\00"
@str = [25 x i8] c"Usage: uudecode [infile]\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [128 x i8]
%5 = alloca [80 x i8]
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i8*, i8** %11
%17 = tail call i32 @perror(i8* %16)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %10
%20 = add nsw i32 %0, -1
br label %23
21: ; preds = %2
%22 = load i32*, i32** @stdin
br label %23
23: ; preds = %21, %19
%24 = phi i32* [ %13, %19 ], [ %22, %21 ]
%25 = phi i32 [ %20, %19 ], [ %0, %21 ]
%26 = icmp eq i32 %25, 1
br i1 %26, label %30, label %27
27: ; preds = %23
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%29 = tail call i32 @exit(i32 2)
unreachable
30: ; preds = %23, %37
%31 = call i64 @fgets(i8* %8, i32 80, i32* %24)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @exit(i32 3)
unreachable
37: ; preds = %30
%38 = call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %30
40: ; preds = %37
%41 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32* %3, i8* %7)
%42 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = call i32 @perror(i8* %7)
%46 = call i32 @exit(i32 4)
unreachable
47: ; preds = %40
%48 = call i32 @decode(i32* %24, i32* %42)
%49 = call i64 @fgets(i8* %8, i32 80, i32* %24)
%50 = icmp eq i64 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %47
%52 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %58, label %54
54: ; preds = %51, %47
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%57 = call i32 @exit(i32 5)
unreachable
58: ; preds = %51
%59 = call i32 @exit(i32 0)
unreachable
}