#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  const int key_len = 25;
  int key_count = 1;
  char alphanum_arr[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  int h, i;
  int randnum;
  if (argc > 2) {
    printf("\nError: Improper use of Key Generator.\n\n");
    return 1;
  }
  if (argc == 2) {
    key_count = atoi(argv[1]);
  }
  srand(time(NULL));
  for (h = 0; h < key_count; h++) {
    for (i = 0; i < key_len; i++) {
      randnum = rand() % 36;
      printf("%c", alphanum_arr[randnum]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x19,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe71(%rip),%rsi
mov    $0x25,%edx
call   1050 <memcpy@plt>
cmpl   $0x2,-0x8(%rbp)
jle    11bd <main+0x5d>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1265 <main+0x105>
cmpl   $0x2,-0x8(%rbp)
jne    11d7 <main+0x77>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    125e <main+0xfe>
movl   $0x0,-0x48(%rbp)
cmpl   $0x19,-0x48(%rbp)
jge    1242 <main+0xe2>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x24,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4c(%rbp)
movslq -0x4c(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%esi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1201 <main+0xa1>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11ee <main+0x8e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jl     1183 <main+0x23>
lea    0xeb2(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r14d
jmp    121b <main+0xbb>
mov    $0x1,%r15d
cmp    $0x2,%edi
jne    119a <main+0x3a>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%r15d
xor    %r14d,%r14d
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
test   %r15d,%r15d
jle    121b <main+0xbb>
lea    0xe49(%rip),%rbx
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    $0x19,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
cltq
movsbl (%rax,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11d0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
cmp    %r15d,%r14d
jne    11c0 <main+0x60>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.alphanum_arr = [37 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\00"
@.str = [41 x i8] c"\0AError: Improper use of Key Generator.\0A\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\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 [37 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 25, i32* %6
store i32 1, i32* %7
%12 = bitcast [37 x i8]* %8 to i8*
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %54
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %7
br label %25
25: ; preds = %20, %17
%26 = call i32 @time(i32* null)
%27 = call i32 @srand(i32 %26)
store i32 0, i32* %9
br label %28
28: ; preds = %50, %25
%29 = load i32, i32* %9
%30 = load i32, i32* %7
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %53
32: ; preds = %28
store i32 0, i32* %10
br label %33
33: ; preds = %45, %32
%34 = load i32, i32* %10
%35 = icmp slt i32 %34, 25
br i1 %35, label %36, label %48
36: ; preds = %33
%37 = call i32 (...) @rand()
%38 = srem i32 %37, 36
store i32 %38, i32* %11
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [37 x i8], [37 x i8]* %8, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %36
%46 = load i32, i32* %10
%47 = add nsw i32 %46, 1
store i32 %47, i32* %10
br label %33
48: ; preds = %33
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %50
50: ; preds = %48
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %28
53: ; preds = %28
store i32 0, i32* %3
br label %54
54: ; preds = %53, %15
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@__const.main.alphanum_arr = [37 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\00"
@str = [40 x i8] c"\0AError: Improper use of Key Generator.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
br label %34
6: ; preds = %2
%7 = icmp eq i32 %0, 2
br i1 %7, label %8, label %12
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
br label %12
12: ; preds = %8, %6
%13 = phi i32 [ %11, %8 ], [ 1, %6 ]
%14 = tail call i32 @time(i32* null)
%15 = tail call i32 @srand(i32 %14)
%16 = icmp sgt i32 %13, 0
br i1 %16, label %17, label %34
17: ; preds = %12, %30
%18 = phi i32 [ %32, %30 ], [ 0, %12 ]
br label %19
19: ; preds = %17, %19
%20 = phi i32 [ 0, %17 ], [ %28, %19 ]
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 36
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [37 x i8], [37 x i8]* @__const.main.alphanum_arr, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = tail call i32 @putchar(i32 %26)
%28 = add nuw nsw i32 %20, 1
%29 = icmp eq i32 %28, 25
br i1 %29, label %30, label %19
30: ; preds = %19
%31 = tail call i32 @putchar(i32 10)
%32 = add nuw nsw i32 %18, 1
%33 = icmp eq i32 %32, %13
br i1 %33, label %34, label %17
34: ; preds = %30, %12, %4
%35 = phi i32 [ 1, %4 ], [ 0, %12 ], [ 0, %30 ]
ret i32 %35
}