#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_CUR;
size_t dsettodata(int /*<<< orphan*/ *);
size_t fread(float *, int, int, int /*<<< orphan*/ *);
size_t fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
size_t dloadsinglefloat(FILE *f, size_t i, float **val) {
  size_t success = dsettodata(f);
  if (success != 0)
    return 1;
  success = fseek(f, sizeof(float) * i, SEEK_CUR);
  if (success != 0)
    return 1;
  success = fread(*val, 1, sizeof(float), f);
  if (success != sizeof(float))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<dloadsinglefloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <dsettodata@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1169 <dloadsinglefloat+0x39>
movq   $0x1,-0x8(%rbp)
jmp    11df <dloadsinglefloat+0xaf>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
mov    0x2e6a(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a1 <dloadsinglefloat+0x71>
movq   $0x1,-0x8(%rbp)
jmp    11df <dloadsinglefloat+0xaf>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x4,-0x28(%rbp)
je     11d7 <dloadsinglefloat+0xa7>
movq   $0x1,-0x8(%rbp)
jmp    11df <dloadsinglefloat+0xaf>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dloadsinglefloat>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
call   1050 <dsettodata@plt>
mov    $0x1,%r12d
test   %rax,%rax
jne    118c <dloadsinglefloat+0x5c>
shl    $0x2,%ebx
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <fseek@plt>
test   %rax,%rax
jne    118c <dloadsinglefloat+0x5c>
mov    (%r15),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
xor    %r12d,%r12d
cmp    $0x4,%rax
setne  %r12b
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_CUR = global i32 0
define i64 @dloadsinglefloat(i32* %0, i64 %1, float** %2) {
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i64
%7 = alloca float**
%8 = alloca i64
store i32* %0, i32** %5
store i64 %1, i64* %6
store float** %2, float*** %7
%9 = load i32*, i32** %5
%10 = call i64 @dsettodata(i32* %9)
store i64 %10, i64* %8
%11 = load i64, i64* %8
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %3
store i64 1, i64* %4
br label %33
14: ; preds = %3
%15 = load i32*, i32** %5
%16 = load i64, i64* %6
%17 = mul i64 4, %16
%18 = trunc i64 %17 to i32
%19 = load i32, i32* @SEEK_CUR
%20 = call i64 @fseek(i32* %15, i32 %18, i32 %19)
store i64 %20, i64* %8
%21 = load i64, i64* %8
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %14
store i64 1, i64* %4
br label %33
24: ; preds = %14
%25 = load float**, float*** %7
%26 = load float*, float** %25
%27 = load i32*, i32** %5
%28 = call i64 @fread(float* %26, i32 1, i32 4, i32* %27)
store i64 %28, i64* %8
%29 = load i64, i64* %8
%30 = icmp ne i64 %29, 4
br i1 %30, label %31, label %32
31: ; preds = %24
store i64 1, i64* %4
br label %33
32: ; preds = %24
store i64 0, i64* %4
br label %33
33: ; preds = %32, %31, %23, %13
%34 = load i64, i64* %4
ret i64 %34
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
define i64 @dloadsinglefloat(i32* %0, i64 %1, float** nocapture %2) {
%4 = tail call i64 @dsettodata(i32* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %3
%7 = trunc i64 %1 to i32
%8 = shl i32 %7, 2
%9 = load i32, i32* @SEEK_CUR
%10 = tail call i64 @fseek(i32* %0, i32 %8, i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %6
%13 = load float*, float** %2
%14 = tail call i64 @fread(float* %13, i32 1, i32 4, i32* %0)
%15 = icmp ne i64 %14, 4
%16 = zext i1 %15 to i64
br label %17
17: ; preds = %12, %6, %3
%18 = phi i64 [ 1, %3 ], [ 1, %6 ], [ %16, %12 ]
ret i64 %18
}