#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 */
char getchar();
scalar_t__ isdigit(char);
scalar_t__ islower(char);
scalar_t__ isspace(char);
scalar_t__ isupper(char);
int /*<<< orphan*/ printf(char *, ...);
char tolower(char);
char toupper(char);
int main() {
  char input[2048];
  char output[2048];
  char c;
  int outWhite = 0;
  int outDigits = 0;
  int outLower = 0;
  int outUpper = 0;
  int i = 0;
  printf("Enter any input from the keyboard. To end input z\n\n");
  printf("(This is what the user enters)\n");
  c = getchar();
  while (c != 'z') {
    if (isspace(c) != 0) {
      outWhite += 1;
    } else if (isdigit(c) != 0) {
      outDigits += 1;
    } else if (islower(c) != 0) {
      outLower += 1;
      c = toupper(c);
    } else if (isupper(c) != 0) {
      outUpper += 1;
      c = tolower(c);
    } else {
    }
    output[i] = c;
    i++;
    c = getchar();
  }
  output[i] = '\0';
  printf("\n(This is what the program outputs)\n%s", output);
  printf("\nThe number of whitespace characters is: %d\n", outWhite);
  printf("The number of digits is: %d\n", outDigits);
  printf("The number of lowercase characters is: %d\n", outLower);
  printf("The number of uppercase characters is: %d\n\n", outUpper);
  printf("Goodbye\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1018(%rbp)
movl   $0x0,-0x101c(%rbp)
movl   $0x0,-0x1020(%rbp)
movl   $0x0,-0x1024(%rbp)
movl   $0x0,-0x1028(%rbp)
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %al,-0x1011(%rbp)
movsbl -0x1011(%rbp),%eax
cmp    $0x7a,%eax
je     1312 <main+0x192>
movsbl -0x1011(%rbp),%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
je     1227 <main+0xa7>
mov    -0x1018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1018(%rbp)
jmp    12dd <main+0x15d>
movsbl -0x1011(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1251 <main+0xd1>
mov    -0x101c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x101c(%rbp)
jmp    12d8 <main+0x158>
movsbl -0x1011(%rbp),%edi
call   1040 <islower@plt>
cmp    $0x0,%rax
je     128d <main+0x10d>
mov    -0x1020(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1020(%rbp)
movsbl -0x1011(%rbp),%edi
call   1050 <toupper@plt>
mov    %al,-0x1011(%rbp)
jmp    12d3 <main+0x153>
movsbl -0x1011(%rbp),%edi
call   10a0 <isupper@plt>
cmp    $0x0,%rax
je     12c9 <main+0x149>
mov    -0x1024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1024(%rbp)
movsbl -0x1011(%rbp),%edi
call   1090 <tolower@plt>
mov    %al,-0x1011(%rbp)
jmp    12ce <main+0x14e>
jmp    12ce <main+0x14e>
jmp    12d3 <main+0x153>
jmp    12d8 <main+0x158>
jmp    12dd <main+0x15d>
mov    -0x1011(%rbp),%cl
movslq -0x1028(%rbp),%rax
mov    %cl,-0x1010(%rbp,%rax,1)
mov    -0x1028(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1028(%rbp)
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %al,-0x1011(%rbp)
jmp    11ed <main+0x6d>
movslq -0x1028(%rbp),%rax
movb   $0x0,-0x1010(%rbp,%rax,1)
lea    -0x1010(%rbp),%rsi
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1018(%rbp),%esi
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x101c(%rbp),%esi
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1020(%rbp),%esi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1024(%rbp),%esi
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
lea    0xf20(%rip),%rdi
call   1060 <puts@plt>
lea    0xf47(%rip),%rdi
call   1060 <puts@plt>
xor    %r13d,%r13d
xor    %eax,%eax
call   1090 <getchar@plt>
cmp    $0x7a,%al
jne    11d6 <main+0x46>
xor    %r12d,%r12d
xor    %r15d,%r15d
xor    %ebx,%ebx
xor    %eax,%eax
jmp    1267 <main+0xd7>
mov    %eax,%ebx
xor    %r14d,%r14d
movl   $0x0,0xc(%rsp)
xor    %r15d,%r15d
xor    %r12d,%r12d
xor    %r13d,%r13d
jmp    120a <main+0x7a>
xchg   %ax,%ax
add    $0x1,%r13d
mov    %bl,0x10(%rsp,%r14,1)
add    $0x1,%r14
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %eax,%ebx
cmp    $0x7a,%al
je     1260 <main+0xd0>
movsbl %bl,%ebp
mov    %ebp,%edi
call   1080 <isspace@plt>
test   %rax,%rax
jne    11f0 <main+0x60>
mov    %ebp,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     122b <main+0x9b>
add    $0x1,%r12d
jmp    11f4 <main+0x64>
mov    %ebp,%edi
call   1040 <islower@plt>
test   %rax,%rax
je     1244 <main+0xb4>
add    $0x1,%r15d
mov    %ebp,%edi
call   1050 <toupper@plt>
jmp    125c <main+0xcc>
mov    %ebp,%edi
call   10b0 <isupper@plt>
test   %rax,%rax
je     11f4 <main+0x64>
addl   $0x1,0xc(%rsp)
mov    %ebp,%edi
call   10a0 <tolower@plt>
mov    %eax,%ebx
jmp    11f4 <main+0x64>
mov    %r14d,%eax
mov    0xc(%rsp),%ebx
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xd8d(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xda1(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdbd(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdc9(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xde3(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe51(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Enter any input from the keyboard. To end input z\0A\0A\00"
@.str.1 = [32 x i8] c"(This is what the user enters)\0A\00"
@.str.2 = [39 x i8] c"\0A(This is what the program outputs)\0A%s\00"
@.str.3 = [45 x i8] c"\0AThe number of whitespace characters is: %d\0A\00"
@.str.4 = [29 x i8] c"The number of digits is: %d\0A\00"
@.str.5 = [43 x i8] c"The number of lowercase characters is: %d\0A\00"
@.str.6 = [44 x i8] c"The number of uppercase characters is: %d\0A\0A\00"
@.str.7 = [9 x i8] c"Goodbye\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2048 x i8]
%3 = alloca [2048 x i8]
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%12 = call signext i8 (...) @getchar()
store i8 %12, i8* %4
br label %13
13: ; preds = %53, %0
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 122
br i1 %16, label %17, label %61
17: ; preds = %13
%18 = load i8, i8* %4
%19 = call i64 @isspace(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %53
24: ; preds = %17
%25 = load i8, i8* %4
%26 = call i64 @isdigit(i8 signext %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %52
31: ; preds = %24
%32 = load i8, i8* %4
%33 = call i64 @islower(i8 signext %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
%38 = load i8, i8* %4
%39 = call signext i8 @toupper(i8 signext %38)
store i8 %39, i8* %4
br label %51
40: ; preds = %31
%41 = load i8, i8* %4
%42 = call i64 @isupper(i8 signext %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
%47 = load i8, i8* %4
%48 = call signext i8 @tolower(i8 signext %47)
store i8 %48, i8* %4
br label %50
49: ; preds = %40
br label %50
50: ; preds = %49, %44
br label %51
51: ; preds = %50, %35
br label %52
52: ; preds = %51, %28
br label %53
53: ; preds = %52, %21
%54 = load i8, i8* %4
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %56
store i8 %54, i8* %57
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
store i32 %59, i32* %9
%60 = call signext i8 (...) @getchar()
store i8 %60, i8* %4
br label %13
61: ; preds = %13
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %63
store i8 0, i8* %64
%65 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %65)
%67 = load i32, i32* %5
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 %67)
%69 = load i32, i32* %6
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %69)
%71 = load i32, i32* %7
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i32 %71)
%73 = load i32, i32* %8
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %73)
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [39 x i8] c"\0A(This is what the program outputs)\0A%s\00"
@.str.3 = [45 x i8] c"\0AThe number of whitespace characters is: %d\0A\00"
@.str.4 = [29 x i8] c"The number of digits is: %d\0A\00"
@.str.5 = [43 x i8] c"The number of lowercase characters is: %d\0A\00"
@.str.6 = [44 x i8] c"The number of uppercase characters is: %d\0A\0A\00"
@str = [51 x i8] c"Enter any input from the keyboard. To end input z\0A\00"
@str.8 = [31 x i8] c"(This is what the user enters)\00"
@str.9 = [8 x i8] c"Goodbye\00"
define i32 @main() {
%1 = alloca [2048 x i8]
%2 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0))
%5 = tail call signext i8 (...) @getchar()
%6 = icmp eq i8 %5, 122
br i1 %6, label %47, label %7
7: ; preds = %0, %35
%8 = phi i64 [ %42, %35 ], [ 0, %0 ]
%9 = phi i32 [ %40, %35 ], [ 0, %0 ]
%10 = phi i32 [ %39, %35 ], [ 0, %0 ]
%11 = phi i32 [ %38, %35 ], [ 0, %0 ]
%12 = phi i32 [ %37, %35 ], [ 0, %0 ]
%13 = phi i8 [ %43, %35 ], [ %5, %0 ]
%14 = tail call i64 @isspace(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %7
%17 = add nsw i32 %12, 1
br label %35
18: ; preds = %7
%19 = tail call i64 @isdigit(i8 signext %13)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = add nsw i32 %11, 1
br label %35
23: ; preds = %18
%24 = tail call i64 @islower(i8 signext %13)
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = add nsw i32 %10, 1
%28 = tail call signext i8 @toupper(i8 signext %13)
br label %35
29: ; preds = %23
%30 = tail call i64 @isupper(i8 signext %13)
%31 = icmp eq i64 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = add nsw i32 %9, 1
%34 = tail call signext i8 @tolower(i8 signext %13)
br label %35
35: ; preds = %21, %32, %29, %26, %16
%36 = phi i8 [ %13, %16 ], [ %13, %21 ], [ %28, %26 ], [ %34, %32 ], [ %13, %29 ]
%37 = phi i32 [ %17, %16 ], [ %12, %21 ], [ %12, %26 ], [ %12, %32 ], [ %12, %29 ]
%38 = phi i32 [ %11, %16 ], [ %22, %21 ], [ %11, %26 ], [ %11, %32 ], [ %11, %29 ]
%39 = phi i32 [ %10, %16 ], [ %10, %21 ], [ %27, %26 ], [ %10, %32 ], [ %10, %29 ]
%40 = phi i32 [ %9, %16 ], [ %9, %21 ], [ %9, %26 ], [ %33, %32 ], [ %9, %29 ]
%41 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 %8
store i8 %36, i8* %41
%42 = add nuw i64 %8, 1
%43 = tail call signext i8 (...) @getchar()
%44 = icmp eq i8 %43, 122
br i1 %44, label %45, label %7
45: ; preds = %35
%46 = and i64 %42, 4294967295
br label %47
47: ; preds = %45, %0
%48 = phi i32 [ 0, %0 ], [ %37, %45 ]
%49 = phi i32 [ 0, %0 ], [ %38, %45 ]
%50 = phi i32 [ 0, %0 ], [ %39, %45 ]
%51 = phi i32 [ 0, %0 ], [ %40, %45 ]
%52 = phi i64 [ 0, %0 ], [ %46, %45 ]
%53 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 %52
store i8 0, i8* %53
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %49)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i32 %50)
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %51)
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.9, i64 0, i64 0))
ret i32 0
}