#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 counter(char *);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int temp = 0;
  char str[100] = {0};
  printf("Please enter a string and I will count the number of the word--'the' "
         "\nMake sure the number of characters smaller than 100\n");
  gets(str);
  for (temp = 0; str[temp] != '\0'; temp++) {
    if (temp == 100) {
      printf("The string is longer than 100 character!The process of the "
             "programe end!\n");
      return 0;
    }
  }
  printf("%d", counter(str));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1050 <gets@plt>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11cd <main+0x8d>
cmpl   $0x64,-0x8(%rbp)
jne    11ba <main+0x7a>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ed <main+0xad>
jmp    11bf <main+0x7f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1184 <main+0x44>
lea    -0x70(%rbp),%rdi
call   1060 <counter@plt>
mov    %eax,%esi
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x68,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1050 <gets@plt>
cmpb   $0x0,(%rsp)
je     11b5 <main+0x75>
mov    $0x4,%eax
nopl   0x0(%rax,%rax,1)
cmp    $0x68,%rax
je     11d4 <main+0x94>
cmpb   $0x0,-0x3(%rsp,%rax,1)
je     11b5 <main+0x75>
cmpb   $0x0,-0x2(%rsp,%rax,1)
je     11b5 <main+0x75>
cmpb   $0x0,-0x1(%rsp,%rax,1)
je     11b5 <main+0x75>
cmpb   $0x0,(%rsp,%rax,1)
lea    0x4(%rax),%rax
jne    1190 <main+0x50>
mov    %rsp,%rdi
call   1060 <counter@plt>
lea    0xe3c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
ret
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
jmp    11cd <main+0x8d>

LLVM IR (-O0):
@.str = [123 x i8] c"Please enter a string and I will count the number of the word--'the' \0AMake sure the number of characters smaller than 100\0A\00"
@.str.1 = [74 x i8] c"The string is longer than 100 character!The process of the programe end!\0A\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
%4 = bitcast [100 x i8]* %3 to i8*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([123 x i8], [123 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
store i32 0, i32* %2
br label %8
8: ; preds = %21, %0
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %8
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 100
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %28
20: ; preds = %15
br label %21
21: ; preds = %20
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %8
24: ; preds = %8
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%26 = call i32 @counter(i8* %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %26)
store i32 0, i32* %1
br label %28
28: ; preds = %24, %18
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@str = [122 x i8] c"Please enter a string and I will count the number of the word--'the' \0AMake sure the number of characters smaller than 100\00"
@str.3 = [73 x i8] c"The string is longer than 100 character!The process of the programe end!\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([122 x i8], [122 x i8]* @str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 0
br i1 %6, label %32, label %27
7: ; preds = %27
%8 = or i64 %28, 1
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %32, label %12
12: ; preds = %7
%13 = or i64 %28, 2
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %32, label %17
17: ; preds = %12
%18 = or i64 %28, 3
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %32, label %22
22: ; preds = %17
%23 = add nuw nsw i64 %28, 4
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %0, %22
%28 = phi i64 [ %23, %22 ], [ 0, %0 ]
%29 = icmp eq i64 %28, 100
br i1 %29, label %30, label %7
30: ; preds = %27
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.3, i64 0, i64 0))
br label %35
32: ; preds = %7, %12, %17, %22, %0
%33 = call i32 @counter(i8* %2)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %32, %30
ret i32 0
}