#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 ll {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fatal(char *);
int /*<<< orphan*/ *ll_append(struct ll *, char *, int /*<<< orphan*/);
struct ll *ll_new();
char *strchr(char *, char);
struct ll *get_slist(char *s) {
  char *e;
  struct ll *list = ll_new();
  do {
    if (list == NULL)
      fatal("out of memory\n");
  } while (0);
  while ((e = strchr(s, ','))) {
    *e = '\0';
    do {
      if (ll_append(list, s, 0) == NULL)
        fatal("out of memory\n");
    } while (0);
    s = e + 1;
  }
  do {
    if (ll_append(list, s, 0) == NULL)
      fatal("out of memory\n");
  } while (0);
  return list;
}


x86 assembly (clang, -O0):
<get_slist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <ll_new@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116e <get_slist+0x2e>
lea    0xe97(%rip),%rdi
call   1050 <fatal@plt>
jmp    1173 <get_slist+0x33>
jmp    1178 <get_slist+0x38>
mov    -0x8(%rbp),%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11d6 <get_slist+0x96>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1040 <ll_append@plt>
cmp    $0x0,%rax
jne    11c0 <get_slist+0x80>
lea    0xe45(%rip),%rdi
call   1050 <fatal@plt>
jmp    11c5 <get_slist+0x85>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1178 <get_slist+0x38>
jmp    11db <get_slist+0x9b>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1040 <ll_append@plt>
cmp    $0x0,%rax
jne    1200 <get_slist+0xc0>
lea    0xe05(%rip),%rdi
call   1050 <fatal@plt>
jmp    1205 <get_slist+0xc5>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_slist>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <ll_new@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1166 <get_slist+0x26>
lea    0xe9f(%rip),%rdi
call   1050 <fatal@plt>
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11cd <get_slist+0x8d>
mov    %rax,%r12
lea    0xe7e(%rip),%r15
jmp    11ac <get_slist+0x6c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    %rax,%r12
test   %rax,%rax
je     11cd <get_slist+0x8d>
movb   $0x0,(%r12)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1040 <ll_append@plt>
test   %rax,%rax
jne    1190 <get_slist+0x50>
mov    %r15,%rdi
call   1050 <fatal@plt>
jmp    1190 <get_slist+0x50>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1040 <ll_append@plt>
test   %rax,%rax
jne    11eb <get_slist+0xab>
lea    0xe1a(%rip),%rdi
call   1050 <fatal@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.ll = type { i32 }
@.str = [15 x i8] c"out of memory\0A\00"
define %struct.ll* @get_slist(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca %struct.ll*
store i8* %0, i8** %2
%5 = call %struct.ll* (...) @ll_new()
store %struct.ll* %5, %struct.ll** %4
br label %6
6: ; preds = %1
%7 = load %struct.ll*, %struct.ll** %4
%8 = icmp eq %struct.ll* %7, null
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @fatal(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
br label %12
12: ; preds = %11
br label %13
13: ; preds = %27, %12
%14 = load i8*, i8** %2
%15 = call i8* @strchr(i8* %14, i8 signext 44)
store i8* %15, i8** %3
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = load i8*, i8** %3
store i8 0, i8* %18
br label %19
19: ; preds = %17
%20 = load %struct.ll*, %struct.ll** %4
%21 = load i8*, i8** %2
%22 = call i32* @ll_append(%struct.ll* %20, i8* %21, i32 0)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call i32 @fatal(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %24, %19
br label %27
27: ; preds = %26
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 1
store i8* %29, i8** %2
br label %13
30: ; preds = %13
br label %31
31: ; preds = %30
%32 = load %struct.ll*, %struct.ll** %4
%33 = load i8*, i8** %2
%34 = call i32* @ll_append(%struct.ll* %32, i8* %33, i32 0)
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 @fatal(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %38
38: ; preds = %36, %31
br label %39
39: ; preds = %38
%40 = load %struct.ll*, %struct.ll** %4
ret %struct.ll* %40
}

LLVM IR (-O2):
%struct.ll = type { i32 }
@.str = [15 x i8] c"out of memory\0A\00"
define %struct.ll* @get_slist(i8* %0) {
%2 = tail call %struct.ll* (...) @ll_new()
%3 = icmp eq %struct.ll* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @fatal(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 44)
%8 = icmp eq i8* %7, null
br i1 %8, label %20, label %9
9: ; preds = %6, %16
%10 = phi i8* [ %18, %16 ], [ %7, %6 ]
%11 = phi i8* [ %17, %16 ], [ %0, %6 ]
store i8 0, i8* %10
%12 = tail call i32* @ll_append(%struct.ll* %2, i8* %11, i32 0)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @fatal(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %9
%17 = getelementptr inbounds i8, i8* %10, i64 1
%18 = tail call i8* @strchr(i8* dereferenceable(1) %17, i8 signext 44)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %9
20: ; preds = %16, %6
%21 = phi i8* [ %0, %6 ], [ %17, %16 ]
%22 = tail call i32* @ll_append(%struct.ll* %2, i8* %21, i32 0)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 @fatal(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
ret %struct.ll* %2
}