#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 /*<<< orphan*/ int64_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, size_t);
int /*<<< orphan*/ twister_genrand64_int64();
void random_array(void *dest, size_t len) {
  size_t i;
  uint8_t *out = dest;
  for (i = 0; i < len; i += sizeof(int64_t)) {
    int64_t r = twister_genrand64_int64();
    size_t count = len > sizeof(int64_t) ? sizeof(int64_t) : len;
    memcpy(out + i, &r, count);
  }
}


x86 assembly (clang, -O0):
<random_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11ae <random_array+0x8e>
mov    $0x0,%al
call   1040 <twister_genrand64_int64@plt>
mov    %eax,-0x24(%rbp)
cmpq   $0x4,-0x10(%rbp)
jbe    1171 <random_array+0x51>
mov    $0x4,%eax
mov    %rax,-0x38(%rbp)
jmp    1179 <random_array+0x59>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rdx
lea    -0x24(%rbp),%rsi
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    1140 <random_array+0x20>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_array>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %rsi,%rsi
je     1176 <random_array+0x56>
mov    %rsi,%r14
mov    %rdi,%r13
cmp    $0x4,%rsi
mov    $0x4,%r15d
cmovb  %rsi,%r15
lea    0xc(%rsp),%r12
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1040 <twister_genrand64_int64@plt>
mov    %eax,0xc(%rsp)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1030 <memcpy@plt>
add    $0x4,%rbx
add    $0x10,%r13
cmp    %r14,%rbx
jb     1150 <random_array+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @random_array(i8* %0, i64 %1) {
%3 = alloca i32
%4 = bitcast i8* %0 to i32*
%5 = icmp eq i64 %1, 0
br i1 %5, label %17, label %6
6: ; preds = %2
%7 = bitcast i32* %3 to i8*
%8 = icmp ult i64 %1, 4
%9 = select i1 %8, i64 %1, i64 4
br label %10
10: ; preds = %6, %10
%11 = phi i64 [ 0, %6 ], [ %15, %10 ]
%12 = call i32 (...) @twister_genrand64_int64()
store i32 %12, i32* %3
%13 = getelementptr inbounds i32, i32* %4, i64 %11
%14 = call i32 @memcpy(i32* %13, i32* %3, i64 %9)
%15 = add i64 %11, 4
%16 = icmp ult i64 %15, %1
br i1 %16, label %10, label %17
17: ; preds = %10, %2
ret void
}