#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 atoi(char *);
scalar_t__ calloc(int, int);
int count_tokens_in_string(char *, char *);
int /*<<< orphan*/ free(char *);
char *get_token_from_string(char *, char *, char *);
char *strdup(char const *);
scalar_t__ strlen(char *);
int *llspeech_make_int_array(const char *original, int *array_len) {
  int *int_array;
  char *copy, *copy2, *next, *token, delim[3] = ",:";
  int i = 0, len;
  if (!original) {
    if (array_len) {
      *array_len = 0;
      return NULL;
    } else {
      int_array = (int *)calloc(1, sizeof(int));
      int_array[0] = 0;
      return int_array;
    }
  }
  copy = strdup(original);
  len = count_tokens_in_string(copy, delim);
  if (array_len) {
    *array_len = len;
    int_array = (int *)calloc(len, sizeof(int));
  } else {
    int_array = (int *)calloc(len + 1, sizeof(int));
    int_array[0] = len;
    i++;
  }
  token = copy;
  copy2 = strdup(original);
  next = get_token_from_string(copy2, delim, token);
  while (strlen(token)) {
    int_array[i++] = atoi(token);
    next = get_token_from_string(next, delim, token);
  }
  if (copy)
    free(copy);
  if (copy2)
    free(copy2);
  return int_array;
}


