#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 fread(float *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(float *);
float *fvec_new(long);
int /*<<< orphan*/ perror(char *);
float *fvec_fread_raw(FILE *f, long d) {
  float *v = fvec_new(d);
  int ret = fread(v, sizeof(*v), d, f);
  if (ret != d) {
    free(v);
    perror("# fvec_fread error 2");
    return NULL;
  }
  return v;
}


x86 assembly (clang, -O0):
<fvec_fread_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fvec_new@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x4,%esi
call   1040 <fread@plt>
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     11a6 <fvec_fread_raw+0x66>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
lea    0xe6c(%rip),%rdi
call   1060 <perror@plt>
movq   $0x0,-0x8(%rbp)
jmp    11ae <fvec_fread_raw+0x6e>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fvec_fread_raw>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1050 <fvec_new@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x4,%esi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1040 <fread@plt>
cltq
cmp    %rbx,%rax
jne    1179 <fvec_fread_raw+0x39>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xe78(%rip),%rdi
call   1060 <perror@plt>
xor    %r14d,%r14d
jmp    1170 <fvec_fread_raw+0x30>

LLVM IR (-O0):
@.str = [21 x i8] c"# fvec_fread error 2\00"
define float* @fvec_fread_raw(i32* %0, i64 %1) {
%3 = alloca float*
%4 = alloca i32*
%5 = alloca i64
%6 = alloca float*
%7 = alloca i32
store i32* %0, i32** %4
store i64 %1, i64* %5
%8 = load i64, i64* %5
%9 = call float* @fvec_new(i64 %8)
store float* %9, float** %6
%10 = load float*, float** %6
%11 = load i64, i64* %5
%12 = load i32*, i32** %4
%13 = call i32 @fread(float* %10, i32 4, i64 %11, i32* %12)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = load i64, i64* %5
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = load float*, float** %6
%20 = call i32 @free(float* %19)
%21 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store float* null, float** %3
br label %24
22: ; preds = %2
%23 = load float*, float** %6
store float* %23, float** %3
br label %24
24: ; preds = %22, %18
%25 = load float*, float** %3
ret float* %25
}

LLVM IR (-O2):
@.str = [21 x i8] c"# fvec_fread error 2\00"
define float* @fvec_fread_raw(i32* nocapture %0, i64 %1) {
%3 = tail call float* @fvec_new(i64 %1)
%4 = tail call i32 @fread(float* %3, i32 4, i64 %1, i32* %0)
%5 = sext i32 %4 to i64
%6 = icmp eq i64 %5, %1
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = tail call i32 @free(float* %3)
%9 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %2, %7
%11 = phi float* [ null, %7 ], [ %3, %2 ]
ret float* %11
}