#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*/ StrUtil_copyString(char **, char *, int /*<<< orphan*/);
scalar_t__ StrUtil_gettok(char *, char **, char *, int);
scalar_t__ realloc(char **, int);
int /*<<< orphan*/ strlen(char *);
int StrUtil_tokenize(char ***tokens, int *ntok, char *string) {
  char token[1024];
  char *ChP = string;
  int count = 0;
  *tokens = NULL;
  while (StrUtil_gettok(token, &ChP, ChP, 1024)) {
    if (!strlen(token))
      break;
    if (!count || !((count + 1) % 10)) {
      *tokens = (char **)realloc(*tokens, (count + 10) * sizeof(char *));
    }
    StrUtil_copyString(&((*tokens)[count++]), token, 0);
  }
  *ntok = count;
  return 1;
}


x86 assembly (clang, -O0):
<StrUtil_tokenize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x428(%rbp)
movl   $0x0,-0x42c(%rbp)
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
lea    -0x420(%rbp),%rdi
mov    -0x428(%rbp),%rdx
lea    -0x428(%rbp),%rsi
mov    $0x400,%ecx
call   1060 <StrUtil_gettok@plt>
cmp    $0x0,%rax
je     123c <StrUtil_tokenize+0xfc>
lea    -0x420(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    11ba <StrUtil_tokenize+0x7a>
jmp    123c <StrUtil_tokenize+0xfc>
cmpl   $0x0,-0x42c(%rbp)
je     11e1 <StrUtil_tokenize+0xa1>
mov    -0x42c(%rbp),%eax
add    $0x1,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1208 <StrUtil_tokenize+0xc8>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x42c(%rbp),%eax
add    $0xa,%eax
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   1040 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x42c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x42c(%rbp)
cltq
shl    $0x3,%rax
add    %rax,%rdi
lea    -0x420(%rbp),%rsi
xor    %edx,%edx
call   1050 <StrUtil_copyString@plt>
jmp    1177 <StrUtil_tokenize+0x37>
mov    -0x42c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x1,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StrUtil_tokenize>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rdx,(%rsp)
movq   $0x0,(%rdi)
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x400,%ecx
call   1060 <StrUtil_gettok@plt>
test   %rax,%rax
mov    %rbx,0x8(%rsp)
je     1215 <StrUtil_tokenize+0xd5>
xor    %ebx,%ebx
lea    0x10(%rsp),%r13
mov    %rsp,%r12
jmp    11d7 <StrUtil_tokenize+0x97>
xchg   %ax,%ax
mov    $0x1,%ebp
mov    $0x1,%r14d
mov    (%r15),%rdi
lea    0x50(,%rbx,8),%esi
call   1040 <realloc@plt>
mov    %rax,(%r15)
lea    (%rax,%rbx,8),%rdi
mov    %r13,%rsi
xor    %edx,%edx
call   1050 <StrUtil_copyString@plt>
mov    (%rsp),%rdx
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0x400,%ecx
call   1060 <StrUtil_gettok@plt>
mov    %rbp,%rbx
test   %rax,%rax
je     121d <StrUtil_tokenize+0xdd>
mov    %r13,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     121a <StrUtil_tokenize+0xda>
test   %rbx,%rbx
je     1190 <StrUtil_tokenize+0x50>
lea    0x1(%rbx),%r14
imul   $0xcccccccd,%r14d,%eax
ror    %eax
cmp    $0x1999999a,%eax
jb     1210 <StrUtil_tokenize+0xd0>
mov    (%r15),%rax
mov    %r14,%rbp
jmp    11ad <StrUtil_tokenize+0x6d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rbp
jmp    119b <StrUtil_tokenize+0x5b>
xor    %r14d,%r14d
jmp    121d <StrUtil_tokenize+0xdd>
mov    %ebx,%r14d
mov    0x8(%rsp),%rax
mov    %r14d,(%rax)
mov    $0x1,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @StrUtil_tokenize(i8*** nocapture %0, i32* nocapture writeonly %1, i8* %2) {
%4 = alloca [1024 x i8]
%5 = alloca i8*
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = bitcast i8** %5 to i8*
store i8* %2, i8** %5
store i8** null, i8*** %0
%8 = call i64 @StrUtil_gettok(i8* %6, i8** %5, i8* %2, i32 1024)
%9 = icmp eq i64 %8, 0
br i1 %9, label %43, label %10
10: ; preds = %3, %32
%11 = phi i64 [ %34, %32 ], [ 0, %3 ]
%12 = call i32 @strlen(i8* %6)
%13 = icmp eq i32 %12, 0
%14 = trunc i64 %11 to i32
br i1 %13, label %41, label %15
15: ; preds = %10
%16 = icmp eq i64 %11, 0
br i1 %16, label %24, label %17
17: ; preds = %15
%18 = add nuw i64 %11, 1
%19 = trunc i64 %18 to i32
%20 = urem i32 %19, 10
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = load i8**, i8*** %0
br label %32
24: ; preds = %15, %17
%25 = phi i32 [ %19, %17 ], [ 1, %15 ]
%26 = phi i64 [ %18, %17 ], [ 1, %15 ]
%27 = load i8**, i8*** %0
%28 = shl i32 %14, 3
%29 = add i32 %28, 80
%30 = call i64 @realloc(i8** %27, i32 %29)
%31 = inttoptr i64 %30 to i8**
store i8** %31, i8*** %0
br label %32
32: ; preds = %22, %24
%33 = phi i32 [ %19, %22 ], [ %25, %24 ]
%34 = phi i64 [ %18, %22 ], [ %26, %24 ]
%35 = phi i8** [ %23, %22 ], [ %31, %24 ]
%36 = getelementptr inbounds i8*, i8** %35, i64 %11
%37 = call i32 @StrUtil_copyString(i8** %36, i8* %6, i32 0)
%38 = load i8*, i8** %5
%39 = call i64 @StrUtil_gettok(i8* %6, i8** %5, i8* %38, i32 1024)
%40 = icmp eq i64 %39, 0
br i1 %40, label %43, label %10
41: ; preds = %10
%42 = trunc i64 %11 to i32
br label %43
43: ; preds = %32, %41, %3
%44 = phi i32 [ 0, %3 ], [ %42, %41 ], [ %33, %32 ]
store i32 %44, i32* %1
ret i32 1
}