#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, const char *argv[]) {
  char ch[50];
  int i, count = 0, num = 0;
  printf("This Program count words with 3 characters in a string\n\n");
  printf("Please enter a string:\n");
  for (i = 0; i < 49; i++) {
    scanf("%c", &ch[i]);
    if (ch[i] != ' ') {
      count++;
    } else {
      if (count == 3) {
        num++;
      }
      count = 0;
    }
    if (ch[i] == '\n') {
      break;
    }
  }
  printf("The words with 3 characters count is: %d\n", num);
  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,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x31,-0x54(%rbp)
jge    11ec <main+0xcc>
movslq -0x54(%rbp),%rax
lea    -0x50(%rbp),%rsi
add    %rax,%rsi
lea    0xece(%rip),%rdi
call   1040 <scanf@plt>
movslq -0x54(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x20,%eax
je     11a8 <main+0x88>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11c2 <main+0xa2>
cmpl   $0x3,-0x58(%rbp)
jne    11bb <main+0x9b>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
movl   $0x0,-0x58(%rbp)
movslq -0x54(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    11d9 <main+0xb9>
jmp    11ec <main+0xcc>
jmp    11de <main+0xbe>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1167 <main+0x47>
mov    -0x5c(%rbp),%esi
lea    0xe5e(%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   %r12
push   %rbx
sub    $0x40,%rsp
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
lea    0xf16(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
lea    0xea2(%rip),%r15
xor    %ebx,%ebx
xor    %esi,%esi
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %esi,%r12d
lea    (%rsp,%rbx,1),%rsi
mov    %r15,%rdi
call   1050 <scanf@plt>
movzbl (%rsp,%rbx,1),%eax
cmp    $0x20,%al
sete   %cl
cmp    $0x3,%ebp
sete   %dl
and    %cl,%dl
movzbl %dl,%esi
add    %r12d,%esi
cmp    $0xa,%al
je     11ad <main+0x7d>
add    $0x1,%ebp
cmp    $0x20,%al
cmove  %r14d,%ebp
add    $0x1,%rbx
cmp    $0x31,%rbx
jne    1170 <main+0x40>
lea    0xe4f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [57 x i8] c"This Program count words with 3 characters in a string\0A\0A\00"
@.str.1 = [24 x i8] c"Please enter a string:\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [42 x i8] c"The words with 3 characters count is: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [50 x i8]
%7 = alloca i32
%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* %8
store i32 0, i32* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %12
12: ; preds = %45, %2
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 49
br i1 %14, label %15, label %48
15: ; preds = %12
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %17
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 32
br i1 %25, label %26, label %29
26: ; preds = %15
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %36
29: ; preds = %15
%30 = load i32, i32* %8
%31 = icmp eq i32 %30, 3
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %35
35: ; preds = %32, %29
store i32 0, i32* %8
br label %36
36: ; preds = %35, %26
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 10
br i1 %42, label %43, label %44
43: ; preds = %36
br label %48
44: ; preds = %36
br label %45
45: ; preds = %44
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %12
48: ; preds = %43, %12
%49 = load i32, i32* %9
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %49)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [42 x i8] c"The words with 3 characters count is: %d\0A\00"
@str = [56 x i8] c"This Program count words with 3 characters in a string\0A\00"
@str.4 = [23 x i8] c"Please enter a string:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.4, i64 0, i64 0))
br label %7
7: ; preds = %2, %20
%8 = phi i64 [ 0, %2 ], [ %23, %20 ]
%9 = phi i32 [ 0, %2 ], [ %18, %20 ]
%10 = phi i32 [ 0, %2 ], [ %22, %20 ]
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %8
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = load i8, i8* %11
%14 = icmp eq i8 %13, 32
%15 = icmp eq i32 %10, 3
%16 = select i1 %14, i1 %15, i1 false
%17 = zext i1 %16 to i32
%18 = add nuw nsw i32 %9, %17
%19 = icmp eq i8 %13, 10
br i1 %19, label %25, label %20
20: ; preds = %7
%21 = add nsw i32 %10, 1
%22 = select i1 %14, i32 0, i32 %21
%23 = add nuw nsw i64 %8, 1
%24 = icmp eq i64 %23, 49
br i1 %24, label %25, label %7
25: ; preds = %7, %20
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %18)
ret i32 0
}