#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 */
scalar_t__ strcmp(char *, char *);
int countWordsInLine(char *line) {
  int wordCount = 1;
  if (strcmp(" ", line) || strcmp("\0", line) || strcmp("\n", line) ||
      strcmp("\r", line)) {
    return wordCount = 0;
  }
  for (int m = 0; line[m] != '\0'; m++) {
    if ((line[m] == ' ' && m != 0) && (line[m - 1] != ' ')) {
      wordCount++;
    }
  }
  return wordCount;
}


x86 assembly (clang, -O0):
<countWordsInLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xed2(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    118b <countWordsInLine+0x7b>
mov    -0x10(%rbp),%rsi
lea    0xebe(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    118b <countWordsInLine+0x7b>
mov    -0x10(%rbp),%rsi
lea    0xea0(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    118b <countWordsInLine+0x7b>
mov    -0x10(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     119e <countWordsInLine+0x8e>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x4(%rbp)
jmp    1215 <countWordsInLine+0x105>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     120f <countWordsInLine+0xff>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    11fc <countWordsInLine+0xec>
cmpl   $0x0,-0x18(%rbp)
je     11fc <countWordsInLine+0xec>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     11fc <countWordsInLine+0xec>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1201 <countWordsInLine+0xf1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a5 <countWordsInLine+0x95>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<countWordsInLine>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee3(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    1168 <countWordsInLine+0x58>
lea    0xed3(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1168 <countWordsInLine+0x58>
lea    0xebb(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1168 <countWordsInLine+0x58>
lea    0xea9(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1171 <countWordsInLine+0x61>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    (%rbx),%cl
mov    $0x1,%ebp
test   %cl,%cl
je     1168 <countWordsInLine+0x58>
mov    $0x1,%eax
jmp    119e <countWordsInLine+0x8e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%ecx
movzbl (%rbx,%rcx,1),%ecx
add    $0x1,%rax
test   %cl,%cl
je     1168 <countWordsInLine+0x58>
cmp    $0x20,%cl
jne    1190 <countWordsInLine+0x80>
cmp    $0x1,%rax
je     1190 <countWordsInLine+0x80>
xor    %ecx,%ecx
cmpb   $0x20,-0x2(%rbx,%rax,1)
setne  %cl
add    %ecx,%ebp
jmp    1190 <countWordsInLine+0x80>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] zeroinitializer
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [2 x i8] c"\0D\00"
define i32 @countWordsInLine(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 1, i32* %4
%6 = load i8*, i8** %3
%7 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %21, label %9
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17, %13, %9, %1
store i32 0, i32* %4
store i32 0, i32* %2
br label %60
22: ; preds = %17
store i32 0, i32* %5
br label %23
23: ; preds = %55, %22
%24 = load i8*, i8** %3
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %58
31: ; preds = %23
%32 = load i8*, i8** %3
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 32
br i1 %38, label %39, label %54
39: ; preds = %31
%40 = load i32, i32* %5
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %54
42: ; preds = %39
%43 = load i8*, i8** %3
%44 = load i32, i32* %5
%45 = sub nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %43, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 32
br i1 %50, label %51, label %54
51: ; preds = %42
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
br label %54
54: ; preds = %51, %42, %39, %31
br label %55
55: ; preds = %54
%56 = load i32, i32* %5
%57 = add nsw i32 %56, 1
store i32 %57, i32* %5
br label %23
58: ; preds = %23
%59 = load i32, i32* %4
store i32 %59, i32* %2
br label %60
60: ; preds = %58, %21
%61 = load i32, i32* %2
ret i32 %61
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] zeroinitializer
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [2 x i8] c"\0D\00"
define i32 @countWordsInLine(i8* %0) {
%2 = tail call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %37
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %37
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %37
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %37
13: ; preds = %10
%14 = load i8, i8* %0
%15 = icmp eq i8 %14, 0
br i1 %15, label %37, label %16
16: ; preds = %13, %30
%17 = phi i64 [ %32, %30 ], [ 0, %13 ]
%18 = phi i8 [ %35, %30 ], [ %14, %13 ]
%19 = phi i32 [ %31, %30 ], [ 1, %13 ]
%20 = icmp eq i8 %18, 32
%21 = icmp ne i64 %17, 0
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %23, label %30
23: ; preds = %16
%24 = add nsw i64 %17, -1
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = icmp ne i8 %26, 32
%28 = zext i1 %27 to i32
%29 = add nsw i32 %19, %28
br label %30
30: ; preds = %23, %16
%31 = phi i32 [ %19, %16 ], [ %29, %23 ]
%32 = add nuw i64 %17, 1
%33 = and i64 %32, 4294967295
%34 = getelementptr inbounds i8, i8* %0, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
br i1 %36, label %37, label %16
37: ; preds = %30, %13, %1, %4, %7, %10
%38 = phi i32 [ 0, %10 ], [ 0, %7 ], [ 0, %4 ], [ 0, %1 ], [ 1, %13 ], [ %31, %30 ]
ret i32 %38
}