#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*/ free(char **);
char **split_string(char *, char *, size_t *);
scalar_t__ strcmp(char *, char *);
char *test_split_string() {
  char str[] = "41,27";
  char delim[] = ",";
  size_t len = 0;
  char **result = split_string(str, delim, &len);
  do {
    if (!(len == 2))
      return "len is not 2";
  } while (0);
  do {
    if (!(strcmp("41", result[0]) == 0))
      return "1: _1_,2 => [_1_, 2]";
  } while (0);
  do {
    if (!(strcmp("27", result[1]) == 0))
      return "2: 1,_2_ => [1, _2_]";
  } while (0);
  free(result);
  return 0;
}


x86 assembly (clang, -O0):
<test_split_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xec2(%rip),%eax
mov    %eax,-0xe(%rbp)
mov    0xebc(%rip),%ax
mov    %ax,-0xa(%rbp)
mov    0xeb3(%rip),%ax
mov    %ax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0xe(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <split_string@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x2,-0x18(%rbp)
je     118f <test_split_string+0x5f>
lea    0xe82(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1214 <test_split_string+0xe4>
jmp    1194 <test_split_string+0x64>
jmp    1199 <test_split_string+0x69>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xe6e(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11c6 <test_split_string+0x96>
lea    0xe5b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1214 <test_split_string+0xe4>
jmp    11cb <test_split_string+0x9b>
jmp    11d0 <test_split_string+0xa0>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe24(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11fe <test_split_string+0xce>
lea    0xe38(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1214 <test_split_string+0xe4>
jmp    1203 <test_split_string+0xd3>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_split_string>:
push   %rbx
sub    $0x20,%rsp
movw   $0x37,0x14(%rsp)
movl   $0x322c3134,0x10(%rsp)
32
movw   $0x2c,0xe(%rsp)
movq   $0x0,0x18(%rsp)
lea    0x10(%rsp),%rdi
lea    0xe(%rsp),%rsi
lea    0x18(%rsp),%rdx
call   1040 <split_string@plt>
cmpq   $0x2,0x18(%rsp)
jne    1190 <test_split_string+0x60>
mov    %rax,%rbx
mov    (%rax),%rsi
lea    0xe96(%rip),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     119d <test_split_string+0x6d>
lea    0xe88(%rip),%rax
jmp    1197 <test_split_string+0x67>
lea    0xe6f(%rip),%rax
add    $0x20,%rsp
pop    %rbx
ret
mov    0x8(%rbx),%rsi
lea    0xe5b(%rip),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11bb <test_split_string+0x8b>
lea    0xe72(%rip),%rax
jmp    1197 <test_split_string+0x67>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    1197 <test_split_string+0x67>

LLVM IR (-O0):
@__const.test_split_string.str = [6 x i8] c"41,27\00"
@__const.test_split_string.delim = [2 x i8] c",\00"
@.str = [13 x i8] c"len is not 2\00"
@.str.1 = [3 x i8] c"41\00"
@.str.2 = [21 x i8] c"1: _1_,2 => [_1_, 2]\00"
@.str.3 = [3 x i8] c"27\00"
@.str.4 = [21 x i8] c"2: 1,_2_ => [1, _2_]\00"
define i8* @test_split_string() {
%1 = alloca i8*
%2 = alloca [6 x i8]
%3 = alloca [2 x i8]
%4 = alloca i64
%5 = alloca i8**
%6 = bitcast [6 x i8]* %2 to i8*
%7 = bitcast [2 x i8]* %3 to i8*
store i64 0, i64* %4
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%10 = call i8** @split_string(i8* %8, i8* %9, i64* %4)
store i8** %10, i8*** %5
br label %11
11: ; preds = %0
%12 = load i64, i64* %4
%13 = icmp eq i64 %12, 2
br i1 %13, label %15, label %14
14: ; preds = %11
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %1
br label %37
15: ; preds = %11
br label %16
16: ; preds = %15
br label %17
17: ; preds = %16
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %17
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %37
24: ; preds = %17
br label %25
25: ; preds = %24
br label %26
26: ; preds = %25
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %26
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8** %1
br label %37
33: ; preds = %26
br label %34
34: ; preds = %33
%35 = load i8**, i8*** %5
%36 = call i32 @free(i8** %35)
store i8* null, i8** %1
br label %37
37: ; preds = %34, %32, %23, %14
%38 = load i8*, i8** %1
ret i8* %38
}

LLVM IR (-O2):
@__const.test_split_string.str = [6 x i8] c"41,27\00"
@.str = [13 x i8] c"len is not 2\00"
@.str.1 = [3 x i8] c"41\00"
@.str.2 = [21 x i8] c"1: _1_,2 => [_1_, 2]\00"
@.str.3 = [3 x i8] c"27\00"
@.str.4 = [21 x i8] c"2: 1,_2_ => [1, _2_]\00"
define i8* @test_split_string() {
%1 = alloca [6 x i8]
%2 = alloca i16
%3 = alloca i64
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%5 = bitcast i16* %2 to i8*
store i16 44, i16* %2
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = call i8** @split_string(i8* %4, i8* %5, i64* %3)
%8 = load i64, i64* %3
%9 = icmp eq i64 %8, 2
br i1 %9, label %10, label %21
10: ; preds = %0
%11 = load i8*, i8** %7
%12 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = getelementptr inbounds i8*, i8** %7, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = call i32 @free(i8** %7)
br label %21
21: ; preds = %14, %10, %0, %19
%22 = phi i8* [ null, %19 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), %14 ]
ret i8* %22
}