#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);
void prog_Char2Args(char *string, int *argc, char **argv) {
  char *ptr;
  if (!string || *string == '\0') {
    *argc = 0;
    return;
  }
  ptr = string;
  argv[0] = ptr;
  *argc = 1;
  while (ptr = strchr(ptr, ' ')) {
    *ptr = '\0';
    ptr++;
    argv[*argc] = ptr;
    (*argc)++;
  }
}


x86 assembly (clang, -O0):
<prog_Char2Args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     113f <prog_Char2Args+0x2f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    114e <prog_Char2Args+0x3e>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    11bd <prog_Char2Args+0xad>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11bd <prog_Char2Args+0xad>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    116b <prog_Char2Args+0x5b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prog_Char2Args>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
test   %rdi,%rdi
je     1157 <prog_Char2Args+0x47>
cmpb   $0x0,(%rdi)
je     1157 <prog_Char2Args+0x47>
mov    %rdx,%r14
mov    %rdi,(%rdx)
movl   $0x1,(%rbx)
nopl   (%rax)
mov    $0x20,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     115d <prog_Char2Args+0x4d>
movb   $0x0,(%rax)
add    $0x1,%rax
movslq (%rbx),%rcx
mov    %rax,(%r14,%rcx,8)
add    $0x1,%ecx
mov    %ecx,(%rbx)
mov    %rax,%rdi
jmp    1130 <prog_Char2Args+0x20>
movl   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @prog_Char2Args(i8* %0, i32* nocapture %1, i8** nocapture writeonly %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %5, %3
store i32 0, i32* %1
br label %21
9: ; preds = %5
store i8* %0, i8** %2
store i32 1, i32* %1
%10 = tail call i8* @strchr(i8* %0, i8 signext 32)
%11 = icmp eq i8* %10, null
br i1 %11, label %21, label %12
12: ; preds = %9, %12
%13 = phi i8* [ %19, %12 ], [ %10, %9 ]
store i8 0, i8* %13
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i32, i32* %1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %2, i64 %16
store i8* %14, i8** %17
%18 = add nsw i32 %15, 1
store i32 %18, i32* %1
%19 = tail call i8* @strchr(i8* %14, i8 signext 32)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %12
21: ; preds = %12, %9, %8
ret void
}