#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 */

/* Variables and functions */
int /*<<< orphan*/ lrand48();
int /*<<< orphan*/ mrand48();
int /*<<< orphan*/ printf(char *, unsigned short, ...);
unsigned short *seed48(unsigned short *);
int main(void) {
  unsigned short seed1[] = {0x1234, 0x5678, 0x9abc};
  unsigned short *oldseed;
  oldseed = seed48(seed1);
  printf("Initial seed: %#06x %#06x %#06x\n", oldseed[0], oldseed[1],
         oldseed[2]);
  printf("lrand48() = %ld\n", lrand48());
  seed48(seed1);
  printf("mrand48() = %ld\n", mrand48());
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeab(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xea5(%rip),%ax
mov    %ax,-0x6(%rbp)
lea    -0xa(%rbp),%rdi
call   1050 <seed48@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%ax
mov    -0x18(%rbp),%rcx
movzwl 0x2(%rcx),%edx
mov    -0x18(%rbp),%rcx
movzwl 0x4(%rcx),%ecx
lea    0xe78(%rip),%rdi
movzwl %ax,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <lrand48@plt>
lea    0xe81(%rip),%rdi
movzwl %ax,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xa(%rbp),%rdi
call   1050 <seed48@plt>
mov    $0x0,%al
call   1040 <mrand48@plt>
lea    0xe71(%rip),%rdi
movzwl %ax,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movzwl 0xeb8(%rip),%eax
mov    %ax,0xc(%rsp)
mov    0xea9(%rip),%eax
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <seed48@plt>
movzwl (%rax),%esi
movzwl 0x2(%rax),%edx
movzwl 0x4(%rax),%ecx
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <lrand48@plt>
movzwl %ax,%esi
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <seed48@plt>
xor    %eax,%eax
call   1040 <mrand48@plt>
movzwl %ax,%esi
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.seed1 = [3 x i16] [i16 4660, i16 22136, i16 -25924]
@.str = [33 x i8] c"Initial seed: %x %x %x\0A\00"
@.str.1 = [17 x i8] c"lrand48() = %ld\0A\00"
@.str.2 = [17 x i8] c"mrand48() = %ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i16]
%3 = alloca i16*
store i32 0, i32* %1
%4 = bitcast [3 x i16]* %2 to i8*
%5 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 0
%6 = call i16* @seed48(i16* %5)
store i16* %6, i16** %3
%7 = load i16*, i16** %3
%8 = getelementptr inbounds i16, i16* %7, i64 0
%9 = load i16, i16* %8
%10 = load i16*, i16** %3
%11 = getelementptr inbounds i16, i16* %10, i64 1
%12 = load i16, i16* %11
%13 = zext i16 %12 to i32
%14 = load i16*, i16** %3
%15 = getelementptr inbounds i16, i16* %14, i64 2
%16 = load i16, i16* %15
%17 = zext i16 %16 to i32
%18 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i16 zeroext %9, i32 %13, i32 %17)
%19 = call i32 (...) @lrand48()
%20 = trunc i32 %19 to i16
%21 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i16 zeroext %20)
%22 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 0
%23 = call i16* @seed48(i16* %22)
%24 = call i32 (...) @mrand48()
%25 = trunc i32 %24 to i16
%26 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i16 zeroext %25)
ret i32 1
}

LLVM IR (-O2):
@__const.main.seed1 = [3 x i16] [i16 4660, i16 22136, i16 -25924]
@.str = [33 x i8] c"Initial seed: %x %x %x\0A\00"
@.str.1 = [17 x i8] c"lrand48() = %ld\0A\00"
@.str.2 = [17 x i8] c"mrand48() = %ld\0A\00"
define i32 @main() {
%1 = alloca [3 x i16]
%2 = bitcast [3 x i16]* %1 to i8*
%3 = getelementptr inbounds [3 x i16], [3 x i16]* %1, i64 0, i64 0
%4 = call i16* @seed48(i16* %3)
%5 = load i16, i16* %4
%6 = getelementptr inbounds i16, i16* %4, i64 1
%7 = load i16, i16* %6
%8 = zext i16 %7 to i32
%9 = getelementptr inbounds i16, i16* %4, i64 2
%10 = load i16, i16* %9
%11 = zext i16 %10 to i32
%12 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i16 zeroext %5, i32 %8, i32 %11)
%13 = call i32 (...) @lrand48()
%14 = trunc i32 %13 to i16
%15 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i16 zeroext %14)
%16 = call i16* @seed48(i16* %3)
%17 = call i32 (...) @mrand48()
%18 = trunc i32 %17 to i16
%19 = call i32 (i8*, i16, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i16 zeroext %18)
ret i32 1
}