#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 */
scalar_t__ malloc(int);
char rand();
int /*<<< orphan*/ srand(scalar_t__);
scalar_t__ time(int /*<<< orphan*/);
char *random_pass(int length, int seed) {
  int type, i;
  char *randomStr = (char *)malloc(length * (sizeof(char) + 1));
  char currentChar, rangeMin, rangeMax;
  for (i = 0; i < length; i++) {
    srand(time(0) + (seed + 7) * (i + 10));
    type = rand() % 3;
    switch (type) {
    case 0:
      rangeMin = 'A';
      rangeMax = 'Z';
      break;
    case 1:
      rangeMin = 'a';
      rangeMax = 'z';
      break;
    case 2:
      rangeMin = '0';
      rangeMax = '9';
      break;
    default:
      rangeMin = 'A';
      rangeMax = 'Z';
    }
    currentChar = rand() % (rangeMax - rangeMin + 1) + rangeMin;
    randomStr[i] = currentChar;
  }
  randomStr[i] = '\0';
  return randomStr;
}


x86 assembly (clang, -O0):
<random_pass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    126e <random_pass+0x12e>
xor    %edi,%edi
mov    %edi,-0x24(%rbp)
call   1040 <time@plt>
mov    %rax,%rdi
mov    -0x8(%rbp),%eax
add    $0x7,%eax
mov    -0x10(%rbp),%ecx
add    $0xa,%ecx
imul   %ecx,%eax
cltq
add    %rax,%rdi
call   1030 <srand@plt>
mov    -0x24(%rbp),%eax
call   1060 <rand@plt>
mov    %al,%cl
movsbl %cl,%eax
movsbq %cl,%rcx
imul   $0x55555556,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
test   %eax,%eax
je     11fe <random_pass+0xbe>
jmp    11dc <random_pass+0x9c>
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
je     120b <random_pass+0xcb>
jmp    11ed <random_pass+0xad>
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
je     1218 <random_pass+0xd8>
jmp    1225 <random_pass+0xe5>
movb   $0x41,-0x1a(%rbp)
movb   $0x5a,-0x1b(%rbp)
jmp    122d <random_pass+0xed>
movb   $0x61,-0x1a(%rbp)
movb   $0x7a,-0x1b(%rbp)
jmp    122d <random_pass+0xed>
movb   $0x30,-0x1a(%rbp)
movb   $0x39,-0x1b(%rbp)
jmp    122d <random_pass+0xed>
movb   $0x41,-0x1a(%rbp)
movb   $0x5a,-0x1b(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
movsbl %al,%eax
movsbl -0x1b(%rbp),%ecx
movsbl -0x1a(%rbp),%edx
sub    %edx,%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
movsbl -0x1a(%rbp),%eax
add    %eax,%edx
mov    %dl,%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%dl
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1168 <random_pass+0x28>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_pass>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebp
lea    0x0(%rbp,%rbp,1),%edi
call   1050 <malloc@plt>
mov    %rax,(%rsp)
test   %ebp,%ebp
jle    1221 <random_pass+0xe1>
add    $0x7,%r14d
movslq %r14d,%r12
mov    %ebp,%r14d
lea    (%r12,%r12,1),%rax
lea    (%rax,%rax,4),%rbp
xor    %ebx,%ebx
jmp    11b9 <random_pass+0x79>
nopl   0x0(%rax,%rax,1)
mov    $0x39,%r15d
mov    $0x30,%r13d
xor    %eax,%eax
call   1060 <rand@plt>
sub    %r13d,%r15d
movsbl %al,%eax
add    $0x1,%r15d
cwtd
idiv   %r15w
add    %r13d,%edx
mov    (%rsp),%rax
mov    %dl,(%rax,%rbx,1)
add    $0x1,%rbx
add    %r12,%rbp
cmp    %rbx,%r14
je     1224 <random_pass+0xe4>
xor    %edi,%edi
call   1040 <time@plt>
lea    (%rax,%rbp,1),%rdi
call   1030 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
movsbl %al,%eax
imul   $0x56,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %cl,%al
movsbl %al,%eax
cmp    $0x2,%eax
je     1180 <random_pass+0x40>
cmp    $0x1,%eax
jne    1210 <random_pass+0xd0>
mov    $0x7a,%r15d
mov    $0x61,%r13d
jmp    118c <random_pass+0x4c>
cs nopw 0x0(%rax,%rax,1)
mov    $0x5a,%r15d
mov    $0x41,%r13d
jmp    118c <random_pass+0x4c>
xor    %r14d,%r14d
mov    (%rsp),%rax
movb   $0x0,(%rax,%r14,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @random_pass(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
store i32 %0, i32* %3
store i32 %1, i32* %4
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = mul i64 %12, 2
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %7
store i32 0, i32* %6
br label %17
17: ; preds = %58, %2
%18 = load i32, i32* %6
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %61
21: ; preds = %17
%22 = call i64 @time(i32 0)
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 7
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 10
%27 = mul nsw i32 %24, %26
%28 = sext i32 %27 to i64
%29 = add nsw i64 %22, %28
%30 = call i32 @srand(i64 %29)
%31 = call signext i8 (...) @rand()
%32 = sext i8 %31 to i32
%33 = srem i32 %32, 3
store i32 %33, i32* %5
%34 = load i32, i32* %5
switch i32 %34, label %38 [
i32 0, label %35
i32 1, label %36
i32 2, label %37
]
35: ; preds = %21
store i8 65, i8* %9
store i8 90, i8* %10
br label %39
36: ; preds = %21
store i8 97, i8* %9
store i8 122, i8* %10
br label %39
37: ; preds = %21
store i8 48, i8* %9
store i8 57, i8* %10
br label %39
38: ; preds = %21
store i8 65, i8* %9
store i8 90, i8* %10
br label %39
39: ; preds = %38, %37, %36, %35
%40 = call signext i8 (...) @rand()
%41 = sext i8 %40 to i32
%42 = load i8, i8* %10
%43 = sext i8 %42 to i32
%44 = load i8, i8* %9
%45 = sext i8 %44 to i32
%46 = sub nsw i32 %43, %45
%47 = add nsw i32 %46, 1
%48 = srem i32 %41, %47
%49 = load i8, i8* %9
%50 = sext i8 %49 to i32
%51 = add nsw i32 %48, %50
%52 = trunc i32 %51 to i8
store i8 %52, i8* %8
%53 = load i8, i8* %8
%54 = load i8*, i8** %7
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
store i8 %53, i8* %57
br label %58
58: ; preds = %39
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
store i32 %60, i32* %6
br label %17
61: ; preds = %17
%62 = load i8*, i8** %7
%63 = load i32, i32* %6
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
store i8 0, i8* %65
%66 = load i8*, i8** %7
ret i8* %66
}

LLVM IR (-O2):
define i8* @random_pass(i32 %0, i32 %1) {
%3 = shl i32 %0, 1
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to i8*
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %40
7: ; preds = %2
%8 = add nsw i32 %1, 7
%9 = sext i32 %8 to i64
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %7, %23
%12 = phi i64 [ 0, %7 ], [ %36, %23 ]
%13 = tail call i64 @time(i32 0)
%14 = add nuw nsw i64 %12, 10
%15 = mul nsw i64 %14, %9
%16 = add nsw i64 %13, %15
%17 = tail call i32 @srand(i64 %16)
%18 = tail call signext i8 (...) @rand()
%19 = srem i8 %18, 3
%20 = sext i8 %19 to i32
switch i32 %20, label %23 [
i32 2, label %22
i32 1, label %21
]
21: ; preds = %11
br label %23
22: ; preds = %11
br label %23
23: ; preds = %11, %22, %21
%24 = phi i32 [ 48, %22 ], [ 97, %21 ], [ 65, %11 ]
%25 = phi i32 [ 57, %22 ], [ 122, %21 ], [ 90, %11 ]
%26 = tail call signext i8 (...) @rand()
%27 = sub nsw i32 %25, %24
%28 = sext i8 %26 to i16
%29 = trunc i32 %27 to i16
%30 = add nsw i16 %29, 1
%31 = srem i16 %28, %30
%32 = zext i16 %31 to i32
%33 = add nuw nsw i32 %24, %32
%34 = trunc i32 %33 to i8
%35 = getelementptr inbounds i8, i8* %5, i64 %12
store i8 %34, i8* %35
%36 = add nuw nsw i64 %12, 1
%37 = icmp eq i64 %36, %10
br i1 %37, label %38, label %11
38: ; preds = %23
%39 = zext i32 %0 to i64
br label %40
40: ; preds = %2, %38
%41 = phi i64 [ %39, %38 ], [ 0, %2 ]
%42 = getelementptr inbounds i8, i8* %5, i64 %41
store i8 0, i8* %42
ret i8* %5
}