#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 uint64_t;
typedef int uint32_t;
struct drand48_data {
  int __init;
  int __a;
  int __c;
};

/* Variables and functions */
scalar_t__ unlikely(int);
int __drand48_iterate(unsigned short int xsubi[3],
                      struct drand48_data *buffer) {
  uint64_t X;
  uint64_t result;
  if (unlikely(!buffer->__init)) {
    buffer->__a = 0x5deece66dull;
    buffer->__c = 0xb;
    buffer->__init = 1;
  }
  X = (uint64_t)xsubi[2] << 32 | (uint32_t)xsubi[1] << 16 | xsubi[0];
  result = X * buffer->__a + buffer->__c;
  xsubi[0] = result & 0xffff;
  xsubi[1] = (result >> 16) & 0xffff;
  xsubi[2] = (result >> 32) & 0xffff;
  return 0;
}


x86 assembly (clang, -O0):
<__drand48_iterate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <unlikely@plt>
cmp    $0x0,%rax
je     1160 <__drand48_iterate+0x50>
mov    -0x10(%rbp),%rax
movl   $0xdeece66d,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0xb,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%rax
movzwl 0x4(%rax),%eax
mov    $0x20,%ecx
shl    %cl,%eax
mov    -0x8(%rbp),%rcx
movzwl 0x2(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
movzwl (%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
imul   0x4(%rcx),%eax
mov    -0x10(%rbp),%rcx
add    0x8(%rcx),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0xffff,%eax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
mov    -0x18(%rbp),%eax
sar    $0x10,%eax
and    $0xffff,%eax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,0x2(%rax)
mov    -0x18(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
and    $0xffff,%eax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,0x4(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__drand48_iterate>:
push   %rbx
mov    %rsi,%rbx
xor    %edi,%edi
cmpl   $0x0,(%rsi)
sete   %dil
call   1030 <unlikely@plt>
test   %rax,%rax
je     113b <__drand48_iterate+0x2b>
movl   $0xb,0x8(%rbx)
movabs $0xdeece66d00000001,%rax
e6 ec de
mov    %rax,(%rbx)
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.drand48_data = type { i32, i32, i32 }
define i32 @__drand48_iterate(i16* %0, %struct.drand48_data* %1) {
%3 = alloca i16*
%4 = alloca %struct.drand48_data*
%5 = alloca i32
%6 = alloca i32
store i16* %0, i16** %3
store %struct.drand48_data* %1, %struct.drand48_data** %4
%7 = load %struct.drand48_data*, %struct.drand48_data** %4
%8 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = icmp ne i32 %9, 0
%11 = xor i1 %10, true
%12 = zext i1 %11 to i32
%13 = call i64 @unlikely(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = load %struct.drand48_data*, %struct.drand48_data** %4
%17 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %16, i32 0, i32 1
store i32 -554899859, i32* %17
%18 = load %struct.drand48_data*, %struct.drand48_data** %4
%19 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %18, i32 0, i32 2
store i32 11, i32* %19
%20 = load %struct.drand48_data*, %struct.drand48_data** %4
%21 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %20, i32 0, i32 0
store i32 1, i32* %21
br label %22
22: ; preds = %15, %2
%23 = load i16*, i16** %3
%24 = getelementptr inbounds i16, i16* %23, i64 2
%25 = load i16, i16* %24
%26 = zext i16 %25 to i32
%27 = shl i32 %26, 32
%28 = load i16*, i16** %3
%29 = getelementptr inbounds i16, i16* %28, i64 1
%30 = load i16, i16* %29
%31 = zext i16 %30 to i32
%32 = shl i32 %31, 16
%33 = or i32 %27, %32
%34 = load i16*, i16** %3
%35 = getelementptr inbounds i16, i16* %34, i64 0
%36 = load i16, i16* %35
%37 = zext i16 %36 to i32
%38 = or i32 %33, %37
store i32 %38, i32* %5
%39 = load i32, i32* %5
%40 = load %struct.drand48_data*, %struct.drand48_data** %4
%41 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %40, i32 0, i32 1
%42 = load i32, i32* %41
%43 = mul nsw i32 %39, %42
%44 = load %struct.drand48_data*, %struct.drand48_data** %4
%45 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %44, i32 0, i32 2
%46 = load i32, i32* %45
%47 = add nsw i32 %43, %46
store i32 %47, i32* %6
%48 = load i32, i32* %6
%49 = and i32 %48, 65535
%50 = trunc i32 %49 to i16
%51 = load i16*, i16** %3
%52 = getelementptr inbounds i16, i16* %51, i64 0
store i16 %50, i16* %52
%53 = load i32, i32* %6
%54 = ashr i32 %53, 16
%55 = and i32 %54, 65535
%56 = trunc i32 %55 to i16
%57 = load i16*, i16** %3
%58 = getelementptr inbounds i16, i16* %57, i64 1
store i16 %56, i16* %58
%59 = load i32, i32* %6
%60 = ashr i32 %59, 32
%61 = and i32 %60, 65535
%62 = trunc i32 %61 to i16
%63 = load i16*, i16** %3
%64 = getelementptr inbounds i16, i16* %63, i64 2
store i16 %62, i16* %64
ret i32 0
}

LLVM IR (-O2):
%struct.drand48_data = type { i32, i32, i32 }
define i32 @__drand48_iterate(i16* nocapture readnone %0, %struct.drand48_data* nocapture %1) {
%3 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %1, i64 0, i32 0
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 0
%6 = zext i1 %5 to i32
%7 = tail call i64 @unlikely(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %1, i64 0, i32 1
store i32 -554899859, i32* %10
%11 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %1, i64 0, i32 2
store i32 11, i32* %11
store i32 1, i32* %3
br label %12
12: ; preds = %9, %2
ret i32 0
}