#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 */
char *findSeparator(char *, char *);
int strlen(char *);
int checkNumberOfSeparators(char *string, char *separator) {
  int counter = 0;
  char *current = string;
  while (findSeparator(current, separator) != (string + strlen(string) - 1)) {
    counter++;
    current = findSeparator(current, separator) + 1;
  }
  return counter;
}


x86 assembly (clang, -O0):
<checkNumberOfSeparators>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <findSeparator@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rcx
mov    %eax,%edx
mov    -0x28(%rbp),%rax
movslq %edx,%rdx
add    %rdx,%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rax
je     11a1 <checkNumberOfSeparators+0x81>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <findSeparator@plt>
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113f <checkNumberOfSeparators+0x1f>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkNumberOfSeparators>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
call   1040 <findSeparator@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
add    %r14,%rax
add    $0xffffffffffffffff,%rax
cmp    %rax,%rbx
je     1197 <checkNumberOfSeparators+0x77>
lea    -0x1(%r14),%r13
xor    %ebp,%ebp
mov    %r14,%rbx
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <findSeparator@plt>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <findSeparator@plt>
mov    %rax,%r12
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
add    %r13,%rax
cmp    %rax,%r12
jne    1160 <checkNumberOfSeparators+0x40>
jmp    1199 <checkNumberOfSeparators+0x79>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @checkNumberOfSeparators(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%7 = load i8*, i8** %3
store i8* %7, i8** %6
br label %8
8: ; preds = %19, %2
%9 = load i8*, i8** %6
%10 = load i8*, i8** %4
%11 = call i8* @findSeparator(i8* %9, i8* %10)
%12 = load i8*, i8** %3
%13 = load i8*, i8** %3
%14 = call i32 @strlen(i8* %13)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 -1
%18 = icmp ne i8* %11, %17
br i1 %18, label %19, label %26
19: ; preds = %8
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
%22 = load i8*, i8** %6
%23 = load i8*, i8** %4
%24 = call i8* @findSeparator(i8* %22, i8* %23)
%25 = getelementptr inbounds i8, i8* %24, i64 1
store i8* %25, i8** %6
br label %8
26: ; preds = %8
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
define i32 @checkNumberOfSeparators(i8* %0, i8* %1) {
%3 = tail call i8* @findSeparator(i8* %0, i8* %1)
%4 = tail call i32 @strlen(i8* %0)
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = getelementptr inbounds i8, i8* %6, i64 -1
%8 = icmp eq i8* %3, %7
br i1 %8, label %22, label %9
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %0, i64 -1
br label %11
11: ; preds = %9, %11
%12 = phi i8* [ %16, %11 ], [ %0, %9 ]
%13 = phi i32 [ %14, %11 ], [ 0, %9 ]
%14 = add nuw nsw i32 %13, 1
%15 = tail call i8* @findSeparator(i8* %12, i8* %1)
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = tail call i8* @findSeparator(i8* %16, i8* %1)
%18 = tail call i32 @strlen(i8* %0)
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %10, i64 %19
%21 = icmp eq i8* %17, %20
br i1 %21, label %22, label %11
22: ; preds = %11, %2
%23 = phi i32 [ 0, %2 ], [ %14, %11 ]
ret i32 %23
}