#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 **calloc(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
char *strdup(char const *);
char *strsep(char **, char *);
char **configArguments(const char *line) {
  char **retval = calloc(7, sizeof(char *));
  char *lcp = strdup(line);
  char *token = NULL;
  int i = 0;
  while ((token = strsep(&lcp, "\n "))) {
    if (i == 6) {
      fprintf(stderr, "Malformed configuration file; too many arguments at %s",
              line);
    }
    retval[i++] = token;
  }
  return retval;
}


x86 assembly (clang, -O0):
<configArguments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x7,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1050 <strsep@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11db <configArguments+0x9b>
cmpl   $0x6,-0x24(%rbp)
jne    11bc <configArguments+0x7c>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe4c(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x24(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    117b <configArguments+0x3b>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<configArguments>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x7,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%r12
mov    %r14,%rdi
call   1060 <strdup@plt>
mov    %rax,(%rsp)
lea    0xe90(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strsep@plt>
test   %rax,%rax
je     1287 <configArguments+0x147>
mov    %rax,(%r12)
lea    0xe74(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strsep@plt>
test   %rax,%rax
je     1287 <configArguments+0x147>
mov    %rax,0x8(%r12)
lea    0xe57(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strsep@plt>
test   %rax,%rax
je     1287 <configArguments+0x147>
mov    %rax,0x10(%r12)
lea    0xe3a(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strsep@plt>
test   %rax,%rax
je     1287 <configArguments+0x147>
mov    %rax,0x18(%r12)
lea    0xe1d(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strsep@plt>
test   %rax,%rax
je     1287 <configArguments+0x147>
mov    %rax,0x20(%r12)
lea    0xe00(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strsep@plt>
test   %rax,%rax
je     1287 <configArguments+0x147>
mov    %rax,0x28(%r12)
lea    0xde7(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strsep@plt>
test   %rax,%rax
je     1287 <configArguments+0x147>
mov    %rax,%r15
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    %r15,0x30(%r12)
lea    0xdb3(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strsep@plt>
test   %rax,%rax
je     1287 <configArguments+0x147>
mov    %r12,%rbx
add    $0x38,%rbx
lea    0xd98(%rip),%r14
mov    %rsp,%r15
nopl   0x0(%rax,%rax,1)
mov    %rax,(%rbx)
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <strsep@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    1270 <configArguments+0x130>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0A \00"
@stderr = global i32 0
@.str.1 = [55 x i8] c"Malformed configuration file; too many arguments at %s\00"
define i8** @configArguments(i8* %0) {
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %2
%7 = call i8** @calloc(i32 7, i32 8)
store i8** %7, i8*** %3
%8 = load i8*, i8** %2
%9 = call i8* @strdup(i8* %8)
store i8* %9, i8** %4
store i8* null, i8** %5
store i32 0, i32* %6
br label %10
10: ; preds = %20, %1
%11 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %27
13: ; preds = %10
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 6
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %2
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16, %13
%21 = load i8*, i8** %5
%22 = load i8**, i8*** %3
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds i8*, i8** %22, i64 %25
store i8* %21, i8** %26
br label %10
27: ; preds = %10
%28 = load i8**, i8*** %3
ret i8** %28
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0A \00"
@stderr = global i32 0
@.str.1 = [55 x i8] c"Malformed configuration file; too many arguments at %s\00"
define noalias i8** @configArguments(i8* %0) {
%2 = alloca i8*
%3 = tail call i8** @calloc(i32 7, i32 8)
%4 = bitcast i8** %2 to i8*
%5 = tail call i8* @strdup(i8* %0)
store i8* %5, i8** %2
%6 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %44, label %8
8: ; preds = %1
store i8* %6, i8** %3
%9 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %44, label %11
11: ; preds = %8
%12 = getelementptr inbounds i8*, i8** %3, i64 1
store i8* %9, i8** %12
%13 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %44, label %15
15: ; preds = %11
%16 = getelementptr inbounds i8*, i8** %3, i64 2
store i8* %13, i8** %16
%17 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i8* %17, null
br i1 %18, label %44, label %19
19: ; preds = %15
%20 = getelementptr inbounds i8*, i8** %3, i64 3
store i8* %17, i8** %20
%21 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i8* %21, null
br i1 %22, label %44, label %23
23: ; preds = %19
%24 = getelementptr inbounds i8*, i8** %3, i64 4
store i8* %21, i8** %24
%25 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i8* %25, null
br i1 %26, label %44, label %27
27: ; preds = %23
%28 = getelementptr inbounds i8*, i8** %3, i64 5
store i8* %25, i8** %28
%29 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%30 = icmp eq i8* %29, null
br i1 %30, label %44, label %31
31: ; preds = %27
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%34 = getelementptr inbounds i8*, i8** %3, i64 6
store i8* %29, i8** %34
%35 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%36 = icmp eq i8* %35, null
br i1 %36, label %44, label %37
37: ; preds = %31, %37
%38 = phi i64 [ %40, %37 ], [ 7, %31 ]
%39 = phi i8* [ %42, %37 ], [ %35, %31 ]
%40 = add nuw i64 %38, 1
%41 = getelementptr inbounds i8*, i8** %3, i64 %38
store i8* %39, i8** %41
%42 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %37
44: ; preds = %37, %8, %11, %15, %19, %23, %27, %31, %1
ret i8** %3
}