#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 */

/* Variables and functions */
double rand_double();
void rand_array_ui32(unsigned int *out, const unsigned int len,
                     const unsigned int a, const unsigned int b) {
  unsigned int i;
  unsigned int r;
  double delta;
  delta = (double)b - (double)a;
  for (i = 0; i < len; i++) {
    r = (unsigned int)(delta * rand_double());
    out[i] = a + r;
  }
}


x86 assembly (clang, -O0):
<rand_array_ui32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm0
mov    -0x10(%rbp),%eax
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1194 <rand_array_ui32+0x84>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
xor    %eax,%eax
call   1030 <rand_double@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%edx
add    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1145 <rand_array_ui32+0x35>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_array_ui32>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
je     1161 <rand_array_ui32+0x51>
mov    %edx,%r14d
mov    %rdi,%r15
mov    %ecx,%eax
cvtsi2sd %rax,%xmm1
mov    %edx,%eax
cvtsi2sd %rax,%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mov    %esi,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <rand_double@plt>
mulsd  (%rsp),%xmm0
cvttsd2si %xmm0,%rax
add    %r14d,%eax
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <rand_array_ui32+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @rand_array_ui32(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = load i32, i32* %8
%13 = uitofp i32 %12 to double
%14 = load i32, i32* %7
%15 = uitofp i32 %14 to double
%16 = fsub double %13, %15
store double %16, double* %11
store i32 0, i32* %9
br label %17
17: ; preds = %33, %4
%18 = load i32, i32* %9
%19 = load i32, i32* %6
%20 = icmp ult i32 %18, %19
br i1 %20, label %21, label %36
21: ; preds = %17
%22 = load double, double* %11
%23 = call double (...) @rand_double()
%24 = fmul double %22, %23
%25 = fptoui double %24 to i32
store i32 %25, i32* %10
%26 = load i32, i32* %7
%27 = load i32, i32* %10
%28 = add i32 %26, %27
%29 = load i32*, i32** %5
%30 = load i32, i32* %9
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
store i32 %28, i32* %32
br label %33
33: ; preds = %21
%34 = load i32, i32* %9
%35 = add i32 %34, 1
store i32 %35, i32* %9
br label %17
36: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @rand_array_ui32(i32* nocapture writeonly %0, i32 %1, i32 %2, i32 %3) {
%5 = uitofp i32 %3 to double
%6 = uitofp i32 %2 to double
%7 = fsub double %5, %6
%8 = icmp eq i32 %1, 0
br i1 %8, label %20, label %9
9: ; preds = %4
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %18, %11 ]
%13 = tail call double (...) @rand_double()
%14 = fmul double %7, %13
%15 = fptoui double %14 to i32
%16 = add i32 %15, %2
%17 = getelementptr inbounds i32, i32* %0, i64 %12
store i32 %16, i32* %17
%18 = add nuw nsw i64 %12, 1
%19 = icmp eq i64 %18, %10
br i1 %19, label %20, label %11
20: ; preds = %11, %4
ret void
}