#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 BUFSIZ;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char string[BUFSIZ];
  char *result;
  FILE *fff;
  if (argc < 3) {
    fprintf(stderr, "\nUsage: %s logfile char\n\n", argv[0]);
    return -1;
  }
  fff = fopen(argv[1], "r");
  if (fff == NULL) {
    fprintf(stderr, "Error opening file %s\n", argv[1]);
    return -1;
  }
  while (1) {
    result = fgets(string, BUFSIZ, fff);
    if (result == NULL)
      break;
    if (string[0] != argv[2][0])
      printf("%s", string);
  }
  fclose(fff);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11cb <main+0x7b>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4d(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    1298 <main+0x148>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe40(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    121e <main+0xce>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe16(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    1298 <main+0x148>
jmp    1223 <main+0xd3>
jmp    1228 <main+0xd8>
mov    -0x40(%rbp),%rdi
mov    0x2da5(%rip),%rax
mov    (%rax),%esi
mov    -0x30(%rbp),%rdx
call   1050 <fgets@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1252 <main+0x102>
jmp    1281 <main+0x131>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
mov    -0x10(%rbp),%rcx
mov    0x10(%rcx),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     127c <main+0x12c>
mov    -0x40(%rbp),%rsi
lea    0xdbc(%rip),%rdi
call   1040 <printf@plt>
jmp    1223 <main+0xd3>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    0x2e70(%rip),%r13
mov    0x0(%r13),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
cmp    $0x2,%edi
jg     119a <main+0x4a>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe6b(%rip),%rsi
jmp    121c <main+0xcc>
mov    0x8(%r14),%rdi
lea    0xe75(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1208 <main+0xb8>
mov    %rax,%r15
mov    0x0(%r13),%esi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11fc <main+0xac>
lea    0xe66(%rip),%r12
jmp    11e4 <main+0x94>
nop
mov    0x0(%r13),%esi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11fc <main+0xac>
movzbl (%rbx),%eax
mov    0x10(%r14),%rcx
cmp    (%rcx),%al
je     11d0 <main+0x80>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
jmp    11d0 <main+0x80>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    1226 <main+0xd6>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xe00(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"\0AUsage: %s logfile char\0A\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"Error opening file %s\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @BUFSIZ
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %6
%14 = alloca i8, i64 %12
store i64 %12, i64* %7
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 3
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %21)
store i32 -1, i32* %3
store i32 1, i32* %10
br label %62
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %9
%28 = load i32*, i32** %9
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %36
30: ; preds = %23
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %34)
store i32 -1, i32* %3
store i32 1, i32* %10
br label %62
36: ; preds = %23
br label %37
37: ; preds = %58, %36
br label %38
38: ; preds = %37
%39 = load i32, i32* @BUFSIZ
%40 = load i32*, i32** %9
%41 = call i8* @fgets(i8* %14, i32 %39, i32* %40)
store i8* %41, i8** %8
%42 = load i8*, i8** %8
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %45
44: ; preds = %38
br label %59
45: ; preds = %38
%46 = getelementptr inbounds i8, i8* %14, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = getelementptr inbounds i8, i8* %51, i64 0
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %48, %54
br i1 %55, label %56, label %58
56: ; preds = %45
%57 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %14)
br label %58
58: ; preds = %56, %45
br label %37
59: ; preds = %44
%60 = load i32*, i32** %9
%61 = call i32 @fclose(i32* %60)
store i32 0, i32* %3
store i32 1, i32* %10
br label %62
62: ; preds = %59, %30, %17
%63 = load i8*, i8** %6
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"\0AUsage: %s logfile char\0A\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"Error opening file %s\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @BUFSIZ
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = icmp slt i32 %0, 3
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %39
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %22, label %16
16: ; preds = %11
%17 = load i32, i32* @BUFSIZ
%18 = call i8* @fgets(i8* %5, i32 %17, i32* %14)
%19 = icmp eq i8* %18, null
br i1 %19, label %37, label %20
20: ; preds = %16
%21 = getelementptr inbounds i8*, i8** %1, i64 2
br label %26
22: ; preds = %11
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %12
%25 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %39
26: ; preds = %20, %33
%27 = load i8, i8* %5
%28 = load i8*, i8** %21
%29 = load i8, i8* %28
%30 = icmp eq i8 %27, %29
br i1 %30, label %33, label %31
31: ; preds = %26
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %5)
br label %33
33: ; preds = %31, %26
%34 = load i32, i32* @BUFSIZ
%35 = call i8* @fgets(i8* %5, i32 %34, i32* %14)
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %26
37: ; preds = %33, %16
%38 = call i32 @fclose(i32* %14)
br label %39
39: ; preds = %37, %22, %7
%40 = phi i32 [ -1, %7 ], [ -1, %22 ], [ 0, %37 ]
ret i32 %40
}