#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 long tv_sec;
  unsigned long tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
unsigned long rand();
int random_number(void) {
  struct timeval t;
  unsigned long val;
  gettimeofday(&t, NULL);
  val = t.tv_sec ^ t.tv_usec ^ rand();
  val ^= val >> 16;
  val ^= val >> 8;
  val ^= val >> 4;
  val ^= val >> 2;
  val ^= val >> 1;
  return val & 1;
}


x86 assembly (clang, -O0):
<random_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x10(%rbp),%rax
xor    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
xor    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shr    $0x10,%rax
xor    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shr    $0x8,%rax
xor    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shr    $0x4,%rax
xor    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shr    $0x2,%rax
xor    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shr    $0x1,%rax
xor    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0x1,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_number>:
push   %rbx
sub    $0x10,%rsp
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%rbx
xor    (%rsp),%rbx
xor    %eax,%eax
call   1040 <rand@plt>
xor    %rbx,%rax
mov    %rax,%rcx
shr    $0x10,%rcx
xor    %rcx,%rax
mov    %rax,%rcx
shr    $0x8,%rcx
xor    %rcx,%rax
mov    %rax,%rcx
shr    $0x4,%rcx
xor    %rcx,%rax
mov    %rax,%rcx
shr    $0x2,%rcx
xor    %ecx,%eax
mov    %eax,%ecx
shr    %ecx
xor    %ecx,%eax
and    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define i32 @random_number() {
%1 = alloca %struct.timeval
%2 = alloca i64
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%5 = load i64, i64* %4
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%7 = load i64, i64* %6
%8 = xor i64 %5, %7
%9 = call i64 (...) @rand()
%10 = xor i64 %8, %9
store i64 %10, i64* %2
%11 = load i64, i64* %2
%12 = lshr i64 %11, 16
%13 = load i64, i64* %2
%14 = xor i64 %13, %12
store i64 %14, i64* %2
%15 = load i64, i64* %2
%16 = lshr i64 %15, 8
%17 = load i64, i64* %2
%18 = xor i64 %17, %16
store i64 %18, i64* %2
%19 = load i64, i64* %2
%20 = lshr i64 %19, 4
%21 = load i64, i64* %2
%22 = xor i64 %21, %20
store i64 %22, i64* %2
%23 = load i64, i64* %2
%24 = lshr i64 %23, 2
%25 = load i64, i64* %2
%26 = xor i64 %25, %24
store i64 %26, i64* %2
%27 = load i64, i64* %2
%28 = lshr i64 %27, 1
%29 = load i64, i64* %2
%30 = xor i64 %29, %28
store i64 %30, i64* %2
%31 = load i64, i64* %2
%32 = and i64 %31, 1
%33 = trunc i64 %32 to i32
ret i32 %33
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define i32 @random_number() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%5 = load i64, i64* %4
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%7 = load i64, i64* %6
%8 = xor i64 %7, %5
%9 = tail call i64 (...) @rand()
%10 = xor i64 %8, %9
%11 = lshr i64 %10, 16
%12 = xor i64 %11, %10
%13 = lshr i64 %12, 8
%14 = xor i64 %13, %12
%15 = lshr i64 %14, 4
%16 = xor i64 %15, %14
%17 = lshr i64 %16, 2
%18 = xor i64 %17, %16
%19 = lshr i64 %18, 1
%20 = xor i64 %19, %18
%21 = trunc i64 %20 to i32
%22 = and i32 %21, 1
ret i32 %22
}