#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, p = '\0';
  if (argc != 2) {
    printf("Usage: %s [FILE]\n", argv[0]);
    return 1;
  }
  fp = fopen(*++argv, "r");
  while ((c = getc(fp)) != EOF) {
    if (c != p)
      putchar(c);
    p = c;
  }
  if (p != '\n')
    putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x1a(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1183 <main+0x43>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1209 <main+0xc9>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xe75(%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    0x2e2c(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11eb <main+0xab>
movsbl -0x19(%rbp),%eax
movsbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
je     11e0 <main+0xa0>
movsbl -0x19(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x19(%rbp),%al
mov    %al,-0x1a(%rbp)
jmp    11a6 <main+0x66>
movsbl -0x1a(%rbp),%eax
cmp    $0xa,%eax
je     1202 <main+0xc2>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11a2 <main+0x62>
mov    0x8(%rsi),%rdi
lea    0xebb(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1060 <getc@plt>
mov    0x2e7a(%rip),%r14
cmp    (%r14),%al
je     11bf <main+0x7f>
xor    %ebp,%ebp
jmp    118d <main+0x4d>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1060 <getc@plt>
cmp    (%r14),%al
je     11b8 <main+0x78>
mov    %ebp,%ecx
mov    %eax,%ebx
movsbl %al,%ebp
cmp    %ebp,%ecx
je     1180 <main+0x40>
movsbl %bl,%edi
call   1030 <putchar@plt>
jmp    1180 <main+0x40>
mov    (%rsi),%rsi
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
jmp    11cb <main+0x8b>
xor    %eax,%eax
cmp    $0xa,%bl
je     11cb <main+0x8b>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
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 i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %8
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %46
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i32 1
store i8** %18, i8*** %5
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
br label %21
21: ; preds = %37, %16
%22 = load i32*, i32** %6
%23 = call signext i8 @getc(i32* %22)
store i8 %23, i8* %7
%24 = sext i8 %23 to i32
%25 = load i8, i8* @EOF
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %24, %26
br i1 %27, label %28, label %39
28: ; preds = %21
%29 = load i8, i8* %7
%30 = sext i8 %29 to i32
%31 = load i8, i8* %8
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %30, %32
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i8, i8* %7
%36 = call i32 @putchar(i8 signext %35)
br label %37
37: ; preds = %34, %28
%38 = load i8, i8* %7
store i8 %38, i8* %8
br label %21
39: ; preds = %21
%40 = load i8, i8* %8
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 10
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 @putchar(i8 signext 10)
br label %45
45: ; preds = %43, %39
store i32 0, i32* %3
br label %46
46: ; preds = %45, %11
%47 = load i32, i32* %3
ret i32 %47
}

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 %29
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 %27, label %14
14: ; preds = %7, %21
%15 = phi i8 [ %22, %21 ], [ %11, %7 ]
%16 = phi i32 [ %17, %21 ], [ 0, %7 ]
%17 = sext i8 %15 to i32
%18 = icmp eq i32 %16, %17
br i1 %18, label %21, label %19
19: ; preds = %14
%20 = tail call i32 @putchar(i8 signext %15)
br label %21
21: ; preds = %19, %14
%22 = tail call signext i8 @getc(i32* %10)
%23 = load i8, i8* @EOF
%24 = icmp eq i8 %22, %23
br i1 %24, label %25, label %14
25: ; preds = %21
%26 = icmp eq i8 %15, 10
br i1 %26, label %29, label %27
27: ; preds = %7, %25
%28 = tail call i32 @putchar(i8 signext 10)
br label %29
29: ; preds = %25, %27, %4
%30 = phi i32 [ 1, %4 ], [ 0, %27 ], [ 0, %25 ]
ret i32 %30
}