#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 *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void strsplit1(char *string, char sep, char *first, char *second) {
  char *sep_ptr = strchr(string, sep);
  int n = sep_ptr - string;
  strncpy(first, string, n);
  first[n] = '\0';
  strcpy(second, sep_ptr + 1);
}


x86 assembly (clang, -O0):
<strsplit1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
call   1040 <strcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strsplit1>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%r12
call   1050 <strchr@plt>
mov    %rax,%r13
mov    %rax,%rbx
sub    %r12,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
movslq %ebx,%rax
movb   $0x0,(%r15,%rax,1)
add    $0x1,%r13
mov    %r14,%rdi
mov    %r13,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <strcpy@plt>

LLVM IR (-O0):
define void @strsplit1(i8* %0, i8 signext %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %5
store i8 %1, i8* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = load i8*, i8** %5
%12 = load i8, i8* %6
%13 = call i8* @strchr(i8* %11, i8 signext %12)
store i8* %13, i8** %9
%14 = load i8*, i8** %9
%15 = load i8*, i8** %5
%16 = ptrtoint i8* %14 to i64
%17 = ptrtoint i8* %15 to i64
%18 = sub i64 %16, %17
%19 = trunc i64 %18 to i32
store i32 %19, i32* %10
%20 = load i8*, i8** %7
%21 = load i8*, i8** %5
%22 = load i32, i32* %10
%23 = call i32 @strncpy(i8* %20, i8* %21, i32 %22)
%24 = load i8*, i8** %7
%25 = load i32, i32* %10
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
store i8 0, i8* %27
%28 = load i8*, i8** %8
%29 = load i8*, i8** %9
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = call i32 @strcpy(i8* %28, i8* %30)
ret void
}

LLVM IR (-O2):
define void @strsplit1(i8* %0, i8 signext %1, i8* %2, i8* %3) {
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext %1)
%6 = ptrtoint i8* %5 to i64
%7 = ptrtoint i8* %0 to i64
%8 = sub i64 %6, %7
%9 = trunc i64 %8 to i32
%10 = tail call i32 @strncpy(i8* %2, i8* %0, i32 %9)
%11 = shl i64 %8, 32
%12 = ashr exact i64 %11, 32
%13 = getelementptr inbounds i8, i8* %2, i64 %12
store i8 0, i8* %13
%14 = getelementptr inbounds i8, i8* %5, i64 1
%15 = tail call i32 @strcpy(i8* %3, i8* %14)
ret void
}