#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 *cstring_skip_black(char *);
char *cstring_skip_white(char *);
char *cstring_split_at_white(char *str, char **next) {
  char *res = cstring_skip_white(str);
  char *end = cstring_skip_black(res);
  if (*end != 0) {
    *end++ = 0;
  }
  if (next != 0) {
    *next = end;
  }
  return res;
}


x86 assembly (clang, -O0):
<cstring_split_at_white>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <cstring_skip_white@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <cstring_skip_black@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     116c <cstring_split_at_white+0x4c>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
cmpq   $0x0,-0x10(%rbp)
je     1182 <cstring_split_at_white+0x62>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cstring_split_at_white>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
call   1040 <cstring_skip_white@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <cstring_skip_black@plt>
cmpb   $0x0,(%rax)
je     1143 <cstring_split_at_white+0x23>
movb   $0x0,(%rax)
add    $0x1,%rax
test   %r14,%r14
je     114b <cstring_split_at_white+0x2b>
mov    %rax,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @cstring_split_at_white(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8** %1, i8*** %4
%7 = load i8*, i8** %3
%8 = call i8* @cstring_skip_white(i8* %7)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = call i8* @cstring_skip_black(i8* %9)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %6
store i8 0, i8* %16
br label %18
18: ; preds = %15, %2
%19 = load i8**, i8*** %4
%20 = icmp ne i8** %19, null
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i8*, i8** %6
%23 = load i8**, i8*** %4
store i8* %22, i8** %23
br label %24
24: ; preds = %21, %18
%25 = load i8*, i8** %5
ret i8* %25
}

LLVM IR (-O2):
define i8* @cstring_split_at_white(i8* %0, i8** writeonly %1) {
%3 = tail call i8* @cstring_skip_white(i8* %0)
%4 = tail call i8* @cstring_skip_black(i8* %3)
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %4, i64 1
store i8 0, i8* %4
br label %9
9: ; preds = %7, %2
%10 = phi i8* [ %8, %7 ], [ %4, %2 ]
%11 = icmp eq i8** %1, null
br i1 %11, label %13, label %12
12: ; preds = %9
store i8* %10, i8** %1
br label %13
13: ; preds = %12, %9
ret i8* %3
}