#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
main() {
  FILE *f;
  int i;
  int buffer[10];
  int numr = 0;
  int counter = 0;
  if ((f = fopen("numbers.bin", "rb")) == NULL) {
    printf("open read file error.\n");
    exit(1);
  }
  while (feof(f) == 0) {
    numr = fread(&i, sizeof(int), 1, f);
    if ((i > 10) && (numr == 1)) {
      printf("Num: %i \n", i);
      counter++;
    }
  }
  printf("The number of numbers above 10 is: %i \n", counter);
  fclose(f);
  printf("\n\n[Press enter to quit]");
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
lea    0xe6c(%rip),%rdi
lea    0xe71(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11c6 <main+0x56>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    11cb <main+0x5b>
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%rax
jne    122b <main+0xbb>
mov    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xa,-0x14(%rbp)
jle    1226 <main+0xb6>
cmpl   $0x1,-0x44(%rbp)
jne    1226 <main+0xb6>
mov    -0x14(%rbp),%esi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11cb <main+0x5b>
mov    -0x48(%rbp),%esi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xe72(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     123f <main+0xbf>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <feof@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11ef <main+0x6f>
lea    0xe5d(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xe6d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x4(%rsp),%r14
lea    0xe14(%rip),%r15
xor    %ebp,%ebp
jmp    120d <main+0x8d>
nop
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    11b5 <main+0x35>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    1200 <main+0x80>
mov    0x4(%rsp),%esi
cmp    $0xb,%esi
jl     1200 <main+0x80>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebp
jmp    1200 <main+0x80>
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"numbers.bin\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [23 x i8] c"open read file error.\0A\00"
@.str.3 = [10 x i8] c"Num: %i \0A\00"
@.str.4 = [40 x i8] c"The number of numbers above 10 is: %i \0A\00"
@.str.5 = [24 x i8] c"\0A\0A[Press enter to quit]\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %2
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
br label %13
13: ; preds = %30, %12
%14 = load i32*, i32** %2
%15 = call i64 @feof(i32* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %31
17: ; preds = %13
%18 = load i32*, i32** %2
%19 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %18)
store i32 %19, i32* %5
%20 = load i32, i32* %3
%21 = icmp sgt i32 %20, 10
br i1 %21, label %22, label %30
22: ; preds = %17
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i32, i32* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %30
30: ; preds = %25, %22, %17
br label %13
31: ; preds = %13
%32 = load i32, i32* %6
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = load i32*, i32** %2
%35 = call i32 @fclose(i32* %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%37 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"numbers.bin\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.3 = [10 x i8] c"Num: %i \0A\00"
@.str.4 = [40 x i8] c"The number of numbers above 10 is: %i \0A\00"
@.str.5 = [24 x i8] c"\0A\0A[Press enter to quit]\00"
@str = [22 x i8] c"open read file error.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = tail call i64 @feof(i32* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %25
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %5, %21
%12 = phi i32 [ %22, %21 ], [ 0, %5 ]
%13 = call i32 @fread(i32* %1, i32 4, i32 1, i32* %3)
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 10
%16 = icmp eq i32 %13, 1
%17 = and i1 %16, %15
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%20 = add nsw i32 %12, 1
br label %21
21: ; preds = %18, %11
%22 = phi i32 [ %20, %18 ], [ %12, %11 ]
%23 = tail call i64 @feof(i32* %3)
%24 = icmp eq i64 %23, 0
br i1 %24, label %11, label %25
25: ; preds = %21, %5
%26 = phi i32 [ 0, %5 ], [ %22, %21 ]
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = tail call i32 @fclose(i32* %3)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%30 = tail call i32 (...) @getchar()
ret i32 0
}