// File: /workspace/github_c_makefile_star2_O3/vlenhart[P]q3bsp/arglist.cpp
// Function: ArgList::Set(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool)
void ArgList::Set( const String& line, bool untilNewLine )
{
  enum State
  {
    LINE_START,
    LINE_SPACE,
    LINE_ARG,
    LINE_ESCAPED,
    LINE_QUOTED,
    LINE_QUOTEDESCAPED
  };
  State state;
  CharVector curArg;

  state = LINE_START;
  curArg.clear();
  mArgs.clear();

  for(unsigned int index = 0; index < line.size(); ++index )
  {
    int ch = line[index];

    if(untilNewLine && ch == '\n' )
    {
      break;
    }

    switch( state )
    {
ProcessCharNormally:  // I know, a goto.  But it was convenient. ;)
    case LINE_ARG:
      if( ch == '"' )
      {
        state = LINE_QUOTED;
      }
      else if( ch == '\\' )
      {
        state = LINE_ESCAPED;
      }
      else if( isspace( ch ) )
      {
        String foo( &curArg[0], curArg.size() );
        mArgs.push_back( foo );
        curArg.clear();
        state = LINE_SPACE;
      }
      else
      {
        curArg.push_back( ch );
      }
      break;
      
    case LINE_START:
      if( !isspace( ch ) )
      {
        state = LINE_ARG;
        goto ProcessCharNormally;
      }
      break;
      
    case LINE_SPACE:
      if( !isspace( ch ) )
      {
        state = LINE_ARG;
        goto ProcessCharNormally;
      }
      break;
      
    case LINE_QUOTED:
      if( ch == '"' )
      {
        state = LINE_ARG;
      }
// Don't process escape characters inside quoted strings!!!
//      else if( ch == '\\' )
//      {
//        state = LINE_QUOTEDESCAPED;
//      }
      else
      {
        curArg.push_back( ch );
      }
      break;
      
    case LINE_ESCAPED:
      ch = TranslateEscapedChar( ch );
      state = LINE_ARG;
      curArg.push_back( ch );
      break;
      
    case LINE_QUOTEDESCAPED:
      ch = TranslateEscapedChar( ch );
      state = LINE_QUOTED;
      curArg.push_back( ch );
      break;
    }
  }

  switch( state )
  {
  case LINE_ARG:
  case LINE_QUOTED:
  case LINE_ESCAPED:
  case LINE_QUOTEDESCAPED:
    {
    String foo( &curArg[0], curArg.size() );
    mArgs.push_back( foo );
    }
    break;
    
  case LINE_START:
  case LINE_SPACE:
    break;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, -0x64(%rbp)
movq %rsi, %r15
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movq $0x0, -0x50(%rbp)
movq (%rdi), %rsi
movq %rdi, -0x70(%rbp)
callq 0x779a
cmpq $0x0, 0x8(%r15)
je 0x705b
xorl %eax, %eax
movl $0x1, %r13d
xorl %ecx, %ecx
movq (%r15), %rdx
movb (%rdx,%rax), %bl
cmpb $0x0, -0x64(%rbp)
je 0x6ecc
cmpb $0xa, %bl
je 0x6ffe
movzbl %bl, %r14d
movsbl %r14b, %r12d
movl %ecx, %eax
leaq 0xbc3b(%rip), %rcx      # 0x12b18
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %r12d, %edi
callq 0x2060
xorl %ecx, %ecx
jmp 0x6f1f
movl $0x2, %ecx
cmpb $0x22, %bl
je 0x6fda
movb %bl, -0x48(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x79f4
jmp 0x6f3d
movl %r12d, %edi
callq 0x2060
movl $0x1, %ecx
testl %eax, %eax
jne 0x6fda
cmpl $0x22, %r14d
je 0x6f3d
cmpl $0x5c, %r14d
jne 0x6f61
movl $0x3, %ecx
jmp 0x6fda
movl $0x4, %ecx
jmp 0x6fda
cmpl $0x66, %r14d
je 0x6fc3
cmpl $0x6e, %r14d
je 0x6fbf
cmpl $0x74, %r14d
leaq -0x48(%rbp), %rsi
jne 0x6fc9
movb $0x9, %bl
jmp 0x6fc9
movl %r12d, %edi
callq 0x2060
testl %eax, %eax
je 0x6fec
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
leaq -0x38(%rbp), %rbx
movq %rbx, -0x48(%rbp)
leaq -0x48(%rbp), %r14
movq %r14, %rdi
callq 0x6d58
movq -0x70(%rbp), %rdi
movq %r14, %rsi
callq 0x7566
movq -0x60(%rbp), %rax
cmpq %rax, -0x58(%rbp)
je 0x6fa3
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x6fb8
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2230
movl $0x1, %ecx
jmp 0x6fda
movb $0xa, %bl
jmp 0x6fc5
movb $0xc, %bl
leaq -0x48(%rbp), %rsi
movb %bl, -0x48(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x79f4
movl $0x2, %ecx
movl %r13d, %eax
incl %r13d
cmpq %rax, 0x8(%r15)
ja 0x6eb7
jmp 0x6ffe
movb %bl, -0x48(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x79f4
jmp 0x6fd5
movq -0x60(%rbp), %rax
addl $-0x2, %ecx
cmpl $0x3, %ecx
ja 0x7047
movq -0x58(%rbp), %rdx
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rbx
movq %rbx, (%rdi)
movq %rax, %rsi
callq 0x6d58
leaq -0x48(%rbp), %rsi
movq -0x70(%rbp), %rdi
callq 0x7566
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x7043
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0x60(%rbp), %rax
testq %rax, %rax
je 0x705b
movq -0x50(%rbp), %rsi
subq %rax, %rsi
movq %rax, %rdi
callq 0x2230
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7070
jmp 0x7091
jmp 0x7091
movq %rbx, %rcx
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %rcx, %rdi
je 0x7094
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2230
jmp 0x7094
jmp 0x7091
jmp 0x7091
movq %rax, %rbx
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x70a9
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x2230
movq %rbx, %rdi
callq 0x23c0
nop