#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 */
typedef int /*<<< orphan*/ found;

/* Variables and functions */
int strlen(char *);
char *strstr(char *, char *);
char **split(char *text, char *pattern) {
  static char *found[64];
  int pattern_length = strlen(pattern);
  char *find;
  int key;
  for (key = 0; key < sizeof(found) / sizeof(*found); key++) {
    if ((find = strstr(text, pattern)) == 0) {
      found[key] = text;
      break;
    }
    text[find - text] = 0;
    found[key] = text;
    text = find + pattern_length;
  }
  found[63] = NULL;
  if (key + 1 < 64) {
    found[key + 1] = NULL;
  }
  return found;
}


x86 assembly (clang, -O0):
<split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    $0x40,%rax
jae    11c7 <split+0xa7>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1184 <split+0x64>
mov    -0x8(%rbp),%rdx
movslq -0x24(%rbp),%rcx
lea    0x2ec5(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
jmp    11c7 <split+0xa7>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdx
movslq -0x24(%rbp),%rcx
lea    0x2e9a(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1143 <split+0x23>
movq   $0x0,0x3066(%rip)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cmp    $0x40,%eax
jge    11f9 <split+0xd9>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2e4f(%rip),%rax
movq   $0x0,(%rax,%rcx,8)
lea    0x2e40(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbp
lea    0x2f05(%rip),%rbx
xor    %r12d,%r12d
lea    0x30eb(%rip),%r13
nopl   (%rax)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     117d <split+0x5d>
movb   $0x0,(%rax)
mov    %r15,-0x8(%rbx)
add    %rbp,%rax
add    $0x1,%r12
add    $0x8,%rbx
mov    %rax,%r15
cmp    $0x40,%r12
jne    1150 <split+0x30>
jmp    1195 <split+0x75>
mov    %r15,-0x8(%rbx)
movq   $0x0,0x30ac(%rip)
mov    %rbx,%r13
cmp    $0x3e,%r12d
ja     119d <split+0x7d>
movq   $0x0,0x0(%r13)
lea    0x2e9c(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@split.found = internal global [64 x i8*] zeroinitializer
define i8** @split(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %5
store i32 0, i32* %7
br label %10
10: ; preds = %40, %2
%11 = load i32, i32* %7
%12 = sext i32 %11 to i64
%13 = icmp ult i64 %12, 64
br i1 %13, label %14, label %43
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = load i8*, i8** %4
%17 = call i8* @strstr(i8* %15, i8* %16)
store i8* %17, i8** %6
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [64 x i8*], [64 x i8*]* @split.found, i64 0, i64 %22
store i8* %20, i8** %23
br label %43
24: ; preds = %14
%25 = load i8*, i8** %3
%26 = load i8*, i8** %6
%27 = load i8*, i8** %3
%28 = ptrtoint i8* %26 to i64
%29 = ptrtoint i8* %27 to i64
%30 = sub i64 %28, %29
%31 = getelementptr inbounds i8, i8* %25, i64 %30
store i8 0, i8* %31
%32 = load i8*, i8** %3
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [64 x i8*], [64 x i8*]* @split.found, i64 0, i64 %34
store i8* %32, i8** %35
%36 = load i8*, i8** %6
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8* %39, i8** %3
br label %40
40: ; preds = %24
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %10
43: ; preds = %19, %10
store i8* null, i8** getelementptr inbounds ([64 x i8*], [64 x i8*]* @split.found, i64 0, i64 63)
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
%46 = icmp slt i32 %45, 64
br i1 %46, label %47, label %52
47: ; preds = %43
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [64 x i8*], [64 x i8*]* @split.found, i64 0, i64 %50
store i8* null, i8** %51
br label %52
52: ; preds = %47, %43
ret i8** getelementptr inbounds ([64 x i8*], [64 x i8*]* @split.found, i64 0, i64 0)
}

LLVM IR (-O2):
@split.found = internal global [64 x i8*] zeroinitializer
define i8** @split(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = sext i32 %3 to i64
br label %5
5: ; preds = %2, %10
%6 = phi i64 [ 0, %2 ], [ %17, %10 ]
%7 = phi i8* [ %0, %2 ], [ %16, %10 ]
%8 = tail call i8* @strstr(i8* dereferenceable(1) %7, i8* dereferenceable(1) %1)
%9 = icmp eq i8* %8, null
br i1 %9, label %19, label %10
10: ; preds = %5
%11 = ptrtoint i8* %8 to i64
%12 = ptrtoint i8* %7 to i64
%13 = sub i64 %11, %12
%14 = getelementptr inbounds i8, i8* %7, i64 %13
store i8 0, i8* %14
%15 = getelementptr inbounds [64 x i8*], [64 x i8*]* @split.found, i64 0, i64 %6
store i8* %7, i8** %15
%16 = getelementptr inbounds i8, i8* %8, i64 %4
%17 = add nuw nsw i64 %6, 1
%18 = icmp eq i64 %17, 64
br i1 %18, label %28, label %5
19: ; preds = %5
%20 = trunc i64 %6 to i32
%21 = and i64 %6, 4294967295
%22 = getelementptr inbounds [64 x i8*], [64 x i8*]* @split.found, i64 0, i64 %21
store i8* %7, i8** %22
store i8* null, i8** getelementptr inbounds ([64 x i8*], [64 x i8*]* @split.found, i64 0, i64 63)
%23 = icmp ult i32 %20, 63
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = add nuw i64 %6, 1
%26 = and i64 %25, 4294967295
%27 = getelementptr inbounds [64 x i8*], [64 x i8*]* @split.found, i64 0, i64 %26
br label %28
28: ; preds = %10, %24
%29 = phi i8** [ %27, %24 ], [ getelementptr inbounds ([64 x i8*], [64 x i8*]* @split.found, i64 0, i64 63), %10 ]
store i8* null, i8** %29
br label %30
30: ; preds = %28, %19
ret i8** getelementptr inbounds ([64 x i8*], [64 x i8*]* @split.found, i64 0, i64 0)
}