#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;

/* Variables and functions */
uint32_t rrbRand(uint32_t rrbSeed) {
  static uint32_t rrbLo, rrbHi;
  if (rrbSeed != 0) {
    rrbLo = rrbSeed;
    rrbHi = ~rrbSeed;
  } else {
    rrbHi = (rrbHi << 16) + (rrbHi >> 16);
    rrbHi += rrbLo;
    rrbLo += rrbHi;
  }
  return rrbHi;
}


x86 assembly (clang, -O0):
<rrbRand>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     112b <rrbRand+0x2b>
mov    -0x4(%rbp),%eax
mov    %eax,0x2f0a(%rip)
mov    -0x4(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,0x2f02(%rip)
jmp    1169 <rrbRand+0x69>
mov    0x2ef7(%rip),%eax
shl    $0x10,%eax
mov    0x2eee(%rip),%ecx
sar    $0x10,%ecx
add    %ecx,%eax
mov    %eax,0x2ee3(%rip)
mov    0x2ed9(%rip),%eax
add    0x2ed7(%rip),%eax
mov    %eax,0x2ed1(%rip)
mov    0x2ecb(%rip),%eax
add    0x2ec1(%rip),%eax
mov    %eax,0x2ebb(%rip)
mov    0x2eb9(%rip),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rrbRand>:
test   %edi,%edi
je     1115 <rrbRand+0x15>
mov    %edi,%eax
mov    %edi,0x2f18(%rip)
not    %eax
mov    %eax,0x2f14(%rip)
ret
mov    0x2f0d(%rip),%eax
mov    %eax,%ecx
shl    $0x10,%ecx
sar    $0x10,%eax
add    %ecx,%eax
mov    0x2ef9(%rip),%ecx
add    %ecx,%eax
mov    %eax,0x2ef5(%rip)
add    %eax,%ecx
mov    %ecx,0x2ee9(%rip)
ret

LLVM IR (-O0):
@rrbRand.rrbLo = internal global i32 0
@rrbRand.rrbHi = internal global i32 0
define i32 @rrbRand(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = load i32, i32* %2
store i32 %6, i32* @rrbRand.rrbLo
%7 = load i32, i32* %2
%8 = xor i32 %7, -1
store i32 %8, i32* @rrbRand.rrbHi
br label %21
9: ; preds = %1
%10 = load i32, i32* @rrbRand.rrbHi
%11 = shl i32 %10, 16
%12 = load i32, i32* @rrbRand.rrbHi
%13 = ashr i32 %12, 16
%14 = add nsw i32 %11, %13
store i32 %14, i32* @rrbRand.rrbHi
%15 = load i32, i32* @rrbRand.rrbLo
%16 = load i32, i32* @rrbRand.rrbHi
%17 = add nsw i32 %16, %15
store i32 %17, i32* @rrbRand.rrbHi
%18 = load i32, i32* @rrbRand.rrbHi
%19 = load i32, i32* @rrbRand.rrbLo
%20 = add nsw i32 %19, %18
store i32 %20, i32* @rrbRand.rrbLo
br label %21
21: ; preds = %9, %5
%22 = load i32, i32* @rrbRand.rrbHi
ret i32 %22
}

LLVM IR (-O2):
@rrbRand.rrbLo = internal unnamed_addr global i32 0
@rrbRand.rrbHi = internal unnamed_addr global i32 0
define i32 @rrbRand(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %5, label %3
3: ; preds = %1
store i32 %0, i32* @rrbRand.rrbLo
%4 = xor i32 %0, -1
store i32 %4, i32* @rrbRand.rrbHi
br label %13
5: ; preds = %1
%6 = load i32, i32* @rrbRand.rrbHi
%7 = shl i32 %6, 16
%8 = ashr i32 %6, 16
%9 = add nsw i32 %7, %8
%10 = load i32, i32* @rrbRand.rrbLo
%11 = add nsw i32 %9, %10
store i32 %11, i32* @rrbRand.rrbHi
%12 = add nsw i32 %11, %10
store i32 %12, i32* @rrbRand.rrbLo
br label %13
13: ; preds = %5, %3
%14 = phi i32 [ %11, %5 ], [ %4, %3 ]
ret i32 %14
}