#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();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void charRandomizer(char *string, size_t length) {
  srand(time(NULL));
  unsigned int num_chars = length - 1;
  unsigned int i;
  for (i = 0; i < num_chars; ++i) {
    string[i] = rand() % (126 - 33 + 1) + 33;
  }
  string[num_chars] = '\0';
}


x86 assembly (clang, -O0):
<charRandomizer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1198 <charRandomizer+0x68>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x5e,%ecx
cltd
idiv   %ecx
add    $0x21,%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1162 <charRandomizer+0x32>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<charRandomizer>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %r12d,%r12d
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
add    $0xffffffff,%r14d
je     1194 <charRandomizer+0x64>
mov    %r14d,%r12d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <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,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <charRandomizer+0x30>
movb   $0x0,(%r15,%r12,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @charRandomizer(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
%7 = call i32 @time(i32* null)
%8 = call i32 @srand(i32 %7)
%9 = load i64, i64* %4
%10 = sub i64 %9, 1
%11 = trunc i64 %10 to i32
store i32 %11, i32* %5
store i32 0, i32* %6
br label %12
12: ; preds = %25, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = icmp ult i32 %13, %14
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 94
%19 = add nsw i32 %18, 33
%20 = trunc i32 %19 to i8
%21 = load i8*, i8** %3
%22 = load i32, i32* %6
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8 %20, i8* %24
br label %25
25: ; preds = %16
%26 = load i32, i32* %6
%27 = add i32 %26, 1
store i32 %27, i32* %6
br label %12
28: ; preds = %12
%29 = load i8*, i8** %3
%30 = load i32, i32* %5
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 0, i8* %32
ret void
}

LLVM IR (-O2):
define void @charRandomizer(i8* nocapture writeonly %0, i64 %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = trunc i64 %1 to i32
%6 = add i32 %5, -1
%7 = icmp eq i32 %6, 0
br i1 %7, label %19, label %8
8: ; preds = %2
%9 = zext i32 %6 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %17, %10 ]
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 94
%14 = trunc i32 %13 to i8
%15 = add nsw i8 %14, 33
%16 = getelementptr inbounds i8, i8* %0, i64 %11
store i8 %15, i8* %16
%17 = add nuw nsw i64 %11, 1
%18 = icmp eq i64 %17, %9
br i1 %18, label %19, label %10
19: ; preds = %10, %2
%20 = phi i64 [ 0, %2 ], [ %9, %10 ]
%21 = getelementptr inbounds i8, i8* %0, i64 %20
store i8 0, i8* %21
ret void
}