#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 getf80(long double *data) {
  long double 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 = *((long double *)buf);
  free(buf);
  return size;
}


x86 assembly (clang, -O0):
<getf80>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
fldz
fstpt  -0x20(%rbp)
movl   $0x10,-0x24(%rbp)
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x10,%esi
call   1040 <getbytes@plt>
cmp    $0x10,%eax
jge    11a7 <getf80+0x67>
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
lea    0xe73(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c3 <getf80+0x83>
mov    -0x30(%rbp),%rax
fldt   (%rax)
mov    -0x10(%rbp),%rax
fstpt  (%rax)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x10,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getf80>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x10,%ebp
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x10,%esi
call   1040 <getbytes@plt>
cmp    $0xf,%eax
jg     1184 <getf80+0x44>
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
lea    0xe85(%rip),%rdi
call   1050 <fputs@plt>
xor    %ebp,%ebp
jmp    1189 <getf80+0x49>
fldt   (%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 @getf80(x86_fp80* %0) {
%2 = alloca i32
%3 = alloca x86_fp80*
%4 = alloca x86_fp80
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store x86_fp80* %0, x86_fp80** %3
store x86_fp80 0xK00000000000000000000, x86_fp80* %4
store i32 16, i32* %5
%8 = call i64 @malloc(i32 16)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = call i32 @getbytes(i8* %10, i32 16)
%12 = icmp slt i32 %11, 16
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 %25
18: ; preds = %1
%19 = load i8*, i8** %6
%20 = bitcast i8* %19 to x86_fp80*
%21 = load x86_fp80, x86_fp80* %20
%22 = load x86_fp80*, x86_fp80** %3
store x86_fp80 %21, x86_fp80* %22
%23 = load i8*, i8** %6
%24 = call i32 @free(i8* %23)
store i32 16, i32* %2
br label %25
25: ; preds = %18, %13
%26 = load i32, i32* %2
ret i32 %26
}

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