#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 {
  unsigned short *__x;
  int __a;
  int __c;
  int __init;
  int /*<<< orphan*/ __old_x;
};

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/, unsigned short *, int);
int seed48_r(unsigned short int seed16v[3], struct drand48_data *buffer) {
  memcpy(buffer->__old_x, buffer->__x, sizeof(buffer->__x));
  buffer->__x[2] = seed16v[2];
  buffer->__x[1] = seed16v[1];
  buffer->__x[0] = seed16v[0];
  buffer->__a = 0x5deece66dull;
  buffer->__c = 0xb;
  buffer->__init = 1;
  return 0;
}


x86 assembly (clang, -O0):
<seed48_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%cx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %cx,0x4(%rax)
mov    -0x8(%rbp),%rax
mov    0x2(%rax),%cx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %cx,0x2(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%cx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %cx,(%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
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seed48_r>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x14(%rsi),%edi
mov    (%rsi),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
movzwl 0x4(%r14),%eax
mov    (%rbx),%rcx
mov    %ax,0x4(%rcx)
movzwl 0x2(%r14),%eax
mov    %ax,0x2(%rcx)
movzwl (%r14),%eax
mov    %ax,(%rcx)
movabs $0xbdeece66d,%rax
mov    %rax,0x8(%rbx)
movl   $0x1,0x10(%rbx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.drand48_data = type { i16*, i32, i32, i32, i32 }
define i32 @seed48_r(i16* %0, %struct.drand48_data* %1) {
%3 = alloca i16*
%4 = alloca %struct.drand48_data*
store i16* %0, i16** %3
store %struct.drand48_data* %1, %struct.drand48_data** %4
%5 = load %struct.drand48_data*, %struct.drand48_data** %4
%6 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %5, i32 0, i32 4
%7 = load i32, i32* %6
%8 = load %struct.drand48_data*, %struct.drand48_data** %4
%9 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %8, i32 0, i32 0
%10 = load i16*, i16** %9
%11 = call i32 @memcpy(i32 %7, i16* %10, i32 8)
%12 = load i16*, i16** %3
%13 = getelementptr inbounds i16, i16* %12, i64 2
%14 = load i16, i16* %13
%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 i16*, i16** %16
%18 = getelementptr inbounds i16, i16* %17, i64 2
store i16 %14, i16* %18
%19 = load i16*, i16** %3
%20 = getelementptr inbounds i16, i16* %19, i64 1
%21 = load i16, i16* %20
%22 = load %struct.drand48_data*, %struct.drand48_data** %4
%23 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %22, i32 0, i32 0
%24 = load i16*, i16** %23
%25 = getelementptr inbounds i16, i16* %24, i64 1
store i16 %21, i16* %25
%26 = load i16*, i16** %3
%27 = getelementptr inbounds i16, i16* %26, i64 0
%28 = load i16, i16* %27
%29 = load %struct.drand48_data*, %struct.drand48_data** %4
%30 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %29, i32 0, i32 0
%31 = load i16*, i16** %30
%32 = getelementptr inbounds i16, i16* %31, i64 0
store i16 %28, i16* %32
%33 = load %struct.drand48_data*, %struct.drand48_data** %4
%34 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %33, i32 0, i32 1
store i32 -554899859, i32* %34
%35 = load %struct.drand48_data*, %struct.drand48_data** %4
%36 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %35, i32 0, i32 2
store i32 11, i32* %36
%37 = load %struct.drand48_data*, %struct.drand48_data** %4
%38 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %37, i32 0, i32 3
store i32 1, i32* %38
ret i32 0
}

LLVM IR (-O2):
%struct.drand48_data = type { i16*, i32, i32, i32, i32 }
define i32 @seed48_r(i16* nocapture %0, %struct.drand48_data* nocapture %1) {
%3 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %1, i64 0, i32 4
%4 = load i32, i32* %3
%5 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %1, i64 0, i32 0
%6 = load i16*, i16** %5
%7 = tail call i32 @memcpy(i32 %4, i16* %6, i32 8)
%8 = getelementptr inbounds i16, i16* %0, i64 2
%9 = load i16, i16* %8
%10 = load i16*, i16** %5
%11 = getelementptr inbounds i16, i16* %10, i64 2
store i16 %9, i16* %11
%12 = getelementptr inbounds i16, i16* %0, i64 1
%13 = load i16, i16* %12
%14 = getelementptr inbounds i16, i16* %10, i64 1
store i16 %13, i16* %14
%15 = load i16, i16* %0
store i16 %15, i16* %10
%16 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %1, i64 0, i32 1
store i32 -554899859, i32* %16
%17 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %1, i64 0, i32 2
store i32 11, i32* %17
%18 = getelementptr inbounds %struct.drand48_data, %struct.drand48_data* %1, i64 0, i32 3
store i32 1, i32* %18
ret i32 0
}