#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*/ copierCharE(void *, void **);
int /*<<< orphan*/ libererSimple(void **);
int /*<<< orphan*/ removeHeadAndTailChar(char **, char);
char *strtok(char *, char const *);
int countNumberOfChamps(char *str, const char *delimitor,
                        int *nbTokenAtFirstLine) {
  int i = 0;
  char *test = NULL;
  char *token = NULL;
  token = strtok(str, delimitor);
  while (token != NULL) {
    i++;
    libererSimple((void **)&test);
    copierCharE((void *)token, (void **)&test);
    token = strtok(NULL, delimitor);
  }
  *nbTokenAtFirstLine = i;
  removeHeadAndTailChar(&test, ' ');
  if (test[0] == '\0') {
    i--;
  }
  libererSimple((void **)&test);
  return i;
}


x86 assembly (clang, -O0):
<countNumberOfChamps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11bc <countNumberOfChamps+0x7c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    -0x28(%rbp),%rdi
call   1050 <libererSimple@plt>
mov    -0x30(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <copierCharE@plt>
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <strtok@plt>
mov    %rax,-0x30(%rbp)
jmp    117c <countNumberOfChamps+0x3c>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x28(%rbp),%rdi
mov    $0x20,%esi
call   1040 <removeHeadAndTailChar@plt>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11ec <countNumberOfChamps+0xac>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
lea    -0x28(%rbp),%rdi
call   1050 <libererSimple@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<countNumberOfChamps>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
movq   $0x0,0x8(%rsp)
call   1060 <strtok@plt>
test   %rax,%rax
je     11ab <countNumberOfChamps+0x6b>
mov    %rax,%rbx
xor    %r13d,%r13d
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13d
mov    %r12,%rdi
call   1050 <libererSimple@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <copierCharE@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1180 <countNumberOfChamps+0x40>
jmp    11ae <countNumberOfChamps+0x6e>
xor    %r13d,%r13d
mov    %r13d,(%r14)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1040 <removeHeadAndTailChar@plt>
mov    0x8(%rsp),%rax
cmpb   $0x1,(%rax)
sbb    $0x0,%r13d
mov    %rbx,%rdi
call   1050 <libererSimple@plt>
mov    %r13d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @countNumberOfChamps(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
store i32 0, i32* %7
store i8* null, i8** %8
store i8* null, i8** %9
%10 = load i8*, i8** %4
%11 = load i8*, i8** %5
%12 = call i8* @strtok(i8* %10, i8* %11)
store i8* %12, i8** %9
br label %13
13: ; preds = %16, %3
%14 = load i8*, i8** %9
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = load i32, i32* %7
%18 = add nsw i32 %17, 1
store i32 %18, i32* %7
%19 = call i32 @libererSimple(i8** %8)
%20 = load i8*, i8** %9
%21 = call i32 @copierCharE(i8* %20, i8** %8)
%22 = load i8*, i8** %5
%23 = call i8* @strtok(i8* null, i8* %22)
store i8* %23, i8** %9
br label %13
24: ; preds = %13
%25 = load i32, i32* %7
%26 = load i32*, i32** %6
store i32 %25, i32* %26
%27 = call i32 @removeHeadAndTailChar(i8** %8, i8 signext 32)
%28 = load i8*, i8** %8
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %24
%34 = load i32, i32* %7
%35 = add nsw i32 %34, -1
store i32 %35, i32* %7
br label %36
36: ; preds = %33, %24
%37 = call i32 @libererSimple(i8** %8)
%38 = load i32, i32* %7
ret i32 %38
}

LLVM IR (-O2):
define i32 @countNumberOfChamps(i8* %0, i8* nocapture %1, i32* nocapture writeonly %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%6 = tail call i8* @strtok(i8* %0, i8* %1)
%7 = icmp eq i8* %6, null
br i1 %7, label %16, label %8
8: ; preds = %3, %8
%9 = phi i8* [ %14, %8 ], [ %6, %3 ]
%10 = phi i32 [ %11, %8 ], [ 0, %3 ]
%11 = add nuw nsw i32 %10, 1
%12 = call i32 @libererSimple(i8** %4)
%13 = call i32 @copierCharE(i8* %9, i8** %4)
%14 = call i8* @strtok(i8* null, i8* %1)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %8
16: ; preds = %8, %3
%17 = phi i32 [ 0, %3 ], [ %11, %8 ]
store i32 %17, i32* %2
%18 = call i32 @removeHeadAndTailChar(i8** %4, i8 signext 32)
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
%22 = sext i1 %21 to i32
%23 = add nsw i32 %17, %22
%24 = call i32 @libererSimple(i8** %4)
ret i32 %23
}