x86 assembly (clang, -O0):
<llspeech_make_int_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0xe79(%rip),%ax
mov    %ax,-0x43(%rbp)
mov    0xe71(%rip),%al
mov    %al,-0x41(%rbp)
movl   $0x0,-0x48(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11f2 <llspeech_make_int_array+0x82>
cmpq   $0x0,-0x18(%rbp)
je     11c8 <llspeech_make_int_array+0x58>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    1306 <llspeech_make_int_array+0x196>
mov    $0x1,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1306 <llspeech_make_int_array+0x196>
mov    -0x10(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x43(%rbp),%rsi
call   1060 <count_tokens_in_string@plt>
mov    %eax,-0x4c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1239 <llspeech_make_int_array+0xc9>
mov    -0x4c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4c(%rbp),%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
jmp    125f <llspeech_make_int_array+0xef>
mov    -0x4c(%rbp),%edi
add    $0x1,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x4c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x43(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1070 <get_token_from_string@plt>
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
je     12d6 <llspeech_make_int_array+0x166>
mov    -0x40(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x48(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%rdi
lea    -0x43(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1070 <get_token_from_string@plt>
mov    %rax,-0x38(%rbp)
jmp    1289 <llspeech_make_int_array+0x119>
cmpq   $0x0,-0x28(%rbp)
je     12ea <llspeech_make_int_array+0x17a>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x30(%rbp)
je     12fe <llspeech_make_int_array+0x18e>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<llspeech_make_int_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
movb   $0x0,0x6(%rsp)
movw   $0x3a2c,0x4(%rsp)
test   %rdi,%rdi
je     11b5 <llspeech_make_int_array+0x55>
mov    %rdi,%r15
call   1080 <strdup@plt>
mov    %rax,%r12
lea    0x4(%rsp),%rsi
mov    %rax,%rdi
call   1050 <count_tokens_in_string@plt>
mov    %eax,%ebx
test   %r14,%r14
je     11cd <llspeech_make_int_array+0x6d>
mov    %ebx,(%r14)
mov    %ebx,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,%r14
xor    %r13d,%r13d
jmp    11e7 <llspeech_make_int_array+0x87>
test   %r14,%r14
je     125e <llspeech_make_int_array+0xfe>
movl   $0x0,(%r14)
xor    %r14d,%r14d
jmp    1276 <llspeech_make_int_array+0x116>
mov    %ebx,%edi
add    $0x1,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,%r14
mov    %ebx,(%rax)
mov    $0x1,%r13d
mov    %r15,%rdi
call   1080 <strdup@plt>
mov    %rax,%r15
lea    0x4(%rsp),%rsi
mov    %rax,%rdi
mov    %r12,%rdx
call   1060 <get_token_from_string@plt>
cmpb   $0x0,(%r12)
je     1247 <llspeech_make_int_array+0xe7>
mov    %rax,%rbx
lea    (%r14,%r13,4),%rbp
lea    0x4(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
call   1070 <atoi@plt>
mov    %eax,0x0(%rbp)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1060 <get_token_from_string@plt>
mov    %rax,%rbx
add    $0x4,%rbp
cmpb   $0x0,(%r12)
jne    1220 <llspeech_make_int_array+0xc0>
mov    %r12,%rdi
call   1030 <free@plt>
test   %r15,%r15
je     1276 <llspeech_make_int_array+0x116>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    1276 <llspeech_make_int_array+0x116>
mov    $0x1,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,%r14
movl   $0x0,(%rax)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.llspeech_make_int_array.delim = [3 x i8] c",:\00"
define i32* @llspeech_make_int_array(i8* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [3 x i8]
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%14 = bitcast [3 x i8]* %11 to i8*
store i32 0, i32* %12
%15 = load i8*, i8** %4
%16 = icmp ne i8* %15, null
br i1 %16, label %28, label %17
17: ; preds = %2
%18 = load i32*, i32** %5
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load i32*, i32** %5
store i32 0, i32* %21
store i32* null, i32** %3
br label %90
22: ; preds = %17
%23 = call i64 @calloc(i32 1, i32 4)
%24 = inttoptr i64 %23 to i32*
store i32* %24, i32** %6
%25 = load i32*, i32** %6
%26 = getelementptr inbounds i32, i32* %25, i64 0
store i32 0, i32* %26
%27 = load i32*, i32** %6
store i32* %27, i32** %3
br label %90
28: ; preds = %2
%29 = load i8*, i8** %4
%30 = call i8* @strdup(i8* %29)
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%33 = call i32 @count_tokens_in_string(i8* %31, i8* %32)
store i32 %33, i32* %13
%34 = load i32*, i32** %5
%35 = icmp ne i32* %34, null
br i1 %35, label %36, label %42
36: ; preds = %28
%37 = load i32, i32* %13
%38 = load i32*, i32** %5
store i32 %37, i32* %38
%39 = load i32, i32* %13
%40 = call i64 @calloc(i32 %39, i32 4)
%41 = inttoptr i64 %40 to i32*
store i32* %41, i32** %6
br label %52
42: ; preds = %28
%43 = load i32, i32* %13
%44 = add nsw i32 %43, 1
%45 = call i64 @calloc(i32 %44, i32 4)
%46 = inttoptr i64 %45 to i32*
store i32* %46, i32** %6
%47 = load i32, i32* %13
%48 = load i32*, i32** %6
%49 = getelementptr inbounds i32, i32* %48, i64 0
store i32 %47, i32* %49
%50 = load i32, i32* %12
%51 = add nsw i32 %50, 1
store i32 %51, i32* %12
br label %52
52: ; preds = %42, %36
%53 = load i8*, i8** %7
store i8* %53, i8** %10
%54 = load i8*, i8** %4
%55 = call i8* @strdup(i8* %54)
store i8* %55, i8** %8
%56 = load i8*, i8** %8
%57 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%58 = load i8*, i8** %10
%59 = call i8* @get_token_from_string(i8* %56, i8* %57, i8* %58)
store i8* %59, i8** %9
br label %60
60: ; preds = %64, %52
%61 = load i8*, i8** %10
%62 = call i64 @strlen(i8* %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %76
64: ; preds = %60
%65 = load i8*, i8** %10
%66 = call i32 @atoi(i8* %65)
%67 = load i32*, i32** %6
%68 = load i32, i32* %12
%69 = add nsw i32 %68, 1
store i32 %69, i32* %12
%70 = sext i32 %68 to i64
%71 = getelementptr inbounds i32, i32* %67, i64 %70
store i32 %66, i32* %71
%72 = load i8*, i8** %9
%73 = getelementptr inbounds [3 x i8], [3 x i8]* %11, i64 0, i64 0
%74 = load i8*, i8** %10
%75 = call i8* @get_token_from_string(i8* %72, i8* %73, i8* %74)
store i8* %75, i8** %9
br label %60
76: ; preds = %60
%77 = load i8*, i8** %7
%78 = icmp ne i8* %77, null
br i1 %78, label %79, label %82
79: ; preds = %76
%80 = load i8*, i8** %7
%81 = call i32 @free(i8* %80)
br label %82
82: ; preds = %79, %76
%83 = load i8*, i8** %8
%84 = icmp ne i8* %83, null
br i1 %84, label %85, label %88
85: ; preds = %82
%86 = load i8*, i8** %8
%87 = call i32 @free(i8* %86)
br label %88
88: ; preds = %85, %82
%89 = load i32*, i32** %6
store i32* %89, i32** %3
br label %90
90: ; preds = %88, %22, %20
%91 = load i32*, i32** %3
ret i32* %91
}

LLVM IR (-O2):
@__const.llspeech_make_int_array.delim = [3 x i8] c",:\00"
define i32* @llspeech_make_int_array(i8* %0, i32* writeonly %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8* %0, null
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = icmp eq i32* %1, null
br i1 %7, label %9, label %8
8: ; preds = %6
store i32 0, i32* %1
br label %44
9: ; preds = %6
%10 = tail call i64 @calloc(i32 1, i32 4)
%11 = inttoptr i64 %10 to i32*
store i32 0, i32* %11
br label %44
12: ; preds = %2
%13 = tail call i8* @strdup(i8* %0)
%14 = call i32 @count_tokens_in_string(i8* %13, i8* %4)
%15 = icmp eq i32* %1, null
br i1 %15, label %19, label %16
16: ; preds = %12
store i32 %14, i32* %1
%17 = call i64 @calloc(i32 %14, i32 4)
%18 = inttoptr i64 %17 to i32*
br label %23
19: ; preds = %12
%20 = add nsw i32 %14, 1
%21 = call i64 @calloc(i32 %20, i32 4)
%22 = inttoptr i64 %21 to i32*
store i32 %14, i32* %22
br label %23
23: ; preds = %19, %16
%24 = phi i32* [ %18, %16 ], [ %22, %19 ]
%25 = phi i64 [ 0, %16 ], [ 1, %19 ]
%26 = call i8* @strdup(i8* %0)
%27 = call i8* @get_token_from_string(i8* %26, i8* %4, i8* %13)
%28 = load i8, i8* %13
%29 = icmp eq i8 %28, 0
br i1 %29, label %39, label %30
30: ; preds = %23, %30
%31 = phi i64 [ %34, %30 ], [ %25, %23 ]
%32 = phi i8* [ %36, %30 ], [ %27, %23 ]
%33 = call i32 @atoi(i8* %13)
%34 = add nuw i64 %31, 1
%35 = getelementptr inbounds i32, i32* %24, i64 %31
store i32 %33, i32* %35
%36 = call i8* @get_token_from_string(i8* %32, i8* %4, i8* %13)
%37 = load i8, i8* %13
%38 = icmp eq i8 %37, 0
br i1 %38, label %39, label %30
39: ; preds = %30, %23
%40 = call i32 @free(i8* %13)
%41 = icmp eq i8* %26, null
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = call i32 @free(i8* %26)
br label %44
44: ; preds = %39, %42, %9, %8
%45 = phi i32* [ null, %8 ], [ %11, %9 ], [ %24, %42 ], [ %24, %39 ]
ret i32* %45
}