#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 */
char EOF;
int /*<<< orphan*/ *fopen(char *, char *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(char const);
int main(int argc, char *argv[]) {
  FILE *fp;
  char c;
  int m = 1;
  const char *morse =
      "ETIANMSURWDKGOHVF L PJBXCYZQ  54 3   2       16       7   8 90";
  if (argc != 2) {
    printf("Usage: %s [FILE]\n", argv[0]);
    return 1;
  }
  fp = fopen(*++argv, "r");
  while ((c = getc(fp)) != EOF || m > 1) {
    if (c == '.') {
      m <<= 1;
    } else if (c == '-') {
      m = (m << 1) + 1;
    } else if (m == 1) {
      putchar(' ');
    } else {
      if (m < 64)
        putchar(morse[m - 2]);
      if (c == '\n' || c == EOF)
        putchar('\n');
      m = 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x20(%rbp)
lea    0xe9c(%rip),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1191 <main+0x51>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xebf(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b0 <main+0x170>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xea6(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <getc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%ecx
mov    0x2e1e(%rip),%rax
movsbl (%rax),%edx
mov    $0x1,%al
cmp    %edx,%ecx
mov    %al,-0x29(%rbp)
jne    11e4 <main+0xa4>
cmpl   $0x1,-0x20(%rbp)
setg   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11f4 <main+0xb4>
jmp    12a9 <main+0x169>
movsbl -0x19(%rbp),%eax
cmp    $0x2e,%eax
jne    120f <main+0xcf>
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12a4 <main+0x164>
movsbl -0x19(%rbp),%eax
cmp    $0x2d,%eax
jne    122d <main+0xed>
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    129f <main+0x15f>
cmpl   $0x1,-0x20(%rbp)
jne    1246 <main+0x106>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    129a <main+0x15a>
cmpl   $0x40,-0x20(%rbp)
jge    1266 <main+0x126>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
je     1289 <main+0x149>
movsbl -0x19(%rbp),%eax
mov    0x2d6a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1293 <main+0x153>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x1,-0x20(%rbp)
jmp    129f <main+0x15f>
jmp    12a4 <main+0x164>
jmp    11b4 <main+0x74>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1231 <main+0xf1>
mov    0x8(%rsi),%rdi
lea    0xef2(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1060 <getc@plt>
mov    %eax,%ebx
mov    0x2e70(%rip),%r15
mov    (%r15),%al
xor    %r14d,%r14d
cmp    %al,%bl
je     1246 <main+0x106>
mov    $0x1,%ebp
lea    0xe6e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x2d,%bl
je     11b0 <main+0x70>
cmp    $0x2e,%bl
jne    11c0 <main+0x80>
add    %ebp,%ebp
jmp    1210 <main+0xd0>
xchg   %ax,%ax
add    %ebp,%ebp
add    $0x1,%ebp
jmp    1210 <main+0xd0>
nopw   0x0(%rax,%rax,1)
cmp    $0x1,%ebp
jne    11d6 <main+0x96>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebp
jmp    1210 <main+0xd0>
cmp    $0x3f,%ebp
jg     11ed <main+0xad>
movslq %ebp,%rax
movsbl -0x2(%rax,%r12,1),%edi
call   1030 <putchar@plt>
movzbl (%r15),%eax
mov    $0x1,%ebp
cmp    $0xa,%bl
je     11fb <main+0xbb>
cmp    %al,%bl
jne    1210 <main+0xd0>
mov    $0xa,%edi
call   1030 <putchar@plt>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
call   1060 <getc@plt>
mov    %eax,%ebx
movzbl (%r15),%eax
cmp    %al,%bl
jne    11a0 <main+0x60>
cmp    $0x1,%ebp
jg     11a0 <main+0x60>
jmp    1246 <main+0x106>
mov    (%rsi),%rsi
lea    0xe04(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [63 x i8] c"ETIANMSURWDKGOHVF L PJBXCYZQ 54 3 2 16 7 8 90\00"
@.str.1 = [18 x i8] c"Usage: %s [FILE]\0A\00"
@.str.2 = [2 x i8] c"r\00"
@EOF = global i8 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
%8 = alloca i32
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %8
store i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %82
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i32 1
store i8** %19, i8*** %5
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %21, i32** %6
br label %22
22: ; preds = %80, %17
%23 = load i32*, i32** %6
%24 = call signext i8 @getc(i32* %23)
store i8 %24, i8* %7
%25 = sext i8 %24 to i32
%26 = load i8, i8* @EOF
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %25, %27
br i1 %28, label %32, label %29
29: ; preds = %22
%30 = load i32, i32* %8
%31 = icmp sgt i32 %30, 1
br label %32
32: ; preds = %29, %22
%33 = phi i1 [ true, %22 ], [ %31, %29 ]
br i1 %33, label %34, label %81
34: ; preds = %32
%35 = load i8, i8* %7
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 46
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i32, i32* %8
%40 = shl i32 %39, 1
store i32 %40, i32* %8
br label %80
41: ; preds = %34
%42 = load i8, i8* %7
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 45
br i1 %44, label %45, label %49
45: ; preds = %41
%46 = load i32, i32* %8
%47 = shl i32 %46, 1
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %79
49: ; preds = %41
%50 = load i32, i32* %8
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 @putchar(i8 signext 32)
br label %78
54: ; preds = %49
%55 = load i32, i32* %8
%56 = icmp slt i32 %55, 64
br i1 %56, label %57, label %65
57: ; preds = %54
%58 = load i8*, i8** %9
%59 = load i32, i32* %8
%60 = sub nsw i32 %59, 2
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %58, i64 %61
%63 = load i8, i8* %62
%64 = call i32 @putchar(i8 signext %63)
br label %65
65: ; preds = %57, %54
%66 = load i8, i8* %7
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 10
br i1 %68, label %75, label %69
69: ; preds = %65
%70 = load i8, i8* %7
%71 = sext i8 %70 to i32
%72 = load i8, i8* @EOF
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %71, %73
br i1 %74, label %75, label %77
75: ; preds = %69, %65
%76 = call i32 @putchar(i8 signext 10)
br label %77
77: ; preds = %75, %69
store i32 1, i32* %8
br label %78
78: ; preds = %77, %52
br label %79
79: ; preds = %78, %45
br label %80
80: ; preds = %79, %38
br label %22
81: ; preds = %32
store i32 0, i32* %3
br label %82
82: ; preds = %81, %12
%83 = load i32, i32* %3
ret i32 %83
}

LLVM IR (-O2):
@.str = [63 x i8] c"ETIANMSURWDKGOHVF L PJBXCYZQ 54 3 2 16 7 8 90\00"
@.str.1 = [18 x i8] c"Usage: %s [FILE]\0A\00"
@.str.2 = [2 x i8] c"r\00"
@EOF = global i8 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %50
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call signext i8 @getc(i32* %10)
%12 = load i8, i8* @EOF
%13 = icmp eq i8 %11, %12
br i1 %13, label %50, label %14
14: ; preds = %7, %43
%15 = phi i8 [ %46, %43 ], [ %12, %7 ]
%16 = phi i8 [ %45, %43 ], [ %11, %7 ]
%17 = phi i32 [ %44, %43 ], [ 1, %7 ]
switch i8 %16, label %23 [
i8 46, label %18
i8 45, label %20
]
18: ; preds = %14
%19 = shl i32 %17, 1
br label %43
20: ; preds = %14
%21 = shl i32 %17, 1
%22 = or i32 %21, 1
br label %43
23: ; preds = %14
%24 = icmp eq i32 %17, 1
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = tail call i32 @putchar(i8 signext 32)
br label %43
27: ; preds = %23
%28 = icmp slt i32 %17, 64
br i1 %28, label %29, label %36
29: ; preds = %27
%30 = add nsw i32 %17, -2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [63 x i8], [63 x i8]* @.str, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = tail call i32 @putchar(i8 signext %33)
%35 = load i8, i8* @EOF
br label %36
36: ; preds = %29, %27
%37 = phi i8 [ %35, %29 ], [ %15, %27 ]
%38 = icmp eq i8 %16, 10
%39 = icmp eq i8 %16, %37
%40 = select i1 %38, i1 true, i1 %39
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = tail call i32 @putchar(i8 signext 10)
br label %43
43: ; preds = %41, %36, %20, %25, %18
%44 = phi i32 [ %19, %18 ], [ %22, %20 ], [ 1, %25 ], [ 1, %36 ], [ 1, %41 ]
%45 = tail call signext i8 @getc(i32* %10)
%46 = load i8, i8* @EOF
%47 = icmp ne i8 %45, %46
%48 = icmp sgt i32 %44, 1
%49 = select i1 %47, i1 true, i1 %48
br i1 %49, label %14, label %50
50: ; preds = %43, %7, %4
%51 = phi i32 [ 1, %4 ], [ 0, %7 ], [ 0, %43 ]
ret i32 %51
}