#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*/ gets(char *);
scalar_t__ isalpha(char);
scalar_t__ isdigit(char);
scalar_t__ islower(char);
scalar_t__ isupper(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  int hasUpper = 0;
  int hasAlpha = 0;
  int hasLower = 0;
  int hasDigit = 0;
  char userChoice;
  char username[25];
  char password[25];
  printf("\nWelcome to the password creator!");
  printf("\nIn this lesson, you will create a password with at least 1 digit, "
         "1 lowercase letter, and 1 uppercase letter");
  do {
    puts("Please enter a username:");
    gets(username);
    printf("\nWelcome, %s. Please enter a password:", username);
    gets(password);
    for (int ctr = 0; ctr < strlen(password); ctr++) {
      printf("\n,Top ctr: %d, hasalpha: %d, hasupper: %d, haslower: %d, "
             "hasdigit: %d",
             ctr, hasAlpha, hasUpper, hasLower, hasDigit);
      hasAlpha += isalpha(password[ctr]);
      hasUpper += isupper(password[ctr]);
      hasLower += islower(password[ctr]);
      hasDigit += isdigit(password[ctr]);
      printf("\n,Bottom ctr: %d, hasalpha: %d, hasupper: %d, haslower: %d, "
             "hasdigit: %d",
             ctr, hasAlpha, hasUpper, hasLower, hasDigit);
    }
    hasAlpha /= 1024;
    hasUpper /= 256;
    hasLower /= 512;
    hasDigit /= 2048;
    printf("\n\n Thank you! Your password has %d letters and %d numbers. %d "
           "are uppercase letters and %d are lowercase letters.",
           hasAlpha, hasDigit, hasUpper, hasLower);
    printf("\nWould you like to go again?");
    scanf(" %c", &userChoice);
  } while (userChoice == 'y' || userChoice == 'Y');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xeb2(%rip),%rdi
call   1050 <puts@plt>
lea    -0x30(%rbp),%rdi
call   1080 <gets@plt>
lea    -0x30(%rbp),%rsi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1080 <gets@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
cmp    %ecx,%eax
jge    12e2 <main+0x152>
mov    -0x54(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movslq -0x54(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%edi
call   1090 <isalpha@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
movslq -0x54(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%edi
call   10a0 <isupper@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
movslq -0x54(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%edi
call   1040 <islower@plt>
mov    %rax,%rcx
movslq -0x10(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x10(%rbp)
movslq -0x54(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x54(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    120e <main+0x7e>
mov    -0xc(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x200,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x800,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0x15(%rbp),%rsi
call   10b0 <scanf@plt>
movsbl -0x15(%rbp),%ecx
mov    $0x1,%al
cmp    $0x79,%ecx
mov    %al,-0x59(%rbp)
je     1372 <main+0x1e2>
movsbl -0x15(%rbp),%eax
cmp    $0x59,%eax
sete   %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    11d7 <main+0x47>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x10(%rsp),%rbp
xor    %r14d,%r14d
movl   $0x0,0xc(%rsp)
xor    %r15d,%r15d
xor    %r13d,%r13d
jmp    1279 <main+0xe9>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0xc(%rsp),%eax
mov    %eax,%ebx
mov    %r13d,%r12d
lea    0x3ff(%rbx),%esi
test   %ebx,%ebx
cmovns %ebx,%esi
sar    $0xa,%esi
lea    0xff(%r14),%ecx
test   %r14d,%r14d
cmovns %r14d,%ecx
sar    $0x8,%ecx
lea    0x1ff(%r15),%r8d
test   %r15d,%r15d
cmovns %r15d,%r8d
sar    $0x9,%r8d
lea    0x7ff(%r12),%edx
test   %r12d,%r12d
cmovns %r12d,%edx
sar    $0xb,%edx
lea    0xf2c(%rip),%rdi
mov    %esi,0xc(%rsp)
mov    %edx,%r13d
mov    %ecx,%r14d
mov    %r8d,%r15d
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xf83(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xf92(%rip),%rdi
lea    0xb(%rsp),%rsi
call   10b0 <scanf@plt>
mov    0xb(%rsp),%al
and    $0xdf,%al
cmp    $0x59,%al
lea    0x10(%rsp),%rbp
jne    1374 <main+0x1e4>
lea    0xe10(%rip),%rdi
call   1050 <puts@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <gets@plt>
lea    0xe10(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbp,%rdi
call   1080 <gets@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    11e0 <main+0x50>
xor    %ebp,%ebp
mov    %r15d,%eax
mov    %r14d,%ecx
mov    0xc(%rsp),%edx
nopw   0x0(%rax,%rax,1)
lea    0xdf9(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%r12d
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %eax,%r8d
mov    %r13d,%r9d
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x10(%rsp,%rbp,1),%edi
call   1090 <isalpha@plt>
mov    %rax,%rbx
add    %r14d,%ebx
movsbl 0x10(%rsp,%rbp,1),%edi
call   10a0 <isupper@plt>
mov    %rax,%r14
add    %r15d,%r14d
movsbl 0x10(%rsp,%rbp,1),%edi
call   1040 <islower@plt>
mov    %rax,%r15
add    %r12d,%r15d
movsbl 0x10(%rsp,%rbp,1),%edi
call   1030 <isdigit@plt>
mov    %rax,%r12
add    %r13d,%r12d
lea    0xde0(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
mov    %r15d,%r8d
mov    %r12d,%r9d
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbp
lea    0x10(%rsp),%rdi
call   1060 <strlen@plt>
movslq %eax,%rsi
mov    %r12d,%r13d
mov    %r15d,%eax
mov    %ebx,%edx
mov    %r14d,%ecx
cmp    %rsi,%rbp
jl     12d0 <main+0x140>
jmp    11e9 <main+0x59>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"\0AWelcome to the password creator!\00"
@.str.1 = [110 x i8] c"\0AIn this lesson, you will create a password with at least 1 digit, 1 lowercase letter, and 1 uppercase letter\00"
@.str.2 = [25 x i8] c"Please enter a username:\00"
@.str.3 = [39 x i8] c"\0AWelcome, %s. Please enter a password:\00"
@.str.4 = [70 x i8] c"\0A,Top ctr: %d, hasalpha: %d, hasupper: %d, haslower: %d, hasdigit: %d\00"
@.str.5 = [73 x i8] c"\0A,Bottom ctr: %d, hasalpha: %d, hasupper: %d, haslower: %d, hasdigit: %d\00"
@.str.6 = [114 x i8] c"\0A\0A Thank you! Your password has %d letters and %d numbers. %d are uppercase letters and %d are lowercase letters.\00"
@.str.7 = [29 x i8] c"\0AWould you like to go again?\00"
@.str.8 = [4 x i8] c" %c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca [25 x i8]
%8 = alloca [25 x i8]
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %101, %0
%13 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 0
%15 = call i32 @gets(i8* %14)
%16 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [25 x i8], [25 x i8]* %8, i64 0, i64 0
%19 = call i32 @gets(i8* %18)
store i32 0, i32* %9
br label %20
20: ; preds = %74, %12
%21 = load i32, i32* %9
%22 = getelementptr inbounds [25 x i8], [25 x i8]* %8, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %77
25: ; preds = %20
%26 = load i32, i32* %9
%27 = load i32, i32* %3
%28 = load i32, i32* %2
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.4, i64 0, i64 0), i32 %26, i32 %27, i32 %28, i32 %29, i32 %30)
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [25 x i8], [25 x i8]* %8, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = call i64 @isalpha(i8 signext %35)
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = add nsw i64 %38, %36
%40 = trunc i64 %39 to i32
store i32 %40, i32* %3
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [25 x i8], [25 x i8]* %8, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = call i64 @isupper(i8 signext %44)
%46 = load i32, i32* %2
%47 = sext i32 %46 to i64
%48 = add nsw i64 %47, %45
%49 = trunc i64 %48 to i32
store i32 %49, i32* %2
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [25 x i8], [25 x i8]* %8, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = call i64 @islower(i8 signext %53)
%55 = load i32, i32* %4
%56 = sext i32 %55 to i64
%57 = add nsw i64 %56, %54
%58 = trunc i64 %57 to i32
store i32 %58, i32* %4
%59 = load i32, i32* %9
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [25 x i8], [25 x i8]* %8, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = call i64 @isdigit(i8 signext %62)
%64 = load i32, i32* %5
%65 = sext i32 %64 to i64
%66 = add nsw i64 %65, %63
%67 = trunc i64 %66 to i32
store i32 %67, i32* %5
%68 = load i32, i32* %9
%69 = load i32, i32* %3
%70 = load i32, i32* %2
%71 = load i32, i32* %4
%72 = load i32, i32* %5
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.5, i64 0, i64 0), i32 %68, i32 %69, i32 %70, i32 %71, i32 %72)
br label %74
74: ; preds = %25
%75 = load i32, i32* %9
%76 = add nsw i32 %75, 1
store i32 %76, i32* %9
br label %20
77: ; preds = %20
%78 = load i32, i32* %3
%79 = sdiv i32 %78, 1024
store i32 %79, i32* %3
%80 = load i32, i32* %2
%81 = sdiv i32 %80, 256
store i32 %81, i32* %2
%82 = load i32, i32* %4
%83 = sdiv i32 %82, 512
store i32 %83, i32* %4
%84 = load i32, i32* %5
%85 = sdiv i32 %84, 2048
store i32 %85, i32* %5
%86 = load i32, i32* %3
%87 = load i32, i32* %5
%88 = load i32, i32* %2
%89 = load i32, i32* %4
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([114 x i8], [114 x i8]* @.str.6, i64 0, i64 0), i32 %86, i32 %87, i32 %88, i32 %89)
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%92 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %6)
br label %93
93: ; preds = %77
%94 = load i8, i8* %6
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 121
br i1 %96, label %101, label %97
97: ; preds = %93
%98 = load i8, i8* %6
%99 = sext i8 %98 to i32
%100 = icmp eq i32 %99, 89
br label %101
101: ; preds = %97, %93
%102 = phi i1 [ true, %93 ], [ %100, %97 ]
br i1 %102, label %12, label %103
103: ; preds = %101
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"\0AWelcome to the password creator!\00"
@.str.1 = [110 x i8] c"\0AIn this lesson, you will create a password with at least 1 digit, 1 lowercase letter, and 1 uppercase letter\00"
@.str.2 = [25 x i8] c"Please enter a username:\00"
@.str.3 = [39 x i8] c"\0AWelcome, %s. Please enter a password:\00"
@.str.4 = [70 x i8] c"\0A,Top ctr: %d, hasalpha: %d, hasupper: %d, haslower: %d, hasdigit: %d\00"
@.str.5 = [73 x i8] c"\0A,Bottom ctr: %d, hasalpha: %d, hasupper: %d, haslower: %d, hasdigit: %d\00"
@.str.6 = [114 x i8] c"\0A\0A Thank you! Your password has %d letters and %d numbers. %d are uppercase letters and %d are lowercase letters.\00"
@.str.7 = [29 x i8] c"\0AWould you like to go again?\00"
@.str.8 = [4 x i8] c" %c\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [25 x i8]
%3 = alloca [25 x i8]
%4 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([110 x i8], [110 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %19, %0
%9 = phi i32 [ 0, %0 ], [ %25, %19 ]
%10 = phi i32 [ 0, %0 ], [ %24, %19 ]
%11 = phi i32 [ 0, %0 ], [ %26, %19 ]
%12 = phi i32 [ 0, %0 ], [ %27, %19 ]
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @gets(i8* %4)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%16 = call i32 @gets(i8* %5)
%17 = call i32 @strlen(i8* %5)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %34, label %19
19: ; preds = %34, %8
%20 = phi i32 [ %9, %8 ], [ %50, %34 ]
%21 = phi i32 [ %10, %8 ], [ %46, %34 ]
%22 = phi i32 [ %11, %8 ], [ %54, %34 ]
%23 = phi i32 [ %12, %8 ], [ %58, %34 ]
%24 = sdiv i32 %21, 1024
%25 = sdiv i32 %20, 256
%26 = sdiv i32 %22, 512
%27 = sdiv i32 %23, 2048
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([114 x i8], [114 x i8]* @.str.6, i64 0, i64 0), i32 %24, i32 %27, i32 %25, i32 %26)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %1)
%31 = load i8, i8* %1
%32 = and i8 %31, -33
%33 = icmp eq i8 %32, 89
br i1 %33, label %8, label %64
34: ; preds = %8, %34
%35 = phi i64 [ %60, %34 ], [ 0, %8 ]
%36 = phi i32 [ %58, %34 ], [ %12, %8 ]
%37 = phi i32 [ %54, %34 ], [ %11, %8 ]
%38 = phi i32 [ %46, %34 ], [ %10, %8 ]
%39 = phi i32 [ %50, %34 ], [ %9, %8 ]
%40 = trunc i64 %35 to i32
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %38, i32 %39, i32 %37, i32 %36)
%42 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 %35
%43 = load i8, i8* %42
%44 = call i64 @isalpha(i8 signext %43)
%45 = trunc i64 %44 to i32
%46 = add i32 %38, %45
%47 = load i8, i8* %42
%48 = call i64 @isupper(i8 signext %47)
%49 = trunc i64 %48 to i32
%50 = add i32 %39, %49
%51 = load i8, i8* %42
%52 = call i64 @islower(i8 signext %51)
%53 = trunc i64 %52 to i32
%54 = add i32 %37, %53
%55 = load i8, i8* %42
%56 = call i64 @isdigit(i8 signext %55)
%57 = trunc i64 %56 to i32
%58 = add i32 %36, %57
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @.str.5, i64 0, i64 0), i32 %40, i32 %46, i32 %50, i32 %54, i32 %58)
%60 = add nuw nsw i64 %35, 1
%61 = call i32 @strlen(i8* %5)
%62 = sext i32 %61 to i64
%63 = icmp slt i64 %60, %62
br i1 %63, label %34, label %19
64: ; preds = %19
ret i32 0
}