#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*/ checkNReads(int, int /*<<< orphan*/ *, int *, int *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *fn;
  FILE *fd;
  int po, ps;
  po = 0;
  ps = 0;
  fn = argv[1];
  fd = fopen(fn, "r");
  checkNReads(10000, fd, &po, &ps);
  fprintf(stderr, "%s\tpo=%d\tps=%d\n", fn, po, ps);
  fclose(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    $0x2710,%edi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1050 <checkNReads@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
lea    0xe4d(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
mov    0x8(%rsi),%r14
lea    0xea2(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    $0x2710,%edi
mov    %rax,%rsi
call   1050 <checkNReads@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    0x4(%rsp),%ecx
mov    (%rsp),%r8d
lea    0xe6c(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"%s\09po=%d\09ps=%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %7
%15 = load i32*, i32** %7
%16 = call i32 @checkNReads(i32 10000, i32* %15, i32* %8, i32* %9)
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %6
%19 = load i32, i32* %8
%20 = load i32, i32* %9
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %19, i32 %20)
%22 = load i32*, i32** %7
%23 = call i32 @fclose(i32* %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"%s\09po=%d\09ps=%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %3
store i32 0, i32* %4
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @checkNReads(i32 10000, i32* %9, i32* %3, i32* %4)
%11 = load i32, i32* @stderr
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %8, i32 %12, i32 %13)
%15 = call i32 @fclose(i32* %9)
ret i32 0
}