#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 EOF;
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, int);
int main(int count, char *argv[]) {
  FILE *pf = fopen(argv[1], "r");
  int c;
  while ((c = fgetc(pf)) != EOF)
    (c == '\n') ? printf("%c", c) : printf("[%c]", c);
  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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeab(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%eax
je     11ab <main+0x7b>
cmpl   $0xa,-0x1c(%rbp)
jne    1197 <main+0x67>
mov    -0x1c(%rbp),%esi
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
jmp    11a6 <main+0x76>
mov    -0x1c(%rbp),%esi
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
jmp    115e <main+0x2e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
lea    0xebd(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <fgetc@plt>
mov    0x2e8e(%rip),%r12
cmp    (%r12),%eax
jne    116e <main+0x3e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe8d(%rip),%r14
lea    0xe89(%rip),%r15
jmp    1198 <main+0x68>
xchg   %ax,%ax
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    (%r12),%eax
je     1160 <main+0x30>
cmp    $0xa,%eax
jne    1180 <main+0x50>
mov    %r14,%rdi
mov    $0xa,%esi
jmp    1185 <main+0x55>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [5 x i8] c"[%c]\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
br label %12
12: ; preds = %26, %2
%13 = load i32*, i32** %6
%14 = call i32 @fgetc(i32* %13)
store i32 %14, i32* %7
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %28
17: ; preds = %12
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %7
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %26
23: ; preds = %17
%24 = load i32, i32* %7
%25 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %23, %20
%27 = phi i32 [ %22, %20 ], [ %25, %23 ]
br label %12
28: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [5 x i8] c"[%c]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @fgetc(i32* %5)
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %20, label %9
9: ; preds = %2, %16
%10 = phi i32 [ %17, %16 ], [ %6, %2 ]
%11 = icmp eq i32 %10, 10
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 10)
br label %16
14: ; preds = %9
%15 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %10)
br label %16
16: ; preds = %14, %12
%17 = tail call i32 @fgetc(i32* %5)
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %9
20: ; preds = %16, %2
ret i32 0
}