#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 ContarCaracter(char *, char);
char getche();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
main() {
  system("title 44_Cascallar_Autrán_Manuel");
  system("color F1");
  system("cls");
  printf("NUMERO DE VECES QUE APARECE UN CARACTER NUNHA CADEA\n");
  printf("===================================================\n");
  char cadea[100];
  char b;
  int conta;
  printf("Introduce unha cadea de caracteres:\n");
  gets(cadea);
  printf("\nIntroduce o caracter que che interesa:\n");
  b = getche();
  conta = ContarCaracter(cadea, b);
  printf(
      "\nO n\243mero de veces que aparece o caracter %c  na cadea \202: %d \n",
      b, conta);
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    0xe9e(%rip),%rdi
call   1030 <system@plt>
lea    0xeb4(%rip),%rdi
call   1030 <system@plt>
lea    0xeb1(%rip),%rdi
call   1030 <system@plt>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1060 <gets@plt>
lea    0xf05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getche@plt>
mov    %al,-0x71(%rbp)
lea    -0x70(%rbp),%rdi
movsbl -0x71(%rbp),%esi
call   1070 <ContarCaracter@plt>
mov    %eax,-0x78(%rbp)
movsbl -0x71(%rbp),%esi
mov    -0x78(%rbp),%edx
lea    0xeff(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf30(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x68,%rsp
lea    0xe93(%rip),%rdi
call   1040 <system@plt>
lea    0xea9(%rip),%rdi
call   1040 <system@plt>
lea    0xea6(%rip),%rdi
call   1040 <system@plt>
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf33(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
lea    0xf40(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <getche@plt>
movsbl %al,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1080 <ContarCaracter@plt>
lea    0xe4f(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe7c(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"title 44_Cascallar_Autr\C3\A1n_Manuel\00"
@.str.1 = [9 x i8] c"color F1\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.3 = [53 x i8] c"NUMERO DE VECES QUE APARECE UN CARACTER NUNHA CADEA\0A\00"
@.str.4 = [53 x i8] c"===================================================\0A\00"
@.str.5 = [37 x i8] c"Introduce unha cadea de caracteres:\0A\00"
@.str.6 = [41 x i8] c"\0AIntroduce o caracter que che interesa:\0A\00"
@.str.7 = [63 x i8] c"\0AO n\A3mero de veces que aparece o caracter %c na cadea \82: %d \0A\00"
@.str.8 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca i8
%3 = alloca i32
%4 = call i32 @system(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
%13 = call signext i8 (...) @getche()
store i8 %13, i8* %2
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%15 = load i8, i8* %2
%16 = call i32 @ContarCaracter(i8* %14, i8 signext %15)
store i32 %16, i32* %3
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0), i32 %18, i32 %19)
%21 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"title 44_Cascallar_Autr\C3\A1n_Manuel\00"
@.str.1 = [9 x i8] c"color F1\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.7 = [63 x i8] c"\0AO n\A3mero de veces que aparece o caracter %c na cadea \82: %d \0A\00"
@.str.8 = [6 x i8] c"pause\00"
@str = [52 x i8] c"NUMERO DE VECES QUE APARECE UN CARACTER NUNHA CADEA\00"
@str.9 = [52 x i8] c"===================================================\00"
@str.10 = [36 x i8] c"Introduce unha cadea de caracteres:\00"
@str.11 = [40 x i8] c"\0AIntroduce o caracter que che interesa:\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = tail call i32 @system(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.9, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.10, i64 0, i64 0))
%9 = call i32 @gets(i8* %7)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.11, i64 0, i64 0))
%11 = call signext i8 (...) @getche()
%12 = call i32 @ContarCaracter(i8* %7, i8 signext %11)
%13 = sext i8 %11 to i32
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.7, i64 0, i64 0), i32 %13, i32 %12)
%15 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}