#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 */
int rand();
int rotl32c(int, int);
int rotr32c(int, int);
void disc_random_twist(uint32_t *val) {
  *val = rotl32c(*val, rand() % 32);
  *val ^= 0x5A827999;
  *val = rotr32c(*val, rand() % 32);
  *val ^= 0x4ED32706;
}


x86 assembly (clang, -O0):
<disc_random_twist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    -0x10(%rbp),%edi
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
call   1030 <rotl32c@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
xor    $0x5a827999,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    -0xc(%rbp),%edi
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
call   1040 <rotr32c@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
xor    $0x4ed32706,%ecx
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disc_random_twist>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%ebp
xor    %eax,%eax
call   1050 <rand@plt>
lea    0x1f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffe0,%ecx
sub    %ecx,%eax
mov    %ebp,%edi
mov    %eax,%esi
call   1030 <rotl32c@plt>
mov    %eax,%ebp
xor    $0x5a827999,%ebp
mov    %ebp,(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
lea    0x1f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffe0,%ecx
sub    %ecx,%eax
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <rotr32c@plt>
xor    $0x4ed32706,%eax
mov    %eax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @disc_random_twist(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = load i32, i32* %3
%5 = call i32 (...) @rand()
%6 = srem i32 %5, 32
%7 = call i32 @rotl32c(i32 %4, i32 %6)
%8 = load i32*, i32** %2
store i32 %7, i32* %8
%9 = load i32*, i32** %2
%10 = load i32, i32* %9
%11 = xor i32 %10, 1518500249
store i32 %11, i32* %9
%12 = load i32*, i32** %2
%13 = load i32, i32* %12
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 32
%16 = call i32 @rotr32c(i32 %13, i32 %15)
%17 = load i32*, i32** %2
store i32 %16, i32* %17
%18 = load i32*, i32** %2
%19 = load i32, i32* %18
%20 = xor i32 %19, 1322460934
store i32 %20, i32* %18
ret void
}

LLVM IR (-O2):
define void @disc_random_twist(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 32
%5 = tail call i32 @rotl32c(i32 %2, i32 %4)
%6 = xor i32 %5, 1518500249
store i32 %6, i32* %0
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 32
%9 = tail call i32 @rotr32c(i32 %6, i32 %8)
%10 = xor i32 %9, 1322460934
store i32 %10, i32* %0
ret void
}