#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 malloc_and_copy(char *, char ***, int, char);
int malloc_the_array(char *, char ***, char);
char **ft_strsplit(char const *s, char c) {
  char **tab;
  int words;
  if (!s)
    return (NULL);
  words = malloc_the_array((char *)s, &tab, c);
  if (words == 0)
    return (tab);
  words = malloc_and_copy((char *)s, &tab, words, c);
  tab[words] = 0;
  return (tab);
}


x86 assembly (clang, -O0):
<ft_strsplit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114a <ft_strsplit+0x2a>
movq   $0x0,-0x8(%rbp)
jmp    11a4 <ft_strsplit+0x84>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
movsbl -0x11(%rbp),%edx
call   1040 <malloc_the_array@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1175 <ft_strsplit+0x55>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a4 <ft_strsplit+0x84>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    -0x20(%rbp),%rsi
movsbl -0x11(%rbp),%ecx
call   1030 <malloc_and_copy@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_strsplit>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     1160 <ft_strsplit+0x40>
mov    %rdi,%rbx
movsbl %sil,%ebp
mov    %rsp,%rsi
mov    %ebp,%edx
call   1040 <malloc_the_array@plt>
test   %eax,%eax
je     115a <ft_strsplit+0x3a>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    %eax,%edx
mov    %ebp,%ecx
call   1030 <malloc_and_copy@plt>
mov    (%rsp),%rcx
cltq
movq   $0x0,(%rcx,%rax,8)
mov    (%rsp),%rax
jmp    1162 <ft_strsplit+0x42>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i8** @ft_strsplit(i8* %0, i8 signext %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8**
%7 = alloca i32
store i8* %0, i8** %4
store i8 %1, i8* %5
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %2
store i8** null, i8*** %3
br label %29
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = load i8, i8* %5
%14 = call i32 @malloc_the_array(i8* %12, i8*** %6, i8 signext %13)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = load i8**, i8*** %6
store i8** %18, i8*** %3
br label %29
19: ; preds = %11
%20 = load i8*, i8** %4
%21 = load i32, i32* %7
%22 = load i8, i8* %5
%23 = call i32 @malloc_and_copy(i8* %20, i8*** %6, i32 %21, i8 signext %22)
store i32 %23, i32* %7
%24 = load i8**, i8*** %6
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
store i8* null, i8** %27
%28 = load i8**, i8*** %6
store i8** %28, i8*** %3
br label %29
29: ; preds = %19, %17, %10
%30 = load i8**, i8*** %3
ret i8** %30
}

LLVM IR (-O2):
define i8** @ft_strsplit(i8* %0, i8 signext %1) {
%3 = alloca i8**
%4 = bitcast i8*** %3 to i8*
%5 = icmp eq i8* %0, null
br i1 %5, label %17, label %6
6: ; preds = %2
%7 = call i32 @malloc_the_array(i8* %0, i8*** %3, i8 signext %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = load i8**, i8*** %3
br label %17
11: ; preds = %6
%12 = call i32 @malloc_and_copy(i8* %0, i8*** %3, i32 %7, i8 signext %1)
%13 = load i8**, i8*** %3
%14 = sext i32 %12 to i64
%15 = getelementptr inbounds i8*, i8** %13, i64 %14
store i8* null, i8** %15
%16 = load i8**, i8*** %3
br label %17
17: ; preds = %2, %11, %9
%18 = phi i8** [ %10, %9 ], [ %16, %11 ], [ null, %2 ]
ret i8** %18
}