#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);
int _split_string_by_comma(char *sentence, char **values, int max_values) {
  int i = 0;
  while (i < max_values && '\0' != *sentence) {
    while (' ' == *sentence || ',' == *sentence) {
      sentence++;
    }
    if ('\0' == *sentence) {
      break;
    }
    values[i++] = sentence;
    if (NULL == (sentence = strchr(sentence, ','))) {
      break;
    }
    *(sentence++) = '\0';
  }
  return i;
}


x86 assembly (clang, -O0):
<_split_string_by_comma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x19(%rbp)
jge    114c <_split_string_by_comma+0x3c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    115c <_split_string_by_comma+0x4c>
jmp    121b <_split_string_by_comma+0x10b>
jmp    1161 <_split_string_by_comma+0x51>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edx
mov    $0x1,%al
mov    $0x20,%ecx
cmp    %edx,%ecx
mov    %al,-0x1a(%rbp)
je     118e <_split_string_by_comma+0x7e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x2c,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    119e <_split_string_by_comma+0x8e>
jmp    11af <_split_string_by_comma+0x9f>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1161 <_split_string_by_comma+0x51>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    11c5 <_split_string_by_comma+0xb5>
jmp    121b <_split_string_by_comma+0x10b>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x18(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rdi
mov    $0x2c,%esi
call   1030 <strchr@plt>
mov    %rax,%rcx
mov    %rcx,-0x8(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1204 <_split_string_by_comma+0xf4>
jmp    121b <_split_string_by_comma+0x10b>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
jmp    112a <_split_string_by_comma+0x1a>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_split_string_by_comma>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edx,%edx
jle    1170 <_split_string_by_comma+0x60>
mov    %edx,%ebp
mov    %rsi,%r14
mov    %edx,%r15d
xor    %ebx,%ebx
mov    (%rdi),%al
test   %al,%al
jne    1138 <_split_string_by_comma+0x28>
jmp    116c <_split_string_by_comma+0x5c>
nopl   (%rax)
movzbl 0x1(%rdi),%eax
add    $0x1,%rdi
cmp    $0x20,%al
je     1130 <_split_string_by_comma+0x20>
cmp    $0x2c,%al
je     1130 <_split_string_by_comma+0x20>
test   %al,%al
je     116c <_split_string_by_comma+0x5c>
mov    %rdi,(%r14,%rbx,8)
add    $0x1,%rbx
mov    $0x2c,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     116c <_split_string_by_comma+0x5c>
mov    %rax,%rdi
add    $0x1,%rdi
movb   $0x0,(%rax)
cmp    %r15,%rbx
jne    1125 <_split_string_by_comma+0x15>
jmp    1172 <_split_string_by_comma+0x62>
mov    %ebx,%ebp
jmp    1172 <_split_string_by_comma+0x62>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @_split_string_by_comma(i8* %0, i8** nocapture writeonly %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %32
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %23
%8 = phi i64 [ 0, %5 ], [ %19, %23 ]
%9 = phi i8* [ %0, %5 ], [ %24, %23 ]
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %30, label %12
12: ; preds = %7, %15
%13 = phi i8 [ %17, %15 ], [ %10, %7 ]
%14 = phi i8* [ %16, %15 ], [ %9, %7 ]
switch i8 %13, label %18 [
i8 32, label %15
i8 44, label %15
i8 0, label %26
]
15: ; preds = %12, %12
%16 = getelementptr inbounds i8, i8* %14, i64 1
%17 = load i8, i8* %16
br label %12
18: ; preds = %12
%19 = add nuw nsw i64 %8, 1
%20 = getelementptr inbounds i8*, i8** %1, i64 %8
store i8* %14, i8** %20
%21 = tail call i8* @strchr(i8* %14, i8 signext 44)
%22 = icmp eq i8* %21, null
br i1 %22, label %28, label %23
23: ; preds = %18
%24 = getelementptr inbounds i8, i8* %21, i64 1
store i8 0, i8* %21
%25 = icmp eq i64 %19, %6
br i1 %25, label %32, label %7
26: ; preds = %12
%27 = trunc i64 %8 to i32
br label %32
28: ; preds = %18
%29 = trunc i64 %19 to i32
br label %32
30: ; preds = %7
%31 = trunc i64 %8 to i32
br label %32
32: ; preds = %23, %28, %30, %26, %3
%33 = phi i32 [ 0, %3 ], [ %27, %26 ], [ %29, %28 ], [ %31, %30 ], [ %2, %23 ]
ret i32 %33
}