#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*/ *strchr(char const *, char const);
unsigned int strlen(char const *);
unsigned int count_desktops(const char *bspwm_output) {
  const char *types = "OoFfUu";
  unsigned int cnt = 0;
  for (unsigned int i = 0; i < strlen(bspwm_output); ++i) {
    if (bspwm_output[i] == ':' && strchr(types, bspwm_output[++i]) != NULL)
      ++cnt;
  }
  return cnt;
}


x86 assembly (clang, -O0):
<count_desktops>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jae    11b7 <count_desktops+0x97>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    11a4 <count_desktops+0x84>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11a4 <count_desktops+0x84>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a9 <count_desktops+0x89>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1145 <count_desktops+0x25>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_desktops>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
call   1030 <strlen@plt>
test   %eax,%eax
je     1186 <count_desktops+0x66>
xor    %ebp,%ebp
lea    0xec3(%rip),%r14
xor    %r15d,%r15d
jmp    115f <count_desktops+0x3f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jae    1189 <count_desktops+0x69>
mov    %ebp,%ebx
cmpb   $0x3a,(%r12,%rbx,1)
jne    1150 <count_desktops+0x30>
movsbl 0x1(%r12,%rbx,1),%esi
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strchr@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%r15d
mov    %ebx,%ebp
jmp    1150 <count_desktops+0x30>
xor    %r15d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"OoFfUu\00"
define i32 @count_desktops(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %33, %1
%7 = load i32, i32* %5
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
%10 = icmp ult i32 %7, %9
br i1 %10, label %11, label %36
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = load i32, i32* %5
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 58
br i1 %18, label %19, label %32
19: ; preds = %11
%20 = load i8*, i8** %3
%21 = load i8*, i8** %2
%22 = load i32, i32* %5
%23 = add i32 %22, 1
store i32 %23, i32* %5
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
%26 = load i8, i8* %25
%27 = call i32* @strchr(i8* %20, i8 signext %26)
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %32
29: ; preds = %19
%30 = load i32, i32* %4
%31 = add i32 %30, 1
store i32 %31, i32* %4
br label %32
32: ; preds = %29, %19, %11
br label %33
33: ; preds = %32
%34 = load i32, i32* %5
%35 = add i32 %34, 1
store i32 %35, i32* %5
br label %6
36: ; preds = %6
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
@.str = [7 x i8] c"OoFfUu\00"
define i32 @count_desktops(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %22, %1
%5 = phi i32 [ 0, %1 ], [ %23, %22 ]
ret i32 %5
6: ; preds = %1, %22
%7 = phi i32 [ %25, %22 ], [ 0, %1 ]
%8 = phi i32 [ %23, %22 ], [ 0, %1 ]
%9 = zext i32 %7 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 58
br i1 %12, label %13, label %22
13: ; preds = %6
%14 = add nuw i32 %7, 1
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = tail call i32* @strchr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %17)
%19 = icmp ne i32* %18, null
%20 = zext i1 %19 to i32
%21 = add i32 %8, %20
br label %22
22: ; preds = %13, %6
%23 = phi i32 [ %8, %6 ], [ %21, %13 ]
%24 = phi i32 [ %7, %6 ], [ %14, %13 ]
%25 = add i32 %24, 1
%26 = tail call i32 @strlen(i8* %0)
%27 = icmp ult i32 %25, %26
br i1 %27, label %6, label %4
}