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

/* Variables and functions */
int /*<<< orphan*/ getBits(unsigned char *, int *, size_t, int);
double pow(int, double);
double ibm2real(unsigned char *buf, size_t off) {
  int sign, exp, fr;
  double native_real;
  getBits(buf, &sign, off, 1);
  getBits(buf, &exp, off + 1, 7);
  exp -= 64;
  getBits(buf, &fr, off + 8, 24);
  native_real = pow(2., -24.) * (double)fr * pow(16., (double)exp);
  return (sign == 1) ? -native_real : native_real;
}


x86 assembly (clang, -O0):
<ibm2real>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rsi
mov    $0x1,%ecx
call   1030 <getBits@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
add    $0x1,%rdx
lea    -0x18(%rbp),%rsi
mov    $0x7,%ecx
call   1030 <getBits@plt>
mov    -0x18(%rbp),%eax
sub    $0x40,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
add    $0x8,%rdx
lea    -0x1c(%rbp),%rsi
mov    $0x18,%ecx
call   1030 <getBits@plt>
mov    $0x2,%edi
movsd  0xe70(%rip),%xmm0
call   1040 <pow@plt>
cvtsi2sdl -0x1c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
mov    $0x10,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    11f3 <ibm2real+0xd3>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11fd <ibm2real+0xdd>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ibm2real>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xc(%rsp),%rsi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   1030 <getBits@plt>
lea    0x1(%rbx),%rdx
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
mov    $0x7,%ecx
call   1030 <getBits@plt>
addl   $0xffffffc0,0x4(%rsp)
add    $0x8,%rbx
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    $0x18,%ecx
call   1030 <getBits@plt>
movsd  0xe85(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
cvtsi2sdl 0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sdl 0x4(%rsp),%xmm0
mov    $0x10,%edi
call   1040 <pow@plt>
mulsd  0x10(%rsp),%xmm0
cmpl   $0x1,0xc(%rsp)
jne    11bd <ibm2real+0x9d>
xorpd  0xe53(%rip),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @ibm2real(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store i8* %0, i8** %3
store i64 %1, i64* %4
%9 = load i8*, i8** %3
%10 = load i64, i64* %4
%11 = call i32 @getBits(i8* %9, i32* %5, i64 %10, i32 1)
%12 = load i8*, i8** %3
%13 = load i64, i64* %4
%14 = add i64 %13, 1
%15 = call i32 @getBits(i8* %12, i32* %6, i64 %14, i32 7)
%16 = load i32, i32* %6
%17 = sub nsw i32 %16, 64
store i32 %17, i32* %6
%18 = load i8*, i8** %3
%19 = load i64, i64* %4
%20 = add i64 %19, 8
%21 = call i32 @getBits(i8* %18, i32* %7, i64 %20, i32 24)
%22 = call double @pow(i32 2, double -2.400000e+01)
%23 = load i32, i32* %7
%24 = sitofp i32 %23 to double
%25 = fmul double %22, %24
%26 = load i32, i32* %6
%27 = sitofp i32 %26 to double
%28 = call double @pow(i32 16, double %27)
%29 = fmul double %25, %28
store double %29, double* %8
%30 = load i32, i32* %5
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %35
32: ; preds = %2
%33 = load double, double* %8
%34 = fneg double %33
br label %37
35: ; preds = %2
%36 = load double, double* %8
br label %37
37: ; preds = %35, %32
%38 = phi double [ %34, %32 ], [ %36, %35 ]
ret double %38
}

LLVM IR (-O2):
define double @ibm2real(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i32 @getBits(i8* %0, i32* %3, i64 %1, i32 1)
%10 = add i64 %1, 1
%11 = call i32 @getBits(i8* %0, i32* %4, i64 %10, i32 7)
%12 = load i32, i32* %4
%13 = add nsw i32 %12, -64
store i32 %13, i32* %4
%14 = add i64 %1, 8
%15 = call i32 @getBits(i8* %0, i32* %5, i64 %14, i32 24)
%16 = call double @pow(i32 2, double -2.400000e+01)
%17 = load i32, i32* %5
%18 = sitofp i32 %17 to double
%19 = fmul double %16, %18
%20 = load i32, i32* %4
%21 = sitofp i32 %20 to double
%22 = call double @pow(i32 16, double %21)
%23 = fmul double %19, %22
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, 1
%26 = fneg double %23
%27 = select i1 %25, double %26, double %23
ret double %27
}