#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 *strtok(char *, char *);
int make_argv(char *args, char **argv) {
  int count = 1;
  char *tok;
  char *s = args;
  while ((tok = strtok(s, " \0"))) {
    argv[count] = tok;
    s = NULL;
    count++;
  }
  return count;
}


x86 assembly (clang, -O0):
<make_argv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xec6(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1173 <make_argv+0x63>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movq   $0x0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112f <make_argv+0x1f>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_argv>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
lea    0xee1(%rip),%rsi
call   1030 <strtok@plt>
test   %rax,%rax
je     1159 <make_argv+0x49>
mov    $0x1,%ebx
lea    0xecb(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
xor    %edi,%edi
mov    %r15,%rsi
call   1030 <strtok@plt>
test   %rax,%rax
jne    1140 <make_argv+0x30>
jmp    115e <make_argv+0x4e>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c" \00\00"
define i32 @make_argv(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
store i8** %1, i8*** %4
store i32 1, i32* %5
%8 = load i8*, i8** %3
store i8* %8, i8** %7
br label %9
9: ; preds = %13, %2
%10 = load i8*, i8** %7
%11 = call i8* @strtok(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = load i8*, i8** %6
%15 = load i8**, i8*** %4
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
store i8* %14, i8** %18
store i8* null, i8** %7
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %9
21: ; preds = %9
%22 = load i32, i32* %5
ret i32 %22
}

LLVM IR (-O2):
@.str = [3 x i8] c" \00\00"
define i32 @make_argv(i8* %0, i8** nocapture writeonly %1) {
%3 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %14, label %5
5: ; preds = %2, %5
%6 = phi i64 [ %9, %5 ], [ 1, %2 ]
%7 = phi i8* [ %10, %5 ], [ %3, %2 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %6
store i8* %7, i8** %8
%9 = add nuw i64 %6, 1
%10 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %5
12: ; preds = %5
%13 = trunc i64 %9 to i32
br label %14
14: ; preds = %12, %2
%15 = phi i32 [ 1, %2 ], [ %13, %12 ]
ret i32 %15
}