// File: /workspace/github_c_makefile_star2_O3/justy989[P]ce/ce_command.c
// Function: ce_command_parse
bool ce_command_parse(CeCommand_t* command, const char* string){
     if(*string == 0) return false;

     const char* start = NULL;
     const char* end = NULL;

     int64_t arg_count = 0;
     start = eat_blanks(string);

     // count the args
     while(*start){
          end = find_end_of_arg(start);
          arg_count++;
          if(!end) break;
          start = eat_blanks(end + 1);
     }

     // account for command at the beginning
     arg_count--;

     start = eat_blanks(string);
     end = find_end_of_arg(start);

     if(!end){
          command->args = NULL;
          command->arg_count = 0;

          int64_t len = strlen(start);
          if(len >= CE_COMMAND_NAME_MAX_LEN){
               ce_log("error: in command '%s' command name is greater than max %d characters\n", string, CE_COMMAND_NAME_MAX_LEN);
               return false;
          }

          strcpy(command->name, start);
          return true;
     }

     // copy the command name
     int64_t len = end - start;
     if(len >= CE_COMMAND_NAME_MAX_LEN){
          ce_log("error: in command '%s' command name is greater than max %d characters\n", string, CE_COMMAND_NAME_MAX_LEN);
          return false;
     }

     strncpy(command->name, start, len);
     command->name[len] = 0;

     // exit early if there are no arguments
     if(arg_count == 0){
          command->args = NULL;
          command->arg_count = 0;
          return true;
     }

     start = eat_blanks(end + 1);

     // allocate the arguments
     command->args = malloc(arg_count * sizeof(*command->args));
     if(!command->args) return false;
     command->arg_count = arg_count;

     CeCommandArg_t* arg = command->args;

     // parse the individual args
     char buffer[CE_COMMAND_ARG_MAX_LEN];
     while(*start){
          end = find_end_of_arg(start);
          if(end){
               int64_t arg_len = end - start;
               if (arg_len >= CE_COMMAND_ARG_MAX_LEN) {
                   return false;
               }
               memset(buffer, 0, arg_len + 1);
               buffer[arg_len] = 0;

               strncpy(buffer, start, arg_len);
               if(!parse_arg(arg, buffer)){
                    ce_command_free(command);
                    return false;
               }
          }else{
               int64_t arg_len = strlen(start);
               if (arg_len >= CE_COMMAND_ARG_MAX_LEN) {
                   return false;
               }
               memset(buffer, 0, arg_len + 1);
               strcpy(buffer, start);
               buffer[arg_len] = 0;
               if(!parse_arg(arg, buffer)){
                    ce_command_free(command);
                    return false;
               }
               break;
          }

          start = eat_blanks(end + 1);
          arg++;
     }

     return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
cmpb $0x0, (%rsi)
je 0x162d1
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x162e7
movq %rax, %r15
cmpb $0x0, (%rax)
je 0x16114
xorl %r12d, %r12d
movq %r15, %rax
movq %r12, %rbp
movq %rax, %rdi
callq 0x1631d
testq %rax, %rax
je 0x1611b
leaq 0x1(%rbp), %r12
incq %rax
movq %rax, %rdi
callq 0x162e7
cmpb $0x0, (%rax)
jne 0x160ee
jmp 0x1611b
movq $-0x1, %rbp
movq %r15, %rdi
callq 0x1631d
testq %rax, %rax
je 0x1622e
movq %rax, %r12
movq %rax, %r13
subq %r15, %r13
cmpq $0x200, %r13            # imm = 0x200
jge 0x16255
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xd0b0
movb $0x0, (%rbx,%r13)
testq %rbp, %rbp
je 0x1626f
incq %r12
movq %r12, %rdi
callq 0x162e7
movq %rax, %r15
movq %rbp, %rdi
shlq $0x4, %rdi
callq 0xd4c0
movq %rax, 0x200(%rbx)
testq %rax, %rax
je 0x162d1
movq %rbp, 0x208(%rbx)
movb $0x1, %bpl
cmpb $0x0, (%r15)
je 0x162d3
movq %rax, %r14
movq %rbx, 0x8(%rsp)
movq %r15, %rdi
callq 0x1631d
testq %rax, %rax
je 0x1627e
movq %rax, %r12
movq %rax, %r13
subq %r15, %r13
cmpq $0x400, %r13            # imm = 0x400
setl %bpl
jge 0x162d3
leaq 0x1(%r13), %rdx
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xd2a0
movb $0x0, 0x10(%rsp,%r13)
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xd0b0
movq %r14, %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %rbx
callq 0x1635a
testb %al, %al
je 0x162c9
incq %r12
movq %r12, %rdi
callq 0x162e7
movq %rax, %r15
addq $0x10, %r14
cmpb $0x0, (%rax)
jne 0x161a4
jmp 0x162d3
xorps %xmm0, %xmm0
movups %xmm0, 0x200(%rbx)
movq %r15, %rdi
callq 0xd210
cmpq $0x200, %rax            # imm = 0x200
jge 0x16255
movq %rbx, %rdi
movq %r15, %rsi
callq 0xd0e0
jmp 0x16279
leaq 0x18f76(%rip), %rdi     # 0x2f1d2
xorl %ebp, %ebp
movq %r14, %rsi
movl $0x200, %edx            # imm = 0x200
xorl %eax, %eax
callq 0xd954
jmp 0x162d3
xorps %xmm0, %xmm0
movups %xmm0, 0x200(%rbx)
movb $0x1, %bpl
jmp 0x162d3
movq %r15, %rdi
callq 0xd210
cmpq $0x3ff, %rax            # imm = 0x3FF
jg 0x162d1
movq %rax, %r12
movq %rax, %rdx
incq %rdx
leaq 0x10(%rsp), %r13
movq %r13, %rdi
xorl %esi, %esi
callq 0xd2a0
movq %r13, %rdi
movq %r15, %rsi
callq 0xd0e0
movb $0x0, 0x10(%rsp,%r12)
movq %r14, %rdi
movq %r13, %rsi
callq 0x1635a
movb $0x1, %bpl
testb %al, %al
jne 0x162d3
movq %rbx, %rdi
callq 0x16443
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq