#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 */
int line_argument_count(char *, char);
scalar_t__ malloc(int);
char *strsep(char **, char *);
char **line_get_arguments(char **line, char delimiter) {
  char **result;
  char *token;
  unsigned int index;
  result =
      (char **)malloc(sizeof(char *) * line_argument_count(*line, delimiter));
  index = 0;
  while ((token = strsep(line, &delimiter)) != NULL) {
    if (token[0] == '\0')
      continue;
    result[index++] = token;
  }
  return result;
}


x86 assembly (clang, -O0):
<line_get_arguments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
movsbl -0x9(%rbp),%esi
call   1050 <line_argument_count@plt>
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x9(%rbp),%rsi
call   1040 <strsep@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11b8 <line_get_arguments+0x88>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    119a <line_get_arguments+0x6a>
jmp    116a <line_get_arguments+0x3a>
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x24(%rbp)
mov    %ecx,%ecx
mov    %rdx,(%rax,%rcx,8)
jmp    116a <line_get_arguments+0x3a>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<line_get_arguments>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %sil,0x7(%rsp)
mov    (%rdi),%rdi
call   1050 <line_argument_count@plt>
lea    0x0(,%rax,8),%edi
call   1030 <malloc@plt>
mov    %rax,%r14
xor    %ebp,%ebp
lea    0x7(%rsp),%r15
nopl   (%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strsep@plt>
test   %rax,%rax
je     1180 <line_get_arguments+0x50>
cmpb   $0x0,(%rax)
je     1160 <line_get_arguments+0x30>
mov    %ebp,%ecx
add    $0x1,%ebp
mov    %rax,(%r14,%rcx,8)
jmp    1160 <line_get_arguments+0x30>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8** @line_get_arguments(i8** %0, i8 signext %1) {
%3 = alloca i8**
%4 = alloca i8
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i8** %0, i8*** %3
store i8 %1, i8* %4
%8 = load i8**, i8*** %3
%9 = load i8*, i8** %8
%10 = load i8, i8* %4
%11 = call i32 @line_argument_count(i8* %9, i8 signext %10)
%12 = sext i32 %11 to i64
%13 = mul i64 8, %12
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8**
store i8** %16, i8*** %5
store i32 0, i32* %7
br label %17
17: ; preds = %28, %27, %2
%18 = load i8**, i8*** %3
%19 = call i8* @strsep(i8** %18, i8* %4)
store i8* %19, i8** %6
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %35
21: ; preds = %17
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %21
br label %17
28: ; preds = %21
%29 = load i8*, i8** %6
%30 = load i8**, i8*** %5
%31 = load i32, i32* %7
%32 = add i32 %31, 1
store i32 %32, i32* %7
%33 = zext i32 %31 to i64
%34 = getelementptr inbounds i8*, i8** %30, i64 %33
store i8* %29, i8** %34
br label %17
35: ; preds = %17
%36 = load i8**, i8*** %5
ret i8** %36
}

LLVM IR (-O2):
define i8** @line_get_arguments(i8** %0, i8 signext %1) {
%3 = alloca i8
store i8 %1, i8* %3
%4 = load i8*, i8** %0
%5 = tail call i32 @line_argument_count(i8* %4, i8 signext %1)
%6 = shl i32 %5, 3
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8**
br label %9
9: ; preds = %17, %2
%10 = phi i32 [ %18, %17 ], [ 0, %2 ]
br label %11
11: ; preds = %9, %14
%12 = call i8* @strsep(i8** %0, i8* %3)
%13 = icmp eq i8* %12, null
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = load i8, i8* %12
%16 = icmp eq i8 %15, 0
br i1 %16, label %11, label %17
17: ; preds = %14
%18 = add i32 %10, 1
%19 = zext i32 %10 to i64
%20 = getelementptr inbounds i8*, i8** %8, i64 %19
store i8* %12, i8** %20
br label %9
21: ; preds = %11
ret i8** %8
}