#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 */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int rand();
int /*<<< orphan*/ srand(scalar_t__);
int strlen(char *);
scalar_t__ time(int /*<<< orphan*/);
int main(int __argc, char **__argv) {
  int i, n, t, v;
  char pass[1000];
  struct timeval tv;
  char *data[] = {"qQwWrRtTpPsSdDfFgGjJhHklLZzXxcCvVbBnNmM", "eEyYuUiIoOaA"};
  gettimeofday(&tv, 0);
  srand(time(0) + tv.tv_usec);
  if (__argc != 2) {
    printf("Usage: %s mask\n", __argv[0]);
    return -1;
  }
  n = strlen(__argv[1]);
  i = 0;
  for (i = 0; i < n; i++) {
    t = __argv[1][i] - '0';
    v = rand() % strlen(data[t]);
    pass[i] = data[t][v];
  }
  pass[i] = 0;
  printf("%s", pass);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2c90(%rip),%rax
mov    %rax,-0x430(%rbp)
mov    0x2c8a(%rip),%rax
mov    %rax,-0x428(%rbp)
lea    -0x418(%rbp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %rax,%rdi
add    -0x418(%rbp),%rdi
call   1060 <srand@plt>
cmpl   $0x2,-0x8(%rbp)
je     11e2 <main+0x82>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a0 <main+0x140>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    127a <main+0x11a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    %eax,-0x434(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x430(%rbp,%rax,8),%rdi
ff
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x434(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x430(%rbp,%rax,8),%rax
ff
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1200 <main+0xa0>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rsi
lea    0xdb1(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f8,%rsp
mov    %rsi,%r15
mov    %edi,%ebp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
xor    %edi,%edi
call   1070 <time@plt>
add    0x8(%rsp),%rax
mov    %rax,%rdi
call   1060 <srand@plt>
cmp    $0x2,%ebp
jne    1202 <main+0xa2>
mov    0x8(%r15),%rdi
call   1030 <strlen@plt>
xor    %ebx,%ebx
test   %eax,%eax
jle    1218 <main+0xb8>
mov    %eax,%r12d
lea    0x2c5c(%rip),%r13
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    0x8(%r15),%rax
movsbq (%rax,%r14,1),%rbx
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ebp
mov    -0x180(%r13,%rbx,8),%rbx
ff
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
movslq %edx,%rax
movzbl (%rbx,%rax,1),%eax
mov    %al,0x10(%rsp,%r14,1)
add    $0x1,%r14
cmp    %r14,%r12
jne    11c0 <main+0x60>
xor    %ebx,%ebx
jmp    121b <main+0xbb>
mov    (%r15),%rsi
lea    0xe29(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%ebx
jmp    1232 <main+0xd2>
xor    %r12d,%r12d
movb   $0x0,0x10(%rsp,%r12,1)
lea    0xe1d(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i64 }
@.str = [40 x i8] c"qQwWrRtTpPsSdDfFgGjJhHklLZzXxcCvVbBnNmM\00"
@.str.1 = [13 x i8] c"eEyYuUiIoOaA\00"
@__const.main.data = [2 x i8*] [i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i32 0, i32 0)]
@.str.2 = [16 x i8] c"Usage: %s mask\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [1000 x i8]
%11 = alloca %struct.timeval
%12 = alloca [2 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = bitcast [2 x i8*]* %12 to i8*
%14 = call i32 @gettimeofday(%struct.timeval* %11, i32 0)
%15 = call i64 @time(i32 0)
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%17 = load i64, i64* %16
%18 = add nsw i64 %15, %17
%19 = call i32 @srand(i64 %18)
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 2
br i1 %21, label %22, label %27
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %25)
store i32 -1, i32* %3
br label %73
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @strlen(i8* %30)
store i32 %31, i32* %7
store i32 0, i32* %6
store i32 0, i32* %6
br label %32
32: ; preds = %64, %27
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %67
36: ; preds = %32
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = sub nsw i32 %44, 48
store i32 %45, i32* %8
%46 = call i32 (...) @rand()
%47 = load i32, i32* %8
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @strlen(i8* %50)
%52 = srem i32 %46, %51
store i32 %52, i32* %9
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 %54
%56 = load i8*, i8** %55
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 %62
store i8 %60, i8* %63
br label %64
64: ; preds = %36
%65 = load i32, i32* %6
%66 = add nsw i32 %65, 1
store i32 %66, i32* %6
br label %32
67: ; preds = %32
%68 = load i32, i32* %6
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 %69
store i8 0, i8* %70
%71 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%72 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %71)
store i32 0, i32* %3
br label %73
73: ; preds = %67, %22
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
%struct.timeval = type { i64 }
@.str = [40 x i8] c"qQwWrRtTpPsSdDfFgGjJhHklLZzXxcCvVbBnNmM\00"
@.str.1 = [13 x i8] c"eEyYuUiIoOaA\00"
@__const.main.data = [2 x i8*] [i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i32 0, i32 0)]
@.str.2 = [16 x i8] c"Usage: %s mask\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x i8]
%4 = alloca %struct.timeval
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.timeval* %4 to i8*
%7 = call i32 @gettimeofday(%struct.timeval* %4, i32 0)
%8 = call i64 @time(i32 0)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%10 = load i64, i64* %9
%11 = add nsw i64 %10, %8
%12 = call i32 @srand(i64 %11)
%13 = icmp eq i32 %0, 2
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = load i8*, i8** %1
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %48
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @strlen(i8* %19)
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %44
22: ; preds = %17
%23 = zext i32 %20 to i64
br label %24
24: ; preds = %22, %24
%25 = phi i64 [ 0, %22 ], [ %40, %24 ]
%26 = load i8*, i8** %18
%27 = getelementptr inbounds i8, i8* %26, i64 %25
%28 = load i8, i8* %27
%29 = sext i8 %28 to i64
%30 = add nsw i64 %29, -48
%31 = call i32 (...) @rand()
%32 = getelementptr inbounds [2 x i8*], [2 x i8*]* @__const.main.data, i64 0, i64 %30
%33 = load i8*, i8** %32
%34 = call i32 @strlen(i8* %33)
%35 = srem i32 %31, %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
%38 = load i8, i8* %37
%39 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %25
store i8 %38, i8* %39
%40 = add nuw nsw i64 %25, 1
%41 = icmp eq i64 %40, %23
br i1 %41, label %42, label %24
42: ; preds = %24
%43 = zext i32 %20 to i64
br label %44
44: ; preds = %17, %42
%45 = phi i64 [ %43, %42 ], [ 0, %17 ]
%46 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %45
store i8 0, i8* %46
%47 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %5)
br label %48
48: ; preds = %44, %14
%49 = phi i32 [ -1, %14 ], [ 0, %44 ]
ret i32 %49
}