#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 *strpbrk(char *, char *);
int /*<<< orphan*/ strspn(char *, char *);
void parse(char *buf, int *argc, char *argv[]) {
  char *delim;
  int count = 0;
  char whsp[] = " \t\n\v\f\r";
  while (1) {
    buf += strspn(buf, whsp);
    delim = strpbrk(buf, whsp);
    if (delim == NULL) {
      break;
    }
    argv[count++] = buf;
    *delim = '\0';
    buf = delim + 1;
  }
  argv[count] = NULL;
  *argc = count;
  return;
}


x86 assembly (clang, -O0):
<parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0xebf(%rip),%eax
mov    %eax,-0x2b(%rbp)
mov    0xeb9(%rip),%ax
mov    %ax,-0x27(%rbp)
mov    0xeb1(%rip),%al
mov    %al,-0x25(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x2b(%rbp),%rsi
call   1030 <strspn@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x2b(%rbp),%rsi
call   1040 <strpbrk@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1196 <parse+0x76>
jmp    11c8 <parse+0xa8>
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x24(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1158 <parse+0x38>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xec5(%rip),%r13
mov    %r13,%rsi
call   1030 <strspn@plt>
movslq %eax,%r12
add    %rbx,%r12
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <strpbrk@plt>
test   %rax,%rax
je     11a6 <parse+0x86>
mov    %rax,%rbx
xor    %ebp,%ebp
lea    0xe9b(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,(%r15,%rbp,8)
add    $0x1,%rbp
movb   $0x0,(%rbx)
lea    0x1(%rbx),%rdi
mov    %r13,%rsi
call   1030 <strspn@plt>
cltq
lea    (%rbx,%rax,1),%r12
add    $0x1,%r12
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <strpbrk@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1170 <parse+0x50>
jmp    11a8 <parse+0x88>
xor    %ebp,%ebp
mov    %ebp,%eax
movq   $0x0,(%r15,%rax,8)
mov    %ebp,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.parse.whsp = [7 x i8] c" \09\0A\0B\0C\0D\00"
define void @parse(i8* %0, i32* %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [7 x i8]
store i8* %0, i8** %4
store i32* %1, i32** %5
store i8** %2, i8*** %6
store i32 0, i32* %8
%10 = bitcast [7 x i8]* %9 to i8*
br label %11
11: ; preds = %3, %24
%12 = load i8*, i8** %4
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 0
%14 = call i32 @strspn(i8* %12, i8* %13)
%15 = load i8*, i8** %4
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds i8, i8* %15, i64 %16
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 0
%20 = call i8* @strpbrk(i8* %18, i8* %19)
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %24
23: ; preds = %11
br label %34
24: ; preds = %11
%25 = load i8*, i8** %4
%26 = load i8**, i8*** %6
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds i8*, i8** %26, i64 %29
store i8* %25, i8** %30
%31 = load i8*, i8** %7
store i8 0, i8* %31
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i64 1
store i8* %33, i8** %4
br label %11
34: ; preds = %23
%35 = load i8**, i8*** %6
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
store i8* null, i8** %38
%39 = load i32, i32* %8
%40 = load i32*, i32** %5
store i32 %39, i32* %40
ret void
}

LLVM IR (-O2):
@__const.parse.whsp = [7 x i8] c" \09\0A\0B\0C\0D\00"
define void @parse(i8* %0, i32* nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i32 @strspn(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @__const.parse.whsp, i64 0, i64 0))
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = tail call i8* @strpbrk(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @__const.parse.whsp, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %23, label %9
9: ; preds = %3, %9
%10 = phi i64 [ %13, %9 ], [ 0, %3 ]
%11 = phi i8* [ %19, %9 ], [ %7, %3 ]
%12 = phi i8* [ %18, %9 ], [ %6, %3 ]
%13 = add nuw i64 %10, 1
%14 = getelementptr inbounds i8*, i8** %2, i64 %10
store i8* %12, i8** %14
store i8 0, i8* %11
%15 = getelementptr inbounds i8, i8* %11, i64 1
%16 = tail call i32 @strspn(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @__const.parse.whsp, i64 0, i64 0))
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = tail call i8* @strpbrk(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @__const.parse.whsp, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %9
21: ; preds = %9
%22 = trunc i64 %13 to i32
br label %23
23: ; preds = %21, %3
%24 = phi i32 [ 0, %3 ], [ %22, %21 ]
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %2, i64 %25
store i8* null, i8** %26
store i32 %24, i32* %1
ret void
}