#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 ocurrencias(char *, char);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  printf(
      "\t\tPrograma que imprime el número de ocurrencias en una cadena.\n\n");
  if (argc != 3) {
    printf("El programa requiere de dos parámetros, el primero es la cadena, "
           "el segundo el caracter.\n");
    return -1;
  }
  printf("Las ocurrencias de '%c' en '%s' son %d.\n", argv[2][0], argv[1],
         ocurrencias(argv[1], argv[2][0]));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
je     1168 <main+0x48>
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b8 <main+0x98>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%esi
call   1040 <ocurrencias@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    %eax,%ecx
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x3,%ebp
jne    1178 <main+0x48>
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%rax
movsbl (%rax),%ebp
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <ocurrencias@plt>
lea    0xe9a(%rip),%rdi
xor    %ebx,%ebx
mov    %ebp,%esi
mov    %r14,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1189 <main+0x59>
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [66 x i8] c"\09\09Programa que imprime el n\C3\BAmero de ocurrencias en una cadena.\0A\0A\00"
@.str.1 = [91 x i8] c"El programa requiere de dos par\C3\A1metros, el primero es la cadena, el segundo el caracter.\0A\00"
@.str.2 = [41 x i8] c"Las ocurrencias de '%c' en '%s' son %d.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 3
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %31
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = call i32 @ocurrencias(i8* %23, i8 signext %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %17, i8* %20, i32 %29)
store i32 0, i32* %3
br label %31
31: ; preds = %11, %9
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str.2 = [41 x i8] c"Las ocurrencias de '%c' en '%s' son %d.\0A\00"
@str = [65 x i8] c"\09\09Programa que imprime el n\C3\BAmero de ocurrencias en una cadena.\0A\00"
@str.3 = [90 x i8] c"El programa requiere de dos par\C3\A1metros, el primero es la cadena, el segundo el caracter.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str, i64 0, i64 0))
%4 = icmp eq i32 %0, 3
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([90 x i8], [90 x i8]* @str.3, i64 0, i64 0))
br label %16
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @ocurrencias(i8* %13, i8 signext %10)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %11, i8* %13, i32 %14)
br label %16
16: ; preds = %7, %5
%17 = phi i32 [ -1, %5 ], [ 0, %7 ]
ret i32 %17
}