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

/* Variables and functions */
int /*<<< orphan*/ _random_bytes(int /*<<< orphan*/ *, int);
uint32_t random_uint32(void) {
  uint32_t ret;
  int8_t bytes[sizeof(uint32_t)];
  _random_bytes((uint8_t *)bytes, sizeof(uint32_t));
  ret = ((bytes[0] & 0xff) << 24) | ((bytes[1] & 0xff) << 16) |
        ((bytes[2] & 0xff) << 8) | (bytes[3] & 0xff);
  return ret;
}


x86 assembly (clang, -O0):
<random_uint32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1030 <_random_bytes@plt>
mov    -0x20(%rbp),%eax
and    $0xff,%eax
shl    $0x18,%eax
mov    -0x1c(%rbp),%ecx
and    $0xff,%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x18(%rbp),%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x14(%rbp),%ecx
and    $0xff,%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_uint32>:
sub    $0x18,%rsp
mov    %rsp,%rdi
mov    $0x4,%esi
call   1030 <_random_bytes@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
shl    $0x18,%eax
movzbl %cl,%ecx
shl    $0x10,%ecx
or     %eax,%ecx
mov    0x8(%rsp),%eax
shl    $0x8,%eax
movzwl %ax,%edx
or     %ecx,%edx
movzbl 0xc(%rsp),%eax
or     %edx,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @random_uint32() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%4 = call i32 @_random_bytes(i32* %3, i32 4)
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%6 = load i32, i32* %5
%7 = and i32 %6, 255
%8 = shl i32 %7, 24
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%10 = load i32, i32* %9
%11 = and i32 %10, 255
%12 = shl i32 %11, 16
%13 = or i32 %8, %12
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%15 = load i32, i32* %14
%16 = and i32 %15, 255
%17 = shl i32 %16, 8
%18 = or i32 %13, %17
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%20 = load i32, i32* %19
%21 = and i32 %20, 255
%22 = or i32 %18, %21
store i32 %22, i32* %1
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
define i32 @random_uint32() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%4 = call i32 @_random_bytes(i32* %3, i32 4)
%5 = load i32, i32* %3
%6 = shl i32 %5, 24
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%8 = load i32, i32* %7
%9 = shl i32 %8, 16
%10 = and i32 %9, 16711680
%11 = or i32 %10, %6
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%13 = load i32, i32* %12
%14 = shl i32 %13, 8
%15 = and i32 %14, 65280
%16 = or i32 %11, %15
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%18 = load i32, i32* %17
%19 = and i32 %18, 255
%20 = or i32 %16, %19
ret i32 %20
}