#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*/ add_output(char *);
int /*<<< orphan*/ init_tokens(char **);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ set_output_error();
void parse_gtp_input(char *command_input_buffer, char tokens[][20]) {
  char current_char = '\0';
  int i = 0;
  int j = 0;
  int k = 0;
  for (i = 0; i < 256; i++) {
    current_char = command_input_buffer[i];
    if (!isspace(current_char) && current_char != '\0') {
      if (k < 20) {
        tokens[j][k] = current_char;
        k++;
      } else {
        set_output_error();
        add_output("MAX_TOKEN_LENGTH exceeded");
        init_tokens(tokens);
        return;
      }
    } else {
      tokens[j][k] = '\0';
      j++;
      k = 0;
      if (j >= 15) {
        set_output_error();
        add_output("MAX_TOKEN_COUNT exceeded");
        init_tokens(tokens);
        return;
      }
      tokens[j][0] = '\0';
    }
    if (current_char == '\0') {
      break;
    }
  }
  return;
}


x86 assembly (clang, -O0):
<parse_gtp_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x100,-0x18(%rbp)
jge    128a <parse_gtp_input+0x14a>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
jne    1201 <parse_gtp_input+0xc1>
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     1201 <parse_gtp_input+0xc1>
cmpl   $0x14,-0x20(%rbp)
jge    11db <parse_gtp_input+0x9b>
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11fc <parse_gtp_input+0xbc>
mov    $0x0,%al
call   1050 <set_output_error@plt>
lea    0xe17(%rip),%rdi
call   1060 <add_output@plt>
mov    -0x10(%rbp),%rdi
call   1030 <init_tokens@plt>
jmp    128f <parse_gtp_input+0x14f>
jmp    1265 <parse_gtp_input+0x125>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0xf,-0x1c(%rbp)
jl     1253 <parse_gtp_input+0x113>
mov    $0x0,%al
call   1050 <set_output_error@plt>
lea    0xdda(%rip),%rdi
call   1060 <add_output@plt>
mov    -0x10(%rbp),%rdi
call   1030 <init_tokens@plt>
jmp    128f <parse_gtp_input+0x14f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movb   $0x0,(%rax)
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jne    1277 <parse_gtp_input+0x137>
jmp    128a <parse_gtp_input+0x14a>
jmp    127c <parse_gtp_input+0x13c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1170 <parse_gtp_input+0x30>
jmp    128f <parse_gtp_input+0x14f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_gtp_input>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r15
xor    %ebx,%ebx
xor    %r14d,%r14d
xor    %r13d,%r13d
jmp    116d <parse_gtp_input+0x2d>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x100,%rbx
je     11d0 <parse_gtp_input+0x90>
movsbl (%r15,%rbx,1),%ebp
mov    %ebp,%edi
call   1040 <isspace@plt>
test   %ebp,%ebp
je     11a0 <parse_gtp_input+0x60>
test   %eax,%eax
jne    11a0 <parse_gtp_input+0x60>
cmp    $0x13,%r14d
jg     11df <parse_gtp_input+0x9f>
movslq %r13d,%rax
movslq %r14d,%rcx
lea    (%rax,%rax,4),%rax
lea    (%r12,%rax,4),%rax
mov    %bpl,(%rcx,%rax,1)
add    $0x1,%r14d
jmp    1160 <parse_gtp_input+0x20>
nop
movslq %r13d,%rax
movslq %r14d,%rcx
lea    (%rax,%rax,4),%rax
lea    (%r12,%rax,4),%rax
movb   $0x0,(%rcx,%rax,1)
cmp    $0xd,%r13d
jg     11e8 <parse_gtp_input+0xa8>
add    $0x1,%r13d
movslq %r13d,%rax
lea    (%rax,%rax,4),%rax
movb   $0x0,(%r12,%rax,4)
xor    %r14d,%r14d
test   %bpl,%bpl
jne    1160 <parse_gtp_input+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe1a(%rip),%rbx
jmp    11ef <parse_gtp_input+0xaf>
lea    0xe2b(%rip),%rbx
xor    %eax,%eax
call   1050 <set_output_error@plt>
mov    %rbx,%rdi
call   1060 <add_output@plt>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <init_tokens@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"MAX_TOKEN_LENGTH exceeded\00"
@.str.1 = [25 x i8] c"MAX_TOKEN_COUNT exceeded\00"
define void @parse_gtp_input(i8* %0, [20 x i8]* %1) {
%3 = alloca i8*
%4 = alloca [20 x i8]*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store [20 x i8]* %1, [20 x i8]** %4
store i8 0, i8* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %6
br label %9
9: ; preds = %76, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 256
br i1 %11, label %12, label %79
12: ; preds = %9
%13 = load i8*, i8** %3
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
store i8 %17, i8* %5
%18 = load i8, i8* %5
%19 = call i32 @isspace(i8 signext %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %46, label %21
21: ; preds = %12
%22 = load i8, i8* %5
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %46
25: ; preds = %21
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 20
br i1 %27, label %28, label %39
28: ; preds = %25
%29 = load i8, i8* %5
%30 = load [20 x i8]*, [20 x i8]** %4
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %30, i64 %32
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [20 x i8], [20 x i8]* %33, i64 0, i64 %35
store i8 %29, i8* %36
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %45
39: ; preds = %25
%40 = call i32 (...) @set_output_error()
%41 = call i32 @add_output(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%42 = load [20 x i8]*, [20 x i8]** %4
%43 = bitcast [20 x i8]* %42 to i8**
%44 = call i32 @init_tokens(i8** %43)
br label %80
45: ; preds = %28
br label %70
46: ; preds = %21, %12
%47 = load [20 x i8]*, [20 x i8]** %4
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [20 x i8], [20 x i8]* %47, i64 %49
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [20 x i8], [20 x i8]* %50, i64 0, i64 %52
store i8 0, i8* %53
%54 = load i32, i32* %7
%55 = add nsw i32 %54, 1
store i32 %55, i32* %7
store i32 0, i32* %8
%56 = load i32, i32* %7
%57 = icmp sge i32 %56, 15
br i1 %57, label %58, label %64
58: ; preds = %46
%59 = call i32 (...) @set_output_error()
%60 = call i32 @add_output(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%61 = load [20 x i8]*, [20 x i8]** %4
%62 = bitcast [20 x i8]* %61 to i8**
%63 = call i32 @init_tokens(i8** %62)
br label %80
64: ; preds = %46
%65 = load [20 x i8]*, [20 x i8]** %4
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [20 x i8], [20 x i8]* %65, i64 %67
%69 = getelementptr inbounds [20 x i8], [20 x i8]* %68, i64 0, i64 0
store i8 0, i8* %69
br label %70
70: ; preds = %64, %45
%71 = load i8, i8* %5
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %70
br label %79
75: ; preds = %70
br label %76
76: ; preds = %75
%77 = load i32, i32* %6
%78 = add nsw i32 %77, 1
store i32 %78, i32* %6
br label %9
79: ; preds = %74, %9
br label %80
80: ; preds = %79, %58, %39
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"MAX_TOKEN_LENGTH exceeded\00"
@.str.1 = [25 x i8] c"MAX_TOKEN_COUNT exceeded\00"
define void @parse_gtp_input(i8* nocapture %0, [20 x i8]* %1) {
br label %3
3: ; preds = %2, %30
%4 = phi i64 [ 0, %2 ], [ %33, %30 ]
%5 = phi i32 [ 0, %2 ], [ %31, %30 ]
%6 = phi i32 [ 0, %2 ], [ %32, %30 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %4
%8 = load i8, i8* %7
%9 = tail call i32 @isspace(i8 signext %8)
%10 = icmp eq i32 %9, 0
%11 = icmp ne i8 %8, 0
%12 = and i1 %11, %10
br i1 %12, label %13, label %20
13: ; preds = %3
%14 = icmp slt i32 %5, 20
br i1 %14, label %15, label %35
15: ; preds = %13
%16 = sext i32 %6 to i64
%17 = sext i32 %5 to i64
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 %16, i64 %17
store i8 %8, i8* %18
%19 = add nsw i32 %5, 1
br label %30
20: ; preds = %3
%21 = sext i32 %6 to i64
%22 = sext i32 %5 to i64
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 %21, i64 %22
store i8 0, i8* %23
%24 = add nsw i32 %6, 1
%25 = icmp sgt i32 %6, 13
br i1 %25, label %35, label %26
26: ; preds = %20
%27 = sext i32 %24 to i64
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 %27, i64 0
store i8 0, i8* %28
%29 = icmp eq i8 %8, 0
br i1 %29, label %41, label %30
30: ; preds = %15, %26
%31 = phi i32 [ %19, %15 ], [ 0, %26 ]
%32 = phi i32 [ %6, %15 ], [ %24, %26 ]
%33 = add nuw nsw i64 %4, 1
%34 = icmp eq i64 %33, 256
br i1 %34, label %41, label %3
35: ; preds = %20, %13
%36 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), %13 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), %20 ]
%37 = tail call i32 (...) @set_output_error()
%38 = tail call i32 @add_output(i8* %36)
%39 = bitcast [20 x i8]* %1 to i8**
%40 = tail call i32 @init_tokens(i8** %39)
br label %41
41: ; preds = %30, %26, %35
ret void
}