#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 *salloc(char *);
int /*<<< orphan*/ strcpy(char *, char *);
size_t strcspn(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, size_t);
void parse_comline(char *input_line, int *num_of_args, char **args) {
  size_t next_space;
  char next_word[200];
  *num_of_args = 0;
  while (strlen(input_line) > 0) {
    if (input_line[0] == ' ') {
      input_line = &(input_line[1]);
    } else {
      next_space = strcspn(input_line, " ");
      if (input_line[next_space] == ' ') {
        strncpy(next_word, input_line, next_space);
        next_word[next_space] = '\0';
        input_line = &(input_line[next_space + 1]);
      } else {
        strcpy(next_word, input_line);
        input_line[0] = '\0';
      }
      args[*num_of_args] = salloc(next_word);
      (*num_of_args)++;
    }
  }
}


x86 assembly (clang, -O0):
<parse_comline>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
jle    124b <parse_comline+0xfb>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11a5 <parse_comline+0x55>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1246 <parse_comline+0xf6>
mov    -0x8(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1060 <strcspn@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1206 <parse_comline+0xb6>
lea    -0xf0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,-0xf0(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    121d <parse_comline+0xcd>
lea    -0xf0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
lea    -0xf0(%rbp),%rdi
call   1070 <salloc@plt>
mov    %rax,%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    1171 <parse_comline+0x21>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_comline>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movl   $0x0,(%rsi)
call   1050 <strlen@plt>
test   %rax,%rax
jle    1205 <parse_comline+0xb5>
lea    0xe7b(%rip),%r12
mov    %rsp,%r13
jmp    11a1 <parse_comline+0x51>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %rax,%rax
jle    1205 <parse_comline+0xb5>
cmpb   $0x20,(%rbx)
je     1190 <parse_comline+0x40>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcspn@plt>
cmpb   $0x20,(%rbx,%rax,1)
jne    11e0 <parse_comline+0x90>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1030 <strncpy@plt>
movb   $0x0,(%rsp,%rbp,1)
add    %rbp,%rbx
add    $0x1,%rbx
jmp    11ee <parse_comline+0x9e>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
movb   $0x0,(%rbx)
mov    %r13,%rdi
call   1070 <salloc@plt>
movslq (%r15),%rcx
mov    %rax,(%r14,%rcx,8)
lea    0x1(%rcx),%eax
mov    %eax,(%r15)
jmp    1194 <parse_comline+0x44>
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define void @parse_comline(i8* %0, i32* %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8**
%7 = alloca i64
%8 = alloca [200 x i8]
store i8* %0, i8** %4
store i32* %1, i32** %5
store i8** %2, i8*** %6
%9 = load i32*, i32** %5
store i32 0, i32* %9
br label %10
10: ; preds = %60, %3
%11 = load i8*, i8** %4
%12 = call i64 @strlen(i8* %11)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %61
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 32
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %4
br label %60
23: ; preds = %14
%24 = load i8*, i8** %4
%25 = call i64 @strcspn(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i64 %25, i64* %7
%26 = load i8*, i8** %4
%27 = load i64, i64* %7
%28 = getelementptr inbounds i8, i8* %26, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 32
br i1 %31, label %32, label %43
32: ; preds = %23
%33 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%34 = load i8*, i8** %4
%35 = load i64, i64* %7
%36 = call i32 @strncpy(i8* %33, i8* %34, i64 %35)
%37 = load i64, i64* %7
%38 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 %37
store i8 0, i8* %38
%39 = load i8*, i8** %4
%40 = load i64, i64* %7
%41 = add i64 %40, 1
%42 = getelementptr inbounds i8, i8* %39, i64 %41
store i8* %42, i8** %4
br label %49
43: ; preds = %23
%44 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%45 = load i8*, i8** %4
%46 = call i32 @strcpy(i8* %44, i8* %45)
%47 = load i8*, i8** %4
%48 = getelementptr inbounds i8, i8* %47, i64 0
store i8 0, i8* %48
br label %49
49: ; preds = %43, %32
%50 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%51 = call i8* @salloc(i8* %50)
%52 = load i8**, i8*** %6
%53 = load i32*, i32** %5
%54 = load i32, i32* %53
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %52, i64 %55
store i8* %51, i8** %56
%57 = load i32*, i32** %5
%58 = load i32, i32* %57
%59 = add nsw i32 %58, 1
store i32 %59, i32* %57
br label %60
60: ; preds = %49, %20
br label %10
61: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define void @parse_comline(i8* %0, i32* nocapture %1, i8** nocapture writeonly %2) {
%4 = alloca [200 x i8]
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
store i32 0, i32* %1
%6 = call i64 @strlen(i8* dereferenceable(1) %0)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %37
8: ; preds = %3, %33
%9 = phi i8* [ %34, %33 ], [ %0, %3 ]
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 32
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %9, i64 1
br label %33
14: ; preds = %8
%15 = call i64 @strcspn(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds i8, i8* %9, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 32
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = call i32 @strncpy(i8* %5, i8* %9, i64 %15)
%21 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 %15
store i8 0, i8* %21
%22 = add i64 %15, 1
%23 = getelementptr inbounds i8, i8* %9, i64 %22
br label %26
24: ; preds = %14
%25 = call i32 @strcpy(i8* %5, i8* %9)
store i8 0, i8* %9
br label %26
26: ; preds = %24, %19
%27 = phi i8* [ %23, %19 ], [ %9, %24 ]
%28 = call i8* @salloc(i8* %5)
%29 = load i32, i32* %1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %2, i64 %30
store i8* %28, i8** %31
%32 = add nsw i32 %29, 1
store i32 %32, i32* %1
br label %33
33: ; preds = %26, %12
%34 = phi i8* [ %13, %12 ], [ %27, %26 ]
%35 = call i64 @strlen(i8* dereferenceable(1) %34)
%36 = icmp sgt i64 %35, 0
br i1 %36, label %8, label %37
37: ; preds = %33, %3
ret void
}