#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ strlcpy(char *, char *, unsigned int);
scalar_t__ strstr(char *, char *);
void Split(char *msg, char *s1, unsigned int s1len, char *s2,
           unsigned int s2len) {
  char *c;
  char buf[512];
  strlcpy(buf, msg, sizeof(buf));
  c = (char *)strstr(buf, "\x001");
  if (c) {
    *c = 0;
    strlcpy(s1, buf, s1len);
    strlcpy(s2, c + 1, s2len);
  } else {
    strlcpy(s1, buf, s1len);
    strlcpy(s2, "", s2len);
  }
}


x86 assembly (clang, -O0):
<Split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x200,%edx
call   1030 <strlcpy@plt>
lea    -0x230(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11a8 <Split+0x88>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x230(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <strlcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
add    $0x1,%rsi
mov    -0x24(%rbp),%edx
call   1030 <strlcpy@plt>
jmp    11ce <Split+0xae>
mov    -0x10(%rbp),%rdi
lea    -0x230(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <strlcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xe38(%rip),%rsi
call   1030 <strlcpy@plt>
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Split>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %edx,%r12d
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x200,%edx
call   1030 <strlcpy@plt>
lea    0xeab(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     1182 <Split+0x62>
mov    %rax,%rbp
movb   $0x0,(%rax)
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    %r12d,%edx
call   1030 <strlcpy@plt>
add    $0x1,%rbp
mov    %r15,%rdi
mov    %rbp,%rsi
jmp    119a <Split+0x7a>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    %r12d,%edx
call   1030 <strlcpy@plt>
lea    0xe6a(%rip),%rsi
mov    %r15,%rdi
mov    %r14d,%edx
call   1030 <strlcpy@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\01\00"
@.str.1 = [1 x i8] zeroinitializer
define void @Split(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca [512 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%14 = load i8*, i8** %6
%15 = call i32 @strlcpy(i8* %13, i8* %14, i32 512)
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%17 = call i64 @strstr(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %11
%19 = load i8*, i8** %11
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %32
21: ; preds = %5
%22 = load i8*, i8** %11
store i8 0, i8* %22
%23 = load i8*, i8** %7
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%25 = load i32, i32* %8
%26 = call i32 @strlcpy(i8* %23, i8* %24, i32 %25)
%27 = load i8*, i8** %9
%28 = load i8*, i8** %11
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i32, i32* %10
%31 = call i32 @strlcpy(i8* %27, i8* %29, i32 %30)
br label %40
32: ; preds = %5
%33 = load i8*, i8** %7
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%35 = load i32, i32* %8
%36 = call i32 @strlcpy(i8* %33, i8* %34, i32 %35)
%37 = load i8*, i8** %9
%38 = load i32, i32* %10
%39 = call i32 @strlcpy(i8* %37, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %32, %21
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\01\00"
@.str.1 = [1 x i8] zeroinitializer
define void @Split(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca [512 x i8]
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%8 = call i32 @strlcpy(i8* %7, i8* %0, i32 512)
%9 = call i64 @strstr(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = inttoptr i64 %9 to i8*
%11 = icmp eq i64 %9, 0
br i1 %11, label %16, label %12
12: ; preds = %5
store i8 0, i8* %10
%13 = call i32 @strlcpy(i8* %1, i8* %7, i32 %2)
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = call i32 @strlcpy(i8* %3, i8* %14, i32 %4)
br label %19
16: ; preds = %5
%17 = call i32 @strlcpy(i8* %1, i8* %7, i32 %2)
%18 = call i32 @strlcpy(i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 %4)
br label %19
19: ; preds = %16, %12
ret void
}