#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 get_highfreq_letter(char *);
int get_word_count(char *);
int /*<<< orphan*/ gets(char *);
scalar_t__ is_valid_string(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
int main(void) {
  char ch;
  char buffer[200];
  char p_uppercase[200];
  int word_num;
  while (1) {
    printf("> Enter string : ");
    gets(buffer);
    if (is_valid_string(buffer))
      break;
    printf(":: Please type alphabet only!\n\n");
  }
  ch = get_highfreq_letter(buffer);
  printf("\n> The alphabet of the highest frequency : %c\n", ch);
  word_num = get_word_count(buffer);
  printf("> The number of words : %d\n", word_num);
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xd0(%rbp),%rdi
call   1060 <gets@plt>
lea    -0xd0(%rbp),%rdi
call   1030 <is_valid_string@plt>
cmp    $0x0,%rax
je     11a7 <main+0x47>
jmp    11ba <main+0x5a>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1172 <main+0x12>
lea    -0xd0(%rbp),%rdi
call   1070 <get_highfreq_letter@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xd0(%rbp),%rdi
call   1080 <get_word_count@plt>
mov    %eax,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe75(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xd0,%rsp
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
mov    %rbx,%rdi
call   1040 <is_valid_string@plt>
test   %rax,%rax
jne    11e7 <main+0x77>
lea    0xeba(%rip),%r14
lea    0xe50(%rip),%r15
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1070 <gets@plt>
mov    %rbx,%rdi
call   1040 <is_valid_string@plt>
test   %rax,%rax
je     11c0 <main+0x50>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1080 <get_highfreq_letter@plt>
movsbl %al,%esi
lea    0xe16(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1090 <get_word_count@plt>
lea    0xe2f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe3b(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"> Enter string : \00"
@.str.1 = [32 x i8] c":: Please type alphabet only!\0A\0A\00"
@.str.2 = [47 x i8] c"\0A> The alphabet of the highest frequency : %c\0A\00"
@.str.3 = [28 x i8] c"> The number of words : %d\0A\00"
@.str.4 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [200 x i8]
%4 = alloca [200 x i8]
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %0, %14
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%9 = call i32 @gets(i8* %8)
%10 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%11 = call i64 @is_valid_string(i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %6
br label %16
14: ; preds = %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %6
16: ; preds = %13
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%18 = call signext i8 @get_highfreq_letter(i8* %17)
store i8 %18, i8* %2
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%23 = call i32 @get_word_count(i8* %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"> Enter string : \00"
@.str.2 = [47 x i8] c"\0A> The alphabet of the highest frequency : %c\0A\00"
@.str.3 = [28 x i8] c"> The number of words : %d\0A\00"
@.str.4 = [6 x i8] c"pause\00"
@str = [31 x i8] c":: Please type alphabet only!\0A\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i64 @is_valid_string(i8* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %0, %7
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @gets(i8* %2)
%11 = call i64 @is_valid_string(i8* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %7, label %13
13: ; preds = %7, %0
%14 = call signext i8 @get_highfreq_letter(i8* %2)
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = call i32 @get_word_count(i8* %2)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}