#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*/ isspace(unsigned char);
void split_line(char *s, char *argv[]) {
  enum { EAT_SPACE, READ_ARG } state = EAT_SPACE;
  while (*s) {
    switch (state) {
    case EAT_SPACE:
      if (!isspace((unsigned char)*s)) {
        *argv++ = s;
        state = READ_ARG;
      }
      break;
    case READ_ARG:
      if (isspace((unsigned char)*s)) {
        *s = '\0';
        state = EAT_SPACE;
      }
      break;
    }
    ++s;
  }
  *argv = (void *)0;
}


x86 assembly (clang, -O0):
<split_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c8 <split_line+0xb8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     1158 <split_line+0x48>
jmp    1147 <split_line+0x37>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     118f <split_line+0x7f>
jmp    11b7 <split_line+0xa7>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
jne    118a <split_line+0x7a>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,(%rax)
movl   $0x1,-0x14(%rbp)
jmp    11b7 <split_line+0xa7>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
je     11b2 <split_line+0xa2>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x14(%rbp)
jmp    11b7 <split_line+0xa7>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1127 <split_line+0x17>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_line>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    (%rdi),%al
test   %al,%al
je     1173 <split_line+0x63>
mov    %rdi,%rbx
xor    %ecx,%ecx
jmp    113c <split_line+0x2c>
mov    %rbx,(%r14)
add    $0x8,%r14
mov    $0x1,%ecx
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1173 <split_line+0x63>
cmp    $0x1,%ecx
je     1160 <split_line+0x50>
test   %ecx,%ecx
jne    1130 <split_line+0x20>
movzbl %al,%edi
call   1030 <isspace@plt>
xor    %ecx,%ecx
test   %eax,%eax
jne    1130 <split_line+0x20>
jmp    1124 <split_line+0x14>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl %al,%edi
call   1030 <isspace@plt>
test   %eax,%eax
je     112b <split_line+0x1b>
movb   $0x0,(%rbx)
xor    %ecx,%ecx
jmp    1130 <split_line+0x20>
movq   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @split_line(i8* %0, i8** nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %25, label %5
5: ; preds = %2, %19
%6 = phi i8 [ %23, %19 ], [ %3, %2 ]
%7 = phi i32 [ %21, %19 ], [ 0, %2 ]
%8 = phi i8** [ %20, %19 ], [ %1, %2 ]
%9 = phi i8* [ %22, %19 ], [ %0, %2 ]
switch i32 %7, label %19 [
i32 0, label %10
i32 1, label %15
]
10: ; preds = %5
%11 = tail call i32 @isspace(i8 zeroext %6)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = getelementptr inbounds i8*, i8** %8, i64 1
store i8* %9, i8** %8
br label %19
15: ; preds = %5
%16 = tail call i32 @isspace(i8 zeroext %6)
%17 = icmp eq i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %15
store i8 0, i8* %9
br label %19
19: ; preds = %15, %18, %10, %13, %5
%20 = phi i8** [ %8, %5 ], [ %8, %18 ], [ %8, %15 ], [ %8, %10 ], [ %14, %13 ]
%21 = phi i32 [ %7, %5 ], [ 0, %18 ], [ 1, %15 ], [ 0, %10 ], [ 1, %13 ]
%22 = getelementptr inbounds i8, i8* %9, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %5
25: ; preds = %19, %2
%26 = phi i8** [ %1, %2 ], [ %20, %19 ]
store i8* null, i8** %26
ret void
}