#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char const *argv[]) {
  char A[51];
  char B[4];
  int i, ocorrencias = 0;
  printf("Digite a palavra: ");
  scanf("%s", A);
  printf("Digite o texto a ser procurado: ");
  scanf("%s", B);
  for (i = 2; A[i] != '\0'; i++) {
    printf("%d = %c%c%c\n", i, A[i - 2], A[i - 1], A[i]);
    if (A[i - 2] == B[0] && A[i - 1] == B[1] && A[i] == B[2]) {
      ocorrencias++;
    }
  }
  printf("Palavra: %s\n", A);
  printf("Texto para procura: %s\n", B);
  printf("Ocorrencias: %d\n", ocorrencias);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x5c(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    0xebd(%rip),%rdi
call   1040 <scanf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x54(%rbp),%rsi
lea    0xe9f(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x2,-0x58(%rbp)
movslq -0x58(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     122a <main+0x10a>
mov    -0x58(%rbp),%esi
mov    -0x58(%rbp),%eax
sub    $0x2,%eax
cltq
movsbl -0x50(%rbp,%rax,1),%edx
mov    -0x58(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x50(%rbp,%rax,1),%ecx
movslq -0x58(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%r8d
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x58(%rbp),%eax
sub    $0x2,%eax
cltq
movsbl -0x50(%rbp,%rax,1),%eax
movsbl -0x54(%rbp),%ecx
cmp    %ecx,%eax
jne    1217 <main+0xf7>
mov    -0x58(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x50(%rbp,%rax,1),%eax
movsbl -0x53(%rbp),%ecx
cmp    %ecx,%eax
jne    1217 <main+0xf7>
movslq -0x58(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
movsbl -0x52(%rbp),%ecx
cmp    %ecx,%eax
jne    1217 <main+0xf7>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    121c <main+0xfc>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1180 <main+0x60>
lea    -0x50(%rbp),%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x54(%rbp),%rsi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x5c(%rbp),%esi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
lea    0xecf(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed1(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0x12(%rsp),%al
test   %al,%al
je     11e9 <main+0xc9>
lea    0x12(%rsp),%rbx
mov    $0x3,%ebp
lea    0xeb4(%rip),%r15
xor    %r14d,%r14d
jmp    11a7 <main+0x87>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
lea    (%rsp,%rax,1),%rbx
add    $0x10,%rbx
movzbl 0x10(%rsp,%rax,1),%eax
add    $0x1,%rbp
test   %al,%al
je     11e9 <main+0xc9>
movsbl %al,%r8d
movsbl 0xd(%rsp,%rbp,1),%edx
movsbl 0xe(%rsp,%rbp,1),%ecx
lea    -0x1(%rbp),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0xd(%rsp,%rbp,1),%eax
cmp    0xc(%rsp),%al
jne    1190 <main+0x70>
movzbl 0xe(%rsp,%rbp,1),%eax
cmp    0xd(%rsp),%al
jne    1190 <main+0x70>
movzbl (%rbx),%eax
xor    %ecx,%ecx
cmp    0xe(%rsp),%al
sete   %cl
add    %ecx,%r14d
jmp    1190 <main+0x70>
lea    0xe54(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe4e(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe53(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Digite a palavra: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [33 x i8] c"Digite o texto a ser procurado: \00"
@.str.3 = [13 x i8] c"%d = %c%c%c\0A\00"
@.str.4 = [13 x i8] c"Palavra: %s\0A\00"
@.str.5 = [24 x i8] c"Texto para procura: %s\0A\00"
@.str.6 = [17 x i8] c"Ocorrencias: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [51 x i8]
%7 = alloca [4 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [51 x i8], [51 x i8]* %6, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
store i32 2, i32* %8
br label %16
16: ; preds = %78, %2
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [51 x i8], [51 x i8]* %6, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %81
23: ; preds = %16
%24 = load i32, i32* %8
%25 = load i32, i32* %8
%26 = sub nsw i32 %25, 2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [51 x i8], [51 x i8]* %6, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = load i32, i32* %8
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [51 x i8], [51 x i8]* %6, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [51 x i8], [51 x i8]* %6, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %24, i32 %30, i32 %36, i32 %41)
%43 = load i32, i32* %8
%44 = sub nsw i32 %43, 2
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [51 x i8], [51 x i8]* %6, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %48, %51
br i1 %52, label %53, label %77
53: ; preds = %23
%54 = load i32, i32* %8
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [51 x i8], [51 x i8]* %6, i64 0, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 1
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %59, %62
br i1 %63, label %64, label %77
64: ; preds = %53
%65 = load i32, i32* %8
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [51 x i8], [51 x i8]* %6, i64 0, i64 %66
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 2
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %69, %72
br i1 %73, label %74, label %77
74: ; preds = %64
%75 = load i32, i32* %9
%76 = add nsw i32 %75, 1
store i32 %76, i32* %9
br label %77
77: ; preds = %74, %64, %53, %23
br label %78
78: ; preds = %77
%79 = load i32, i32* %8
%80 = add nsw i32 %79, 1
store i32 %80, i32* %8
br label %16
81: ; preds = %16
%82 = getelementptr inbounds [51 x i8], [51 x i8]* %6, i64 0, i64 0
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %82)
%84 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %84)
%86 = load i32, i32* %9
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %86)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Digite a palavra: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [33 x i8] c"Digite o texto a ser procurado: \00"
@.str.3 = [13 x i8] c"%d = %c%c%c\0A\00"
@.str.4 = [13 x i8] c"Palavra: %s\0A\00"
@.str.5 = [24 x i8] c"Texto para procura: %s\0A\00"
@.str.6 = [17 x i8] c"Ocorrencias: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [51 x i8]
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%11 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 2
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %53, label %14
14: ; preds = %2
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
br label %17
17: ; preds = %14, %46
%18 = phi i64 [ 2, %14 ], [ %48, %46 ]
%19 = phi i8 [ %12, %14 ], [ %51, %46 ]
%20 = phi i8* [ %11, %14 ], [ %50, %46 ]
%21 = phi i32 [ 0, %14 ], [ %47, %46 ]
%22 = sext i8 %19 to i32
%23 = add nsw i64 %18, -2
%24 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = add nsw i64 %18, -1
%28 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = trunc i64 %18 to i32
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %31, i32 %26, i32 %30, i32 %22)
%33 = load i8, i8* %24
%34 = load i8, i8* %6
%35 = icmp eq i8 %33, %34
br i1 %35, label %36, label %46
36: ; preds = %17
%37 = load i8, i8* %28
%38 = load i8, i8* %15
%39 = icmp eq i8 %37, %38
br i1 %39, label %40, label %46
40: ; preds = %36
%41 = load i8, i8* %20
%42 = load i8, i8* %16
%43 = icmp eq i8 %41, %42
%44 = zext i1 %43 to i32
%45 = add nsw i32 %21, %44
br label %46
46: ; preds = %40, %17, %36
%47 = phi i32 [ %21, %36 ], [ %21, %17 ], [ %45, %40 ]
%48 = add nuw i64 %18, 1
%49 = and i64 %48, 4294967295
%50 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = icmp eq i8 %51, 0
br i1 %52, label %53, label %17
53: ; preds = %46, %2
%54 = phi i32 [ 0, %2 ], [ %47, %46 ]
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %6)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %54)
ret i32 0
}