#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 */
typedef int /*<<< orphan*/ _bf;

/* Variables and functions */
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *strchr(char *, char);
char *strdup(char *);
scalar_t__ strlen(char *);
char *strtok_r(char *, char *, char **);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char *);
int split_parameters(char *parameter_string, int *argc, char **argv) {
  int count = 1;
  argv[0] = NULL;
  if (parameter_string != NULL && strlen(parameter_string) != 0) {
    char *arg = NULL, *saveptr = NULL, *token = NULL;
    arg = strdup(parameter_string);
    if (strchr(arg, ' ') != NULL) {
      token = strtok_r(arg, " ", &saveptr);
      if (token != NULL) {
        argv[count] = strdup(token);
        count++;
        while ((token = strtok_r(NULL, " ", &saveptr)) != NULL) {
          argv[count] = strdup(token);
          count++;
          if (count >= 32) {
            {
              char _bf[1024] = {0};
              snprintf(_bf, sizeof(_bf) - 1,
                       "ERROR: too many arguments to input plugin\n");
              fprintf(stderr, "%s", " i: ");
              fprintf(stderr, "%s", _bf);
              syslog(LOG_INFO, "%s", _bf);
            };
            return 0;
          }
        }
      }
    }
  }
  *argc = count;
  return 1;
}


