#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 */
typedef int /*<<< orphan*/ v;

/* Variables and functions */
int cnt(char *, char *);
char **malloc(int);
char *strdup(char *);
char *strtok(char *, char *);
void tok_ini0(char *s, char *del, int *pc, char ***pv) {
  int i, c;
  char *tok;
  char **v;
  c = cnt(s, del);
  v = malloc(c * sizeof(v[0]));
  tok = s;
  i = 0;
  while ((tok = strtok(tok, del)) != NULL) {
    v[i++] = strdup(tok);
    tok = NULL;
  }
  *pc = c;
  *pv = v;
}


x86 assembly (clang, -O0):
<tok_ini0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <cnt@plt>
mov    %eax,-0x28(%rbp)
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     11d4 <tok_ini0+0x94>
mov    -0x30(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,%rdx
mov    -0x38(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x24(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
movq   $0x0,-0x30(%rbp)
jmp    118a <tok_ini0+0x4a>
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tok_ini0>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1050 <cnt@plt>
mov    %eax,%r12d
lea    0x0(,%r12,8),%edi
call   1030 <malloc@plt>
mov    %rax,%r13
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     11af <tok_ini0+0x6f>
mov    %r13,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rax,%rdi
call   1060 <strdup@plt>
mov    %rax,0x0(%rbp)
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <strtok@plt>
add    $0x8,%rbp
test   %rax,%rax
jne    1190 <tok_ini0+0x50>
mov    %r12d,(%r15)
mov    %r13,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @tok_ini0(i8* %0, i8* %1, i32* %2, i8*** %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8***
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8**
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i8*** %3, i8**** %8
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = call i32 @cnt(i8* %13, i8* %14)
store i32 %15, i32* %10
%16 = load i32, i32* %10
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 8
%19 = trunc i64 %18 to i32
%20 = call i8** @malloc(i32 %19)
store i8** %20, i8*** %12
%21 = load i8*, i8** %5
store i8* %21, i8** %11
store i32 0, i32* %9
br label %22
22: ; preds = %27, %4
%23 = load i8*, i8** %11
%24 = load i8*, i8** %6
%25 = call i8* @strtok(i8* %23, i8* %24)
store i8* %25, i8** %11
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %35
27: ; preds = %22
%28 = load i8*, i8** %11
%29 = call i8* @strdup(i8* %28)
%30 = load i8**, i8*** %12
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 1
store i32 %32, i32* %9
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds i8*, i8** %30, i64 %33
store i8* %29, i8** %34
store i8* null, i8** %11
br label %22
35: ; preds = %22
%36 = load i32, i32* %10
%37 = load i32*, i32** %7
store i32 %36, i32* %37
%38 = load i8**, i8*** %12
%39 = load i8***, i8**** %8
store i8** %38, i8*** %39
ret void
}

LLVM IR (-O2):
define void @tok_ini0(i8* %0, i8* %1, i32* nocapture writeonly %2, i8*** nocapture writeonly %3) {
%5 = tail call i32 @cnt(i8* %0, i8* %1)
%6 = shl i32 %5, 3
%7 = tail call i8** @malloc(i32 %6)
%8 = tail call i8* @strtok(i8* %0, i8* %1)
%9 = icmp eq i8* %8, null
br i1 %9, label %18, label %10
10: ; preds = %4, %10
%11 = phi i64 [ %14, %10 ], [ 0, %4 ]
%12 = phi i8* [ %16, %10 ], [ %8, %4 ]
%13 = tail call i8* @strdup(i8* %12)
%14 = add nuw i64 %11, 1
%15 = getelementptr inbounds i8*, i8** %7, i64 %11
store i8* %13, i8** %15
%16 = tail call i8* @strtok(i8* null, i8* %1)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %10
18: ; preds = %10, %4
store i32 %5, i32* %2
store i8** %7, i8*** %3
ret void
}