#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 *strchr(char *, char const);
int splitEx(char *src, const char seperator, char **pCols, const int nMaxCols) {
  char *p;
  char **pCurrent;
  int count = 0;
  if (nMaxCols <= 0) {
    return 0;
  }
  p = src;
  pCurrent = pCols;
  while (1) {
    *pCurrent = p;
    pCurrent++;
    count++;
    if (count >= nMaxCols) {
      break;
    }
    p = strchr(p, seperator);
    if (p == NULL) {
      break;
    }
    *p = '\0';
    p++;
  }
  return count;
}


x86 assembly (clang, -O0):
<splitEx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x0,-0x24(%rbp)
jg     1146 <splitEx+0x36>
movl   $0x0,-0x4(%rbp)
jmp    11c6 <splitEx+0xb6>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jl     1187 <splitEx+0x77>
jmp    11c0 <splitEx+0xb0>
mov    -0x30(%rbp),%rdi
movsbl -0x11(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11a8 <splitEx+0x98>
jmp    11c0 <splitEx+0xb0>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1156 <splitEx+0x46>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<splitEx>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %ecx,%ecx
jle    1165 <splitEx+0x55>
mov    %rdx,%r14
mov    %rdi,%rax
mov    %rdi,(%rdx)
mov    $0x1,%ebp
cmp    $0x1,%ecx
je     116b <splitEx+0x5b>
mov    %ecx,%ebp
mov    $0x1,%ebx
movsbl %sil,%r15d
nopl   0x0(%rax)
mov    %rax,%rdi
mov    %r15d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1169 <splitEx+0x59>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1140 <splitEx+0x30>
jmp    116b <splitEx+0x5b>
xor    %ebp,%ebp
jmp    116b <splitEx+0x5b>
mov    %ebx,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @splitEx(i8* %0, i8 signext %1, i8** nocapture writeonly %2, i32 %3) {
%5 = icmp slt i32 %3, 1
br i1 %5, label %19, label %6
6: ; preds = %4
store i8* %0, i8** %2
%7 = icmp eq i32 %3, 1
br i1 %7, label %19, label %8
8: ; preds = %6, %15
%9 = phi i32 [ %17, %15 ], [ 1, %6 ]
%10 = phi i8** [ %12, %15 ], [ %2, %6 ]
%11 = phi i8* [ %16, %15 ], [ %0, %6 ]
%12 = getelementptr inbounds i8*, i8** %10, i64 1
%13 = tail call i8* @strchr(i8* dereferenceable(1) %11, i8 signext %1)
%14 = icmp eq i8* %13, null
br i1 %14, label %19, label %15
15: ; preds = %8
store i8 0, i8* %13
%16 = getelementptr inbounds i8, i8* %13, i64 1
store i8* %16, i8** %12
%17 = add nuw nsw i32 %9, 1
%18 = icmp eq i32 %17, %3
br i1 %18, label %19, label %8
19: ; preds = %8, %15, %6, %4
%20 = phi i32 [ 0, %4 ], [ 1, %6 ], [ %9, %8 ], [ %3, %15 ]
ret i32 %20
}