#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 */
struct scanner {
  int dummy;
};
typedef int /*<<< orphan*/ b;

/* Variables and functions */
int /*<<< orphan*/ filter(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanner_free(struct scanner *);
scalar_t__ scanner_readline(struct scanner *, char *, int);
int filter_lines(struct scanner *s) {
  char b[8192] = {0};
  if (s == NULL)
    return -1;
  while (scanner_readline(s, b, sizeof(b)) >= 0) {
    filter(b);
    if (*b)
      puts(b);
  }
  scanner_free(s);
  return 0;
}


x86 assembly (clang, -O0):
<filter_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2010,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x2010(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1070 <memset@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1189 <filter_lines+0x39>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <filter_lines+0x97>
jmp    118e <filter_lines+0x3e>
mov    -0x10(%rbp),%rdi
lea    -0x2010(%rbp),%rsi
mov    $0x2000,%edx
call   1040 <scanner_readline@plt>
cmp    $0x0,%rax
jl     11d7 <filter_lines+0x87>
lea    -0x2010(%rbp),%rdi
call   1050 <filter@plt>
cmpb   $0x0,-0x2010(%rbp)
je     11d2 <filter_lines+0x82>
lea    -0x2010(%rbp),%rdi
call   1030 <puts@plt>
jmp    118e <filter_lines+0x3e>
mov    -0x10(%rbp),%rdi
call   1060 <scanner_free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_lines>:
push   %r14
push   %rbx
sub    $0x2008,%rsp
mov    %rdi,%r14
mov    %rsp,%rdi
mov    $0x2000,%edx
xor    %esi,%esi
call   1070 <memset@plt>
test   %r14,%r14
je     11c9 <filter_lines+0x79>
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x2000,%edx
call   1040 <scanner_readline@plt>
test   %rax,%rax
js     11bd <filter_lines+0x6d>
mov    %rsp,%rbx
jmp    11a5 <filter_lines+0x55>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x2000,%edx
call   1040 <scanner_readline@plt>
test   %rax,%rax
js     11bd <filter_lines+0x6d>
mov    %rbx,%rdi
call   1050 <filter@plt>
cmpb   $0x0,(%rsp)
je     1190 <filter_lines+0x40>
mov    %rbx,%rdi
call   1030 <puts@plt>
jmp    1190 <filter_lines+0x40>
mov    %r14,%rdi
call   1060 <scanner_free@plt>
xor    %eax,%eax
jmp    11ce <filter_lines+0x7e>
mov    $0xffffffff,%eax
add    $0x2008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.scanner = type { i32 }
define i32 @filter_lines(%struct.scanner* %0) {
%2 = alloca i32
%3 = alloca %struct.scanner*
%4 = alloca [8192 x i8]
store %struct.scanner* %0, %struct.scanner** %3
%5 = bitcast [8192 x i8]* %4 to i8*
%6 = load %struct.scanner*, %struct.scanner** %3
%7 = icmp eq %struct.scanner* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 -1, i32* %2
br label %28
9: ; preds = %1
br label %10
10: ; preds = %24, %9
%11 = load %struct.scanner*, %struct.scanner** %3
%12 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%13 = call i64 @scanner_readline(%struct.scanner* %11, i8* %12, i32 8192)
%14 = icmp sge i64 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %10
%16 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%17 = call i32 @filter(i8* %16)
%18 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%23 = call i32 @puts(i8* %22)
br label %24
24: ; preds = %21, %15
br label %10
25: ; preds = %10
%26 = load %struct.scanner*, %struct.scanner** %3
%27 = call i32 @scanner_free(%struct.scanner* %26)
store i32 0, i32* %2
br label %28
28: ; preds = %25, %8
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
%struct.scanner = type { i32 }
define i32 @filter_lines(%struct.scanner* %0) {
%2 = alloca [8192 x i8]
%3 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%4 = icmp eq %struct.scanner* %0, null
br i1 %4, label %19, label %5
5: ; preds = %1
%6 = call i64 @scanner_readline(%struct.scanner* %0, i8* %3, i32 8192)
%7 = icmp sgt i64 %6, -1
br i1 %7, label %8, label %17
8: ; preds = %5, %14
%9 = call i32 @filter(i8* %3)
%10 = load i8, i8* %3
%11 = icmp eq i8 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = call i32 @puts(i8* %3)
br label %14
14: ; preds = %12, %8
%15 = call i64 @scanner_readline(%struct.scanner* %0, i8* %3, i32 8192)
%16 = icmp sgt i64 %15, -1
br i1 %16, label %8, label %17
17: ; preds = %14, %5
%18 = call i32 @scanner_free(%struct.scanner* %0)
br label %19
19: ; preds = %1, %17
%20 = phi i32 [ 0, %17 ], [ -1, %1 ]
ret i32 %20
}