#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 libc_strlen(char *);
int libc_strpos(char *, char *);
char *libc_strpstr_nomo(char *, char *);
int libc_substr_count(char *, char *);
char **malloc(int);
char **libc_explode(char *se, char *str) {
  int i = 0, l = 0, n = 0, len = libc_strlen(str),
      cou = libc_substr_count(str, se);
  char **ret = malloc(cou + 1);
  while (l != -1) {
    l = libc_strpos(str, se);
    ret[i] = libc_strpstr_nomo(str, se);
    str = str + l + libc_strlen(se);
    i++;
  }
  return ret;
}


x86 assembly (clang, -O0):
<libc_explode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <libc_strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <libc_substr_count@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
je     120c <libc_explode+0xbc>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <libc_strpos@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1070 <libc_strpstr_nomo@plt>
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <libc_strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a0 <libc_explode+0x50>
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libc_explode>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1060 <libc_strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <libc_substr_count@plt>
lea    0x1(%rax),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rbp
nop
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <libc_strpos@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <libc_strpstr_nomo@plt>
mov    %rax,0x0(%rbp)
movslq %r12d,%r12
add    %r12,%rbx
mov    %r14,%rdi
call   1060 <libc_strlen@plt>
cltq
add    %rax,%rbx
add    $0x8,%rbp
cmp    $0xffffffff,%r12d
jne    1180 <libc_explode+0x30>
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define noalias i8** @libc_explode(i8* %0, i8* %1) {
%3 = tail call i32 @libc_strlen(i8* %1)
%4 = tail call i32 @libc_substr_count(i8* %1, i8* %0)
%5 = add nsw i32 %4, 1
%6 = tail call i8** @malloc(i32 %5)
br label %7
7: ; preds = %2, %7
%8 = phi i64 [ 0, %2 ], [ %18, %7 ]
%9 = phi i8* [ %1, %2 ], [ %17, %7 ]
%10 = tail call i32 @libc_strpos(i8* %9, i8* %0)
%11 = tail call i8* @libc_strpstr_nomo(i8* %9, i8* %0)
%12 = getelementptr inbounds i8*, i8** %6, i64 %8
store i8* %11, i8** %12
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds i8, i8* %9, i64 %13
%15 = tail call i32 @libc_strlen(i8* %0)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = add nuw i64 %8, 1
%19 = icmp eq i32 %10, -1
br i1 %19, label %20, label %7
20: ; preds = %7
ret i8** %6
}