#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 {
  scalar_t__ tv_usec;
};

/* Variables and functions */
scalar_t__ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
char *randoms(int length) {
  int i;
  struct timeval tv;
  char *string = (char *)malloc(length * sizeof(char));
  for (i = 0; i < length - 1; ++i) {
    if (gettimeofday(&tv, NULL) == 0) {
      unsigned int usec = (unsigned int)(tv.tv_usec);
      srand(usec);
      string[i] = (rand() % 94) + 33;
    }
  }
  string[i] = '\0';
  return string;
}


x86 assembly (clang, -O0):
<randoms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11cc <randoms+0x8c>
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
cmp    $0x0,%rax
jne    11b9 <randoms+0x79>
mov    -0x10(%rbp),%rax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x5e,%ecx
cltd
idiv   %ecx
add    $0x21,%edx
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11be <randoms+0x7e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1165 <randoms+0x25>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randoms>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
call   1050 <malloc@plt>
mov    %rax,%r14
cmp    $0x2,%ebx
jl     11bd <randoms+0x7d>
add    $0xffffffff,%ebx
mov    %ebx,%r12d
mov    %rsp,%r15
xor    %ebx,%ebx
jmp    1179 <randoms+0x39>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r12
je     11c0 <randoms+0x80>
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
test   %rax,%rax
jne    1170 <randoms+0x30>
mov    (%rsp),%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0xffffffffae4c415d,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
shr    $0x6,%ecx
add    %edx,%ecx
imul   $0x5e,%ecx,%ecx
sub    %ecx,%eax
add    $0x21,%al
mov    %al,(%r14,%rbx,1)
jmp    1170 <randoms+0x30>
xor    %r12d,%r12d
movb   $0x0,(%r14,%r12,1)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i64 }
define i8* @randoms(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.timeval
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = mul i64 %8, 1
%10 = trunc i64 %9 to i32
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %5
store i32 0, i32* %3
br label %13
13: ; preds = %36, %1
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = sub nsw i32 %15, 1
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %39
18: ; preds = %13
%19 = call i64 @gettimeofday(%struct.timeval* %4, i32* null)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %35
21: ; preds = %18
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%23 = load i64, i64* %22
%24 = trunc i64 %23 to i32
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = call i32 @srand(i32 %25)
%27 = call i32 (...) @rand()
%28 = srem i32 %27, 94
%29 = add nsw i32 %28, 33
%30 = trunc i32 %29 to i8
%31 = load i8*, i8** %5
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 %30, i8* %34
br label %35
35: ; preds = %21, %18
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %13
39: ; preds = %13
%40 = load i8*, i8** %5
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
store i8 0, i8* %43
%44 = load i8*, i8** %5
ret i8* %44
}

LLVM IR (-O2):
%struct.timeval = type { i64 }
define i8* @randoms(i32 %0) {
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %2 to i8*
%4 = tail call i64 @malloc(i32 %0)
%5 = inttoptr i64 %4 to i8*
%6 = add i32 %0, -1
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %29
8: ; preds = %1
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%10 = zext i32 %6 to i64
br label %11
11: ; preds = %8, %24
%12 = phi i64 [ 0, %8 ], [ %25, %24 ]
%13 = call i64 @gettimeofday(%struct.timeval* %2, i32* null)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = load i64, i64* %9
%17 = trunc i64 %16 to i32
%18 = tail call i32 @srand(i32 %17)
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 94
%21 = trunc i32 %20 to i8
%22 = add nsw i8 %21, 33
%23 = getelementptr inbounds i8, i8* %5, i64 %12
store i8 %22, i8* %23
br label %24
24: ; preds = %11, %15
%25 = add nuw nsw i64 %12, 1
%26 = icmp eq i64 %25, %10
br i1 %26, label %27, label %11
27: ; preds = %24
%28 = zext i32 %6 to i64
br label %29
29: ; preds = %1, %27
%30 = phi i64 [ %28, %27 ], [ 0, %1 ]
%31 = getelementptr inbounds i8, i8* %5, i64 %30
store i8 0, i8* %31
ret i8* %5
}