#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*/ d;

/* Variables and functions */
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int const getbytes(char *, int const);
scalar_t__ malloc(int const);
int /*<<< orphan*/ stderr;
int getf32(long double *data) {
  float d = 0;
  const int size = sizeof(d);
  char *buf = (char *)malloc(size);
  char *byte;
  if (getbytes(buf, size) < size) {
    fputs("error reading data\n", stderr);
    free(buf);
    return 0;
  }
  *data = *((float *)buf);
  free(buf);
  return size;
}


x86 assembly (clang, -O0):
<getf32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x4,-0x18(%rbp)
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1040 <getbytes@plt>
cmp    $0x4,%eax
jge    11aa <getf32+0x6a>
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
lea    0xe70(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c6 <getf32+0x86>
mov    -0x20(%rbp),%rax
flds   (%rax)
mov    -0x10(%rbp),%rax
fstpt  (%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x4,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getf32>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x4,%ebp
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x4,%esi
call   1040 <getbytes@plt>
cmp    $0x3,%eax
jg     1184 <getf32+0x44>
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
lea    0xe85(%rip),%rdi
call   1050 <fputs@plt>
xor    %ebp,%ebp
jmp    1189 <getf32+0x49>
flds   (%rbx)
fstpt  (%r14)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"error reading data\0A\00"
@stderr = global i32 0
define i32 @getf32(x86_fp80* %0) {
%2 = alloca i32
%3 = alloca x86_fp80*
%4 = alloca float
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store x86_fp80* %0, x86_fp80** %3
store float 0.000000e+00, float* %4
store i32 4, i32* %5
%8 = call i64 @malloc(i32 4)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = call i32 @getbytes(i8* %10, i32 4)
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %18
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i8*, i8** %6
%17 = call i32 @free(i8* %16)
store i32 0, i32* %2
br label %26
18: ; preds = %1
%19 = load i8*, i8** %6
%20 = bitcast i8* %19 to float*
%21 = load float, float* %20
%22 = fpext float %21 to x86_fp80
%23 = load x86_fp80*, x86_fp80** %3
store x86_fp80 %22, x86_fp80* %23
%24 = load i8*, i8** %6
%25 = call i32 @free(i8* %24)
store i32 4, i32* %2
br label %26
26: ; preds = %18, %13
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@.str = [20 x i8] c"error reading data\0A\00"
@stderr = global i32 0
define i32 @getf32(x86_fp80* nocapture writeonly %0) {
%2 = tail call i64 @malloc(i32 4)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @getbytes(i8* %3, i32 4)
%5 = icmp slt i32 %4, 4
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %13
9: ; preds = %1
%10 = inttoptr i64 %2 to float*
%11 = load float, float* %10
%12 = fpext float %11 to x86_fp80
store x86_fp80 %12, x86_fp80* %0
br label %13
13: ; preds = %9, %6
%14 = phi i32 [ 0, %6 ], [ 4, %9 ]
%15 = tail call i32 @free(i8* %3)
ret i32 %14
}