#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 *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main() {
  char str[30];
  int i, length;
  int characters, digits, alphabets;
  characters = 0;
  digits = 0;
  alphabets = 0;
  printf("Please input a string:");
  gets(str);
  length = strlen(str);
  for (i = 0; i < length; i++) {
    if (str[i] > '0' && str[i] < '9') {
      digits++;
    } else if (str[i] >= 'a' && str[i] <= 'z' ||
               str[i] >= 'A' && str[i] <= 'Z') {
      alphabets++;
    } else {
      characters++;
    }
  }
  printf("%s has %d characters, %d digits, %d alphabets!\n", str, characters,
         digits, alphabets);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1233 <main+0x103>
movslq -0x34(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x30,%eax
jle    11bc <main+0x8c>
movslq -0x34(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x39,%eax
jge    11bc <main+0x8c>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1220 <main+0xf0>
movslq -0x34(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x61,%eax
jl     11e0 <main+0xb0>
movslq -0x34(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x7a,%eax
jle    1204 <main+0xd4>
movslq -0x34(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x41,%eax
jl     1212 <main+0xe2>
movslq -0x34(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x5a,%eax
jg     1212 <main+0xe2>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    121b <main+0xeb>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1220 <main+0xf0>
jmp    1225 <main+0xf5>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    117e <main+0x4e>
lea    -0x30(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    -0x40(%rbp),%ecx
mov    -0x44(%rbp),%r8d
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xec2(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <gets@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    $0x0,%ecx
mov    $0x0,%r8d
test   %eax,%eax
jle    11b5 <main+0x85>
mov    %eax,%eax
xor    %edx,%edx
xor    %r8d,%r8d
xor    %ecx,%ecx
xor    %ebx,%ebx
jmp    118c <main+0x5c>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ecx
add    $0x1,%rdx
cmp    %rdx,%rax
je     11b5 <main+0x85>
movzbl (%rsp,%rdx,1),%esi
lea    -0x31(%rsi),%edi
cmp    $0x7,%dil
jbe    1180 <main+0x50>
and    $0xdf,%sil
add    $0xbf,%sil
cmp    $0x19,%sil
ja     11b0 <main+0x80>
add    $0x1,%r8d
jmp    1183 <main+0x53>
nopl   (%rax)
add    $0x1,%ebx
jmp    1183 <main+0x53>
lea    0xe5b(%rip),%rdi
mov    %rsp,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Please input a string:\00"
@.str.1 = [48 x i8] c"%s has %d characters, %d digits, %d alphabets!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %4
store i32 0, i32* %3
br label %13
13: ; preds = %70, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %73
17: ; preds = %13
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp sgt i32 %22, 48
br i1 %23, label %24, label %34
24: ; preds = %17
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp slt i32 %29, 57
br i1 %30, label %31, label %34
31: ; preds = %24
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %69
34: ; preds = %24, %17
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp sge i32 %39, 97
br i1 %40, label %41, label %48
41: ; preds = %34
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp sle i32 %46, 122
br i1 %47, label %62, label %48
48: ; preds = %41, %34
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp sge i32 %53, 65
br i1 %54, label %55, label %65
55: ; preds = %48
%56 = load i32, i32* %3
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp sle i32 %60, 90
br i1 %61, label %62, label %65
62: ; preds = %55, %41
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
store i32 %64, i32* %7
br label %68
65: ; preds = %55, %48
%66 = load i32, i32* %5
%67 = add nsw i32 %66, 1
store i32 %67, i32* %5
br label %68
68: ; preds = %65, %62
br label %69
69: ; preds = %68, %31
br label %70
70: ; preds = %69
%71 = load i32, i32* %3
%72 = add nsw i32 %71, 1
store i32 %72, i32* %3
br label %13
73: ; preds = %13
%74 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%75 = load i32, i32* %5
%76 = load i32, i32* %6
%77 = load i32, i32* %7
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %74, i32 %75, i32 %76, i32 %77)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Please input a string:\00"
@.str.1 = [48 x i8] c"%s has %d characters, %d digits, %d alphabets!\0A\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %34
7: ; preds = %0
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %7, %28
%10 = phi i64 [ 0, %7 ], [ %32, %28 ]
%11 = phi i32 [ 0, %7 ], [ %31, %28 ]
%12 = phi i32 [ 0, %7 ], [ %30, %28 ]
%13 = phi i32 [ 0, %7 ], [ %29, %28 ]
%14 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %10
%15 = load i8, i8* %14
%16 = add i8 %15, -49
%17 = icmp ult i8 %16, 8
br i1 %17, label %18, label %20
18: ; preds = %9
%19 = add nsw i32 %12, 1
br label %28
20: ; preds = %9
%21 = and i8 %15, -33
%22 = add i8 %21, -65
%23 = icmp ult i8 %22, 26
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = add nsw i32 %11, 1
br label %28
26: ; preds = %20
%27 = add nsw i32 %13, 1
br label %28
28: ; preds = %18, %26, %24
%29 = phi i32 [ %13, %18 ], [ %13, %24 ], [ %27, %26 ]
%30 = phi i32 [ %19, %18 ], [ %12, %24 ], [ %12, %26 ]
%31 = phi i32 [ %11, %18 ], [ %25, %24 ], [ %11, %26 ]
%32 = add nuw nsw i64 %10, 1
%33 = icmp eq i64 %32, %8
br i1 %33, label %34, label %9
34: ; preds = %28, %0
%35 = phi i32 [ 0, %0 ], [ %29, %28 ]
%36 = phi i32 [ 0, %0 ], [ %30, %28 ]
%37 = phi i32 [ 0, %0 ], [ %31, %28 ]
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 %35, i32 %36, i32 %37)
ret i32 0
}