#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 /*<<< orphan*/ EXIT_FAILURE;
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ getPwd(int);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ puts(int /*<<< orphan*/);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int length, repetitions;
  int opt;
  int i;
  srand(time(0));
  if (argc < 3) {
    fprintf(stderr, "Usage: %s -l length -n number of passwords\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  while ((opt = getopt(argc, argv, "l:n:")) != -1) {
    switch (opt) {
    case 'n':
      repetitions = atoi(optarg);
      break;
    case 'l':
      length = atoi(optarg);
      break;
    default:
      fprintf(stderr, "Usage: %s -l length -n number of passwords\n", argv[0]);
      exit(EXIT_FAILURE);
    }
  }
  for (i = 0; i < repetitions; i++)
    puts(getPwd(length));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
cmpl   $0x3,-0x8(%rbp)
jge    11d8 <main+0x58>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe3b(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    11dd <main+0x5d>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe41(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     127c <main+0xfc>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x6c,%eax
je     1237 <main+0xb7>
jmp    1210 <main+0x90>
mov    -0x24(%rbp),%eax
sub    $0x6e,%eax
jne    124d <main+0xcd>
jmp    1221 <main+0xa1>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
call   1080 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    1277 <main+0xf7>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    1277 <main+0xf7>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd9c(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    11dd <main+0x5d>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    12ac <main+0x12c>
mov    -0x14(%rbp),%edi
call   10a0 <getPwd@plt>
mov    %eax,%edi
call   1030 <puts@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1283 <main+0x103>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
cmp    $0x3,%r15d
jl     1224 <main+0xa4>
lea    0xe80(%rip),%r12
mov    0x2e45(%rip),%r13
jmp    11cb <main+0x4b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%r13),%edi
call   1080 <atoi@plt>
mov    %eax,%ebx
mov    %r15d,%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   1070 <getopt@plt>
cmp    $0x6c,%eax
je     11c0 <main+0x40>
cmp    $0x6e,%eax
jne    11f0 <main+0x70>
mov    0x0(%r13),%edi
call   1080 <atoi@plt>
mov    %eax,%ebp
jmp    11cb <main+0x4b>
cmp    $0xffffffff,%eax
jne    1224 <main+0xa4>
test   %ebp,%ebp
jle    1213 <main+0x93>
nopl   0x0(%rax)
mov    %ebx,%edi
call   10a0 <getPwd@plt>
mov    %eax,%edi
call   1030 <puts@plt>
add    $0xffffffff,%ebp
jne    1200 <main+0x80>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xdc9(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"Usage: %s -l length -n number of passwords\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"l:n:\00"
@optarg = global i32 0
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @time(i32 0)
%11 = call i32 @srand(i32 %10)
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
br label %23
23: ; preds = %44, %22
%24 = load i32, i32* %4
%25 = load i8**, i8*** %5
%26 = call i32 @getopt(i32 %24, i8** %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 %26, i32* %8
%27 = icmp ne i32 %26, -1
br i1 %27, label %28, label %45
28: ; preds = %23
%29 = load i32, i32* %8
switch i32 %29, label %36 [
i32 110, label %30
i32 108, label %33
]
30: ; preds = %28
%31 = load i32, i32* @optarg
%32 = call i32 @atoi(i32 %31)
store i32 %32, i32* %7
br label %44
33: ; preds = %28
%34 = load i32, i32* @optarg
%35 = call i32 @atoi(i32 %34)
store i32 %35, i32* %6
br label %44
36: ; preds = %28
%37 = load i32, i32* @stderr
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %40)
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %33, %30
br label %23
45: ; preds = %23
store i32 0, i32* %9
br label %46
46: ; preds = %54, %45
%47 = load i32, i32* %9
%48 = load i32, i32* %7
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %57
50: ; preds = %46
%51 = load i32, i32* %6
%52 = call i32 @getPwd(i32 %51)
%53 = call i32 @puts(i32 %52)
br label %54
54: ; preds = %50
%55 = load i32, i32* %9
%56 = add nsw i32 %55, 1
store i32 %56, i32* %9
br label %46
57: ; preds = %46
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"Usage: %s -l length -n number of passwords\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"l:n:\00"
@optarg = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @time(i32 0)
%4 = tail call i32 @srand(i32 %3)
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %20
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %20, %23
%13 = phi i32 [ %25, %23 ], [ %22, %20 ]
%14 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
switch i32 %14, label %26 [
i32 -1, label %15
i32 110, label %17
i32 108, label %23
]
15: ; preds = %12
%16 = icmp sgt i32 %21, 0
br i1 %16, label %32, label %38
17: ; preds = %12
%18 = load i32, i32* @optarg
%19 = tail call i32 @atoi(i32 %18)
br label %20
20: ; preds = %2, %17
%21 = phi i32 [ %19, %17 ], [ undef, %2 ]
%22 = phi i32 [ %13, %17 ], [ undef, %2 ]
br label %12
23: ; preds = %12
%24 = load i32, i32* @optarg
%25 = tail call i32 @atoi(i32 %24)
br label %12
26: ; preds = %12
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %1
%29 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %15, %32
%33 = phi i32 [ %36, %32 ], [ 0, %15 ]
%34 = tail call i32 @getPwd(i32 %13)
%35 = tail call i32 @puts(i32 %34)
%36 = add nuw nsw i32 %33, 1
%37 = icmp eq i32 %36, %21
br i1 %37, label %38, label %32
38: ; preds = %32, %15
ret i32 0
}