#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
char *generate_pass(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
void generate_password(int length, int count) {
  if (length < 6) {
    fprintf(stderr, "Minimum length is 6 characters.\n");
    return;
  }
  for (int i = 0; i < count; i++) {
    char *pass = generate_pass(length);
    if (pass == NULL) {
      fprintf(stderr, "Generating new password failed.\n");
      return;
    }
    printf("%s\n", pass);
    free(pass);
  }
}


x86 assembly (clang, -O0):
<generate_password>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x6,-0x4(%rbp)
jge    1172 <generate_password+0x32>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11dd <generate_password+0x9d>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11dd <generate_password+0x9d>
mov    -0x4(%rbp),%edi
call   1040 <generate_pass@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b6 <generate_password+0x76>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11dd <generate_password+0x9d>
mov    -0x18(%rbp),%rsi
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1179 <generate_password+0x39>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_password>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x6,%edi
jge    116d <generate_password+0x2d>
lea    0xeac(%rip),%r14
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fprintf@plt>
mov    %esi,%ebp
test   %esi,%esi
jle    11b8 <generate_password+0x78>
mov    %edi,%r12d
lea    0xea4(%rip),%r14
lea    0xebe(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12d,%edi
call   1040 <generate_pass@plt>
test   %rax,%rax
je     1154 <generate_password+0x14>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0xffffffff,%ebp
jne    1190 <generate_password+0x50>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"Minimum length is 6 characters.\0A\00"
@.str.1 = [33 x i8] c"Generating new password failed.\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @generate_password(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 6
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %33
12: ; preds = %2
store i32 0, i32* %5
br label %13
13: ; preds = %30, %12
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %33
17: ; preds = %13
%18 = load i32, i32* %3
%19 = call i8* @generate_pass(i32 %18)
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %33
25: ; preds = %17
%26 = load i8*, i8** %6
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %6
%29 = call i32 @free(i8* %28)
br label %30
30: ; preds = %25
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %13
33: ; preds = %9, %22, %13
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"Minimum length is 6 characters.\0A\00"
@.str.1 = [33 x i8] c"Generating new password failed.\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @generate_password(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 6
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %19
6: ; preds = %4, %10
%7 = phi i32 [ %13, %10 ], [ 0, %4 ]
%8 = tail call i8* @generate_pass(i32 %0)
%9 = icmp eq i8* %8, null
br i1 %9, label %15, label %10
10: ; preds = %6
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%12 = tail call i32 @free(i8* %8)
%13 = add nuw nsw i32 %7, 1
%14 = icmp eq i32 %13, %1
br i1 %14, label %19, label %6
15: ; preds = %6, %2
%16 = phi i8* [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), %6 ]
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* %16)
br label %19
19: ; preds = %10, %15, %4
ret void
}