#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);
int main(int argc, char *argv[]) {
  FILE *fp;
  char c;
  bool first = true, nl = true;
  if (argc != 2) {
    printf("Usage: %s [FILE]\n", argv[0]);
    return 1;
  }
  fp = fopen(*++argv, "r");
  while ((c = getc(fp)) != EOF) {
    nl = c == '\n';
    if (first && c >= 'a' && c <= 'z') {
      putchar(c & 223);
      first = false;
    } else {
      putchar(c);
      first = c == ' ' || c == '\t' || c == '\n';
    }
  }
  if (!nl)
    putchar('\n');
  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)
movl   $0x1,-0x24(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     118d <main+0x4d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1289 <main+0x149>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xe6b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <getc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2e22(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     126e <main+0x12e>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1224 <main+0xe4>
movsbl -0x19(%rbp),%eax
cmp    $0x61,%eax
jl     1224 <main+0xe4>
movsbl -0x19(%rbp),%eax
cmp    $0x7a,%eax
jg     1224 <main+0xe4>
movsbl -0x19(%rbp),%eax
and    $0xdf,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x20(%rbp)
jmp    1269 <main+0x129>
movsbl -0x19(%rbp),%edi
call   1030 <putchar@plt>
movsbl -0x19(%rbp),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x25(%rbp)
je     125e <main+0x11e>
movsbl -0x19(%rbp),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x25(%rbp)
je     125e <main+0x11e>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x20(%rbp)
jmp    11b0 <main+0x70>
cmpl   $0x0,-0x24(%rbp)
jne    1282 <main+0x142>
mov    $0xa,%edi
call   1030 <putchar@plt>
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    11ec <main+0xac>
mov    0x8(%rsi),%rdi
lea    0xeb3(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1060 <getc@plt>
mov    0x2e72(%rip),%r15
xor    %r14d,%r14d
cmp    (%r15),%al
je     1213 <main+0xd3>
mov    $0x1,%ebx
jmp    11a0 <main+0x60>
nopl   0x0(%rax)
movzbl %al,%ebx
mov    %r12,%rdi
call   1060 <getc@plt>
cmp    (%r15),%al
je     1203 <main+0xc3>
mov    %eax,%ebp
cmp    $0xa,%al
sete   %r13b
test   %ebx,%ebx
je     11d0 <main+0x90>
lea    -0x61(%rbp),%eax
cmp    $0x19,%al
ja     11d0 <main+0x90>
mov    %ebp,%eax
and    $0xdf,%al
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
jmp    1193 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %bpl,%edi
call   1030 <putchar@plt>
mov    $0x1,%al
cmp    $0x9,%bpl
je     1190 <main+0x50>
cmp    $0x20,%bpl
je     1190 <main+0x50>
mov    %r13d,%eax
jmp    1190 <main+0x50>
mov    (%rsi),%rsi
lea    0xe0a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%r14d
jmp    1213 <main+0xd3>
cmp    $0xa,%bpl
je     1213 <main+0xd3>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Usage: %s [FILE]\0A\00"
@.str.1 = [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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %8
store i32 1, i32* %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, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %74
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.1, i64 0, i64 0))
store i32* %21, i32** %6
br label %22
22: ; preds = %67, %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 %29, label %68
29: ; preds = %22
%30 = load i8, i8* %7
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 10
%33 = zext i1 %32 to i32
store i32 %33, i32* %9
%34 = load i32, i32* %8
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %50
36: ; preds = %29
%37 = load i8, i8* %7
%38 = sext i8 %37 to i32
%39 = icmp sge i32 %38, 97
br i1 %39, label %40, label %50
40: ; preds = %36
%41 = load i8, i8* %7
%42 = sext i8 %41 to i32
%43 = icmp sle i32 %42, 122
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = load i8, i8* %7
%46 = sext i8 %45 to i32
%47 = and i32 %46, 223
%48 = trunc i32 %47 to i8
%49 = call i32 @putchar(i8 signext %48)
store i32 0, i32* %8
br label %67
50: ; preds = %40, %36, %29
%51 = load i8, i8* %7
%52 = call i32 @putchar(i8 signext %51)
%53 = load i8, i8* %7
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 32
br i1 %55, label %64, label %56
56: ; preds = %50
%57 = load i8, i8* %7
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 9
br i1 %59, label %64, label %60
60: ; preds = %56
%61 = load i8, i8* %7
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 10
br label %64
64: ; preds = %60, %56, %50
%65 = phi i1 [ true, %56 ], [ true, %50 ], [ %63, %60 ]
%66 = zext i1 %65 to i32
store i32 %66, i32* %8
br label %67
67: ; preds = %64, %44
br label %22
68: ; preds = %22
%69 = load i32, i32* %9
%70 = icmp ne i32 %69, 0
br i1 %70, label %73, label %71
71: ; preds = %68
%72 = call i32 @putchar(i8 signext 10)
br label %73
73: ; preds = %71, %68
store i32 0, i32* %3
br label %74
74: ; preds = %73, %12
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
@.str = [18 x i8] c"Usage: %s [FILE]\0A\00"
@.str.1 = [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, i64 0, i64 0), i8* %5)
br label %39
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.1, 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 %39, label %14
14: ; preds = %7, %31
%15 = phi i8 [ %33, %31 ], [ %11, %7 ]
%16 = phi i32 [ %32, %31 ], [ 1, %7 ]
%17 = icmp eq i8 %15, 10
%18 = icmp ne i32 %16, 0
%19 = add i8 %15, -97
%20 = icmp ult i8 %19, 26
%21 = and i1 %18, %20
br i1 %21, label %22, label %25
22: ; preds = %14
%23 = and i8 %15, -33
%24 = tail call i32 @putchar(i8 signext %23)
br label %31
25: ; preds = %14
%26 = tail call i32 @putchar(i8 signext %15)
switch i8 %15, label %27 [
i8 32, label %28
i8 9, label %28
]
27: ; preds = %25
br label %28
28: ; preds = %25, %25, %27
%29 = phi i1 [ true, %25 ], [ %17, %27 ], [ true, %25 ]
%30 = zext i1 %29 to i32
br label %31
31: ; preds = %28, %22
%32 = phi i32 [ 0, %22 ], [ %30, %28 ]
%33 = tail call signext i8 @getc(i32* %10)
%34 = load i8, i8* @EOF
%35 = icmp eq i8 %33, %34
br i1 %35, label %36, label %14
36: ; preds = %31
br i1 %17, label %39, label %37
37: ; preds = %36
%38 = tail call i32 @putchar(i8 signext 10)
br label %39
39: ; preds = %7, %36, %37, %4
%40 = phi i32 [ 1, %4 ], [ 0, %37 ], [ 0, %36 ], [ 0, %7 ]
ret i32 %40
}