#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 */

/* Variables and functions */
int /*<<< orphan*/ STDIN_FILENO;
scalar_t__ filter_lines(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int program_parseargs(int, char **);
char *program_poparg();
int /*<<< orphan*/ scanner_new(int /*<<< orphan*/);
int /*<<< orphan*/ scanner_open(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *arg;
  do {
    int argidx = program_parseargs(argc, argv);
    if (argidx > 0) {
      argv += argidx;
      argc -= argidx;
    }
  } while (0);
  arg = program_poparg();
  if (arg == NULL)
    filter_lines(scanner_new(STDIN_FILENO));
  while (arg) {
    if (filter_lines(scanner_open(arg)) != 0)
      fprintf(stderr,
              " "
              "\x1b[31;1m"
              "err"
              "\x1b[0m"
              " ~ "
              "failed to open '%s'"
              "\n",
              arg);
    arg = program_poparg();
  }
  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    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <program_parseargs@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11af <main+0x4f>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    11b4 <main+0x54>
mov    $0x0,%al
call   1070 <program_poparg@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11df <main+0x7f>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1030 <scanner_new@plt>
mov    %eax,%edi
call   1050 <filter_lines@plt>
jmp    11e4 <main+0x84>
cmpq   $0x0,-0x18(%rbp)
je     1232 <main+0xd2>
mov    -0x18(%rbp),%rdi
call   1080 <scanner_open@plt>
mov    %eax,%edi
call   1050 <filter_lines@plt>
cmp    $0x0,%rax
je     1222 <main+0xc2>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xde3(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1070 <program_poparg@plt>
mov    %rax,-0x18(%rbp)
jmp    11e4 <main+0x84>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
call   1040 <program_parseargs@plt>
xor    %eax,%eax
call   1070 <program_poparg@plt>
test   %rax,%rax
je     11c3 <main+0x63>
mov    %rax,%rbx
mov    0x2e60(%rip),%r15
lea    0xe79(%rip),%r14
jmp    119f <main+0x3f>
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <program_poparg@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11d8 <main+0x78>
mov    %rbx,%rdi
call   1080 <scanner_open@plt>
mov    %eax,%edi
call   1050 <filter_lines@plt>
test   %rax,%rax
je     1190 <main+0x30>
mov    (%r15),%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
jmp    1190 <main+0x30>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1030 <scanner_new@plt>
mov    %eax,%edi
call   1050 <filter_lines@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@stderr = global i32 0
@.str = [39 x i8] c" \1B[31;1merr\1B[0m ~ failed to open '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @program_parseargs(i32 %9, i8** %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %8
%15 = load i32, i32* %7
%16 = load i8**, i8*** %5
%17 = sext i32 %15 to i64
%18 = getelementptr inbounds i8*, i8** %16, i64 %17
store i8** %18, i8*** %5
%19 = load i32, i32* %7
%20 = load i32, i32* %4
%21 = sub nsw i32 %20, %19
store i32 %21, i32* %4
br label %22
22: ; preds = %14, %8
br label %23
23: ; preds = %22
%24 = call i8* (...) @program_poparg()
store i8* %24, i8** %6
%25 = load i8*, i8** %6
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = load i32, i32* @STDIN_FILENO
%29 = call i32 @scanner_new(i32 %28)
%30 = call i64 @filter_lines(i32 %29)
br label %31
31: ; preds = %27, %23
br label %32
32: ; preds = %44, %31
%33 = load i8*, i8** %6
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %46
35: ; preds = %32
%36 = load i8*, i8** %6
%37 = call i32 @scanner_open(i8* %36)
%38 = call i64 @filter_lines(i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %35
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %6
%43 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %40, %35
%45 = call i8* (...) @program_poparg()
store i8* %45, i8** %6
br label %32
46: ; preds = %32
ret i32 0
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@stderr = global i32 0
@.str = [39 x i8] c" \1B[31;1merr\1B[0m ~ failed to open '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @program_parseargs(i32 %0, i8** %1)
%4 = tail call i8* (...) @program_poparg()
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @STDIN_FILENO
%8 = tail call i32 @scanner_new(i32 %7)
%9 = tail call i64 @filter_lines(i32 %8)
br label %21
10: ; preds = %2, %18
%11 = phi i8* [ %19, %18 ], [ %4, %2 ]
%12 = tail call i32 @scanner_open(i8* %11)
%13 = tail call i64 @filter_lines(i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %18
18: ; preds = %15, %10
%19 = tail call i8* (...) @program_poparg()
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %10
21: ; preds = %18, %6
ret i32 0
}