#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 */
struct slName {
  int dummy;
};

/* Variables and functions */
struct slName *newSlName(char *);
int /*<<< orphan*/ slAddHead(struct slName **, struct slName *);
struct slName *slNameNewN(char *, int);
int /*<<< orphan*/ slReverse(struct slName **);
char *strchr(char *, char);
struct slName *charSepToSlNames(char *string, char c) {
  struct slName *list = NULL, *el;
  char *s, *e;
  s = string;
  while (s != NULL && s[0] != 0) {
    e = strchr(s, c);
    if (e == NULL) {
      el = newSlName(s);
      slAddHead(&list, el);
      break;
    } else {
      el = slNameNewN(s, e - s);
      slAddHead(&list, el);
      s = e + 1;
    }
  }
  slReverse(&list);
  return list;
}


x86 assembly (clang, -O0):
<charSepToSlNames>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x31(%rbp)
je     1192 <charSepToSlNames+0x42>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11a2 <charSepToSlNames+0x52>
jmp    1215 <charSepToSlNames+0xc5>
mov    -0x28(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11dd <charSepToSlNames+0x8d>
mov    -0x28(%rbp),%rdi
call   1060 <newSlName@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    -0x18(%rbp),%rdi
call   1040 <slAddHead@plt>
jmp    1215 <charSepToSlNames+0xc5>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1070 <slNameNewN@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    -0x18(%rbp),%rdi
call   1040 <slAddHead@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1172 <charSepToSlNames+0x22>
lea    -0x18(%rbp),%rdi
call   1050 <slReverse@plt>
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<charSepToSlNames>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movq   $0x0,(%rsp)
test   %rdi,%rdi
je     11cc <charSepToSlNames+0x7c>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     11cc <charSepToSlNames+0x7c>
movsbl %sil,%r15d
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r15d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11b9 <charSepToSlNames+0x69>
mov    %rax,%rbp
mov    %ebp,%esi
sub    %ebx,%esi
mov    %rbx,%rdi
call   1070 <slNameNewN@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <slAddHead@plt>
mov    %rbp,%rbx
add    $0x1,%rbx
cmpb   $0x0,0x1(%rbp)
jne    1180 <charSepToSlNames+0x30>
jmp    11cc <charSepToSlNames+0x7c>
mov    %rbx,%rdi
call   1060 <newSlName@plt>
mov    %rsp,%rdi
mov    %rax,%rsi
call   1040 <slAddHead@plt>
mov    %rsp,%rdi
call   1050 <slReverse@plt>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.slName = type { i32 }
define %struct.slName* @charSepToSlNames(i8* %0, i8 signext %1) {
%3 = alloca %struct.slName*
%4 = bitcast %struct.slName** %3 to i8*
store %struct.slName* null, %struct.slName** %3
%5 = icmp eq i8* %0, null
br i1 %5, label %26, label %6
6: ; preds = %2
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %26, label %9
9: ; preds = %6, %16
%10 = phi i8* [ %23, %16 ], [ %0, %6 ]
%11 = call i8* @strchr(i8* %10, i8 signext %1)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = call %struct.slName* @newSlName(i8* %10)
%15 = call i32 @slAddHead(%struct.slName** %3, %struct.slName* %14)
br label %26
16: ; preds = %9
%17 = ptrtoint i8* %11 to i64
%18 = ptrtoint i8* %10 to i64
%19 = sub i64 %17, %18
%20 = trunc i64 %19 to i32
%21 = call %struct.slName* @slNameNewN(i8* %10, i32 %20)
%22 = call i32 @slAddHead(%struct.slName** %3, %struct.slName* %21)
%23 = getelementptr inbounds i8, i8* %11, i64 1
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %9
26: ; preds = %16, %6, %2, %13
%27 = call i32 @slReverse(%struct.slName** %3)
%28 = load %struct.slName*, %struct.slName** %3
ret %struct.slName* %28
}