#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 uint32_t;
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
int32_t rand_r(uint32_t *seed) {
  uint32_t s = *seed;
  uint32_t uret;
  s = (s * 1103515245) + 12345;
  uret = s & 0xffe00000;
  s = (s * 1103515245) + 12345;
  uret += (s & 0xfffc0000) >> 11;
  s = (s * 1103515245) + 12345;
  uret += (s & 0xfe000000) >> (11 + 14);
  *seed = s;
  return (int32_t)uret;
}


x86 assembly (clang, -O0):
<rand_r>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
imul   $0x41c64e6d,-0xc(%rbp),%eax
add    $0x3039,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xffe00000,%eax
mov    %eax,-0x10(%rbp)
imul   $0x41c64e6d,-0xc(%rbp),%eax
add    $0x3039,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfffc0000,%eax
shr    $0xb,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
imul   $0x41c64e6d,-0xc(%rbp),%eax
add    $0x3039,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfe000000,%eax
shr    $0x19,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_r>:
imul   $0x41c64e6d,(%rdi),%eax
add    $0x3039,%eax
imul   $0x41c64e6d,%eax,%ecx
and    $0xffe00000,%eax
add    $0x3039,%ecx
imul   $0x41c64e6d,%ecx,%edx
shr    $0xb,%ecx
and    $0xffffff80,%ecx
or     %eax,%ecx
add    $0x3039,%edx
mov    %edx,(%rdi)
mov    %edx,%eax
shr    $0x19,%eax
or     %ecx,%eax
ret

LLVM IR (-O0):
define i32 @rand_r(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = load i32, i32* %5
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = mul nsw i32 %7, 1103515245
%9 = add nsw i32 %8, 12345
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = and i32 %10, -2097152
store i32 %11, i32* %4
%12 = load i32, i32* %3
%13 = mul nsw i32 %12, 1103515245
%14 = add nsw i32 %13, 12345
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = and i32 %15, -262144
%17 = lshr i32 %16, 11
%18 = load i32, i32* %4
%19 = add i32 %18, %17
store i32 %19, i32* %4
%20 = load i32, i32* %3
%21 = mul nsw i32 %20, 1103515245
%22 = add nsw i32 %21, 12345
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = and i32 %23, -33554432
%25 = lshr i32 %24, 25
%26 = load i32, i32* %4
%27 = add i32 %26, %25
store i32 %27, i32* %4
%28 = load i32, i32* %3
%29 = load i32*, i32** %2
store i32 %28, i32* %29
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
define i32 @rand_r(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = mul nsw i32 %2, 1103515245
%4 = add nsw i32 %3, 12345
%5 = and i32 %4, -2097152
%6 = mul nsw i32 %4, 1103515245
%7 = add nsw i32 %6, 12345
%8 = lshr i32 %7, 11
%9 = and i32 %8, 2097024
%10 = or i32 %9, %5
%11 = mul nsw i32 %7, 1103515245
%12 = add nsw i32 %11, 12345
%13 = lshr i32 %12, 25
%14 = or i32 %10, %13
store i32 %12, i32* %0
ret i32 %14
}