#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 */
int rand();
void randKey(unsigned char key[8]) {
  unsigned char i;
  for (i = 0; i < 8; i++)
    key[i] = rand() % 0x0100;
}


x86 assembly (clang, -O0):
<randKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0x8,%eax
jge    1154 <randKey+0x44>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%rax
movzbl -0x9(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x9(%rbp),%al
add    $0x1,%al
mov    %al,-0x9(%rbp)
jmp    1120 <randKey+0x10>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randKey>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <rand@plt>
mov    %al,(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %al,0x1(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %al,0x2(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %al,0x3(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %al,0x4(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %al,0x5(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %al,0x6(%rbx)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %al,0x7(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @randKey(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
store i8* %0, i8** %2
store i8 0, i8* %3
br label %4
4: ; preds = %16, %1
%5 = load i8, i8* %3
%6 = zext i8 %5 to i32
%7 = icmp slt i32 %6, 8
br i1 %7, label %8, label %19
8: ; preds = %4
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 256
%11 = trunc i32 %10 to i8
%12 = load i8*, i8** %2
%13 = load i8, i8* %3
%14 = zext i8 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
store i8 %11, i8* %15
br label %16
16: ; preds = %8
%17 = load i8, i8* %3
%18 = add i8 %17, 1
store i8 %18, i8* %3
br label %4
19: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @randKey(i8* nocapture writeonly %0) {
%2 = tail call i32 (...) @rand()
%3 = trunc i32 %2 to i8
store i8 %3, i8* %0
%4 = tail call i32 (...) @rand()
%5 = trunc i32 %4 to i8
%6 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %5, i8* %6
%7 = tail call i32 (...) @rand()
%8 = trunc i32 %7 to i8
%9 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %8, i8* %9
%10 = tail call i32 (...) @rand()
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %11, i8* %12
%13 = tail call i32 (...) @rand()
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %14, i8* %15
%16 = tail call i32 (...) @rand()
%17 = trunc i32 %16 to i8
%18 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %17, i8* %18
%19 = tail call i32 (...) @rand()
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %20, i8* %21
%22 = tail call i32 (...) @rand()
%23 = trunc i32 %22 to i8
%24 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %23, i8* %24
ret void
}