#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 */
scalar_t__ isspace(unsigned char);
char **buildargv(char *input) {
  static char *arglist[256];
  int numargs = 0;
  while (1) {
    while (isspace((unsigned char)*input) && *input != 0)
      input++;
    if (*input == 0)
      break;
    arglist[numargs++] = input;
    while (!isspace((unsigned char)*input) && *input != 0)
      input++;
    if (*input == 0)
      break;
    *(input++) = 0;
  }
  arglist[numargs] = NULL;
  return arglist;
}


x86 assembly (clang, -O0):
<buildargv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
jmp    1128 <buildargv+0x18>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xd(%rbp)
je     1156 <buildargv+0x46>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1166 <buildargv+0x56>
jmp    1177 <buildargv+0x67>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1128 <buildargv+0x18>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    118c <buildargv+0x7c>
jmp    1224 <buildargv+0x114>
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
movslq %eax,%rcx
lea    0x2e9b(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xe(%rbp)
jne    11d7 <buildargv+0xc7>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
test   $0x1,%al
jne    11e7 <buildargv+0xd7>
jmp    11f8 <buildargv+0xe8>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11a9 <buildargv+0x99>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    120d <buildargv+0xfd>
jmp    1224 <buildargv+0x114>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
jmp    1123 <buildargv+0x13>
movslq -0xc(%rbp),%rcx
lea    0x2e11(%rip),%rax
movq   $0x0,(%rax,%rcx,8)
lea    0x2e02(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buildargv>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
xor    %r15d,%r15d
lea    0x2f1e(%rip),%r14
movzbl (%rbx),%edi
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <isspace@plt>
test   %rax,%rax
je     1150 <buildargv+0x40>
cmpb   $0x0,(%rbx)
je     118e <buildargv+0x7e>
movzbl 0x1(%rbx),%edi
add    $0x1,%rbx
jmp    1130 <buildargv+0x20>
nopl   0x0(%rax)
cmpb   $0x0,(%rbx)
je     118e <buildargv+0x7e>
mov    %rbx,(%r14,%r15,8)
add    $0x1,%r15
movzbl (%rbx),%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    1180 <buildargv+0x70>
cmpb   $0x0,(%rbx)
je     118e <buildargv+0x7e>
movzbl 0x1(%rbx),%edi
add    $0x1,%rbx
jmp    1160 <buildargv+0x50>
nopl   0x0(%rax)
cmpb   $0x0,(%rbx)
je     118e <buildargv+0x7e>
movb   $0x0,(%rbx)
add    $0x1,%rbx
jmp    1122 <buildargv+0x12>
movslq %r15d,%rax
movq   $0x0,(%r14,%rax,8)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@buildargv.arglist = internal global [256 x i8*] zeroinitializer
define i8** @buildargv(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %1, %53
br label %5
5: ; preds = %17, %4
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = call i64 @isspace(i8 zeroext %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br label %15
15: ; preds = %10, %5
%16 = phi i1 [ false, %5 ], [ %14, %10 ]
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %2
br label %5
20: ; preds = %15
%21 = load i8*, i8** %2
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
br label %56
26: ; preds = %20
%27 = load i8*, i8** %2
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds [256 x i8*], [256 x i8*]* @buildargv.arglist, i64 0, i64 %30
store i8* %27, i8** %31
br label %32
32: ; preds = %44, %26
%33 = load i8*, i8** %2
%34 = load i8, i8* %33
%35 = call i64 @isspace(i8 zeroext %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %42, label %37
37: ; preds = %32
%38 = load i8*, i8** %2
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 0
br label %42
42: ; preds = %37, %32
%43 = phi i1 [ false, %32 ], [ %41, %37 ]
br i1 %43, label %44, label %47
44: ; preds = %42
%45 = load i8*, i8** %2
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %2
br label %32
47: ; preds = %42
%48 = load i8*, i8** %2
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %47
br label %56
53: ; preds = %47
%54 = load i8*, i8** %2
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %2
store i8 0, i8* %54
br label %4
56: ; preds = %52, %25
%57 = load i32, i32* %3
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [256 x i8*], [256 x i8*]* @buildargv.arglist, i64 0, i64 %58
store i8* null, i8** %59
ret i8** getelementptr inbounds ([256 x i8*], [256 x i8*]* @buildargv.arglist, i64 0, i64 0)
}

LLVM IR (-O2):
@buildargv.arglist = internal global [256 x i8*] zeroinitializer
define i8** @buildargv(i8* %0) {
br label %2
2: ; preds = %40, %1
%3 = phi i64 [ %22, %40 ], [ 0, %1 ]
%4 = phi i8* [ %41, %40 ], [ %0, %1 ]
%5 = load i8, i8* %4
%6 = tail call i64 @isspace(i8 zeroext %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %2, %12
%9 = phi i8* [ %13, %12 ], [ %4, %2 ]
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %42, label %12
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %9, i64 1
%14 = load i8, i8* %13
%15 = tail call i64 @isspace(i8 zeroext %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %8
17: ; preds = %12, %2
%18 = phi i8* [ %4, %2 ], [ %13, %12 ]
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %42, label %21
21: ; preds = %17
%22 = add nuw i64 %3, 1
%23 = getelementptr inbounds [256 x i8*], [256 x i8*]* @buildargv.arglist, i64 0, i64 %3
store i8* %18, i8** %23
%24 = load i8, i8* %18
%25 = tail call i64 @isspace(i8 zeroext %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %21, %31
%28 = phi i8* [ %32, %31 ], [ %18, %21 ]
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %42, label %31
31: ; preds = %27
%32 = getelementptr inbounds i8, i8* %28, i64 1
%33 = load i8, i8* %32
%34 = tail call i64 @isspace(i8 zeroext %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %27, label %36
36: ; preds = %31, %21
%37 = phi i8* [ %18, %21 ], [ %32, %31 ]
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %36
%41 = getelementptr inbounds i8, i8* %37, i64 1
store i8 0, i8* %37
br label %2
42: ; preds = %36, %17, %8, %27
%43 = phi i64 [ %22, %27 ], [ %3, %8 ], [ %22, %36 ], [ %3, %17 ]
%44 = shl i64 %43, 32
%45 = ashr exact i64 %44, 32
%46 = getelementptr inbounds [256 x i8*], [256 x i8*]* @buildargv.arglist, i64 0, i64 %45
store i8* null, i8** %46
ret i8** getelementptr inbounds ([256 x i8*], [256 x i8*]* @buildargv.arglist, i64 0, i64 0)
}