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

/* Variables and functions */
double RAND_MAX;
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
scalar_t__ malloc(int);
double rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
unsigned char *CreateData(int len) {
  unsigned char *data = (unsigned char *)malloc(len);
  struct timeval tv;
  struct timezone tz;
  int counter = len;
  gettimeofday(&tv, &tz);
  srand(tv.tv_sec);
  for (counter = 0; counter < len; counter++)
    data[counter] = 255.0 * rand() / (RAND_MAX + 1.0);
  return data;
}


x86 assembly (clang, -O0):
<CreateData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <gettimeofday@plt>
mov    -0x18(%rbp),%edi
call   1040 <srand@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d2 <CreateData+0x92>
xor    %eax,%eax
call   1060 <rand@plt>
movsd  0xe6c(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2e49(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe5d(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1179 <CreateData+0x39>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CreateData>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
call   1050 <malloc@plt>
mov    %rax,%r15
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1030 <gettimeofday@plt>
mov    0x8(%rsp),%edi
call   1040 <srand@plt>
test   %ebp,%ebp
jle    11b1 <CreateData+0x71>
mov    %ebp,%ebp
mov    0x2e6f(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
mulsd  0xe71(%rip),%xmm0
movsd  (%r14),%xmm1
addsd  0xe6c(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1180 <CreateData+0x40>
mov    %r15,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
%struct.timezone = type { i32 }
@RAND_MAX = global double 0.000000e+00
define i8* @CreateData(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.timeval
%5 = alloca %struct.timezone
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %3
%10 = load i32, i32* %2
store i32 %10, i32* %6
%11 = call i32 @gettimeofday(%struct.timeval* %4, %struct.timezone* %5)
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%13 = load i32, i32* %12
%14 = call i32 @srand(i32 %13)
store i32 0, i32* %6
br label %15
15: ; preds = %30, %1
%16 = load i32, i32* %6
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %33
19: ; preds = %15
%20 = call double (...) @rand()
%21 = fmul double 2.550000e+02, %20
%22 = load double, double* @RAND_MAX
%23 = fadd double %22, 1.000000e+00
%24 = fdiv double %21, %23
%25 = fptoui double %24 to i8
%26 = load i8*, i8** %3
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 %25, i8* %29
br label %30
30: ; preds = %19
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %15
33: ; preds = %15
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
%struct.timezone = type { i32 }
@RAND_MAX = global double 0.000000e+00
define i8* @CreateData(i32 %0) {
%2 = alloca %struct.timeval
%3 = alloca %struct.timezone
%4 = tail call i64 @malloc(i32 %0)
%5 = inttoptr i64 %4 to i8*
%6 = bitcast %struct.timeval* %2 to i8*
%7 = bitcast %struct.timezone* %3 to i8*
%8 = call i32 @gettimeofday(%struct.timeval* %2, %struct.timezone* %3)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%10 = load i32, i32* %9
%11 = tail call i32 @srand(i32 %10)
%12 = icmp sgt i32 %0, 0
br i1 %12, label %13, label %26
13: ; preds = %1
%14 = zext i32 %0 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %24, %15 ]
%17 = tail call double (...) @rand()
%18 = fmul double %17, 2.550000e+02
%19 = load double, double* @RAND_MAX
%20 = fadd double %19, 1.000000e+00
%21 = fdiv double %18, %20
%22 = fptoui double %21 to i8
%23 = getelementptr inbounds i8, i8* %5, i64 %16
store i8 %22, i8* %23
%24 = add nuw nsw i64 %16, 1
%25 = icmp eq i64 %24, %14
br i1 %25, label %26, label %15
26: ; preds = %15, %1
ret i8* %5
}