#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 fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
size_t fwrite(void *, int, int, int /*<<< orphan*/ *);
size_t dsavechunkfloat(FILE *f, size_t i, size_t size, float *buf) {
  size_t success = dsettodata(f);
  if (success != 0)
    return 1;
  success = fseek(f, sizeof(float) * i, SEEK_CUR);
  if (success != 0)
    return 1;
  success = fwrite((void *)buf, 1, sizeof(float) * size, f);
  if (success != sizeof(float) * size)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<dsavechunkfloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <dsettodata@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     116d <dsavechunkfloat+0x3d>
movq   $0x1,-0x8(%rbp)
jmp    11ef <dsavechunkfloat+0xbf>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
mov    0x2e66(%rip),%rax
mov    (%rax),%edx
call   1030 <fseek@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11a5 <dsavechunkfloat+0x75>
movq   $0x1,-0x8(%rbp)
jmp    11ef <dsavechunkfloat+0xbf>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fwrite@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
shl    $0x2,%rcx
cmp    %rcx,%rax
je     11e7 <dsavechunkfloat+0xb7>
movq   $0x1,-0x8(%rbp)
jmp    11ef <dsavechunkfloat+0xbf>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsavechunkfloat>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r12
call   1050 <dsettodata@plt>
mov    $0x1,%r13d
test   %rax,%rax
jne    1191 <dsavechunkfloat+0x61>
shl    $0x2,%ebx
mov    0x2e89(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    %ebx,%esi
call   1030 <fseek@plt>
test   %rax,%rax
jne    1191 <dsavechunkfloat+0x61>
shl    $0x2,%r14
mov    %r15,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %r12,%rcx
call   1040 <fwrite@plt>
xor    %r13d,%r13d
cmp    %r14,%rax
setne  %r13b
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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