#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 */
char *agregar_cadena(char const *, int);
char **malloc(size_t);
char *strchr(char const *, char);
int strlen(char const *);
char **split(const char *str, char sep) {
  char *vector[strlen(str)];
  char *pal_aux = strchr(str, sep);
  size_t i = 0;
  while (pal_aux != NULL) {
    vector[i] = agregar_cadena(str, strlen(str) - strlen(pal_aux));
    str = pal_aux + 1;
    pal_aux = strchr(str, sep);
    i++;
  }
  vector[i] = agregar_cadena(str, strlen(str));
  i++;
  vector[i] = NULL;
  char **strv = malloc((i + 1) * sizeof(char *));
  if (!strv)
    return NULL;
  for (int j = 0; j <= i; j++) {
    strv[j] = vector[j];
  }
  return strv;
}


x86 assembly (clang, -O0):
<split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     120d <split+0xcd>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x5c(%rbp),%esi
mov    -0x58(%rbp),%rdi
sub    %eax,%esi
call   1030 <agregar_cadena@plt>
mov    %rax,%rdx
mov    -0x50(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    119a <split+0x5a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%esi
call   1030 <agregar_cadena@plt>
mov    %rax,%rdx
mov    -0x50(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x38(%rbp),%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rdi
add    $0x1,%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1284 <split+0x144>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    12ce <split+0x18e>
movl   $0x0,-0x48(%rbp)
movslq -0x48(%rbp),%rax
cmp    -0x38(%rbp),%rax
ja     12bf <split+0x17f>
mov    -0x50(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x40(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    128b <split+0x14b>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r12d
mov    %rdi,%r13
call   1040 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%rbx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r13,%rdi
mov    %r12d,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11e8 <split+0x98>
mov    %rax,%r15
xor    %r14d,%r14d
movsbl %r12b,%eax
mov    %eax,-0x2c(%rbp)
nopl   (%rax)
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %rbx,%r12
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <strlen@plt>
sub    %eax,%ebx
mov    %r13,%rdi
mov    %ebx,%esi
mov    %r12,%rbx
call   1030 <agregar_cadena@plt>
mov    %rax,(%r12,%r14,8)
mov    %r15,%r13
add    $0x1,%r13
mov    %r13,%rdi
mov    -0x2c(%rbp),%esi
call   1050 <strchr@plt>
mov    %rax,%r15
add    $0x1,%r14
test   %rax,%rax
jne    11a0 <split+0x50>
jmp    11eb <split+0x9b>
xor    %r14d,%r14d
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1030 <agregar_cadena@plt>
mov    %rax,(%rbx,%r14,8)
movq   $0x0,0x8(%rbx,%r14,8)
lea    0x10(,%r14,8),%rdi
call   1070 <malloc@plt>
mov    %rbx,%rsi
mov    %rax,%rbx
test   %rax,%rax
je     123f <split+0xef>
add    $0x2,%r14
cmp    $0x2,%r14
mov    $0x1,%edx
cmovae %r14,%rdx
shl    $0x3,%rdx
mov    %rbx,%rdi
call   1060 <memcpy@plt>
mov    %rbx,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8** @split(i8* %0, i8 signext %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %4
store i8 %1, i8* %5
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %6
%17 = alloca i8*, i64 %15
store i64 %15, i64* %7
%18 = load i8*, i8** %4
%19 = load i8, i8* %5
%20 = call i8* @strchr(i8* %18, i8 signext %19)
store i8* %20, i8** %8
store i64 0, i64* %9
br label %21
21: ; preds = %24, %2
%22 = load i8*, i8** %8
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %41
24: ; preds = %21
%25 = load i8*, i8** %4
%26 = load i8*, i8** %4
%27 = call i32 @strlen(i8* %26)
%28 = load i8*, i8** %8
%29 = call i32 @strlen(i8* %28)
%30 = sub nsw i32 %27, %29
%31 = call i8* @agregar_cadena(i8* %25, i32 %30)
%32 = load i64, i64* %9
%33 = getelementptr inbounds i8*, i8** %17, i64 %32
store i8* %31, i8** %33
%34 = load i8*, i8** %8
%35 = getelementptr inbounds i8, i8* %34, i64 1
store i8* %35, i8** %4
%36 = load i8*, i8** %4
%37 = load i8, i8* %5
%38 = call i8* @strchr(i8* %36, i8 signext %37)
store i8* %38, i8** %8
%39 = load i64, i64* %9
%40 = add i64 %39, 1
store i64 %40, i64* %9
br label %21
41: ; preds = %21
%42 = load i8*, i8** %4
%43 = load i8*, i8** %4
%44 = call i32 @strlen(i8* %43)
%45 = call i8* @agregar_cadena(i8* %42, i32 %44)
%46 = load i64, i64* %9
%47 = getelementptr inbounds i8*, i8** %17, i64 %46
store i8* %45, i8** %47
%48 = load i64, i64* %9
%49 = add i64 %48, 1
store i64 %49, i64* %9
%50 = load i64, i64* %9
%51 = getelementptr inbounds i8*, i8** %17, i64 %50
store i8* null, i8** %51
%52 = load i64, i64* %9
%53 = add i64 %52, 1
%54 = mul i64 %53, 8
%55 = call i8** @malloc(i64 %54)
store i8** %55, i8*** %10
%56 = load i8**, i8*** %10
%57 = icmp ne i8** %56, null
br i1 %57, label %59, label %58
58: ; preds = %41
store i8** null, i8*** %3
store i32 1, i32* %11
br label %79
59: ; preds = %41
store i32 0, i32* %12
br label %60
60: ; preds = %74, %59
%61 = load i32, i32* %12
%62 = sext i32 %61 to i64
%63 = load i64, i64* %9
%64 = icmp ule i64 %62, %63
br i1 %64, label %65, label %77
65: ; preds = %60
%66 = load i32, i32* %12
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %17, i64 %67
%69 = load i8*, i8** %68
%70 = load i8**, i8*** %10
%71 = load i32, i32* %12
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %70, i64 %72
store i8* %69, i8** %73
br label %74
74: ; preds = %65
%75 = load i32, i32* %12
%76 = add nsw i32 %75, 1
store i32 %76, i32* %12
br label %60
77: ; preds = %60
%78 = load i8**, i8*** %10
store i8** %78, i8*** %3
store i32 1, i32* %11
br label %79
79: ; preds = %77, %58
%80 = load i8*, i8** %6
%81 = load i8**, i8*** %3
ret i8** %81
}

LLVM IR (-O2):
define noalias i8** @split(i8* %0, i8 signext %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = zext i32 %3 to i64
%5 = alloca i8*, i64 %4
%6 = bitcast i8** %5 to i8*
%7 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext %1)
%8 = icmp eq i8* %7, null
br i1 %8, label %22, label %9
9: ; preds = %2, %9
%10 = phi i64 [ %20, %9 ], [ 0, %2 ]
%11 = phi i8* [ %19, %9 ], [ %7, %2 ]
%12 = phi i8* [ %18, %9 ], [ %0, %2 ]
%13 = tail call i32 @strlen(i8* %12)
%14 = tail call i32 @strlen(i8* %11)
%15 = sub nsw i32 %13, %14
%16 = tail call i8* @agregar_cadena(i8* %12, i32 %15)
%17 = getelementptr inbounds i8*, i8** %5, i64 %10
store i8* %16, i8** %17
%18 = getelementptr inbounds i8, i8* %11, i64 1
%19 = tail call i8* @strchr(i8* %18, i8 signext %1)
%20 = add i64 %10, 1
%21 = icmp eq i8* %19, null
br i1 %21, label %22, label %9
22: ; preds = %9, %2
%23 = phi i8* [ %0, %2 ], [ %18, %9 ]
%24 = phi i64 [ 0, %2 ], [ %20, %9 ]
%25 = tail call i32 @strlen(i8* %23)
%26 = tail call i8* @agregar_cadena(i8* %23, i32 %25)
%27 = getelementptr inbounds i8*, i8** %5, i64 %24
store i8* %26, i8** %27
%28 = add i64 %24, 1
%29 = getelementptr inbounds i8*, i8** %5, i64 %28
store i8* null, i8** %29
%30 = shl i64 %24, 3
%31 = add i64 %30, 16
%32 = tail call i8** @malloc(i64 %31)
%33 = icmp eq i8** %32, null
br i1 %33, label %39, label %34
34: ; preds = %22
%35 = bitcast i8** %32 to i8*
%36 = add i64 %24, 2
%37 = call i64 @llvm.umax.i64(i64 %36, i64 1)
%38 = shl nuw i64 %37, 3
br label %39
39: ; preds = %34, %22
ret i8** %32
}