#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 */
struct timeval {
  int /*<<< orphan*/ tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
void GetRand(char *r) {
  struct timeval tpstart;
  int i = 0;
  for (i = 0; i < 16; i++) {
    gettimeofday(&tpstart, NULL);
    srand(tpstart.tv_usec);
    *(r + i) = rand() % 255;
  }
}


x86 assembly (clang, -O0):
<GetRand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    1191 <GetRand+0x61>
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x10(%rbp),%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0xff,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <GetRand+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetRand>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r15
lea    0x8(%rsp),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0xffffffff80808081,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
shr    $0x7,%ecx
add    %edx,%ecx
add    %eax,%ecx
mov    %cl,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    $0x10,%rbx
jne    1150 <GetRand+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
define void @GetRand(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.timeval
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
store i32 0, i32* %4
br label %5
5: ; preds = %20, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 16
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%11 = load i32, i32* %10
%12 = call i32 @srand(i32 %11)
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 255
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %2
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 %15, i8* %19
br label %20
20: ; preds = %8
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %5
23: ; preds = %5
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
define void @GetRand(i8* nocapture writeonly %0) {
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %2 to i8*
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
br label %5
5: ; preds = %1, %5
%6 = phi i64 [ 0, %1 ], [ %14, %5 ]
%7 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%8 = load i32, i32* %4
%9 = tail call i32 @srand(i32 %8)
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 255
%12 = trunc i32 %11 to i8
%13 = getelementptr inbounds i8, i8* %0, i64 %6
store i8 %12, i8* %13
%14 = add nuw nsw i64 %6, 1
%15 = icmp eq i64 %14, 16
br i1 %15, label %16, label %5
16: ; preds = %5
ret void
}