int main() {
  char months[] = "JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC";
  char **tokens;
  printf("months=[%s]\n\n", months);
  tokens = str_split(months, ',');
  if (tokens) {
    int i;
    for (i = 0; *(tokens + i); i++) {
      printf("month=[%s]\n", *(tokens + i));
      free(*(tokens + i));
    }
    printf("\n");
    free(tokens);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x30,%edx
call   1050 <memcpy@plt>
lea    -0x40(%rbp),%rsi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x2c,%esi
mov    $0x0,%al
call   1060 <str_split@plt>
cltq
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1201 <main+0xc1>
movl   $0x0,-0x4c(%rbp)
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11ea <main+0xaa>
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    119e <main+0x5e>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xebd(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x2c,%esi
xor    %eax,%eax
call   1060 <str_split@plt>
test   %eax,%eax
je     11e1 <main+0xa1>
movslq %eax,%r14
mov    (%r14),%rsi
test   %rsi,%rsi
je     11cf <main+0x8f>
lea    0x8(%r14),%rbx
lea    0xe95(%rip),%r15
nopl   0x0(%rax)
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x8(%rbx),%rdi
call   1030 <free@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    11b0 <main+0x70>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.months = [48 x i8] c"JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC\00"
@.str = [14 x i8] c"months=[%s]\0A\0A\00"
@.str.1 = [12 x i8] c"month=[%s]\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [48 x i8]
%3 = alloca i8**
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [48 x i8]* %2 to i8*
%6 = getelementptr inbounds [48 x i8], [48 x i8]* %2, i64 0, i64 0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [48 x i8], [48 x i8]* %2, i64 0, i64 0
%9 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @str_split to i32 (i8*, i32, ...)*)(i8* %8, i32 44)
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i8**
store i8** %11, i8*** %3
%12 = load i8**, i8*** %3
%13 = icmp ne i8** %12, null
br i1 %13, label %14, label %41
14: ; preds = %0
store i32 0, i32* %4
br label %15
15: ; preds = %34, %14
%16 = load i8**, i8*** %3
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %37
22: ; preds = %15
%23 = load i8**, i8*** %3
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = load i8**, i8*** %3
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
br label %34
34: ; preds = %22
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %15
37: ; preds = %15
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%39 = load i8**, i8*** %3
%40 = bitcast i8** %39 to i8*
br label %41
41: ; preds = %37, %0
ret i32 0
}

LLVM IR (-O2):
@__const.main.months = [48 x i8] c"JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC\00"
@.str = [14 x i8] c"months=[%s]\0A\0A\00"
@.str.1 = [12 x i8] c"month=[%s]\0A\00"
define i32 @main() {
%1 = alloca [48 x i8]
%2 = getelementptr inbounds [48 x i8], [48 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @str_split to i32 (i8*, i32, ...)*)(i8* %2, i32 44)
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to i8**
%7 = icmp eq i32 %4, 0
br i1 %7, label %24, label %8
8: ; preds = %0
%9 = load i8*, i8** %6
%10 = icmp eq i8* %9, null
br i1 %10, label %21, label %11
11: ; preds = %8, %11
%12 = phi i64 [ %17, %11 ], [ 0, %8 ]
%13 = phi i8* [ %19, %11 ], [ %9, %8 ]
%14 = phi i8** [ %18, %11 ], [ %6, %8 ]
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%16 = load i8*, i8** %14
%17 = add nuw i64 %12, 1
%18 = getelementptr inbounds i8*, i8** %6, i64 %17
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %11
21: ; preds = %11, %8
%22 = call i32 @putchar(i32 10)
%23 = inttoptr i64 %5 to i8*
br label %24
24: ; preds = %21, %0
ret i32 0
}