#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(scalar_t__, int);
int /*<<< orphan*/ free(char *);
char *mystrcpy(char *, size_t);
int /*<<< orphan*/ parse_input(char *, char **);
int /*<<< orphan*/ strcmp(char *, char *);
scalar_t__ strlen(char *);
char *strtok(char *, char *);
scalar_t__ trimwhitespace(char *, scalar_t__, char *);
bool split_concurrent(char *buf, size_t buf_len,
                      char *args[1024 / 2][1024 / 2 + 1], int *num) {
  *num = 0;
  char *command_buffers[1024 / 2] = {NULL};
  bool to_continue = true;
  char *bufcpy = mystrcpy(buf, buf_len + 1);
  char *token = strtok(bufcpy, ";");
  if (!token) {
    return true;
  }
  do {
    char *subbufcpy = calloc(strlen(token) + 1, sizeof(char *));
    if (trimwhitespace(subbufcpy, strlen(token) + 1, token)) {
      if (!strcmp(subbufcpy, "quit") || !strcmp(subbufcpy, "exit")) {
        to_continue = false;
        free(subbufcpy);
      } else {
        command_buffers[*num] = subbufcpy;
        (*num)++;
      }
    }
  } while ((token = strtok(NULL, ";")));
  int i;
  for (i = 0; i < *num; i++) {
    parse_input(command_buffers[i], args[i]);
    free(command_buffers[i]);
  }
  free(bufcpy);
  return to_continue;
}


