#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 /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
void split(char *str, char *delimiter, char *out1, char *out2) {
  char strs[2][100];
  char *token;
  int i = 0;
  token = strtok(str, delimiter);
  while (token != 0) {
    strcpy(strs[i], token);
    i++;
    token = strtok(0, delimiter);
  }
  strcpy(out1, strs[0]);
  strcpy(out2, strs[1]);
}


x86 assembly (clang, -O0):
<split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0xfc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strtok@plt>
mov    %rax,-0xf8(%rbp)
cmpq   $0x0,-0xf8(%rbp)
je     11b0 <split+0x90>
movslq -0xfc(%rbp),%rax
lea    -0xf0(%rbp),%rdi
imul   $0x64,%rax,%rax
add    %rax,%rdi
mov    -0xf8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0xfc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc(%rbp)
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1040 <strtok@plt>
mov    %rax,-0xf8(%rbp)
jmp    1159 <split+0x39>
mov    -0x18(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
add    $0x64,%rsi
call   1030 <strcpy@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
call   1040 <strtok@plt>
test   %rax,%rax
je     116e <split+0x4e>
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1040 <strtok@plt>
add    $0x64,%rbx
test   %rax,%rax
jne    1150 <split+0x30>
mov    %rsp,%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
lea    0x64(%rsp),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @split(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [2 x [100 x i8]]
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 0, i32* %11
%12 = load i8*, i8** %5
%13 = load i8*, i8** %6
%14 = call i8* @strtok(i8* %12, i8* %13)
store i8* %14, i8** %10
br label %15
15: ; preds = %18, %4
%16 = load i8*, i8** %10
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %29
18: ; preds = %15
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [2 x [100 x i8]], [2 x [100 x i8]]* %9, i64 0, i64 %20
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %21, i64 0, i64 0
%23 = load i8*, i8** %10
%24 = call i32 @strcpy(i8* %22, i8* %23)
%25 = load i32, i32* %11
%26 = add nsw i32 %25, 1
store i32 %26, i32* %11
%27 = load i8*, i8** %6
%28 = call i8* @strtok(i8* null, i8* %27)
store i8* %28, i8** %10
br label %15
29: ; preds = %15
%30 = load i8*, i8** %7
%31 = getelementptr inbounds [2 x [100 x i8]], [2 x [100 x i8]]* %9, i64 0, i64 0
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %31, i64 0, i64 0
%33 = call i32 @strcpy(i8* %30, i8* %32)
%34 = load i8*, i8** %8
%35 = getelementptr inbounds [2 x [100 x i8]], [2 x [100 x i8]]* %9, i64 0, i64 1
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %35, i64 0, i64 0
%37 = call i32 @strcpy(i8* %34, i8* %36)
ret void
}

LLVM IR (-O2):
define void @split(i8* %0, i8* nocapture %1, i8* %2, i8* %3) {
%5 = alloca [2 x [100 x i8]]
%6 = getelementptr inbounds [2 x [100 x i8]], [2 x [100 x i8]]* %5, i64 0, i64 0, i64 0
%7 = tail call i8* @strtok(i8* %0, i8* %1)
%8 = icmp eq i8* %7, null
br i1 %8, label %17, label %9
9: ; preds = %4, %9
%10 = phi i64 [ %14, %9 ], [ 0, %4 ]
%11 = phi i8* [ %15, %9 ], [ %7, %4 ]
%12 = getelementptr inbounds [2 x [100 x i8]], [2 x [100 x i8]]* %5, i64 0, i64 %10, i64 0
%13 = call i32 @strcpy(i8* %12, i8* %11)
%14 = add nuw i64 %10, 1
%15 = call i8* @strtok(i8* null, i8* %1)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %9
17: ; preds = %9, %4
%18 = call i32 @strcpy(i8* %2, i8* %6)
%19 = getelementptr inbounds [2 x [100 x i8]], [2 x [100 x i8]]* %5, i64 0, i64 1, i64 0
%20 = call i32 @strcpy(i8* %3, i8* %19)
ret void
}