#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(buffer, sizeof(int), 10, f);
    for (i = 0; i < numr; i++) {
      if (buffer[i] > 10) {
        printf("Num: %i \n", buffer[i]);
        counter++;
      }
    }
  }
  printf("The number of numbers above 10 is: %i \n", counter);
  fclose(f);
  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    1251 <main+0xe1>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x4,%esi
mov    $0xa,%edx
call   1030 <fread@plt>
mov    %eax,-0x44(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    124c <main+0xdc>
movslq -0x14(%rbp),%rax
cmpl   $0xa,-0x40(%rbp,%rax,4)
jle    1239 <main+0xc9>
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    123e <main+0xce>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ff <main+0x8f>
jmp    11cb <main+0x5b>
mov    -0x48(%rbp),%esi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@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   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe6b(%rip),%rdi
lea    0xe70(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1251 <main+0xd1>
mov    %rax,%r15
mov    %rax,%rdi
call   1080 <feof@plt>
xor    %r13d,%r13d
test   %rax,%rax
je     11ee <main+0x6e>
lea    0xe55(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%r14
lea    0xe17(%rip),%r12
xor    %r13d,%r13d
jmp    120d <main+0x8d>
nopl   (%rax)
mov    %r15,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    11bd <main+0x3d>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0xa,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
test   %eax,%eax
jle    1200 <main+0x80>
mov    %eax,%ebx
xor    %ebp,%ebp
jmp    1239 <main+0xb9>
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1200 <main+0x80>
mov    (%rsp,%rbp,4),%esi
cmp    $0xb,%esi
jl     1230 <main+0xb0>
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%r13d
jmp    1230 <main+0xb0>
lea    0xde9(%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"
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 = %43, %12
%14 = load i32*, i32** %2
%15 = call i64 @feof(i32* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %44
17: ; preds = %13
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%19 = load i32*, i32** %2
%20 = call i32 @fread(i32* %18, i32 4, i32 10, i32* %19)
store i32 %20, i32* %5
store i32 0, i32* %3
br label %21
21: ; preds = %40, %17
%22 = load i32, i32* %3
%23 = load i32, i32* %5
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %43
25: ; preds = %21
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = icmp sgt i32 %29, 10
br i1 %30, label %31, label %39
31: ; preds = %25
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %39
39: ; preds = %31, %25
br label %40
40: ; preds = %39
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %21
43: ; preds = %21
br label %13
44: ; preds = %13
%45 = load i32, i32* %6
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %45)
%47 = load i32*, i32** %2
%48 = call i32 @fclose(i32* %47)
%49 = 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 = [22 x i8] c"open read file error.\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x 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 %10, label %5
5: ; preds = %0
%6 = tail call i64 @feof(i32* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %36
8: ; preds = %5
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
br label %17
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %32, %17
%14 = phi i32 [ %18, %17 ], [ %33, %32 ]
%15 = tail call i64 @feof(i32* %3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %36
17: ; preds = %8, %13
%18 = phi i32 [ 0, %8 ], [ %14, %13 ]
%19 = call i32 @fread(i32* %9, i32 4, i32 10, i32* %3)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %13
21: ; preds = %17
%22 = zext i32 %19 to i64
br label %23
23: ; preds = %21, %32
%24 = phi i64 [ 0, %21 ], [ %34, %32 ]
%25 = phi i32 [ %18, %21 ], [ %33, %32 ]
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %24
%27 = load i32, i32* %26
%28 = icmp sgt i32 %27, 10
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%31 = add nsw i32 %25, 1
br label %32
32: ; preds = %23, %29
%33 = phi i32 [ %31, %29 ], [ %25, %23 ]
%34 = add nuw nsw i64 %24, 1
%35 = icmp eq i64 %34, %22
br i1 %35, label %13, label %23
36: ; preds = %13, %5
%37 = phi i32 [ 0, %5 ], [ %14, %13 ]
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%39 = tail call i32 @fclose(i32* %3)
%40 = tail call i32 (...) @getchar()
ret i32 0
}