int __jrand48_r(xsubi, buffer, result)
unsigned short int xsubi[3];
struct drand48_data *buffer;
long int *result;
{
  if (__drand48_iterate(xsubi, buffer) < 0)
    return -1;
  if (sizeof(unsigned short int) == 2)
    *result = (((long int)(xsubi[2] & 0x7fff)) << 16) | xsubi[1];
  else
    *result = xsubi[2] & 0x7fffffffl;
  if (xsubi[2] & (1 << (sizeof(xsubi[2]) * 8 - 1)))
    *result *= -1;
  return 0;
}


x86 assembly (clang, -O0):
<__jrand48_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1030 <__drand48_iterate@plt>
cmp    $0x0,%eax
jge    1148 <__jrand48_r+0x38>
movl   $0xffffffff,-0x4(%rbp)
jmp    1196 <__jrand48_r+0x86>
mov    -0x10(%rbp),%rax
movzwl 0x4(%rax),%eax
and    $0x7fff,%eax
movslq %eax,%rcx
shl    $0x10,%rcx
mov    -0x10(%rbp),%rax
movzwl 0x2(%rax),%eax
or     %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movzwl 0x4(%rax),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     118f <__jrand48_r+0x7f>
mov    -0x20(%rbp),%rax
imul   $0xffffffffffffffff,(%rax),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__jrand48_r>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <__drand48_iterate@plt>
test   %eax,%eax
js     114e <__jrand48_r+0x3e>
movzwl 0x4(%rbx),%ecx
mov    %ecx,%edx
and    $0x7fff,%edx
shl    $0x10,%rdx
movzwl 0x2(%rbx),%eax
or     %rdx,%rax
mov    %rax,(%r14)
test   %cx,%cx
jns    1153 <__jrand48_r+0x43>
neg    %rax
mov    %rax,(%r14)
jmp    1153 <__jrand48_r+0x43>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.drand48_data = type opaque
define i32 @__jrand48_r(i16* %0, %struct.drand48_data* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i16*
%6 = alloca %struct.drand48_data*
%7 = alloca i64*
store i16* %0, i16** %5
store %struct.drand48_data* %1, %struct.drand48_data** %6
store i64* %2, i64** %7
%8 = load i16*, i16** %5
%9 = load %struct.drand48_data*, %struct.drand48_data** %6
%10 = call i32 (i16*, %struct.drand48_data*, ...) bitcast (i32 (...)* @__drand48_iterate to i32 (i16*, %struct.drand48_data*, ...)*)(i16* %8, %struct.drand48_data* %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %3
store i32 -1, i32* %4
br label %38
13: ; preds = %3
%14 = load i16*, i16** %5
%15 = getelementptr inbounds i16, i16* %14, i64 2
%16 = load i16, i16* %15
%17 = zext i16 %16 to i32
%18 = and i32 %17, 32767
%19 = sext i32 %18 to i64
%20 = shl i64 %19, 16
%21 = load i16*, i16** %5
%22 = getelementptr inbounds i16, i16* %21, i64 1
%23 = load i16, i16* %22
%24 = zext i16 %23 to i64
%25 = or i64 %20, %24
%26 = load i64*, i64** %7
store i64 %25, i64* %26
%27 = load i16*, i16** %5
%28 = getelementptr inbounds i16, i16* %27, i64 2
%29 = load i16, i16* %28
%30 = zext i16 %29 to i32
%31 = and i32 %30, 32768
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %13
%34 = load i64*, i64** %7
%35 = load i64, i64* %34
%36 = mul nsw i64 %35, -1
store i64 %36, i64* %34
br label %37
37: ; preds = %33, %13
store i32 0, i32* %4
br label %38
38: ; preds = %37, %12
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
%struct.drand48_data = type opaque
define i32 @__jrand48_r(i16* %0, %struct.drand48_data* %1, i64* nocapture writeonly %2) {
%4 = tail call i32 (i16*, %struct.drand48_data*, ...) bitcast (i32 (...)* @__drand48_iterate to i32 (i16*, %struct.drand48_data*, ...)*)(i16* %0, %struct.drand48_data* %1)
%5 = icmp slt i32 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = getelementptr inbounds i16, i16* %0, i64 2
%8 = load i16, i16* %7
%9 = and i16 %8, 32767
%10 = zext i16 %9 to i64
%11 = shl nuw nsw i64 %10, 16
%12 = getelementptr inbounds i16, i16* %0, i64 1
%13 = load i16, i16* %12
%14 = zext i16 %13 to i64
%15 = or i64 %11, %14
store i64 %15, i64* %2
%16 = icmp sgt i16 %8, -1
br i1 %16, label %19, label %17
17: ; preds = %6
%18 = sub nsw i64 0, %15
store i64 %18, i64* %2
br label %19
19: ; preds = %6, %17, %3
%20 = phi i32 [ -1, %3 ], [ 0, %17 ], [ 0, %6 ]
ret i32 %20
}