#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 *parser_get_next_word(char **);
char *strdup(char *);
int parser_split_line(char *line, unsigned int argsmax, char **argv) {
  unsigned int argc = 0;
  char *s;
  while (argc < argsmax && (s = parser_get_next_word(&line)))
    argv[argc++] = strdup(s);
  return argc;
}


x86 assembly (clang, -O0):
<parser_split_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x29(%rbp)
jae    1162 <parser_split_line+0x42>
lea    -0x8(%rbp),%rdi
call   1030 <parser_get_next_word@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1172 <parser_split_line+0x52>
jmp    1198 <parser_split_line+0x78>
mov    -0x28(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
mov    %ecx,%ecx
mov    %rdx,(%rax,%rcx,8)
jmp    113a <parser_split_line+0x1a>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parser_split_line>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,(%rsp)
test   %esi,%esi
je     1167 <parser_split_line+0x47>
mov    %rdx,%r14
mov    %esi,%r12d
xor    %ebx,%ebx
mov    %rsp,%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <parser_get_next_word@plt>
test   %rax,%rax
je     1169 <parser_split_line+0x49>
mov    %rax,%rdi
call   1040 <strdup@plt>
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <parser_split_line+0x20>
mov    %r12d,%ebx
jmp    1169 <parser_split_line+0x49>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @parser_split_line(i8* %0, i32 %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
store i32 0, i32* %7
br label %9
9: ; preds = %18, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp ult i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = call i8* @parser_get_next_word(i8** %4)
store i8* %14, i8** %8
%15 = icmp ne i8* %14, null
br label %16
16: ; preds = %13, %9
%17 = phi i1 [ false, %9 ], [ %15, %13 ]
br i1 %17, label %18, label %26
18: ; preds = %16
%19 = load i8*, i8** %8
%20 = call i8* @strdup(i8* %19)
%21 = load i8**, i8*** %6
%22 = load i32, i32* %7
%23 = add i32 %22, 1
store i32 %23, i32* %7
%24 = zext i32 %22 to i64
%25 = getelementptr inbounds i8*, i8** %21, i64 %24
store i8* %20, i8** %25
br label %9
26: ; preds = %16
%27 = load i32, i32* %7
ret i32 %27
}

LLVM IR (-O2):
define i32 @parser_split_line(i8* %0, i32 %1, i8** nocapture writeonly %2) {
%4 = alloca i8*
store i8* %0, i8** %4
%5 = icmp eq i32 %1, 0
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %12
%9 = phi i64 [ 0, %6 ], [ %14, %12 ]
%10 = call i8* @parser_get_next_word(i8** %4)
%11 = icmp eq i8* %10, null
br i1 %11, label %17, label %12
12: ; preds = %8
%13 = call i8* @strdup(i8* %10)
%14 = add nuw nsw i64 %9, 1
%15 = getelementptr inbounds i8*, i8** %2, i64 %9
store i8* %13, i8** %15
%16 = icmp eq i64 %14, %7
br i1 %16, label %19, label %8
17: ; preds = %8
%18 = trunc i64 %9 to i32
br label %19
19: ; preds = %12, %17, %3
%20 = phi i32 [ 0, %3 ], [ %18, %17 ], [ %1, %12 ]
ret i32 %20
}