#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;
  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)
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    115d <ft_strsplit+0x3d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    118c <ft_strsplit+0x6c>
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
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %rsp,%rsi
mov    %ebp,%edx
call   1040 <malloc_the_array@plt>
test   %eax,%eax
je     1155 <ft_strsplit+0x35>
movsbl %bpl,%ecx
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <malloc_and_copy@plt>
mov    (%rsp),%rcx
cltq
movq   $0x0,(%rcx,%rax,8)
mov    (%rsp),%rax
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 = load i8, i8* %5
%10 = call i32 @malloc_the_array(i8* %8, i8*** %6, i8 signext %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = load i8**, i8*** %6
store i8** %14, i8*** %3
br label %25
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = load i32, i32* %7
%18 = load i8, i8* %5
%19 = call i32 @malloc_and_copy(i8* %16, i8*** %6, i32 %17, i8 signext %18)
store i32 %19, i32* %7
%20 = load i8**, i8*** %6
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
store i8* null, i8** %23
%24 = load i8**, i8*** %6
store i8** %24, i8*** %3
br label %25
25: ; preds = %15, %13
%26 = load i8**, i8*** %3
ret i8** %26
}

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