#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_MAX;
double rand();
void get_random_bytes(void *data, unsigned int size) {
  unsigned int i;
  unsigned char *buf = data;
  for (i = 0; i < size; ++i)
    buf[i] = 1 + (int)(255.0 * (rand() / (RAND_MAX + 1.0)));
}


x86 assembly (clang, -O0):
<get_random_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1188 <get_random_bytes+0x78>
mov    $0x0,%al
call   1030 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xebc(%rip),%xmm0
mov    0x2e95(%rip),%rax
addsd  (%rax),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe9d(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112e <get_random_bytes+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_random_bytes>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     1163 <get_random_bytes+0x53>
mov    %rdi,%r14
mov    %esi,%r12d
mov    0x2ebf(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <rand@plt>
movsd  (%r15),%xmm1
addsd  0xebc(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  0xeb8(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%al
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <get_random_bytes+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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