#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*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ chomp(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  FILE *f;
  char line[1024];
  if (argc < 2)
    return 1;
  f = fopen(argv[1], "r");
  if (f == NULL)
    return 1;
  if (chomp(line, sizeof(line), f)) {
    printf("%s\n", line);
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    116f <main+0x2f>
movl   $0x1,-0x4(%rbp)
jmp    11d9 <main+0x99>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe82(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119e <main+0x5e>
movl   $0x1,-0x4(%rbp)
jmp    11d9 <main+0x99>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1050 <chomp@plt>
cmp    $0x0,%rax
je     11d0 <main+0x90>
lea    -0x420(%rbp),%rsi
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x408,%rsp
mov    $0x1,%ebp
cmp    $0x2,%edi
jl     1199 <main+0x59>
mov    0x8(%rsi),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1199 <main+0x59>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1050 <chomp@plt>
test   %rax,%rax
je     118f <main+0x4f>
lea    0xe7b(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x408,%rsp
pop    %rbx
pop    %rbp
ret

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

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