#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  char *filename = argv[1];
  FILE *file = fopen(filename, "r");
  int u = 0;
  if (file != NULL) {
    char line[500];
    while ((fgets(line, sizeof line, file) != NULL) && (u <= 1)) {
      if (line[0] == 'u')
        u++;
      else if (line[0] == '\"')
        fputs(line, stdout);
    }
    fclose(file);
  } else {
    perror(filename);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1245 <main+0xf5>
jmp    11a0 <main+0x50>
lea    -0x220(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x1f4,%esi
call   1050 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x221(%rbp)
je     11d7 <main+0x87>
cmpl   $0x1,-0x24(%rbp)
setle  %al
mov    %al,-0x221(%rbp)
mov    -0x221(%rbp),%al
test   $0x1,%al
jne    11ea <main+0x9a>
jmp    1237 <main+0xe7>
movsbl -0x220(%rbp),%eax
cmp    $0x75,%eax
jne    1208 <main+0xb8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1232 <main+0xe2>
movsbl -0x220(%rbp),%eax
cmp    $0x22,%eax
jne    122d <main+0xdd>
lea    -0x220(%rbp),%rdi
mov    0x2dba(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
jmp    1232 <main+0xe2>
jmp    11a0 <main+0x50>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    124e <main+0xfe>
mov    -0x18(%rbp),%rdi
call   1070 <perror@plt>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1f8,%rsp
mov    0x8(%rsi),%r14
lea    0xe98(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11fd <main+0xad>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x1f4,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11e5 <main+0x95>
xor    %ebp,%ebp
mov    0x2e46(%rip),%r15
mov    %rsp,%r14
nopl   (%rax)
movzbl (%rsp),%eax
cmp    $0x22,%al
je     11c0 <main+0x70>
cmp    $0x75,%al
jne    11cb <main+0x7b>
add    $0x1,%ebp
jmp    11cb <main+0x7b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15),%esi
mov    %r14,%rdi
call   1040 <fputs@plt>
mov    %r14,%rdi
mov    $0x1f4,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11e5 <main+0x95>
cmp    $0x2,%ebp
jl     11a0 <main+0x50>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x1f8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14,%rdi
call   1070 <perror@plt>
jmp    11ed <main+0x9d>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca [500 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %7
store i32 0, i32* %8
%15 = load i32*, i32** %7
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %50
17: ; preds = %2
br label %18
18: ; preds = %46, %17
%19 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%20 = load i32*, i32** %7
%21 = call i32* @fgets(i8* %19, i32 500, i32* %20)
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i32, i32* %8
%25 = icmp sle i32 %24, 1
br label %26
26: ; preds = %23, %18
%27 = phi i1 [ false, %18 ], [ %25, %23 ]
br i1 %27, label %28, label %47
28: ; preds = %26
%29 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 117
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %46
36: ; preds = %28
%37 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 34
br i1 %40, label %41, label %45
41: ; preds = %36
%42 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%43 = load i32, i32* @stdout
%44 = call i32 @fputs(i8* %42, i32 %43)
br label %45
45: ; preds = %41, %36
br label %46
46: ; preds = %45, %33
br label %18
47: ; preds = %26
%48 = load i32*, i32** %7
%49 = call i32 @fclose(i32* %48)
br label %53
50: ; preds = %2
%51 = load i8*, i8** %6
%52 = call i32 @perror(i8* %51)
br label %53
53: ; preds = %50, %47
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [500 x i8]
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %28, label %8
8: ; preds = %2
%9 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%10 = call i32* @fgets(i8* %9, i32 500, i32* %6)
%11 = icmp eq i32* %10, null
br i1 %11, label %26, label %12
12: ; preds = %8, %20
%13 = phi i32 [ %21, %20 ], [ 0, %8 ]
%14 = load i8, i8* %9
switch i8 %14, label %20 [
i8 117, label %15
i8 34, label %17
]
15: ; preds = %12
%16 = add nsw i32 %13, 1
br label %20
17: ; preds = %12
%18 = load i32, i32* @stdout
%19 = call i32 @fputs(i8* %9, i32 %18)
br label %20
20: ; preds = %12, %17, %15
%21 = phi i32 [ %16, %15 ], [ %13, %17 ], [ %13, %12 ]
%22 = call i32* @fgets(i8* %9, i32 500, i32* %6)
%23 = icmp ne i32* %22, null
%24 = icmp slt i32 %21, 2
%25 = select i1 %23, i1 %24, i1 false
br i1 %25, label %12, label %26
26: ; preds = %20, %8
%27 = call i32 @fclose(i32* %6)
br label %30
28: ; preds = %2
%29 = tail call i32 @perror(i8* %5)
br label %30
30: ; preds = %28, %26
ret i32 0
}