#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ armFinalizationCode(int /*<<< orphan*/ *);
int /*<<< orphan*/ armInitializationCode(int /*<<< orphan*/ *);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ encode3Spaces(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ encode7Spaces(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ encodeDash(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ encodeDot(int /*<<< orphan*/ *, int /*<<< orphan*/);
char *encodeLetter(char);
int /*<<< orphan*/ encodeSpace(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 3) {
    printf("Usage: ./MorseEncoder <input> <output.s>\n");
    exit(EXIT_SUCCESS);
  }
  FILE *in = fopen(argv[1], "r");
  if (in == NULL) {
    fprintf(stderr, "Error opening file %s\n", argv[1]);
  }
  FILE *out = fopen(argv[2], "w");
  if (out == NULL) {
    fprintf(stderr, "Error opening file %s\n", argv[2]);
  }
  char *buffer = (char *)calloc(512, sizeof(char));
  if (buffer == NULL) {
    perror("ERROR calloc for buffer\n");
    goto endmain;
  }
  armInitializationCode(out);
  int loopNumber = 1;
  while (!feof(in)) {
    if (fgets(buffer, 512, in) == NULL) {
      goto endmain;
    }
    for (int i = 0; buffer[i] != '\0'; i++) {
      char *morseCode = encodeLetter(buffer[i]);
      for (int j = 0; morseCode[j] != '\0'; j++) {
        if (morseCode[j] == ' ') {
          encodeSpace(out, loopNumber++);
        } else if (morseCode[j] == '\t') {
          encode7Spaces(out, loopNumber++);
        } else if (morseCode[j] == '.') {
          encodeDot(out, loopNumber++);
        } else if (morseCode[j] == '-') {
          encodeDash(out, loopNumber++);
        } else if (morseCode[j] == '_') {
          encode3Spaces(out, loopNumber++);
        } else {
          fprintf(stderr, "Invalid morse token %c\n", morseCode[j]);
        }
      }
      free(morseCode);
    }
  }
endmain:
  armFinalizationCode(out);
  free(buffer);
  fclose(in);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     125a <main+0x3a>
lea    0xdb9(%rip),%rdi
call   1060 <printf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdc1(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    129c <main+0x7c>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd97(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd98(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12de <main+0xbe>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xd55(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    $0x200,%edi
mov    $0x1,%esi
call   10b0 <calloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    130d <main+0xed>
lea    0xd42(%rip),%rdi
call   1110 <perror@plt>
jmp    14fa <main+0x2da>
mov    -0x20(%rbp),%rdi
call   10e0 <armInitializationCode@plt>
movl   $0x1,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   10d0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    133b <main+0x11b>
jmp    14f5 <main+0x2d5>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x200,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
jne    135c <main+0x13c>
jmp    14fa <main+0x2da>
movl   $0x0,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     14f0 <main+0x2d0>
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1130 <encodeLetter@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     14d9 <main+0x2b9>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    13d7 <main+0x1b7>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
call   1070 <encodeSpace@plt>
jmp    14c6 <main+0x2a6>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
jne    1405 <main+0x1e5>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
call   1140 <encode7Spaces@plt>
jmp    14c1 <main+0x2a1>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1433 <main+0x213>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
call   1030 <encodeDot@plt>
jmp    14bc <main+0x29c>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
jne    1461 <main+0x241>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
call   10f0 <encodeDash@plt>
jmp    14b7 <main+0x297>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
jne    148f <main+0x26f>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
call   1080 <encode3Spaces@plt>
jmp    14b2 <main+0x292>
mov    0x2b4a(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xbb3(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    14b7 <main+0x297>
jmp    14bc <main+0x29c>
jmp    14c1 <main+0x2a1>
jmp    14c6 <main+0x2a6>
jmp    14cb <main+0x2ab>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1394 <main+0x174>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1363 <main+0x143>
jmp    131d <main+0xfd>
jmp    14fa <main+0x2da>
mov    -0x20(%rbp),%rdi
call   10a0 <armFinalizationCode@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x3,%edi
jne    1431 <main+0x211>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe77(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    126d <main+0x4d>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe58(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0x10(%rbx),%rdi
lea    0xe5d(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,%r13
test   %rax,%rax
jne    12a0 <main+0x80>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xe25(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    $0x200,%edi
mov    $0x1,%esi
call   10b0 <calloc@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1420 <main+0x200>
mov    %r13,%rdi
call   10e0 <armInitializationCode@plt>
mov    %r14,%rdi
call   10d0 <feof@plt>
test   %eax,%eax
je     1300 <main+0xe0>
mov    %r13,%rdi
call   10a0 <armFinalizationCode@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %r13,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebx
lea    0xde4(%rip),%r12
lea    0xced(%rip),%r15
mov    %r14,0x8(%rsp)
mov    %rbp,0x10(%rsp)
jmp    1331 <main+0x111>
nop
mov    0x8(%rsp),%r14
mov    %r14,%rdi
call   10d0 <feof@plt>
test   %eax,%eax
jne    12cf <main+0xaf>
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     12cf <main+0xaf>
mov    0x0(%rbp),%al
test   %al,%al
je     1320 <main+0x100>
xor    %ecx,%ecx
jmp    1380 <main+0x160>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x18(%rsp),%rdi
call   1040 <free@plt>
mov    0x10(%rsp),%rbp
mov    0x20(%rsp),%rcx
mov    0x1(%rbp,%rcx,1),%al
add    $0x1,%rcx
test   %al,%al
je     1320 <main+0x100>
mov    %rcx,0x20(%rsp)
movsbl %al,%edi
call   1130 <encodeLetter@plt>
mov    %rax,%rbp
mov    %rax,0x18(%rsp)
jmp    13ac <main+0x18c>
lea    0x1(%rbx),%r14d
mov    %r13,%rdi
mov    %ebx,%esi
call   1030 <encodeDot@plt>
add    $0x1,%rbp
mov    %r14d,%ebx
movzbl 0x0(%rbp),%eax
cmp    $0x2e,%rax
ja     13d0 <main+0x1b0>
movslq (%r15,%rax,4),%rcx
add    %r15,%rcx
jmp    *%rcx
lea    0x1(%rbx),%r14d
mov    %r13,%rdi
mov    %ebx,%esi
call   1140 <encode7Spaces@plt>
jmp    13a5 <main+0x185>
nop
cmp    $0x5f,%al
jne    13e4 <main+0x1c4>
lea    0x1(%rbx),%r14d
mov    %r13,%rdi
mov    %ebx,%esi
call   1080 <encode3Spaces@plt>
jmp    13a5 <main+0x185>
movsbl %al,%edx
mov    0x2bf2(%rip),%rax
mov    (%rax),%edi
mov    %r12,%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
add    $0x1,%rbp
jmp    13ac <main+0x18c>
lea    0x1(%rbx),%r14d
mov    %r13,%rdi
mov    %ebx,%esi
call   1070 <encodeSpace@plt>
jmp    13a5 <main+0x185>
lea    0x1(%rbx),%r14d
mov    %r13,%rdi
mov    %ebx,%esi
call   10f0 <encodeDash@plt>
jmp    13a5 <main+0x185>
lea    0xcb0(%rip),%rdi
call   1110 <perror@plt>
jmp    12cf <main+0xaf>
lea    0xcd0(%rip),%rdi
call   1050 <puts@plt>
mov    0x2b94(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>

LLVM IR (-O0):
@.str = [42 x i8] c"Usage: ./MorseEncoder <input> <output.s>\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"Error opening file %s\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [25 x i8] c"ERROR calloc for buffer\0A\00"
@.str.5 = [24 x i8] c"Invalid morse token %c\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_SUCCESS
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %6
%24 = load i32*, i32** %6
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %32
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %26, %19
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %36, i32** %7
%37 = load i32*, i32** %7
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %45
39: ; preds = %32
%40 = load i32, i32* @stderr
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %39, %32
%46 = call i64 @calloc(i32 512, i32 1)
%47 = inttoptr i64 %46 to i8*
store i8* %47, i8** %8
%48 = load i8*, i8** %8
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %52
50: ; preds = %45
%51 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %180
52: ; preds = %45
%53 = load i32*, i32** %7
%54 = call i32 @armInitializationCode(i32* %53)
store i32 1, i32* %9
br label %55
55: ; preds = %178, %52
%56 = load i32*, i32** %6
%57 = call i32 @feof(i32* %56)
%58 = icmp ne i32 %57, 0
%59 = xor i1 %58, true
br i1 %59, label %60, label %179
60: ; preds = %55
%61 = load i8*, i8** %8
%62 = load i32*, i32** %6
%63 = call i32* @fgets(i8* %61, i32 512, i32* %62)
%64 = icmp eq i32* %63, null
br i1 %64, label %65, label %66
65: ; preds = %60
br label %180
66: ; preds = %60
store i32 0, i32* %10
br label %67
67: ; preds = %175, %66
%68 = load i8*, i8** %8
%69 = load i32, i32* %10
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %178
75: ; preds = %67
%76 = load i8*, i8** %8
%77 = load i32, i32* %10
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %76, i64 %78
%80 = load i8, i8* %79
%81 = call i8* @encodeLetter(i8 signext %80)
store i8* %81, i8** %11
store i32 0, i32* %12
br label %82
82: ; preds = %169, %75
%83 = load i8*, i8** %11
%84 = load i32, i32* %12
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp ne i32 %88, 0
br i1 %89, label %90, label %172
90: ; preds = %82
%91 = load i8*, i8** %11
%92 = load i32, i32* %12
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %91, i64 %93
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp eq i32 %96, 32
br i1 %97, label %98, label %103
98: ; preds = %90
%99 = load i32*, i32** %7
%100 = load i32, i32* %9
%101 = add nsw i32 %100, 1
store i32 %101, i32* %9
%102 = call i32 @encodeSpace(i32* %99, i32 %100)
br label %168
103: ; preds = %90
%104 = load i8*, i8** %11
%105 = load i32, i32* %12
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8, i8* %104, i64 %106
%108 = load i8, i8* %107
%109 = sext i8 %108 to i32
%110 = icmp eq i32 %109, 9
br i1 %110, label %111, label %116
111: ; preds = %103
%112 = load i32*, i32** %7
%113 = load i32, i32* %9
%114 = add nsw i32 %113, 1
store i32 %114, i32* %9
%115 = call i32 @encode7Spaces(i32* %112, i32 %113)
br label %167
116: ; preds = %103
%117 = load i8*, i8** %11
%118 = load i32, i32* %12
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i8, i8* %117, i64 %119
%121 = load i8, i8* %120
%122 = sext i8 %121 to i32
%123 = icmp eq i32 %122, 46
br i1 %123, label %124, label %129
124: ; preds = %116
%125 = load i32*, i32** %7
%126 = load i32, i32* %9
%127 = add nsw i32 %126, 1
store i32 %127, i32* %9
%128 = call i32 @encodeDot(i32* %125, i32 %126)
br label %166
129: ; preds = %116
%130 = load i8*, i8** %11
%131 = load i32, i32* %12
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i8, i8* %130, i64 %132
%134 = load i8, i8* %133
%135 = sext i8 %134 to i32
%136 = icmp eq i32 %135, 45
br i1 %136, label %137, label %142
137: ; preds = %129
%138 = load i32*, i32** %7
%139 = load i32, i32* %9
%140 = add nsw i32 %139, 1
store i32 %140, i32* %9
%141 = call i32 @encodeDash(i32* %138, i32 %139)
br label %165
142: ; preds = %129
%143 = load i8*, i8** %11
%144 = load i32, i32* %12
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i8, i8* %143, i64 %145
%147 = load i8, i8* %146
%148 = sext i8 %147 to i32
%149 = icmp eq i32 %148, 95
br i1 %149, label %150, label %155
150: ; preds = %142
%151 = load i32*, i32** %7
%152 = load i32, i32* %9
%153 = add nsw i32 %152, 1
store i32 %153, i32* %9
%154 = call i32 @encode3Spaces(i32* %151, i32 %152)
br label %164
155: ; preds = %142
%156 = load i32, i32* @stderr
%157 = load i8*, i8** %11
%158 = load i32, i32* %12
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds i8, i8* %157, i64 %159
%161 = load i8, i8* %160
%162 = sext i8 %161 to i32
%163 = call i32 (i32, i8*, ...) @fprintf(i32 %156, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %162)
br label %164
164: ; preds = %155, %150
br label %165
165: ; preds = %164, %137
br label %166
166: ; preds = %165, %124
br label %167
167: ; preds = %166, %111
br label %168
168: ; preds = %167, %98
br label %169
169: ; preds = %168
%170 = load i32, i32* %12
%171 = add nsw i32 %170, 1
store i32 %171, i32* %12
br label %82
172: ; preds = %82
%173 = load i8*, i8** %11
%174 = call i32 @free(i8* %173)
br label %175
175: ; preds = %172
%176 = load i32, i32* %10
%177 = add nsw i32 %176, 1
store i32 %177, i32* %10
br label %67
178: ; preds = %67
br label %55
179: ; preds = %55
br label %180
180: ; preds = %179, %65, %50
%181 = load i32*, i32** %7
%182 = call i32 @armFinalizationCode(i32* %181)
%183 = load i8*, i8** %8
%184 = call i32 @free(i8* %183)
%185 = load i32*, i32** %6
%186 = call i32 @fclose(i32* %185)
%187 = load i32*, i32** %7
%188 = call i32 @fclose(i32* %187)
ret i32 0
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"Error opening file %s\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [25 x i8] c"ERROR calloc for buffer\0A\00"
@.str.5 = [24 x i8] c"Invalid morse token %c\0A\00"
@str = [41 x i8] c"Usage: ./MorseEncoder <input> <output.s>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%6 = load i32, i32* @EXIT_SUCCESS
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %9
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %13, %8
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %18
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %22, %17
%27 = tail call i64 @calloc(i32 512, i32 1)
%28 = inttoptr i64 %27 to i8*
%29 = icmp eq i64 %27, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %85
32: ; preds = %26
%33 = tail call i32 @armInitializationCode(i32* %20)
%34 = tail call i32 @feof(i32* %11)
%35 = icmp eq i32 %34, 0
br i1 %35, label %40, label %85
36: ; preds = %57, %44
%37 = phi i32 [ %41, %44 ], [ %54, %57 ]
%38 = tail call i32 @feof(i32* %11)
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %85
40: ; preds = %32, %36
%41 = phi i32 [ %37, %36 ], [ 1, %32 ]
%42 = tail call i32* @fgets(i8* %28, i32 512, i32* %11)
%43 = icmp eq i32* %42, null
br i1 %43, label %85, label %44
44: ; preds = %40
%45 = load i8, i8* %28
%46 = icmp eq i8 %45, 0
br i1 %46, label %36, label %47
47: ; preds = %44, %57
%48 = phi i64 [ %59, %57 ], [ 0, %44 ]
%49 = phi i8 [ %61, %57 ], [ %45, %44 ]
%50 = phi i32 [ %54, %57 ], [ %41, %44 ]
%51 = tail call i8* @encodeLetter(i8 signext %49)
br label %52
52: ; preds = %82, %47
%53 = phi i64 [ %84, %82 ], [ 0, %47 ]
%54 = phi i32 [ %83, %82 ], [ %50, %47 ]
%55 = getelementptr inbounds i8, i8* %51, i64 %53
%56 = load i8, i8* %55
switch i8 %56, label %78 [
i8 0, label %57
i8 32, label %63
i8 9, label %66
i8 46, label %69
i8 45, label %72
i8 95, label %75
]
57: ; preds = %52
%58 = tail call i32 @free(i8* %51)
%59 = add nuw i64 %48, 1
%60 = getelementptr inbounds i8, i8* %28, i64 %59
%61 = load i8, i8* %60
%62 = icmp eq i8 %61, 0
br i1 %62, label %36, label %47
63: ; preds = %52
%64 = add nsw i32 %54, 1
%65 = tail call i32 @encodeSpace(i32* %20, i32 %54)
br label %82
66: ; preds = %52
%67 = add nsw i32 %54, 1
%68 = tail call i32 @encode7Spaces(i32* %20, i32 %54)
br label %82
69: ; preds = %52
%70 = add nsw i32 %54, 1
%71 = tail call i32 @encodeDot(i32* %20, i32 %54)
br label %82
72: ; preds = %52
%73 = add nsw i32 %54, 1
%74 = tail call i32 @encodeDash(i32* %20, i32 %54)
br label %82
75: ; preds = %52
%76 = add nsw i32 %54, 1
%77 = tail call i32 @encode3Spaces(i32* %20, i32 %54)
br label %82
78: ; preds = %52
%79 = sext i8 %56 to i32
%80 = load i32, i32* @stderr
%81 = tail call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %79)
br label %82
82: ; preds = %63, %69, %75, %78, %72, %66
%83 = phi i32 [ %64, %63 ], [ %67, %66 ], [ %70, %69 ], [ %73, %72 ], [ %76, %75 ], [ %54, %78 ]
%84 = add nuw i64 %53, 1
br label %52
85: ; preds = %40, %36, %32, %30
%86 = tail call i32 @armFinalizationCode(i32* %20)
%87 = tail call i32 @free(i8* %28)
%88 = tail call i32 @fclose(i32* %11)
%89 = tail call i32 @fclose(i32* %20)
ret i32 0
}