#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 timeval {
  unsigned int tv_usec;
  int tv_sec;
};

/* Variables and functions */
unsigned int getpid();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
void sran32_tod_r(unsigned *pstate0, unsigned *pstate1) {
  struct timeval tod;
  (void)gettimeofday(&tod, 0);
  *pstate0 = getpid() ^ tod.tv_usec;
  *pstate1 = tod.tv_sec ^ (tod.tv_usec * tod.tv_usec + 1);
}


x86 assembly (clang, -O0):
<sran32_tod_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%ecx
xor    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%eax
imul   -0x18(%rbp),%eax
add    $0x1,%eax
xor    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sran32_tod_r>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    (%rsp),%ecx
xor    %ecx,%eax
mov    %eax,(%rbx)
imul   %ecx,%ecx
add    $0x1,%ecx
xor    0x4(%rsp),%ecx
mov    %ecx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define void @sran32_tod_r(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca %struct.timeval
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = call i32 @gettimeofday(%struct.timeval* %5, i32 0)
%7 = call i32 (...) @getpid()
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%9 = load i32, i32* %8
%10 = xor i32 %7, %9
%11 = load i32*, i32** %3
store i32 %10, i32* %11
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%17 = load i32, i32* %16
%18 = mul i32 %15, %17
%19 = add i32 %18, 1
%20 = xor i32 %13, %19
%21 = load i32*, i32** %4
store i32 %20, i32* %21
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define void @sran32_tod_r(i32* nocapture writeonly %0, i32* nocapture writeonly %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%6 = call i32 (...) @getpid()
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%8 = load i32, i32* %7
%9 = xor i32 %8, %6
store i32 %9, i32* %0
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%11 = load i32, i32* %10
%12 = mul i32 %8, %8
%13 = add i32 %12, 1
%14 = xor i32 %11, %13
store i32 %14, i32* %1
ret void
}