#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(unsigned int);
int /*<<< orphan*/ timer(unsigned int *);
char *generateSalt(char *saltbuf, int saltLength) {
  int i, rnd;
  unsigned int clock[2];
  timer(clock);
  srand(clock[1]);
  for (i = 0; i < saltLength; i++) {
    rnd = rand() % 50;
    saltbuf[i] = rnd < 25 ? rnd + 65 : rnd + 72;
  }
  saltbuf[saltLength] = '\0';
  return saltbuf;
}


x86 assembly (clang, -O0):
<generateSalt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <timer@plt>
mov    -0x18(%rbp),%edi
call   1040 <srand@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b4 <generateSalt+0x84>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x32,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
cmpl   $0x19,-0x14(%rbp)
jge    118d <generateSalt+0x5d>
mov    -0x14(%rbp),%eax
add    $0x41,%eax
mov    %eax,-0x20(%rbp)
jmp    1196 <generateSalt+0x66>
mov    -0x14(%rbp),%eax
add    $0x48,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1157 <generateSalt+0x27>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generateSalt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
mov    %rsp,%rdi
call   1030 <timer@plt>
mov    0x4(%rsp),%edi
call   1040 <srand@plt>
test   %r14d,%r14d
jle    11a0 <generateSalt+0x70>
mov    %r14d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
mov    %eax,%edx
sub    %ecx,%edx
lea    0x41(%rdx),%esi
neg    %ecx
cmp    $0x19,%edx
lea    0x48(%rax,%rcx,1),%eax
cmovl  %esi,%eax
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <generateSalt+0x30>
movslq %r14d,%rax
movb   $0x0,(%r15,%rax,1)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @generateSalt(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [2 x i32]
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%9 = call i32 @timer(i32* %8)
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%11 = load i32, i32* %10
%12 = call i32 @srand(i32 %11)
store i32 0, i32* %5
br label %13
13: ; preds = %35, %2
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %38
17: ; preds = %13
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 50
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp slt i32 %20, 25
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 65
br label %28
25: ; preds = %17
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 72
br label %28
28: ; preds = %25, %22
%29 = phi i32 [ %24, %22 ], [ %27, %25 ]
%30 = trunc i32 %29 to i8
%31 = load i8*, i8** %3
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 %30, i8* %34
br label %35
35: ; preds = %28
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %13
38: ; preds = %13
%39 = load i8*, i8** %3
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
store i8 0, i8* %42
%43 = load i8*, i8** %3
ret i8* %43
}

LLVM IR (-O2):
define i8* @generateSalt(i8* returned writeonly %0, i32 %1) {
%3 = alloca [2 x i32]
%4 = bitcast [2 x i32]* %3 to i8*
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%6 = call i32 @timer(i32* %5)
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%8 = load i32, i32* %7
%9 = call i32 @srand(i32 %8)
%10 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %24
11: ; preds = %2
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %22, %13 ]
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 50
%17 = icmp slt i32 %16, 25
%18 = select i1 %17, i32 65, i32 72
%19 = add nsw i32 %18, %16
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds i8, i8* %0, i64 %14
store i8 %20, i8* %21
%22 = add nuw nsw i64 %14, 1
%23 = icmp eq i64 %22, %12
br i1 %23, label %24, label %13
24: ; preds = %13, %2
%25 = sext i32 %1 to i64
%26 = getelementptr inbounds i8, i8* %0, i64 %25
store i8 0, i8* %26
ret i8* %0
}