#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 odd = 0, even = 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] % 2 == 1) {
        odd++;
      } else {
        even++;
      }
    }
  }
  printf("There are %d odd and %d even numbers\n", odd, even);
  fclose(f);
  printf("\n\n[Hit ENTER to close]");
  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)
movl   $0x0,-0x4c(%rbp)
lea    0xe65(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11cd <main+0x5d>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    11d2 <main+0x62>
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%rax
jne    125a <main+0xea>
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    1255 <main+0xe5>
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1239 <main+0xc9>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1242 <main+0xd2>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1247 <main+0xd7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1206 <main+0x96>
jmp    11d2 <main+0x62>
mov    -0x48(%rbp),%esi
mov    -0x4c(%rbp),%edx
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xdce(%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
sub    $0x28,%rsp
lea    0xe7f(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1360 <main+0x1e0>
mov    %rax,%r15
mov    %rax,%rdi
call   1080 <feof@plt>
xor    %ebp,%ebp
mov    $0x0,%ebx
test   %rax,%rax
je     11f9 <main+0x79>
lea    0xe5b(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
mov    %rsp,%r14
xor    %ebp,%ebp
jmp    121d <main+0x9d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%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    1210 <main+0x90>
mov    %eax,%ecx
cmp    $0x8,%eax
jae    1250 <main+0xd0>
xor    %eax,%eax
jmp    1330 <main+0x1b0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ecx,%eax
and    $0xfffffff8,%eax
movd   %ebx,%xmm0
movd   %ebp,%xmm2
lea    0x0(,%rcx,4),%rdx
and    $0xffffffffffffffe0,%rdx
pxor   %xmm1,%xmm1
xor    %esi,%esi
pxor   %xmm3,%xmm3
movdqa 0xd85(%rip),%xmm7
pcmpeqd %xmm8,%xmm8
movdqa (%rsp,%rsi,1),%xmm5
movdqa 0x10(%rsp,%rsi,1),%xmm4
movdqa %xmm5,%xmm6
psrld  $0x1f,%xmm6
paddd  %xmm5,%xmm6
psrad  $0x1,%xmm6
paddd  %xmm6,%xmm6
psubd  %xmm6,%xmm5
movdqa %xmm4,%xmm6
psrld  $0x1f,%xmm6
paddd  %xmm4,%xmm6
psrad  $0x1,%xmm6
paddd  %xmm6,%xmm6
psubd  %xmm6,%xmm4
pcmpeqd %xmm7,%xmm5
psubd  %xmm5,%xmm2
pcmpeqd %xmm7,%xmm4
psubd  %xmm4,%xmm3
paddd  %xmm5,%xmm0
psubd  %xmm8,%xmm0
paddd  %xmm4,%xmm1
psubd  %xmm8,%xmm1
add    $0x20,%rsi
cmp    %rsi,%rdx
jne    1280 <main+0x100>
paddd  %xmm2,%xmm3
pshufd $0xee,%xmm3,%xmm2
paddd  %xmm3,%xmm2
pshufd $0x55,%xmm2,%xmm3
paddd  %xmm2,%xmm3
movd   %xmm3,%ebp
paddd  %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%ebx
cmp    %rcx,%rax
je     1210 <main+0x90>
nopw   0x0(%rax,%rax,1)
mov    (%rsp,%rax,4),%edx
mov    %edx,%esi
shr    $0x1f,%esi
add    %edx,%esi
and    $0xfffffffe,%esi
sub    %esi,%edx
xor    %esi,%esi
xor    %edi,%edi
cmp    $0x1,%edx
setne  %sil
sete   %dil
add    %edi,%ebp
add    %esi,%ebx
add    $0x1,%rax
cmp    %rax,%rcx
jne    1330 <main+0x1b0>
jmp    1210 <main+0x90>
lea    0xcf5(%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 = [38 x i8] c"There are %d odd and %d even numbers\0A\00"
@.str.4 = [23 x i8] c"\0A\0A[Hit ENTER to close]\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = 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* %8, i32** %2
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %0
br label %14
14: ; preds = %43, %13
%15 = load i32*, i32** %2
%16 = call i64 @feof(i32* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %44
18: ; preds = %14
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%20 = load i32*, i32** %2
%21 = call i32 @fread(i32* %19, i32 4, i32 10, i32* %20)
store i32 %21, i32* %5
store i32 0, i32* %3
br label %22
22: ; preds = %40, %18
%23 = load i32, i32* %3
%24 = load i32, i32* %5
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %43
26: ; preds = %22
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = srem i32 %30, 2
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %36
33: ; preds = %26
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %39
36: ; preds = %26
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %39
39: ; preds = %36, %33
br label %40
40: ; preds = %39
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %22
43: ; preds = %22
br label %14
44: ; preds = %14
%45 = load i32, i32* %6
%46 = load i32, i32* %7
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %45, i32 %46)
%48 = load i32*, i32** %2
%49 = call i32 @fclose(i32* %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%51 = 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 = [38 x i8] c"There are %d odd and %d even numbers\0A\00"
@.str.4 = [23 x i8] c"\0A\0A[Hit ENTER to close]\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 %83
8: ; preds = %5
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
br label %18
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 = %68, %58, %18
%14 = phi i32 [ %20, %18 ], [ %60, %58 ], [ %77, %68 ]
%15 = phi i32 [ %19, %18 ], [ %62, %58 ], [ %80, %68 ]
%16 = tail call i64 @feof(i32* %3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %83
18: ; preds = %8, %13
%19 = phi i32 [ 0, %8 ], [ %15, %13 ]
%20 = phi i32 [ 0, %8 ], [ %14, %13 ]
%21 = call i32 @fread(i32* %9, i32 4, i32 10, i32* %3)
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %13
23: ; preds = %18
%24 = zext i32 %21 to i64
%25 = icmp ult i32 %21, 8
br i1 %25, label %64, label %26
26: ; preds = %23
%27 = and i64 %24, 4294967288
%28 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %19, i64 0
%29 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %20, i64 0
br label %30
30: ; preds = %30, %26
%31 = phi i64 [ 0, %26 ], [ %56, %30 ]
%32 = phi <4 x i32> [ %28, %26 ], [ %54, %30 ]
%33 = phi <4 x i32> [ zeroinitializer, %26 ], [ %55, %30 ]
%34 = phi <4 x i32> [ %29, %26 ], [ %48, %30 ]
%35 = phi <4 x i32> [ zeroinitializer, %26 ], [ %49, %30 ]
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %31
%37 = bitcast i32* %36 to <4 x i32>*
%38 = load <4 x i32>, <4 x i32>* %37
%39 = getelementptr inbounds i32, i32* %36, i64 4
%40 = bitcast i32* %39 to <4 x i32>*
%41 = load <4 x i32>, <4 x i32>* %40
%42 = srem <4 x i32> %38, <i32 2, i32 2, i32 2, i32 2>
%43 = srem <4 x i32> %41, <i32 2, i32 2, i32 2, i32 2>
%44 = icmp eq <4 x i32> %42, <i32 1, i32 1, i32 1, i32 1>
%45 = icmp eq <4 x i32> %43, <i32 1, i32 1, i32 1, i32 1>
%46 = zext <4 x i1> %44 to <4 x i32>
%47 = zext <4 x i1> %45 to <4 x i32>
%48 = add <4 x i32> %34, %46
%49 = add <4 x i32> %35, %47
%50 = xor <4 x i1> %44, <i1 true, i1 true, i1 true, i1 true>
%51 = xor <4 x i1> %45, <i1 true, i1 true, i1 true, i1 true>
%52 = zext <4 x i1> %50 to <4 x i32>
%53 = zext <4 x i1> %51 to <4 x i32>
%54 = add <4 x i32> %32, %52
%55 = add <4 x i32> %33, %53
%56 = add nuw i64 %31, 8
%57 = icmp eq i64 %56, %27
br i1 %57, label %58, label %30
58: ; preds = %30
%59 = add <4 x i32> %49, %48
%60 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %59)
%61 = add <4 x i32> %55, %54
%62 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %61)
%63 = icmp eq i64 %27, %24
br i1 %63, label %13, label %64
64: ; preds = %23, %58
%65 = phi i64 [ 0, %23 ], [ %27, %58 ]
%66 = phi i32 [ %19, %23 ], [ %62, %58 ]
%67 = phi i32 [ %20, %23 ], [ %60, %58 ]
br label %68
68: ; preds = %64, %68
%69 = phi i64 [ %81, %68 ], [ %65, %64 ]
%70 = phi i32 [ %80, %68 ], [ %66, %64 ]
%71 = phi i32 [ %77, %68 ], [ %67, %64 ]
%72 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %69
%73 = load i32, i32* %72
%74 = srem i32 %73, 2
%75 = icmp eq i32 %74, 1
%76 = zext i1 %75 to i32
%77 = add nsw i32 %71, %76
%78 = xor i1 %75, true
%79 = zext i1 %78 to i32
%80 = add nsw i32 %70, %79
%81 = add nuw nsw i64 %69, 1
%82 = icmp eq i64 %81, %24
br i1 %82, label %13, label %68
83: ; preds = %13, %5
%84 = phi i32 [ 0, %5 ], [ %14, %13 ]
%85 = phi i32 [ 0, %5 ], [ %15, %13 ]
%86 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %84, i32 %85)
%87 = tail call i32 @fclose(i32* %3)
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%89 = tail call i32 (...) @getchar()
ret i32 0
}