#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 */
struct _reent {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ __dorand48(struct _reent *, unsigned short *);
double ldexp(double, int);
double _erand48_r(struct _reent *r, unsigned short xseed[3]) {
  __dorand48(r, xseed);
  return ldexp((double)xseed[0], -48) + ldexp((double)xseed[1], -32) +
         ldexp((double)xseed[2], -16);
}


x86 assembly (clang, -O0):
<_erand48_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <__dorand48@plt>
mov    -0x10(%rbp),%rax
movzwl (%rax),%eax
cvtsi2sd %eax,%xmm0
mov    $0xffffffd0,%edi
call   1030 <ldexp@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movzwl 0x2(%rax),%eax
cvtsi2sd %eax,%xmm0
mov    $0xffffffe0,%edi
call   1030 <ldexp@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movzwl 0x4(%rax),%eax
cvtsi2sd %eax,%xmm0
mov    $0xfffffff0,%edi
call   1030 <ldexp@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
addsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_erand48_r>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
call   1040 <__dorand48@plt>
movzwl (%rbx),%eax
cvtsi2sd %eax,%xmm0
mov    $0xffffffd0,%edi
call   1030 <ldexp@plt>
movsd  %xmm0,0x8(%rsp)
movzwl 0x2(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    $0xffffffe0,%edi
call   1030 <ldexp@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movzwl 0x4(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    $0xfffffff0,%edi
call   1030 <ldexp@plt>
addsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct._reent = type { i32 }
define double @_erand48_r(%struct._reent* %0, i16* %1) {
%3 = alloca %struct._reent*
%4 = alloca i16*
store %struct._reent* %0, %struct._reent** %3
store i16* %1, i16** %4
%5 = load %struct._reent*, %struct._reent** %3
%6 = load i16*, i16** %4
%7 = call i32 @__dorand48(%struct._reent* %5, i16* %6)
%8 = load i16*, i16** %4
%9 = getelementptr inbounds i16, i16* %8, i64 0
%10 = load i16, i16* %9
%11 = uitofp i16 %10 to double
%12 = call double @ldexp(double %11, i32 -48)
%13 = load i16*, i16** %4
%14 = getelementptr inbounds i16, i16* %13, i64 1
%15 = load i16, i16* %14
%16 = uitofp i16 %15 to double
%17 = call double @ldexp(double %16, i32 -32)
%18 = fadd double %12, %17
%19 = load i16*, i16** %4
%20 = getelementptr inbounds i16, i16* %19, i64 2
%21 = load i16, i16* %20
%22 = uitofp i16 %21 to double
%23 = call double @ldexp(double %22, i32 -16)
%24 = fadd double %18, %23
ret double %24
}

LLVM IR (-O2):
%struct._reent = type { i32 }
define double @_erand48_r(%struct._reent* %0, i16* %1) {
%3 = tail call i32 @__dorand48(%struct._reent* %0, i16* %1)
%4 = load i16, i16* %1
%5 = uitofp i16 %4 to double
%6 = tail call double @ldexp(double %5, i32 -48)
%7 = getelementptr inbounds i16, i16* %1, i64 1
%8 = load i16, i16* %7
%9 = uitofp i16 %8 to double
%10 = tail call double @ldexp(double %9, i32 -32)
%11 = fadd double %6, %10
%12 = getelementptr inbounds i16, i16* %1, i64 2
%13 = load i16, i16* %12
%14 = uitofp i16 %13 to double
%15 = tail call double @ldexp(double %14, i32 -16)
%16 = fadd double %11, %15
ret double %16
}