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

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned char *, int /*<<< orphan*/ *, scalar_t__);
int /*<<< orphan*/ prng_uint32();
void prng_bytes(unsigned char *buff, uint8_t len) {
  uint8_t i;
  uint32_t rnd;
  for (i = 0; i + sizeof(uint32_t) <= len; i += sizeof(uint32_t)) {
    rnd = prng_uint32();
    memcpy(buff + i, &rnd, sizeof(uint32_t));
  }
  if (i < len) {
    rnd = prng_uint32();
    memcpy(buff + i, &rnd, len - i);
  }
}


x86 assembly (clang, -O0):
<prng_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
cmp    -0x10(%rbp),%rax
ja     117b <prng_bytes+0x5b>
mov    $0x0,%al
call   1040 <prng_uint32@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
add    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <prng_bytes+0x18>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    11ac <prng_bytes+0x8c>
mov    $0x0,%al
call   1040 <prng_uint32@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
add    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
sub    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rsi
call   1030 <memcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prng_bytes>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r12
mov    %rdi,%r14
cmp    $0x4,%rsi
jae    113e <prng_bytes+0x1e>
xor    %r13d,%r13d
jmp    117c <prng_bytes+0x5c>
lea    0xc(%rsp),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <prng_uint32@plt>
mov    %eax,0xc(%rsp)
lea    (%r14,%rbx,1),%rdi
mov    $0x4,%edx
mov    %r15,%rsi
call   1030 <memcpy@plt>
lea    0x4(%rbx),%r13
add    $0x8,%rbx
cmp    %r12,%rbx
mov    %r13,%rbx
jbe    1150 <prng_bytes+0x30>
cmp    %r12,%r13
jge    11a2 <prng_bytes+0x82>
xor    %eax,%eax
call   1040 <prng_uint32@plt>
mov    %eax,0xc(%rsp)
add    %r13,%r14
sub    %r13,%r12
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
mov    %r12,%rdx
call   1030 <memcpy@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @prng_bytes(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
store i64 0, i64* %5
br label %7
7: ; preds = %18, %2
%8 = load i64, i64* %5
%9 = add i64 %8, 4
%10 = load i64, i64* %4
%11 = icmp ule i64 %9, %10
br i1 %11, label %12, label %21
12: ; preds = %7
%13 = call i32 (...) @prng_uint32()
store i32 %13, i32* %6
%14 = load i8*, i8** %3
%15 = load i64, i64* %5
%16 = getelementptr inbounds i8, i8* %14, i64 %15
%17 = call i32 @memcpy(i8* %16, i32* %6, i64 4)
br label %18
18: ; preds = %12
%19 = load i64, i64* %5
%20 = add i64 %19, 4
store i64 %20, i64* %5
br label %7
21: ; preds = %7
%22 = load i64, i64* %5
%23 = load i64, i64* %4
%24 = icmp slt i64 %22, %23
br i1 %24, label %25, label %34
25: ; preds = %21
%26 = call i32 (...) @prng_uint32()
store i32 %26, i32* %6
%27 = load i8*, i8** %3
%28 = load i64, i64* %5
%29 = getelementptr inbounds i8, i8* %27, i64 %28
%30 = load i64, i64* %4
%31 = load i64, i64* %5
%32 = sub nsw i64 %30, %31
%33 = call i32 @memcpy(i8* %29, i32* %6, i64 %32)
br label %34
34: ; preds = %25, %21
ret void
}

LLVM IR (-O2):
define void @prng_bytes(i8* %0, i64 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp ult i64 %1, 4
br i1 %5, label %14, label %6
6: ; preds = %2, %6
%7 = phi i64 [ %12, %6 ], [ 4, %2 ]
%8 = phi i64 [ %7, %6 ], [ 0, %2 ]
%9 = call i32 (...) @prng_uint32()
store i32 %9, i32* %3
%10 = getelementptr inbounds i8, i8* %0, i64 %8
%11 = call i32 @memcpy(i8* %10, i32* %3, i64 4)
%12 = add i64 %7, 4
%13 = icmp ugt i64 %12, %1
br i1 %13, label %14, label %6
14: ; preds = %6, %2
%15 = phi i64 [ 0, %2 ], [ %7, %6 ]
%16 = icmp slt i64 %15, %1
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = call i32 (...) @prng_uint32()
store i32 %18, i32* %3
%19 = getelementptr inbounds i8, i8* %0, i64 %15
%20 = sub nsw i64 %1, %15
%21 = call i32 @memcpy(i8* %19, i32* %3, i64 %20)
br label %22
22: ; preds = %17, %14
ret void
}