#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 */
typedef int /*<<< orphan*/ numbers;
typedef int /*<<< orphan*/ chars;
typedef int /*<<< orphan*/ alphaNum;
typedef int /*<<< orphan*/ allSigns;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
char *random_string(int, char *, int);
void generatePassword(int length, int option) {
  switch (option) {
  case 0: {
    char allSigns[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrst"
                      "uvwxyz!#$%&/()=?+*-_.:,;@\\|<{}[]";
    int allSignsSize = sizeof(allSigns);
    printf("%s", random_string(length, allSigns, allSignsSize));
  } break;
  case 1: {
    char alphaNum[] =
        "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    int alphaNumSize = sizeof(alphaNum);
    printf("%s", random_string(length, alphaNum, alphaNumSize));
  } break;
  case 2: {
    char numbers[] = "0123456789";
    int numbersSize = sizeof(numbers);
    printf("%s", random_string(length, numbers, numbersSize));
  } break;
  case 3: {
    char chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    int charsSize = sizeof(chars);
    printf("%s", random_string(length, chars, charsSize));
  } break;
  default: {
  } break;
  }
}


x86 assembly (clang, -O0):
<generatePassword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x120(%rbp)
sub    $0x3,%rax
ja     129c <generatePassword+0x16c>
mov    -0x120(%rbp),%rax
lea    0xe9d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x70(%rbp),%rdi
lea    0xe99(%rip),%rsi
mov    $0x59,%edx
call   1050 <memcpy@plt>
movl   $0x59,-0x74(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    -0x74(%rbp),%edx
call   1030 <random_string@plt>
mov    %rax,%rsi
lea    0xf44(%rip),%rdi
call   1040 <printf@plt>
jmp    12a1 <generatePassword+0x171>
lea    -0xc0(%rbp),%rdi
lea    0xeb7(%rip),%rsi
mov    $0x3f,%edx
call   1050 <memcpy@plt>
movl   $0x3f,-0xc4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xc0(%rbp),%rsi
mov    -0xc4(%rbp),%edx
call   1030 <random_string@plt>
mov    %rax,%rsi
lea    0xef9(%rip),%rdi
call   1040 <printf@plt>
jmp    12a1 <generatePassword+0x171>
mov    0xeeb(%rip),%rax
mov    %rax,-0xcf(%rbp)
mov    0xee5(%rip),%ax
mov    %ax,-0xc7(%rbp)
mov    0xeda(%rip),%al
mov    %al,-0xc5(%rbp)
movl   $0xb,-0xd4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xcf(%rbp),%rsi
mov    -0xd4(%rbp),%edx
call   1030 <random_string@plt>
mov    %rax,%rsi
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
jmp    12a1 <generatePassword+0x171>
lea    -0x110(%rbp),%rdi
lea    0xe51(%rip),%rsi
mov    $0x35,%edx
call   1050 <memcpy@plt>
movl   $0x35,-0x114(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    -0x114(%rbp),%edx
call   1030 <random_string@plt>
mov    %rax,%rsi
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
jmp    12a1 <generatePassword+0x171>
jmp    12a1 <generatePassword+0x171>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generatePassword>:
sub    $0x68,%rsp
cmp    $0x3,%esi
ja     123a <generatePassword+0x11a>
mov    %esi,%eax
lea    0xeca(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movups 0xf13(%rip),%xmm0
movups %xmm0,0x49(%rsp)
movaps 0xefe(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xee2(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe8e(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    $0x59,%edx
jmp    1226 <generatePassword+0x106>
movups 0xf05(%rip),%xmm0
movups %xmm0,0x2f(%rsp)
movaps 0xeea(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xece(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    $0x3f,%edx
jmp    1226 <generatePassword+0x106>
movabs $0x3736353433323130,%rax
35 36 37
mov    %rax,(%rsp)
movl   $0x393837,0x7(%rsp)
mov    %rsp,%rsi
mov    $0xb,%edx
jmp    1226 <generatePassword+0x106>
movaps 0xedd(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea5(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x7a797877767574,%rax
mov    %rax,0x2d(%rsp)
mov    %rsp,%rsi
mov    $0x35,%edx
call   1030 <random_string@plt>
lea    0xeb3(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
add    $0x68,%rsp
ret

LLVM IR (-O0):
@__const.generatePassword.allSigns = [89 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&/()=?+*-_.:,;@\\|<{}[]\00"
@.str = [3 x i8] c"%s\00"
@__const.generatePassword.alphaNum = [63 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\00"
@__const.generatePassword.numbers = [11 x i8] c"0123456789\00"
@__const.generatePassword.chars = [53 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\00"
define void @generatePassword(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [89 x i8]
%6 = alloca i32
%7 = alloca [63 x i8]
%8 = alloca i32
%9 = alloca [11 x i8]
%10 = alloca i32
%11 = alloca [53 x i8]
%12 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%13 = load i32, i32* %4
switch i32 %13, label %42 [
i32 0, label %14
i32 1, label %21
i32 2, label %28
i32 3, label %35
]
14: ; preds = %2
%15 = bitcast [89 x i8]* %5 to i8*
store i32 89, i32* %6
%16 = load i32, i32* %3
%17 = getelementptr inbounds [89 x i8], [89 x i8]* %5, i64 0, i64 0
%18 = load i32, i32* %6
%19 = call i8* @random_string(i32 %16, i8* %17, i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %43
21: ; preds = %2
%22 = bitcast [63 x i8]* %7 to i8*
store i32 63, i32* %8
%23 = load i32, i32* %3
%24 = getelementptr inbounds [63 x i8], [63 x i8]* %7, i64 0, i64 0
%25 = load i32, i32* %8
%26 = call i8* @random_string(i32 %23, i8* %24, i32 %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %26)
br label %43
28: ; preds = %2
%29 = bitcast [11 x i8]* %9 to i8*
store i32 11, i32* %10
%30 = load i32, i32* %3
%31 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 0
%32 = load i32, i32* %10
%33 = call i8* @random_string(i32 %30, i8* %31, i32 %32)
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %33)
br label %43
35: ; preds = %2
%36 = bitcast [53 x i8]* %11 to i8*
store i32 53, i32* %12
%37 = load i32, i32* %3
%38 = getelementptr inbounds [53 x i8], [53 x i8]* %11, i64 0, i64 0
%39 = load i32, i32* %12
%40 = call i8* @random_string(i32 %37, i8* %38, i32 %39)
%41 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %40)
br label %43
42: ; preds = %2
br label %43
43: ; preds = %42, %35, %28, %21, %14
ret void
}

LLVM IR (-O2):
@__const.generatePassword.allSigns = [89 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&/()=?+*-_.:,;@\\|<{}[]\00"
@.str = [3 x i8] c"%s\00"
@__const.generatePassword.alphaNum = [63 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\00"
@__const.generatePassword.numbers = [11 x i8] c"0123456789\00"
@__const.generatePassword.chars = [53 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\00"
define void @generatePassword(i32 %0, i32 %1) {
%3 = alloca [89 x i8]
%4 = alloca [63 x i8]
%5 = alloca [11 x i8]
%6 = alloca [53 x i8]
switch i32 %1, label %23 [
i32 0, label %7
i32 1, label %11
i32 2, label %15
i32 3, label %19
]
7: ; preds = %2
%8 = getelementptr inbounds [89 x i8], [89 x i8]* %3, i64 0, i64 0
%9 = call i8* @random_string(i32 %0, i8* %8, i32 89)
%10 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %23
11: ; preds = %2
%12 = getelementptr inbounds [63 x i8], [63 x i8]* %4, i64 0, i64 0
%13 = call i8* @random_string(i32 %0, i8* %12, i32 63)
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %23
15: ; preds = %2
%16 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%17 = call i8* @random_string(i32 %0, i8* %16, i32 11)
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %23
19: ; preds = %2
%20 = getelementptr inbounds [53 x i8], [53 x i8]* %6, i64 0, i64 0
%21 = call i8* @random_string(i32 %0, i8* %20, i32 53)
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %2, %19, %15, %11, %7
ret void
}