#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 drand48_data {
  long *__x;
  int __a;
  int __c;
  int __init;
};

/* Variables and functions */
int __srand48_r(long int seedval, struct drand48_data *buffer) {
  if (sizeof(long int) > 4)
    seedval &= 0xffffffffl;
  buffer->__x[2] = seedval >> 16;
  buffer->__x[1] = seedval & 0xffffl;
  buffer->__x[0] = 0x330e;
  buffer->__a = 0x5deece66dull;
  buffer->__c = 0xb;
  buffer->__init = 1;
  return 0;
}


x86 assembly (clang, -O0):
<__srand48_r>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0xffffffff,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
sar    $0x10,%rcx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rcx,0x10(%rax)
mov    -0x8(%rbp),%rcx
and    $0xffff,%rcx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movq   $0x330e,(%rax)
mov    -0x10(%rbp),%rax
movl   $0xdeece66d,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0xb,0xc(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,0x10(%rax)
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__srand48_r>:
movzwl %di,%eax
shr    $0x10,%edi
mov    (%rsi),%rcx
mov    %rdi,0x10(%rcx)
mov    %rax,0x8(%rcx)
movq   $0x330e,(%rcx)
movabs $0xbdeece66d,%rax
mov    %rax,0x8(%rsi)
movl   $0x1,0x10(%rsi)
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.drand48_data = type { i64*, i32, i32, i32 }
define i32 @__srand48_r(i64 %0, %struct.drand48_data* %1) {
%3 = alloca i64
%4 = alloca %struct.drand48_data*
store i64 %0, i64* %3
store %struct.drand48_data* %1, %struct.drand48_data** %4
%5 = load i64, i64* %3
%6 = and i64 %5, 4294967295
store i64 %6, i64* %3
%7 = load i64, i64* %3
%8 = ashr i64 %7, 16
%9 = load %struct.drand48_data*, %struct.drand48_data** %4
%10 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %9, i32 0, i32 0
%11 = load i64*, i64** %10
%12 = getelementptr inbounds i64, i64* %11, i64 2
store i64 %8, i64* %12
%13 = load i64, i64* %3
%14 = and i64 %13, 65535
%15 = load %struct.drand48_data*, %struct.drand48_data** %4
%16 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %15, i32 0, i32 0
%17 = load i64*, i64** %16
%18 = getelementptr inbounds i64, i64* %17, i64 1
store i64 %14, i64* %18
%19 = load %struct.drand48_data*, %struct.drand48_data** %4
%20 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %19, i32 0, i32 0
%21 = load i64*, i64** %20
%22 = getelementptr inbounds i64, i64* %21, i64 0
store i64 13070, i64* %22
%23 = load %struct.drand48_data*, %struct.drand48_data** %4
%24 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %23, i32 0, i32 1
store i32 -554899859, i32* %24
%25 = load %struct.drand48_data*, %struct.drand48_data** %4
%26 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %25, i32 0, i32 2
store i32 11, i32* %26
%27 = load %struct.drand48_data*, %struct.drand48_data** %4
%28 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %27, i32 0, i32 3
store i32 1, i32* %28
ret i32 0
}

LLVM IR (-O2):
%struct.drand48_data = type { i64*, i32, i32, i32 }
define i32 @__srand48_r(i64 %0, %struct.drand48_data* nocapture %1) {
%3 = lshr i64 %0, 16
%4 = and i64 %3, 65535
%5 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %1, i64 0, i32 0
%6 = load i64*, i64** %5
%7 = getelementptr inbounds i64, i64* %6, i64 2
store i64 %4, i64* %7
%8 = and i64 %0, 65535
%9 = getelementptr inbounds i64, i64* %6, i64 1
store i64 %8, i64* %9
store i64 13070, i64* %6
%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
%12 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %1, i64 0, i32 3
store i32 1, i32* %12
ret i32 0
}