#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__ isspace(char);
int countSegments(char *s) {
  int count = 0;
  while (*s) {
    while (isspace(*s))
      ++s;
    if (*s) {
      ++count;
      while (*s && !isspace(*s))
        ++s;
    }
  }
  return count;
}


x86 assembly (clang, -O0):
<countSegments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ca <countSegments+0xba>
jmp    1135 <countSegments+0x25>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     115c <countSegments+0x4c>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1135 <countSegments+0x25>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c5 <countSegments+0xb5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xd(%rbp)
je     119f <countSegments+0x8f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11af <countSegments+0x9f>
jmp    11c0 <countSegments+0xb0>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1172 <countSegments+0x62>
jmp    11c5 <countSegments+0xb5>
jmp    1123 <countSegments+0x13>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<countSegments>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1188 <countSegments+0x78>
mov    %rdi,%rbx
xor    %ebp,%ebp
movsbl %al,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1030 <isspace@plt>
test   %rax,%rax
je     1150 <countSegments+0x40>
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
jmp    1130 <countSegments+0x20>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx),%al
test   %al,%al
je     118a <countSegments+0x7a>
add    $0x1,%ebp
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    1180 <countSegments+0x70>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <countSegments+0x50>
jmp    118a <countSegments+0x7a>
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%al
test   %al,%al
jne    111e <countSegments+0xe>
jmp    118a <countSegments+0x7a>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @countSegments(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %41, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %42
8: ; preds = %4
br label %9
9: ; preds = %14, %8
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = call i64 @isspace(i8 signext %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %2
br label %9
17: ; preds = %9
%18 = load i8*, i8** %2
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %41
21: ; preds = %17
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %24
24: ; preds = %37, %21
%25 = load i8*, i8** %2
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %24
%30 = load i8*, i8** %2
%31 = load i8, i8* %30
%32 = call i64 @isspace(i8 signext %31)
%33 = icmp ne i64 %32, 0
%34 = xor i1 %33, true
br label %35
35: ; preds = %29, %24
%36 = phi i1 [ false, %24 ], [ %34, %29 ]
br i1 %36, label %37, label %40
37: ; preds = %35
%38 = load i8*, i8** %2
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %2
br label %24
40: ; preds = %35
br label %41
41: ; preds = %40, %17
br label %4
42: ; preds = %4
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
define i32 @countSegments(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %34, label %4
4: ; preds = %1, %31
%5 = phi i8 [ %32, %31 ], [ %2, %1 ]
%6 = phi i32 [ %21, %31 ], [ 0, %1 ]
%7 = phi i8* [ %23, %31 ], [ %0, %1 ]
%8 = tail call i64 @isspace(i8 signext %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %4, %10
%11 = phi i8* [ %12, %10 ], [ %7, %4 ]
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = tail call i64 @isspace(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %10
16: ; preds = %10, %4
%17 = phi i8* [ %7, %4 ], [ %12, %10 ]
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %34, label %20
20: ; preds = %16
%21 = add nuw nsw i32 %6, 1
br label %22
22: ; preds = %20, %27
%23 = phi i8* [ %17, %20 ], [ %28, %27 ]
%24 = phi i8 [ %18, %20 ], [ %29, %27 ]
%25 = tail call i64 @isspace(i8 signext %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = getelementptr inbounds i8, i8* %23, i64 1
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %34, label %22
31: ; preds = %22
%32 = load i8, i8* %23
%33 = icmp eq i8 %32, 0
br i1 %33, label %34, label %4
34: ; preds = %16, %31, %27, %1
%35 = phi i32 [ 0, %1 ], [ %21, %27 ], [ %6, %16 ], [ %21, %31 ]
ret i32 %35
}