#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*/ *const);
int /*<<< orphan*/ *FOPEN(char const *, char *);
size_t FREAD(void *const, int, size_t const, int /*<<< orphan*/ *const);
void *MALLOC(size_t const);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ free(void *const);
int /*<<< orphan*/ printMatches(void *const, size_t const);
int /*<<< orphan*/ printf(char *, char const *);
int main(int argc, const char **argv) {
  size_t const bufferSize = 64 * (1 << 10);
  void *const buffer = MALLOC(bufferSize);
  const char *exename = argv[0];
  const char *filename = argv[1];
  assert(argc >= 1);
  if (argc != 2) {
    printf("usage : %s FILENAME \n", exename);
    return 1;
  }
  {
    FILE *const f = FOPEN(filename, "rb");
    size_t const size = FREAD(buffer, 1, bufferSize, f);
    FCLOSE(f);
    printMatches(buffer, size);
  }
  free(buffer);
}


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)
movq   $0x10000,-0x18(%rbp)
mov    $0x10000,%edi
call   1090 <MALLOC@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x1,-0x8(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
cmpl   $0x2,-0x8(%rbp)
je     11fa <main+0x7a>
mov    -0x28(%rbp),%rsi
lea    0xe17(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1248 <main+0xc8>
mov    -0x30(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1070 <FOPEN@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10000,%edx
call   1080 <FREAD@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <FCLOSE@plt>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   10a0 <printMatches@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x10000,%edi
call   1090 <MALLOC@plt>
mov    %rax,%r12
mov    (%rbx),%r14
mov    0x8(%rbx),%r15
xor    %edi,%edi
test   %ebp,%ebp
setg   %dil
call   1060 <assert@plt>
cmp    $0x2,%ebp
jne    11fc <main+0x7c>
lea    0xe5c(%rip),%rsi
mov    %r15,%rdi
call   1070 <FOPEN@plt>
mov    %rax,%rbx
mov    $0x10000,%edx
mov    %r12,%rdi
mov    $0x1,%esi
mov    %rax,%rcx
call   1080 <FREAD@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1050 <FCLOSE@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   10a0 <printMatches@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    1210 <main+0x90>
lea    0xdfd(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"usage : %s FILENAME \0A\00"
@.str.1 = [3 x i8] c"rb\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 65536, i64* %6
%12 = call i8* @MALLOC(i64 65536)
store i8* %12, i8** %7
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
store i8* %15, i8** %8
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
store i8* %18, i8** %9
%19 = load i32, i32* %4
%20 = icmp sge i32 %19, 1
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 2
br i1 %24, label %25, label %28
25: ; preds = %2
%26 = load i8*, i8** %8
%27 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %26)
store i32 1, i32* %3
br label %41
28: ; preds = %2
%29 = load i8*, i8** %9
%30 = call i32* @FOPEN(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %30, i32** %10
%31 = load i8*, i8** %7
%32 = load i32*, i32** %10
%33 = call i64 @FREAD(i8* %31, i32 1, i64 65536, i32* %32)
store i64 %33, i64* %11
%34 = load i32*, i32** %10
%35 = call i32 @FCLOSE(i32* %34)
%36 = load i8*, i8** %7
%37 = load i64, i64* %11
%38 = call i32 @printMatches(i8* %36, i64 %37)
%39 = load i8*, i8** %7
%40 = call i32 @free(i8* %39)
br label %41
41: ; preds = %28, %25
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str = [22 x i8] c"usage : %s FILENAME \0A\00"
@.str.1 = [3 x i8] c"rb\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i8* @MALLOC(i64 65536)
%4 = load i8*, i8** %1
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = icmp sgt i32 %0, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = icmp eq i32 %0, 2
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %19
13: ; preds = %2
%14 = tail call i32* @FOPEN(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i64 @FREAD(i8* %3, i32 1, i64 65536, i32* %14)
%16 = tail call i32 @FCLOSE(i32* %14)
%17 = tail call i32 @printMatches(i8* %3, i64 %15)
%18 = tail call i32 @free(i8* %3)
br label %19
19: ; preds = %13, %11
%20 = phi i32 [ 1, %11 ], [ 0, %13 ]
ret i32 %20
}