#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 */
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ filter_line(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
void filter(char *inf) {
  FILE *ifile;
  char line[1024];
  char *lp;
  ifile = fopen(inf, "r");
  if (ifile != NULL) {
    while ((lp = fgets(line, sizeof(line), ifile)) != NULL) {
      filter_line(lp);
    }
  } else {
    printf("Cannot open input-file %s\n", inf);
  }
}


x86 assembly (clang, -O0):
<filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11af <filter+0x6f>
jmp    1173 <filter+0x33>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
mov    %rax,-0x418(%rbp)
cmp    $0x0,%rax
je     11aa <filter+0x6a>
mov    -0x418(%rbp),%rdi
call   1030 <filter_line@plt>
jmp    1173 <filter+0x33>
jmp    11bf <filter+0x7f>
mov    -0x8(%rbp),%rsi
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%r14
lea    0xeac(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11a8 <filter+0x68>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     119d <filter+0x5d>
mov    %rsp,%r14
nopl   0x0(%rax)
mov    %rax,%rdi
call   1030 <filter_line@plt>
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    1180 <filter+0x40>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe53(%rip),%rdi
mov    %r14,%rsi
add    $0x408,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [27 x i8] c"Cannot open input-file %s\0A\00"
define void @filter(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [1024 x i8]
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %3
%8 = load i32*, i32** %3
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %20
10: ; preds = %1
br label %11
11: ; preds = %16, %10
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%13 = load i32*, i32** %3
%14 = call i8* @fgets(i8* %12, i32 1024, i32* %13)
store i8* %14, i8** %5
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i8*, i8** %5
%18 = call i32 @filter_line(i8* %17)
br label %11
19: ; preds = %11
br label %23
20: ; preds = %1
%21 = load i8*, i8** %2
%22 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20, %19
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [27 x i8] c"Cannot open input-file %s\0A\00"
define void @filter(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %14, label %6
6: ; preds = %1
%7 = call i8* @fgets(i8* %3, i32 1024, i32* %4)
%8 = icmp eq i8* %7, null
br i1 %8, label %16, label %9
9: ; preds = %6, %9
%10 = phi i8* [ %12, %9 ], [ %7, %6 ]
%11 = call i32 @filter_line(i8* %10)
%12 = call i8* @fgets(i8* %3, i32 1024, i32* %4)
%13 = icmp eq i8* %12, null
br i1 %13, label %16, label %9
14: ; preds = %1
%15 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %16
16: ; preds = %9, %6, %14
ret void
}