#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*/ SEEK_SET;
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fread(float *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int fileSizeFourBytes(FILE *fin) {
  int z = -1;
  float x;
  while (!feof(fin)) {
    fread(&x, sizeof(unsigned int), 1, fin);
    z++;
  }
  fseek(fin, 0, SEEK_SET);
  return z;
}


x86 assembly (clang, -O0):
<fileSizeFourBytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1161 <fileSizeFourBytes+0x31>
jmp    1186 <fileSizeFourBytes+0x56>
mov    -0x8(%rbp),%rcx
lea    -0x10(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <fileSizeFourBytes+0x13>
mov    -0x8(%rbp),%rdi
mov    0x2e4f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fileSizeFourBytes>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1040 <feof@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
jne    1184 <fileSizeFourBytes+0x54>
mov    $0xffffffff,%ebp
lea    0xc(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1040 <feof@plt>
test   %eax,%eax
je     1160 <fileSizeFourBytes+0x30>
mov    0x2e55(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <fseek@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @fileSizeFourBytes(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca float
store i32* %0, i32** %2
store i32 -1, i32* %3
br label %5
5: ; preds = %10, %1
%6 = load i32*, i32** %2
%7 = call i32 @feof(i32* %6)
%8 = icmp ne i32 %7, 0
%9 = xor i1 %8, true
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i32*, i32** %2
%12 = call i32 @fread(float* %4, i32 4, i32 1, i32* %11)
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %5
15: ; preds = %5
%16 = load i32*, i32** %2
%17 = load i32, i32* @SEEK_SET
%18 = call i32 @fseek(i32* %16, i32 0, i32 %17)
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @fileSizeFourBytes(i32* nocapture %0) {
%2 = alloca float
%3 = bitcast float* %2 to i8*
%4 = tail call i32 @feof(i32* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %1, %6
%7 = phi i32 [ %9, %6 ], [ -1, %1 ]
%8 = call i32 @fread(float* %2, i32 4, i32 1, i32* %0)
%9 = add nsw i32 %7, 1
%10 = tail call i32 @feof(i32* %0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %6, label %12
12: ; preds = %6, %1
%13 = phi i32 [ -1, %1 ], [ %9, %6 ]
%14 = load i32, i32* @SEEK_SET
%15 = tail call i32 @fseek(i32* %0, i32 0, i32 %14)
ret i32 %13
}