x86 assembly (clang, -O0):
<split_concurrent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1060,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1050 <memset@plt>
movl   $0x1,-0x1034(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
call   10a0 <mystrcpy@plt>
mov    %rax,-0x1040(%rbp)
mov    -0x1040(%rbp),%rdi
lea    0xe08(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x1048(%rbp)
cmpq   $0x0,-0x1048(%rbp)
jne    121e <split_concurrent+0x8e>
movl   $0x1,-0x4(%rbp)
jmp    13a6 <split_concurrent+0x216>
jmp    1223 <split_concurrent+0x93>
mov    -0x1048(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x1050(%rbp)
mov    -0x1050(%rbp),%rax
mov    %rax,-0x1060(%rbp)
mov    -0x1048(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1060(%rbp),%rdi
mov    %rax,%rsi
add    $0x1,%rsi
mov    -0x1048(%rbp),%rdx
call   1060 <trimwhitespace@plt>
cmp    $0x0,%rax
je     12fe <split_concurrent+0x16e>
mov    -0x1050(%rbp),%rdi
lea    0xd6f(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     12bd <split_concurrent+0x12d>
mov    -0x1050(%rbp),%rdi
lea    0xd58(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    12d8 <split_concurrent+0x148>
movl   $0x0,-0x1034(%rbp)
mov    -0x1050(%rbp),%rdi
call   1030 <free@plt>
jmp    12f9 <split_concurrent+0x169>
mov    -0x1050(%rbp),%rcx
mov    -0x28(%rbp),%rax
movslq (%rax),%rax
mov    %rcx,-0x1030(%rbp,%rax,8)
ff
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    12fe <split_concurrent+0x16e>
jmp    1303 <split_concurrent+0x173>
xor    %eax,%eax
mov    %eax,%edi
lea    0xcf2(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x1048(%rbp)
cmp    $0x0,%rax
jne    1223 <split_concurrent+0x93>
movl   $0x0,-0x1054(%rbp)
mov    -0x1054(%rbp),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jge    1391 <split_concurrent+0x201>
movslq -0x1054(%rbp),%rax
mov    -0x1030(%rbp,%rax,8),%rdi
ff
mov    -0x20(%rbp),%rsi
movslq -0x1054(%rbp),%rax
imul   $0x1008,%rax,%rax
add    %rax,%rsi
call   1090 <parse_input@plt>
movslq -0x1054(%rbp),%rax
mov    -0x1030(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
mov    -0x1054(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1054(%rbp)
jmp    132e <split_concurrent+0x19e>
mov    -0x1040(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1034(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_concurrent>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %rdi,%r15
movl   $0x0,(%rcx)
lea    0x10(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   1050 <memset@plt>
add    $0x1,%rbp
mov    %r15,%rdi
mov    %rbp,%rsi
call   10a0 <mystrcpy@plt>
mov    %rax,%rbx
lea    0xe23(%rip),%rsi
mov    %rax,%rdi
call   10b0 <strtok@plt>
test   %rax,%rax
je     12ea <split_concurrent+0x15a>
mov    %rax,%r15
mov    %rbx,0x8(%rsp)
mov    $0x1,%ebx
lea    0xdfe(%rip),%rbp
jmp    122c <split_concurrent+0x9c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
xor    %edi,%edi
mov    %rbp,%rsi
call   10b0 <strtok@plt>
mov    %rax,%r15
test   %rax,%rax
je     1297 <split_concurrent+0x107>
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,%r13
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rsi
mov    %r13,%rdi
mov    %r15,%rdx
call   1060 <trimwhitespace@plt>
test   %rax,%rax
je     121a <split_concurrent+0x8a>
mov    %r13,%rdi
lea    0xd97(%rip),%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1210 <split_concurrent+0x80>
mov    %r13,%rdi
lea    0xd89(%rip),%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1210 <split_concurrent+0x80>
movslq (%r14),%rax
mov    %r13,0x10(%rsp,%rax,8)
add    $0x1,%eax
mov    %eax,(%r14)
jmp    121a <split_concurrent+0x8a>
mov    %ebx,%r15d
cmpl   $0x0,(%r14)
jle    12db <split_concurrent+0x14b>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,8),%rbp
mov    %rbp,%rdi
mov    %r12,%rsi
call   1090 <parse_input@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
add    $0x1,%rbx
movslq (%r14),%rax
add    $0x1008,%r12
cmp    %rax,%rbx
jl     12b0 <split_concurrent+0x120>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %r15d,%eax
jmp    12ef <split_concurrent+0x15f>
mov    $0x1,%eax
add    $0x1018,%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 = [5 x i8] c"quit\00"
@.str.2 = [5 x i8] c"exit\00"
define i32 @split_concurrent(i8* %0, i64 %1, [513 x i8*]* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca [513 x i8*]*
%9 = alloca i32*
%10 = alloca [512 x i8*]
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
store i8* %0, i8** %6
store i64 %1, i64* %7
store [513 x i8*]* %2, [513 x i8*]** %8
store i32* %3, i32** %9
%16 = load i32*, i32** %9
store i32 0, i32* %16
%17 = bitcast [512 x i8*]* %10 to i8*
store i32 1, i32* %11
%18 = load i8*, i8** %6
%19 = load i64, i64* %7
%20 = add i64 %19, 1
%21 = call i8* @mystrcpy(i8* %18, i64 %20)
store i8* %21, i8** %12
%22 = load i8*, i8** %12
%23 = call i8* @strtok(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %23, i8** %13
%24 = load i8*, i8** %13
%25 = icmp ne i8* %24, null
br i1 %25, label %27, label %26
26: ; preds = %4
store i32 1, i32* %5
br label %94
27: ; preds = %4
br label %28
28: ; preds = %62, %27
%29 = load i8*, i8** %13
%30 = call i64 @strlen(i8* %29)
%31 = add nsw i64 %30, 1
%32 = call i8* @calloc(i64 %31, i32 8)
store i8* %32, i8** %14
%33 = load i8*, i8** %14
%34 = load i8*, i8** %13
%35 = call i64 @strlen(i8* %34)
%36 = add nsw i64 %35, 1
%37 = load i8*, i8** %13
%38 = call i64 @trimwhitespace(i8* %33, i64 %36, i8* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %61
40: ; preds = %28
%41 = load i8*, i8** %14
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i8*, i8** %14
%46 = call i32 @strcmp(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%47 = icmp ne i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %44, %40
store i32 0, i32* %11
%49 = load i8*, i8** %14
%50 = call i32 @free(i8* %49)
br label %60
51: ; preds = %44
%52 = load i8*, i8** %14
%53 = load i32*, i32** %9
%54 = load i32, i32* %53
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [512 x i8*], [512 x i8*]* %10, i64 0, i64 %55
store i8* %52, i8** %56
%57 = load i32*, i32** %9
%58 = load i32, i32* %57
%59 = add nsw i32 %58, 1
store i32 %59, i32* %57
br label %60
60: ; preds = %51, %48
br label %61
61: ; preds = %60, %28
br label %62
62: ; preds = %61
%63 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %63, i8** %13
%64 = icmp ne i8* %63, null
br i1 %64, label %28, label %65
65: ; preds = %62
store i32 0, i32* %15
br label %66
66: ; preds = %87, %65
%67 = load i32, i32* %15
%68 = load i32*, i32** %9
%69 = load i32, i32* %68
%70 = icmp slt i32 %67, %69
br i1 %70, label %71, label %90
71: ; preds = %66
%72 = load i32, i32* %15
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [512 x i8*], [512 x i8*]* %10, i64 0, i64 %73
%75 = load i8*, i8** %74
%76 = load [513 x i8*]*, [513 x i8*]** %8
%77 = load i32, i32* %15
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [513 x i8*], [513 x i8*]* %76, i64 %78
%80 = getelementptr inbounds [513 x i8*], [513 x i8*]* %79, i64 0, i64 0
%81 = call i32 @parse_input(i8* %75, i8** %80)
%82 = load i32, i32* %15
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [512 x i8*], [512 x i8*]* %10, i64 0, i64 %83
%85 = load i8*, i8** %84
%86 = call i32 @free(i8* %85)
br label %87
87: ; preds = %71
%88 = load i32, i32* %15
%89 = add nsw i32 %88, 1
store i32 %89, i32* %15
br label %66
90: ; preds = %66
%91 = load i8*, i8** %12
%92 = call i32 @free(i8* %91)
%93 = load i32, i32* %11
store i32 %93, i32* %5
br label %94
94: ; preds = %90, %26
%95 = load i32, i32* %5
ret i32 %95
}

LLVM IR (-O2):
@.str = [2 x i8] c";\00"
@.str.1 = [5 x i8] c"quit\00"
@.str.2 = [5 x i8] c"exit\00"
define i32 @split_concurrent(i8* %0, i64 %1, [513 x i8*]* %2, i32* nocapture %3) {
%5 = alloca [512 x i8*]
store i32 0, i32* %3
%6 = bitcast [512 x i8*]* %5 to i8*
%7 = add i64 %1, 1
%8 = tail call i8* @mystrcpy(i8* %0, i64 %7)
%9 = tail call i8* @strtok(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %54, label %11
11: ; preds = %4, %34
%12 = phi i32 [ %35, %34 ], [ 1, %4 ]
%13 = phi i8* [ %36, %34 ], [ %9, %4 ]
%14 = tail call i64 @strlen(i8* dereferenceable(1) %13)
%15 = add nsw i64 %14, 1
%16 = tail call i8* @calloc(i64 %15, i32 8)
%17 = tail call i64 @strlen(i8* dereferenceable(1) %13)
%18 = add nsw i64 %17, 1
%19 = tail call i64 @trimwhitespace(i8* %16, i64 %18, i8* %13)
%20 = icmp eq i64 %19, 0
br i1 %20, label %34, label %21
21: ; preds = %11
%22 = tail call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = tail call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24, %21
%28 = tail call i32 @free(i8* %16)
br label %34
29: ; preds = %24
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [512 x i8*], [512 x i8*]* %5, i64 0, i64 %31
store i8* %16, i8** %32
%33 = add nsw i32 %30, 1
store i32 %33, i32* %3
br label %34
34: ; preds = %27, %29, %11
%35 = phi i32 [ %12, %29 ], [ 0, %27 ], [ %12, %11 ]
%36 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %11
38: ; preds = %34
%39 = load i32, i32* %3
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %52
41: ; preds = %38, %41
%42 = phi i64 [ %48, %41 ], [ 0, %38 ]
%43 = getelementptr inbounds [512 x i8*], [512 x i8*]* %5, i64 0, i64 %42
%44 = load i8*, i8** %43
%45 = getelementptr inbounds [513 x i8*], [513 x i8*]* %2, i64 %42, i64 0
%46 = tail call i32 @parse_input(i8* %44, i8** %45)
%47 = tail call i32 @free(i8* %44)
%48 = add nuw nsw i64 %42, 1
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = icmp slt i64 %48, %50
br i1 %51, label %41, label %52
52: ; preds = %41, %38
%53 = tail call i32 @free(i8* %8)
br label %54
54: ; preds = %4, %52
%55 = phi i32 [ %35, %52 ], [ 1, %4 ]
ret i32 %55
}