#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdin;
int main() {
  int count = 0, i = 0;
  char str[100], str1;
  printf("Enter the string\n");
  gets(str);
  printf("Enter the character\n");
  fflush(stdin);
  scanf("%c", &str1);
  while (str[i] != '\0') {
    if (str[i] == str1) {
      count++;
    }
    i++;
  }
  printf("The frequency of character in string is %d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <gets@plt>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    0xe8d(%rip),%rdi
lea    -0x71(%rbp),%rsi
call   1060 <scanf@plt>
movslq -0xc(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11e1 <main+0xa1>
movslq -0xc(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
movsbl -0x71(%rbp),%ecx
cmp    %ecx,%eax
jne    11d3 <main+0x93>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a3 <main+0x63>
mov    -0x8(%rbp),%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x78,%rsp
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rdi
call   1050 <gets@plt>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0xe75(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x10(%rsp),%dl
test   %dl,%dl
je     11c7 <main+0x77>
mov    0xf(%rsp),%al
lea    0x11(%rsp),%rcx
xor    %esi,%esi
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
cmp    %al,%dl
sete   %dil
add    %edi,%esi
movzbl (%rcx),%edx
add    $0x1,%rcx
test   %dl,%dl
jne    11b0 <main+0x60>
jmp    11c9 <main+0x79>
xor    %esi,%esi
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter the string\0A\00"
@.str.1 = [21 x i8] c"Enter the character\0A\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [44 x i8] c"The frequency of character in string is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = call i32 @gets(i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = call i32 @fflush(i32 %10)
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
br label %13
13: ; preds = %32, %0
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %35
20: ; preds = %13
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = load i8, i8* %5
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %25, %27
br i1 %28, label %29, label %32
29: ; preds = %20
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %2
br label %32
32: ; preds = %29, %20
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %13
35: ; preds = %13
%36 = load i32, i32* %2
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %36)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [44 x i8] c"The frequency of character in string is %d\0A\00"
@str = [17 x i8] c"Enter the string\00"
@str.4 = [20 x i8] c"Enter the character\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca i8
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%5 = call i32 @gets(i8* %3)
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.4, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fflush(i32 %7)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%10 = load i8, i8* %3
%11 = icmp eq i8 %10, 0
br i1 %11, label %25, label %12
12: ; preds = %0
%13 = load i8, i8* %2
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %21, %14 ]
%16 = phi i8 [ %10, %12 ], [ %23, %14 ]
%17 = phi i32 [ 0, %12 ], [ %20, %14 ]
%18 = icmp eq i8 %16, %13
%19 = zext i1 %18 to i32
%20 = add nuw nsw i32 %17, %19
%21 = add nuw nsw i64 %15, 1
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %14
25: ; preds = %14, %0
%26 = phi i32 [ 0, %0 ], [ %20, %14 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %26)
ret i32 0
}