#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*/ assert(int /*<<< orphan*/);
char **calloc(int, int);
int /*<<< orphan*/ ignore_extra(char const, char **);
char *strsep(char **, char const *);
char **laco_split_by(const char split_with, char *string, int ignore_repeats) {
  assert(string != NULL);
  size_t i;
  char **result = calloc(16, sizeof(char *));
  for (i = 0; (result[i] = strsep(&string, &split_with)); i++) {
    if (ignore_repeats) {
      ignore_extra(split_with, &string);
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<laco_split_by>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0x10,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x1(%rbp),%rsi
call   1060 <strsep@plt>
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
je     11d2 <laco_split_by+0x92>
cmpl   $0x0,-0x14(%rbp)
je     11bc <laco_split_by+0x7c>
lea    -0x10(%rbp),%rsi
movsbl -0x1(%rbp),%edi
call   1050 <ignore_extra@plt>
jmp    11c1 <laco_split_by+0x81>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1182 <laco_split_by+0x42>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<laco_split_by>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r12d
mov    %dil,0x7(%rsp)
mov    %rsi,0x8(%rsp)
xor    %edi,%edi
test   %rsi,%rsi
setne  %dil
call   1040 <assert@plt>
mov    $0x10,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%r14
lea    0x8(%rsp),%rdi
lea    0x7(%rsp),%rsi
call   1060 <strsep@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     11dc <laco_split_by+0x9c>
mov    %r14,%rbp
add    $0x8,%rbp
lea    0x8(%rsp),%rbx
lea    0x7(%rsp),%r15
jmp    11c8 <laco_split_by+0x88>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strsep@plt>
mov    %rax,0x0(%rbp)
add    $0x8,%rbp
test   %rax,%rax
je     11dc <laco_split_by+0x9c>
test   %r12d,%r12d
je     11b0 <laco_split_by+0x70>
movsbl 0x7(%rsp),%edi
mov    %rbx,%rsi
call   1050 <ignore_extra@plt>
jmp    11b0 <laco_split_by+0x70>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8** @laco_split_by(i8 signext %0, i8* %1, i32 %2) {
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i8**
store i8 %0, i8* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i8** @calloc(i32 16, i32 8)
store i8** %13, i8*** %8
store i64 0, i64* %7
br label %14
14: ; preds = %27, %3
%15 = call i8* @strsep(i8** %5, i8* %4)
%16 = load i8**, i8*** %8
%17 = load i64, i64* %7
%18 = getelementptr inbounds i8*, i8** %16, i64 %17
store i8* %15, i8** %18
%19 = icmp ne i8* %15, null
br i1 %19, label %20, label %30
20: ; preds = %14
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i8, i8* %4
%25 = call i32 @ignore_extra(i8 signext %24, i8** %5)
br label %26
26: ; preds = %23, %20
br label %27
27: ; preds = %26
%28 = load i64, i64* %7
%29 = add i64 %28, 1
store i64 %29, i64* %7
br label %14
30: ; preds = %14
%31 = load i8**, i8*** %8
ret i8** %31
}

LLVM IR (-O2):
define noalias i8** @laco_split_by(i8 signext %0, i8* %1, i32 %2) {
%4 = alloca i8
%5 = alloca i8*
store i8 %0, i8* %4
store i8* %1, i8** %5
%6 = icmp ne i8* %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i8** @calloc(i32 16, i32 8)
%10 = call i8* @strsep(i8** %5, i8* %4)
store i8* %10, i8** %9
%11 = icmp eq i8* %10, null
br i1 %11, label %24, label %12
12: ; preds = %3
%13 = icmp eq i32 %2, 0
br label %14
14: ; preds = %12, %19
%15 = phi i64 [ 0, %12 ], [ %20, %19 ]
br i1 %13, label %19, label %16
16: ; preds = %14
%17 = load i8, i8* %4
%18 = call i32 @ignore_extra(i8 signext %17, i8** %5)
br label %19
19: ; preds = %14, %16
%20 = add i64 %15, 1
%21 = call i8* @strsep(i8** %5, i8* %4)
%22 = getelementptr inbounds i8*, i8** %9, i64 %20
store i8* %21, i8** %22
%23 = icmp eq i8* %21, null
br i1 %23, label %24, label %14
24: ; preds = %19, %3
ret i8** %9
}