x86 assembly (clang, -O0):
<split_parameters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
cmpq   $0x0,-0x10(%rbp)
je     1334 <split_parameters+0x1b4>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
je     1334 <split_parameters+0x1b4>
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     132f <split_parameters+0x1af>
mov    -0x30(%rbp),%rdi
lea    0xe22(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1070 <strtok_r@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     132a <split_parameters+0x1aa>
mov    -0x40(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdde(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1070 <strtok_r@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     1325 <split_parameters+0x1a5>
mov    -0x40(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x20,-0x24(%rbp)
jl     1320 <split_parameters+0x1a0>
lea    -0x440(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x440(%rbp),%rdi
mov    $0x3ff,%esi
lea    0xd45(%rip),%rdx
call   1050 <snprintf@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
lea    0xd5b(%rip),%rsi
lea    0xd57(%rip),%rdx
call   1080 <fprintf@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
lea    -0x440(%rbp),%rdx
lea    0xd38(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
lea    -0x440(%rbp),%rdx
lea    0xd1c(%rip),%rsi
call   1090 <syslog@plt>
movl   $0x0,-0x4(%rbp)
jmp    1344 <split_parameters+0x1c4>
jmp    1248 <split_parameters+0xc8>
jmp    132a <split_parameters+0x1aa>
jmp    132f <split_parameters+0x1af>
jmp    1334 <split_parameters+0x1b4>
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_parameters>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%r15
movq   $0x0,(%rdx)
mov    $0x1,%r14d
mov    $0x1,%ebx
test   %rdi,%rdi
je     12ba <split_parameters+0x14a>
cmpb   $0x0,(%rdi)
mov    $0x1,%ebx
je     12ba <split_parameters+0x14a>
mov    %rdx,%rbp
movq   $0x0,0x8(%rsp)
call   1090 <strdup@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     12ba <split_parameters+0x14a>
lea    0xe4e(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %r12,%rdi
call   1060 <strtok_r@plt>
test   %rax,%rax
je     12ba <split_parameters+0x14a>
mov    %rax,%rdi
call   1090 <strdup@plt>
mov    %rax,0x8(%rbp)
mov    $0x2,%ebx
lea    0xe20(%rip),%r12
lea    0x8(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r12,%rsi
mov    %r13,%rdx
call   1060 <strtok_r@plt>
test   %rax,%rax
je     12ba <split_parameters+0x14a>
mov    %rax,%rdi
call   1090 <strdup@plt>
mov    %rax,0x0(%rbp,%rbx,8)
add    $0x1,%rbx
cmp    $0x20,%rbx
jne    1220 <split_parameters+0xb0>
lea    0x10(%rsp),%r15
xor    %r14d,%r14d
mov    $0x400,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xd95(%rip),%rdx
mov    %r15,%rdi
mov    $0x3ff,%esi
call   1040 <snprintf@plt>
mov    0x2d61(%rip),%rbx
mov    (%rbx),%edi
lea    0xda3(%rip),%rbp
lea    0xd9f(%rip),%rdx
mov    %rbp,%rsi
call   1070 <fprintf@plt>
mov    (%rbx),%edi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1070 <fprintf@plt>
mov    0x2d2d(%rip),%rax
mov    (%rax),%edi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1080 <syslog@plt>
jmp    12bd <split_parameters+0x14d>
mov    %ebx,(%r15)
mov    %r14d,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [43 x i8] c"ERROR: too many arguments to input plugin\0A\00"
@stderr = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [5 x i8] c" i: \00"
@LOG_INFO = global i32 0
define i32 @split_parameters(i8* %0, i32* %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [1024 x i8]
store i8* %0, i8** %5
store i32* %1, i32** %6
store i8** %2, i8*** %7
store i32 1, i32* %8
%13 = load i8**, i8*** %7
%14 = getelementptr inbounds i8*, i8** %13, i64 0
store i8* null, i8** %14
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %71
17: ; preds = %3
%18 = load i8*, i8** %5
%19 = call i64 @strlen(i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %71
21: ; preds = %17
store i8* null, i8** %9
store i8* null, i8** %10
store i8* null, i8** %11
%22 = load i8*, i8** %5
%23 = call i8* @strdup(i8* %22)
store i8* %23, i8** %9
%24 = load i8*, i8** %9
%25 = call i32* @strchr(i8* %24, i8 signext 32)
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %70
27: ; preds = %21
%28 = load i8*, i8** %9
%29 = call i8* @strtok_r(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %10)
store i8* %29, i8** %11
%30 = load i8*, i8** %11
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %69
32: ; preds = %27
%33 = load i8*, i8** %11
%34 = call i8* @strdup(i8* %33)
%35 = load i8**, i8*** %7
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
store i8* %34, i8** %38
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %41
41: ; preds = %67, %32
%42 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %10)
store i8* %42, i8** %11
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %68
44: ; preds = %41
%45 = load i8*, i8** %11
%46 = call i8* @strdup(i8* %45)
%47 = load i8**, i8*** %7
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
store i8* %46, i8** %50
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
store i32 %52, i32* %8
%53 = load i32, i32* %8
%54 = icmp sge i32 %53, 32
br i1 %54, label %55, label %67
55: ; preds = %44
%56 = bitcast [1024 x i8]* %12 to i8*
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%58 = call i32 @snprintf(i8* %57, i32 1023, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%59 = load i32, i32* @stderr
%60 = call i32 @fprintf(i32 %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%61 = load i32, i32* @stderr
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%63 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %62)
%64 = load i32, i32* @LOG_INFO
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%66 = call i32 @syslog(i32 %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %65)
store i32 0, i32* %4
br label %74
67: ; preds = %44
br label %41
68: ; preds = %41
br label %69
69: ; preds = %68, %27
br label %70
70: ; preds = %69, %21
br label %71
71: ; preds = %70, %17, %3
%72 = load i32, i32* %8
%73 = load i32*, i32** %6
store i32 %72, i32* %73
store i32 1, i32* %4
br label %74
74: ; preds = %71, %55
%75 = load i32, i32* %4
ret i32 %75
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [43 x i8] c"ERROR: too many arguments to input plugin\0A\00"
@stderr = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [5 x i8] c" i: \00"
@LOG_INFO = global i32 0
define i32 @split_parameters(i8* %0, i32* nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = alloca i8*
%5 = alloca [1024 x i8]
store i8* null, i8** %2
%6 = icmp eq i8* %0, null
br i1 %6, label %43, label %7
7: ; preds = %3
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %43, label %10
10: ; preds = %7
%11 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%12 = tail call i8* @strdup(i8* %0)
%13 = tail call i32* @strchr(i8* %12, i8 signext 32)
%14 = icmp eq i32* %13, null
br i1 %14, label %32, label %15
15: ; preds = %10
%16 = call i8* @strtok_r(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4)
%17 = icmp eq i8* %16, null
br i1 %17, label %32, label %18
18: ; preds = %15
%19 = call i8* @strdup(i8* %16)
%20 = getelementptr inbounds i8*, i8** %2, i64 1
store i8* %19, i8** %20
br label %21
21: ; preds = %25, %18
%22 = phi i64 [ %28, %25 ], [ 2, %18 ]
%23 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4)
%24 = icmp eq i8* %23, null
br i1 %24, label %30, label %25
25: ; preds = %21
%26 = call i8* @strdup(i8* %23)
%27 = getelementptr inbounds i8*, i8** %2, i64 %22
store i8* %26, i8** %27
%28 = add nuw nsw i64 %22, 1
%29 = icmp eq i64 %28, 32
br i1 %29, label %34, label %21
30: ; preds = %21
%31 = trunc i64 %22 to i32
br label %32
32: ; preds = %30, %15, %10
%33 = phi i32 [ 1, %10 ], [ 1, %15 ], [ %31, %30 ]
br label %43
34: ; preds = %25
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%36 = call i32 @snprintf(i8* %35, i32 1023, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%41 = load i32, i32* @LOG_INFO
%42 = call i32 @syslog(i32 %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %35)
br label %45
43: ; preds = %32, %7, %3
%44 = phi i32 [ 1, %7 ], [ 1, %3 ], [ %33, %32 ]
store i32 %44, i32* %1
br label %45
45: ; preds = %34, %43
%46 = phi i32 [ 1, %43 ], [ 0, %34 ]
ret i32 %46
}