#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char **);
void *realloc(char **, int);
int /*<<< orphan*/ stderr;
char *strtok(char *, char const *);
char **minstack_str_split_tools(char *s, const char *ct, int *nb_element) {
  char **tab = NULL;
  if (s != NULL && ct != NULL && nb_element != NULL) {
    int i;
    char *cs = NULL;
    size_t size = 1;
    for (i = 0; (cs = strtok(s, ct)); i++) {
      if (size <= i + 1) {
        void *tmp = NULL;
        size <<= 1;
        tmp = realloc(tab, sizeof(*tab) * size);
        if (tmp != NULL) {
          tab = tmp;
        } else {
          fprintf(stderr, "Memoire insuffisante\n");
          free(tab);
          tab = NULL;
          exit(EXIT_FAILURE);
        }
      }
      tab[i] = cs;
      s = NULL;
    }
    tab[i] = NULL;
    *nb_element = i;
  }
  return tab;
}


x86 assembly (clang, -O0):
<minstack_str_split_tools>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1290 <minstack_str_split_tools+0x140>
cmpq   $0x0,-0x10(%rbp)
je     1290 <minstack_str_split_tools+0x140>
cmpq   $0x0,-0x18(%rbp)
je     1290 <minstack_str_split_tools+0x140>
movq   $0x0,-0x30(%rbp)
movq   $0x1,-0x38(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1277 <minstack_str_split_tools+0x127>
mov    -0x38(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
ja     1251 <minstack_str_split_tools+0x101>
movq   $0x0,-0x40(%rbp)
mov    -0x38(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1218 <minstack_str_split_tools+0xc8>
mov    -0x40(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    124c <minstack_str_split_tools+0xfc>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1251 <minstack_str_split_tools+0x101>
mov    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movq   $0x0,-0x8(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a4 <minstack_str_split_tools+0x54>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minstack_str_split_tools>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r12d,%r12d
test   %rdi,%rdi
je     11df <minstack_str_split_tools+0x8f>
mov    %rsi,%r15
test   %rsi,%rsi
je     11df <minstack_str_split_tools+0x8f>
test   %rdx,%rdx
je     11df <minstack_str_split_tools+0x8f>
mov    %rdx,(%rsp)
mov    %r15,%rsi
call   1060 <strtok@plt>
mov    %rax,%rbx
mov    $0x1,%r13d
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    11a9 <minstack_str_split_tools+0x59>
nopl   0x0(%rax)
mov    %rbx,(%r12,%rbp,8)
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <strtok@plt>
mov    %rax,%rbx
mov    %r14,%rbp
test   %rax,%rax
je     11cd <minstack_str_split_tools+0x7d>
lea    0x1(%rbp),%r14
cmp    %r14,%r13
ja     1190 <minstack_str_split_tools+0x40>
mov    %r13d,%esi
shl    $0x4,%esi
mov    %r12,%rdi
call   1050 <realloc@plt>
test   %rax,%rax
je     11f1 <minstack_str_split_tools+0xa1>
add    %r13,%r13
mov    %rax,%r12
jmp    1190 <minstack_str_split_tools+0x40>
mov    %r14d,%eax
movq   $0x0,(%r12,%rax,8)
mov    (%rsp),%rax
mov    %r14d,(%rax)
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
call   1040 <fprintf@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Memoire insuffisante\0A\00"
@EXIT_FAILURE = global i32 0
define i8** @minstack_str_split_tools(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
store i8** null, i8*** %7
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %69
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %69
17: ; preds = %14
%18 = load i32*, i32** %6
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %69
20: ; preds = %17
store i8* null, i8** %9
store i64 1, i64* %10
store i32 0, i32* %8
br label %21
21: ; preds = %59, %20
%22 = load i8*, i8** %4
%23 = load i8*, i8** %5
%24 = call i8* @strtok(i8* %22, i8* %23)
store i8* %24, i8** %9
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %62
26: ; preds = %21
%27 = load i64, i64* %10
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = icmp ule i64 %27, %30
br i1 %31, label %32, label %53
32: ; preds = %26
store i8* null, i8** %11
%33 = load i64, i64* %10
%34 = shl i64 %33, 1
store i64 %34, i64* %10
%35 = load i8**, i8*** %7
%36 = load i64, i64* %10
%37 = mul i64 8, %36
%38 = trunc i64 %37 to i32
%39 = call i8* @realloc(i8** %35, i32 %38)
store i8* %39, i8** %11
%40 = load i8*, i8** %11
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %45
42: ; preds = %32
%43 = load i8*, i8** %11
%44 = bitcast i8* %43 to i8**
store i8** %44, i8*** %7
br label %52
45: ; preds = %32
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%48 = load i8**, i8*** %7
%49 = call i32 @free(i8** %48)
store i8** null, i8*** %7
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %42
br label %53
53: ; preds = %52, %26
%54 = load i8*, i8** %9
%55 = load i8**, i8*** %7
%56 = load i32, i32* %8
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
store i8* %54, i8** %58
store i8* null, i8** %4
br label %59
59: ; preds = %53
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
br label %21
62: ; preds = %21
%63 = load i8**, i8*** %7
%64 = load i32, i32* %8
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
store i8* null, i8** %66
%67 = load i32, i32* %8
%68 = load i32*, i32** %6
store i32 %67, i32* %68
br label %69
69: ; preds = %62, %17, %14, %3
%70 = load i8**, i8*** %7
ret i8** %70
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Memoire insuffisante\0A\00"
@EXIT_FAILURE = global i32 0
define i8** @minstack_str_split_tools(i8* %0, i8* %1, i32* writeonly %2) {
%4 = icmp ne i8* %0, null
%5 = icmp ne i8* %1, null
%6 = and i1 %4, %5
%7 = icmp ne i32* %2, null
%8 = and i1 %6, %7
br i1 %8, label %9, label %43
9: ; preds = %3
%10 = tail call i8* @strtok(i8* %0, i8* %1)
%11 = icmp ne i8* %10, null
br label %12
12: ; preds = %9, %33
%13 = phi i64 [ 0, %9 ], [ %17, %33 ]
%14 = phi i8* [ %10, %9 ], [ %37, %33 ]
%15 = phi i64 [ 1, %9 ], [ %35, %33 ]
%16 = phi i8** [ null, %9 ], [ %34, %33 ]
%17 = add nuw i64 %13, 1
%18 = icmp ugt i64 %15, %17
br i1 %18, label %33, label %19
19: ; preds = %12
%20 = trunc i64 %15 to i32
%21 = shl i32 %20, 4
%22 = tail call i8* @realloc(i8** %16, i32 %21)
%23 = icmp eq i8* %22, null
br i1 %23, label %27, label %24
24: ; preds = %19
%25 = shl i64 %15, 1
%26 = bitcast i8* %22 to i8**
br label %33
27: ; preds = %19
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%30 = tail call i32 @free(i8** %16)
%31 = load i32, i32* @EXIT_FAILURE
%32 = tail call i32 @exit(i32 %31)
unreachable
33: ; preds = %24, %12
%34 = phi i8** [ %26, %24 ], [ %16, %12 ]
%35 = phi i64 [ %25, %24 ], [ %15, %12 ]
%36 = getelementptr inbounds i8*, i8** %34, i64 %13
store i8* %14, i8** %36
%37 = tail call i8* @strtok(i8* null, i8* %1)
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %12
39: ; preds = %33
%40 = trunc i64 %17 to i32
%41 = and i64 %17, 4294967295
%42 = getelementptr inbounds i8*, i8** %34, i64 %41
store i8* null, i8** %42
store i32 %40, i32* %2
br label %43
43: ; preds = %39, %3
%44 = phi i8** [ %34, %39 ], [ null, %3 ]
ret i8** %44
}