#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 */
size_t strcspn(char *, char const *);
int /*<<< orphan*/ strspn(char *, char const *);
char *split(const char *c, size_t *l, const char *separator, char **state) {
  char *current;
  current = *state ? *state : (char *)c;
  if (!*current || *c == 0)
    return NULL;
  current += strspn(current, separator);
  *l = strcspn(current, separator);
  *state = current + *l;
  return (char *)current;
}


x86 assembly (clang, -O0):
<split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     1156 <split+0x36>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    115e <split+0x3e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     1183 <split+0x63>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1190 <split+0x70>
movq   $0x0,-0x8(%rbp)
jmp    11de <split+0xbe>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strspn@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcspn@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
add    (%rax),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    (%rcx),%rbx
test   %rbx,%rbx
cmove  %rdi,%rbx
cmpb   $0x0,(%rbx)
je     116e <split+0x4e>
cmpb   $0x0,(%rdi)
je     116e <split+0x4e>
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rbx,%rdi
mov    %rdx,%rsi
call   1030 <strspn@plt>
movslq %eax,%r13
add    %rbx,%r13
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <strcspn@plt>
mov    %rax,(%r14)
add    %r13,%rax
mov    %rax,(%r12)
jmp    1171 <split+0x51>
xor    %r13d,%r13d
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @split(i8* %0, i64* %1, i8* %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64*
%8 = alloca i8*
%9 = alloca i8**
%10 = alloca i8*
store i8* %0, i8** %6
store i64* %1, i64** %7
store i8* %2, i8** %8
store i8** %3, i8*** %9
%11 = load i8**, i8*** %9
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %4
%15 = load i8**, i8*** %9
%16 = load i8*, i8** %15
br label %19
17: ; preds = %4
%18 = load i8*, i8** %6
br label %19
19: ; preds = %17, %14
%20 = phi i8* [ %16, %14 ], [ %18, %17 ]
store i8* %20, i8** %10
%21 = load i8*, i8** %10
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i8*, i8** %6
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %24, %19
store i8* null, i8** %5
br label %47
30: ; preds = %24
%31 = load i8*, i8** %10
%32 = load i8*, i8** %8
%33 = call i32 @strspn(i8* %31, i8* %32)
%34 = load i8*, i8** %10
%35 = sext i32 %33 to i64
%36 = getelementptr inbounds i8, i8* %34, i64 %35
store i8* %36, i8** %10
%37 = load i8*, i8** %10
%38 = load i8*, i8** %8
%39 = call i64 @strcspn(i8* %37, i8* %38)
%40 = load i64*, i64** %7
store i64 %39, i64* %40
%41 = load i8*, i8** %10
%42 = load i64*, i64** %7
%43 = load i64, i64* %42
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8**, i8*** %9
store i8* %44, i8** %45
%46 = load i8*, i8** %10
store i8* %46, i8** %5
br label %47
47: ; preds = %30, %29
%48 = load i8*, i8** %5
ret i8* %48
}

LLVM IR (-O2):
define i8* @split(i8* %0, i64* nocapture writeonly %1, i8* nocapture %2, i8** nocapture %3) {
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
%7 = select i1 %6, i8* %0, i8* %5
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %4
%11 = load i8, i8* %0
%12 = icmp eq i8 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = tail call i32 @strspn(i8* %7, i8* %2)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %7, i64 %15
%17 = tail call i64 @strcspn(i8* %16, i8* %2)
store i64 %17, i64* %1
%18 = getelementptr inbounds i8, i8* %16, i64 %17
store i8* %18, i8** %3
br label %19
19: ; preds = %4, %10, %13
%20 = phi i8* [ %16, %13 ], [ null, %10 ], [ null, %4 ]
ret i8* %20
}