// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x1bcf8
movb $0x0, -0x1(%rbp)
jmp 0x1c038
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1c050
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpb $0x0, (%rax)
je 0x1bd5b
movq -0x20(%rbp), %rdi
callq 0x1c0a0
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x1bd48
jmp 0x1bd5b
movq -0x28(%rbp), %rdi
addq $0x1, %rdi
callq 0x1c050
movq %rax, -0x20(%rbp)
jmp 0x1bd1d
movq -0x30(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1c050
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1c0a0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x1bdf3
movq -0x10(%rbp), %rax
movq $0x0, 0x200(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x208(%rax)
movq -0x20(%rbp), %rdi
callq 0xd200
movq %rax, -0x38(%rbp)
cmpq $0x200, -0x38(%rbp)     # imm = 0x200
jl 0x1bddd
movq -0x18(%rbp), %rsi
leaq 0x2838d(%rip), %rdi     # 0x44155
movl $0x200, %edx            # imm = 0x200
movb $0x0, %al
callq 0xd8f0
movb $0x0, -0x1(%rbp)
jmp 0x1c038
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xd0e0
movb $0x1, -0x1(%rbp)
jmp 0x1c038
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x40(%rbp)
cmpq $0x200, -0x40(%rbp)     # imm = 0x200
jl 0x1be2c
movq -0x18(%rbp), %rsi
leaq 0x2833e(%rip), %rdi     # 0x44155
movl $0x200, %edx            # imm = 0x200
movb $0x0, %al
callq 0xd8f0
movb $0x0, -0x1(%rbp)
jmp 0x1c038
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0xd0b0
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
movb $0x0, (%rax,%rcx)
cmpq $0x0, -0x30(%rbp)
jne 0x1be77
movq -0x10(%rbp), %rax
movq $0x0, 0x200(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x208(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x1c038
movq -0x28(%rbp), %rdi
addq $0x1, %rdi
callq 0x1c050
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
shlq $0x4, %rdi
callq 0xd4a0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x200(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x200(%rax)
jne 0x1beba
movb $0x0, -0x1(%rbp)
jmp 0x1c038
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x208(%rax)
movq -0x10(%rbp), %rax
movq 0x200(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
cmpb $0x0, (%rax)
je 0x1c034
movq -0x20(%rbp), %rdi
callq 0x1c0a0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1bf8f
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x458(%rbp)
cmpq $0x400, -0x458(%rbp) # imm = 0x400
jl 0x1bf25
movb $0x0, -0x1(%rbp)
jmp 0x1c038
leaq -0x450(%rbp), %rdi
movq -0x458(%rbp), %rdx
addq $0x1, %rdx
xorl %esi, %esi
callq 0xd290
movq -0x458(%rbp), %rax
movb $0x0, -0x450(%rbp,%rax)
leaq -0x450(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x458(%rbp), %rdx
callq 0xd0b0
movq -0x48(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0x1c150
testb $0x1, %al
jne 0x1bf8a
movq -0x10(%rbp), %rdi
callq 0x1c2f0
movb $0x0, -0x1(%rbp)
jmp 0x1c038
jmp 0x1c012
movq -0x20(%rbp), %rdi
callq 0xd200
movq %rax, -0x460(%rbp)
cmpq $0x400, -0x460(%rbp) # imm = 0x400
jl 0x1bfb5
movb $0x0, -0x1(%rbp)
jmp 0x1c038
leaq -0x450(%rbp), %rdi
movq -0x460(%rbp), %rdx
addq $0x1, %rdx
xorl %esi, %esi
callq 0xd290
leaq -0x450(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xd0e0
movq -0x460(%rbp), %rax
movb $0x0, -0x450(%rbp,%rax)
movq -0x48(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0x1c150
testb $0x1, %al
jne 0x1c010
movq -0x10(%rbp), %rdi
callq 0x1c2f0
movb $0x0, -0x1(%rbp)
jmp 0x1c038
jmp 0x1c034
movq -0x28(%rbp), %rdi
addq $0x1, %rdi
callq 0x1c050
movq %rax, -0x20(%rbp)
movq -0x48(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x48(%rbp)
jmp 0x1bed8
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
nopw %cs:(%rax,%rax)