#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 /*<<< orphan*/ kpccfatal(char *);
char *strtok(char *, char *);
int split_args(char **split, char *args) {
  char *tok;
  int i = 0;
  tok = strtok(args, ";");
  while (tok && i < 32) {
    split[i++] = tok;
    tok = strtok(NULL, ";");
  }
  if (tok && i == 32)
    kpccfatal("Too many args modifiers\n");
  return i;
}


x86 assembly (clang, -O0):
<split_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x1d(%rbp)
je     1165 <split_args+0x45>
cmpl   $0x20,-0x1c(%rbp)
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1175 <split_args+0x55>
jmp    11a8 <split_args+0x88>
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe66(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    114b <split_args+0x2b>
cmpq   $0x0,-0x18(%rbp)
je     11c9 <split_args+0xa9>
cmpl   $0x20,-0x1c(%rbp)
jne    11c9 <split_args+0xa9>
lea    0xe3e(%rip),%rdi
call   1030 <kpccfatal@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_args>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rax
mov    %rdi,%r14
lea    0xecb(%rip),%rsi
mov    %rax,%rdi
call   1040 <strtok@plt>
test   %rax,%rax
je     118f <split_args+0x6f>
xor    %ebx,%ebx
lea    0xeb5(%rip),%r15
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbx),%r12
mov    %rax,(%r14,%rbx,8)
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     1170 <split_args+0x50>
cmp    $0x1f,%rbx
mov    %r12,%rbx
jb     1150 <split_args+0x30>
test   %rax,%rax
je     1192 <split_args+0x72>
cmp    $0x20,%r12d
jne    1192 <split_args+0x72>
lea    0xe80(%rip),%rdi
call   1030 <kpccfatal@plt>
mov    $0x20,%r12d
jmp    1192 <split_args+0x72>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c";\00"
@.str.1 = [25 x i8] c"Too many args modifiers\0A\00"
define i32 @split_args(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8** %0, i8*** %3
store i8* %1, i8** %4
store i32 0, i32* %6
%7 = load i8*, i8** %4
%8 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %5
br label %9
9: ; preds = %17, %2
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 32
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ false, %9 ], [ %14, %12 ]
br i1 %16, label %17, label %25
17: ; preds = %15
%18 = load i8*, i8** %5
%19 = load i8**, i8*** %3
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds i8*, i8** %19, i64 %22
store i8* %18, i8** %23
%24 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %24, i8** %5
br label %9
25: ; preds = %15
%26 = load i8*, i8** %5
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32, i32* %6
%30 = icmp eq i32 %29, 32
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @kpccfatal(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %31, %28, %25
%34 = load i32, i32* %6
ret i32 %34
}

LLVM IR (-O2):
@.str = [2 x i8] c";\00"
@.str.1 = [25 x i8] c"Too many args modifiers\0A\00"
define i32 @split_args(i8** nocapture writeonly %0, i8* %1) {
%3 = tail call i8* @strtok(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %20, label %5
5: ; preds = %2, %5
%6 = phi i64 [ %8, %5 ], [ 0, %2 ]
%7 = phi i8* [ %10, %5 ], [ %3, %2 ]
%8 = add nuw nsw i64 %6, 1
%9 = getelementptr inbounds i8*, i8** %0, i64 %6
store i8* %7, i8** %9
%10 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i8* %10, null
%12 = icmp ult i64 %6, 31
%13 = select i1 %11, i1 %12, i1 false
br i1 %13, label %5, label %14
14: ; preds = %5
%15 = trunc i64 %8 to i32
%16 = icmp eq i32 %15, 32
%17 = select i1 %11, i1 %16, i1 false
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 @kpccfatal(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %2, %18, %14
%21 = phi i32 [ 32, %18 ], [ %15, %14 ], [ 0, %2 ]
ret i32 %21
}