#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 *strdup(char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int split1(char *strin, char *strpt[], char splitc) {
  char rest[10000], str[10000], ww[10000];
  int len, i, l;
  strncpy(str, strin, 10000);
  len = strlen(strin);
  for (i = 0; i < len; i++) {
    if (str[i] == splitc) {
      l = i;
      strncpy(ww, str, l);
      ww[l] = '\0';
      strpt[0] = strdup(ww);
      l = len - (i + 1);
      if (l <= 0)
        return 1;
      strncpy(rest, str + i + 1, l);
      rest[l] = '\0';
      strpt[1] = strdup(rest);
      return 2;
    }
  }
  strpt[0] = strdup(strin);
  strpt[1] = NULL;
  return 1;
}


x86 assembly (clang, -O0):
<split1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7560,%rsp
mov    %dl,%al
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %al,-0x19(%rbp)
lea    -0x4e40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x2710,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x7554(%rbp)
movl   $0x0,-0x7558(%rbp)
mov    -0x7558(%rbp),%eax
cmp    -0x7554(%rbp),%eax
jge    128f <split1+0x15f>
movslq -0x7558(%rbp),%rax
movsbl -0x4e40(%rbp,%rax,1),%eax
ff
movsbl -0x19(%rbp),%ecx
cmp    %ecx,%eax
jne    1276 <split1+0x146>
mov    -0x7558(%rbp),%eax
mov    %eax,-0x755c(%rbp)
lea    -0x7550(%rbp),%rdi
lea    -0x4e40(%rbp),%rsi
mov    -0x755c(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x755c(%rbp),%rax
movb   $0x0,-0x7550(%rbp,%rax,1)
lea    -0x7550(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x7554(%rbp),%eax
mov    -0x7558(%rbp),%ecx
add    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x755c(%rbp)
cmpl   $0x0,-0x755c(%rbp)
jg     121d <split1+0xed>
movl   $0x1,-0x4(%rbp)
jmp    12b5 <split1+0x185>
lea    -0x2730(%rbp),%rdi
lea    -0x4e40(%rbp),%rsi
movslq -0x7558(%rbp),%rax
add    %rax,%rsi
add    $0x1,%rsi
mov    -0x755c(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x755c(%rbp),%rax
movb   $0x0,-0x2730(%rbp,%rax,1)
lea    -0x2730(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
movl   $0x2,-0x4(%rbp)
jmp    12b5 <split1+0x185>
jmp    127b <split1+0x14b>
mov    -0x7558(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7558(%rbp)
jmp    1176 <split1+0x46>
mov    -0x10(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,0x8(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x7560,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7538,%rsp
mov    %edx,%r13d
mov    %rsi,%r14
mov    %rdi,%r12
mov    %rsp,%rdi
mov    %r12,%rsi
mov    $0x2710,%edx
call   1030 <strncpy@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1193 <split1+0x63>
mov    %eax,%r15d
mov    %eax,%eax
lea    0x1(%rsp),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %r13b,-0x1(%rbx)
je     11a7 <split1+0x77>
add    $0x1,%rbp
add    $0x1,%rbx
cmp    %rbp,%rax
jne    1180 <split1+0x50>
mov    %r12,%rdi
call   1050 <strdup@plt>
mov    %rax,(%r14)
mov    $0x1,%eax
xor    %ecx,%ecx
jmp    120c <split1+0xdc>
lea    0x2710(%rsp),%r12
mov    %rsp,%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x2710(%rsp,%rbp,1)
mov    %r12,%rdi
call   1050 <strdup@plt>
mov    %rax,(%r14)
add    $0xffffffff,%r15d
sub    %rbp,%r15
test   %r15d,%r15d
jle    1222 <split1+0xf2>
lea    0x4e20(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
mov    %r15d,%eax
movb   $0x0,0x4e20(%rsp,%rax,1)
mov    %rbp,%rdi
call   1050 <strdup@plt>
mov    %rax,%rcx
mov    $0x2,%eax
mov    %rcx,0x8(%r14)
add    $0x7538,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%eax
jmp    1210 <split1+0xe0>

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

LLVM IR (-O2):
define i32 @split1(i8* %0, i8** nocapture writeonly %1, i8 signext %2) {
%4 = alloca [10000 x i8]
%5 = alloca [10000 x i8]
%6 = alloca [10000 x i8]
%7 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%10 = call i32 @strncpy(i8* %8, i8* %0, i32 10000)
%11 = call i32 @strlen(i8* %0)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %39
13: ; preds = %3
%14 = zext i32 %11 to i64
br label %15
15: ; preds = %13, %36
%16 = phi i64 [ 0, %13 ], [ %37, %36 ]
%17 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, %2
br i1 %19, label %20, label %36
20: ; preds = %15
%21 = trunc i64 %16 to i32
%22 = and i64 %16, 4294967295
%23 = call i32 @strncpy(i8* %9, i8* %8, i32 %21)
%24 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 %22
store i8 0, i8* %24
%25 = call i8* @strdup(i8* %9)
store i8* %25, i8** %1
%26 = xor i32 %21, -1
%27 = add i32 %11, %26
%28 = icmp slt i32 %27, 1
br i1 %28, label %45, label %29
29: ; preds = %20
%30 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 %22
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = call i32 @strncpy(i8* %7, i8* %31, i32 %27)
%33 = zext i32 %27 to i64
%34 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 %33
store i8 0, i8* %34
%35 = call i8* @strdup(i8* %7)
br label %41
36: ; preds = %15
%37 = add nuw nsw i64 %16, 1
%38 = icmp eq i64 %37, %14
br i1 %38, label %39, label %15
39: ; preds = %36, %3
%40 = call i8* @strdup(i8* %0)
store i8* %40, i8** %1
br label %41
41: ; preds = %29, %39
%42 = phi i8* [ null, %39 ], [ %35, %29 ]
%43 = phi i32 [ 1, %39 ], [ 2, %29 ]
%44 = getelementptr inbounds i8*, i8** %1, i64 1
store i8* %42, i8** %44
br label %45
45: ; preds = %41, %20
%46 = phi i32 [ 1, %20 ], [ %43, %41 ]
ret i32 %46
}