#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 /*<<< orphan*/ scanf(char *, char *);
int substitui(char *, char, char);
int main() {
  int cont;
  char txt[15], c1, c2;
  printf("entre com um texto: ");
  gets(txt);
  printf("entre com um letra que estaja na frase: ");
  scanf(" %c", &c1);
  printf("entre com outra letra: ");
  scanf(" %c", &c2);
  cont = substitui(&txt[0], c1, c2);
  printf("\na letra %c foi tracada %d vezes\n", c1, cont);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x13(%rbp),%rdi
call   1040 <gets@plt>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0x15(%rbp),%rsi
call   1050 <scanf@plt>
lea    -0x13(%rbp),%rdi
mov    -0x14(%rbp),%al
movsbl %al,%esi
movsbl -0x15(%rbp),%edx
call   1060 <substitui@plt>
mov    %eax,-0x4(%rbp)
movsbl -0x14(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x9(%rsp),%r14
mov    %r14,%rdi
call   1040 <gets@plt>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec7(%rip),%rbx
lea    0x7(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movsbl 0x7(%rsp),%esi
movsbl 0x8(%rsp),%edx
mov    %r14,%rdi
call   1060 <substitui@plt>
movsbl 0x7(%rsp),%esi
lea    0xe9d(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [21 x i8] c"entre com um texto: \00"
@.str.1 = [41 x i8] c"entre com um letra que estaja na frase: \00"
@.str.2 = [4 x i8] c" %c\00"
@.str.3 = [24 x i8] c"entre com outra letra: \00"
@.str.4 = [34 x i8] c"\0Aa letra %c foi tracada %d vezes\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i8]
%3 = alloca i8
%4 = alloca i8
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%12 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%13 = load i8, i8* %3
%14 = load i8, i8* %4
%15 = call i32 @substitui(i8* %12, i8 signext %13, i8 signext %14)
store i32 %15, i32* %1
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = load i32, i32* %1
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %17, i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"entre com um texto: \00"
@.str.1 = [41 x i8] c"entre com um letra que estaja na frase: \00"
@.str.2 = [4 x i8] c" %c\00"
@.str.3 = [24 x i8] c"entre com outra letra: \00"
@.str.4 = [34 x i8] c"\0Aa letra %c foi tracada %d vezes\0A\00"
define i32 @main() {
%1 = alloca [15 x i8]
%2 = alloca i8
%3 = alloca i8
%4 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %4)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%11 = load i8, i8* %2
%12 = load i8, i8* %3
%13 = call i32 @substitui(i8* %4, i8 signext %11, i8 signext %12)
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %15, i32 %13)
ret i32 0
}