#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 unsigned long uint32_t;

/* Variables and functions */
double RAND_MAX;
scalar_t__ UINT_MAX;
double rand();
void get_big_randnum(void *buf, unsigned int size) {
  uint32_t *x = buf;
  int i;
  for (i = 0; i < size; i += 4, x++) {
    *x = (unsigned long)((float)UINT_MAX * (rand() / (RAND_MAX + 1.0)));
  }
}


x86 assembly (clang, -O0):
<get_big_randnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11c4 <get_big_randnum+0xb4>
mov    0x2ea7(%rip),%rax
cvtsi2ssq (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xor    %eax,%eax
call   1030 <rand@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mov    0x2e7b(%rip),%rax
movsd  (%rax),%xmm2
movsd  0xe8f(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rcx
mov    %rcx,%rdx
sar    $0x3f,%rdx
movsd  0xe74(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rdx,%rax
or     %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    112e <get_big_randnum+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_big_randnum>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %esi,%esi
je     119c <get_big_randnum+0x8c>
mov    %esi,%ebp
mov    %rdi,%r14
mov    0x2ebc(%rip),%r15
mov    0x2ead(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm0,%xmm0
cvtsi2ssq (%r15),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
movsd  (%r12),%xmm1
addsd  0xe99(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,%rcx
sar    $0x3f,%rcx
subsd  0xe83(%rip),%xmm0
cvttsd2si %xmm0,%rdx
and    %rcx,%rdx
or     %rax,%rdx
mov    %rdx,(%r14,%rbx,2)
add    $0x4,%rbx
cmp    %ebp,%ebx
jb     1140 <get_big_randnum+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@UINT_MAX = global i64 0
@RAND_MAX = global double 0.000000e+00
define void @get_big_randnum(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64*
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = bitcast i8* %7 to i64*
store i64* %8, i64** %5
store i32 0, i32* %6
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp ult i32 %10, %11
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i64, i64* @UINT_MAX
%15 = sitofp i64 %14 to float
%16 = fpext float %15 to double
%17 = call double (...) @rand()
%18 = load double, double* @RAND_MAX
%19 = fadd double %18, 1.000000e+00
%20 = fdiv double %17, %19
%21 = fmul double %16, %20
%22 = fptoui double %21 to i64
%23 = load i64*, i64** %5
store i64 %22, i64* %23
br label %24
24: ; preds = %13
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 4
store i32 %26, i32* %6
%27 = load i64*, i64** %5
%28 = getelementptr inbounds i64, i64* %27, i32 1
store i64* %28, i64** %5
br label %9
29: ; preds = %9
ret void
}

LLVM IR (-O2):
@UINT_MAX = global i64 0
@RAND_MAX = global double 0.000000e+00
define void @get_big_randnum(i8* nocapture writeonly %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %21, label %4
4: ; preds = %2
%5 = bitcast i8* %0 to i64*
br label %6
6: ; preds = %4, %6
%7 = phi i32 [ %18, %6 ], [ 0, %4 ]
%8 = phi i64* [ %19, %6 ], [ %5, %4 ]
%9 = load i64, i64* @UINT_MAX
%10 = sitofp i64 %9 to float
%11 = fpext float %10 to double
%12 = tail call double (...) @rand()
%13 = load double, double* @RAND_MAX
%14 = fadd double %13, 1.000000e+00
%15 = fdiv double %12, %14
%16 = fmul double %15, %11
%17 = fptoui double %16 to i64
store i64 %17, i64* %8
%18 = add nuw nsw i32 %7, 4
%19 = getelementptr inbounds i64, i64* %8, i64 1
%20 = icmp ult i32 %18, %1
br i1 %20, label %6, label %21
21: ; preds = %6, %2
ret void
}