// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3_complete
SQLITE_API int sqlite3_complete(const char *zSql){
  u8 state = 0;   /* Current state, using numbers defined in header comment */
  u8 token;       /* Value of the next token */

#ifndef SQLITE_OMIT_TRIGGER
  /* A complex statement machine used to detect the end of a CREATE TRIGGER
  ** statement.  This is the normal case.
  */
  static const u8 trans[8][8] = {
                     /* Token:                                                */
     /* State:       **  SEMI  WS  OTHER  EXPLAIN  CREATE  TEMP  TRIGGER  END */
     /* 0 INVALID: */ {    1,  0,     2,       3,      4,    2,       2,   2, },
     /* 1   START: */ {    1,  1,     2,       3,      4,    2,       2,   2, },
     /* 2  NORMAL: */ {    1,  2,     2,       2,      2,    2,       2,   2, },
     /* 3 EXPLAIN: */ {    1,  3,     3,       2,      4,    2,       2,   2, },
     /* 4  CREATE: */ {    1,  4,     2,       2,      2,    4,       5,   2, },
     /* 5 TRIGGER: */ {    6,  5,     5,       5,      5,    5,       5,   5, },
     /* 6    SEMI: */ {    6,  6,     5,       5,      5,    5,       5,   7, },
     /* 7     END: */ {    1,  7,     5,       5,      5,    5,       5,   5, },
  };
#else
  /* If triggers are not supported by this compile then the statement machine
  ** used to detect the end of a statement is much simplier
  */
  static const u8 trans[3][3] = {
                     /* Token:           */
     /* State:       **  SEMI  WS  OTHER */
     /* 0 INVALID: */ {    1,  0,     2, },
     /* 1   START: */ {    1,  1,     2, },
     /* 2  NORMAL: */ {    1,  2,     2, },
  };
#endif /* SQLITE_OMIT_TRIGGER */

  while( *zSql ){
    switch( *zSql ){
      case ';': {  /* A semicolon */
        token = tkSEMI;
        break;
      }
      case ' ':
      case '\r':
      case '\t':
      case '\n':
      case '\f': {  /* White space is ignored */
        token = tkWS;
        break;
      }
      case '/': {   /* C-style comments */
        if( zSql[1]!='*' ){
          token = tkOTHER;
          break;
        }
        zSql += 2;
        while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }
        if( zSql[0]==0 ) return 0;
        zSql++;
        token = tkWS;
        break;
      }
      case '-': {   /* SQL-style comments from "--" to end of line */
        if( zSql[1]!='-' ){
          token = tkOTHER;
          break;
        }
        while( *zSql && *zSql!='\n' ){ zSql++; }
        if( *zSql==0 ) return state==1;
        token = tkWS;
        break;
      }
      case '[': {   /* Microsoft-style identifiers in [...] */
        zSql++;
        while( *zSql && *zSql!=']' ){ zSql++; }
        if( *zSql==0 ) return 0;
        token = tkOTHER;
        break;
      }
      case '`':     /* Grave-accent quoted symbols used by MySQL */
      case '"':     /* single- and double-quoted strings */
      case '\'': {
        int c = *zSql;
        zSql++;
        while( *zSql && *zSql!=c ){ zSql++; }
        if( *zSql==0 ) return 0;
        token = tkOTHER;
        break;
      }
      default: {
#ifdef SQLITE_EBCDIC
        unsigned char c;
#endif
        if( IdChar((u8)*zSql) ){
          /* Keywords and unquoted identifiers */
          int nId;
          for(nId=1; IdChar(zSql[nId]); nId++){}
#ifdef SQLITE_OMIT_TRIGGER
          token = tkOTHER;
#else
          switch( *zSql ){
            case 'c': case 'C': {
              if( nId==6 && sqlite3StrNICmp(zSql, "create", 6)==0 ){
                token = tkCREATE;
              }else{
                token = tkOTHER;
              }
              break;
            }
            case 't': case 'T': {
              if( nId==7 && sqlite3StrNICmp(zSql, "trigger", 7)==0 ){
                token = tkTRIGGER;
              }else if( nId==4 && sqlite3StrNICmp(zSql, "temp", 4)==0 ){
                token = tkTEMP;
              }else if( nId==9 && sqlite3StrNICmp(zSql, "temporary", 9)==0 ){
                token = tkTEMP;
              }else{
                token = tkOTHER;
              }
              break;
            }
            case 'e':  case 'E': {
              if( nId==3 && sqlite3StrNICmp(zSql, "end", 3)==0 ){
                token = tkEND;
              }else
#ifndef SQLITE_OMIT_EXPLAIN
              if( nId==7 && sqlite3StrNICmp(zSql, "explain", 7)==0 ){
                token = tkEXPLAIN;
              }else
#endif
              {
                token = tkOTHER;
              }
              break;
            }
            default: {
              token = tkOTHER;
              break;
            }
          }
#endif /* SQLITE_OMIT_TRIGGER */
          zSql += nId-1;
        }else{
          /* Operators and special symbols */
          token = tkOTHER;
        }
        break;
      }
    }
    state = trans[state][token];
    zSql++;
  }
  return state==1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %r12d, %r12d
pushq $0x1
popq %rsi
leaq 0x55b76(%rip), %rdi     # 0x681b0
pushq $0x2
popq %r8
leaq 0x5592b(%rip), %r15     # 0x67f70
movabsq $-0x100000000, %r9      # imm = 0xFFFFFFFF00000000
movabsq $0x100000000, %r13      # imm = 0x100000000
movabsq $0x100000001, %r10      # imm = 0x100000001
leaq 0x58eb9(%rip), %r11     # 0x6b523
movzbl (%rbx), %eax
leal -0x9(%rax), %ecx
cmpl $0x2, %ecx
jb 0x12812
leal -0xc(%rax), %ecx
cmpl $0x2, %ecx
jb 0x12812
cmpl $0x20, %eax
je 0x12812
cmpl $0x22, %eax
je 0x12798
cmpl $0x27, %eax
je 0x12798
cmpl $0x2d, %eax
je 0x127cc
cmpl $0x2f, %eax
je 0x127ec
cmpl $0x3b, %eax
je 0x12822
cmpl $0x5b, %eax
je 0x127b6
cmpl $0x60, %eax
je 0x12798
testl %eax, %eax
je 0x12976
testb $0x46, (%rax,%r15)
je 0x1281a
xorl %edx, %edx
movq %r9, %r14
addq %r13, %r14
movzbl 0x1(%rbx,%rdx), %ecx
incq %rdx
testb $0x46, (%rcx,%r15)
jne 0x126e5
addl $-0x43, %eax
movq %r8, %rcx
cmpl $0x31, %eax
ja 0x12957
btq %rax, %r10
jb 0x1287d
movabsq $0x400000004, %rcx      # imm = 0x400000004
btq %rax, %rcx
jb 0x12829
movabsq $0x2000000020000, %rcx  # imm = 0x2000000020000
btq %rax, %rcx
movq %r8, %rcx
jae 0x12957
cmpl $0x4, %edx
je 0x12912
cmpl $0x9, %edx
je 0x12904
cmpl $0x7, %edx
jne 0x12954
movq %rbx, %rdi
leaq 0x5c88d(%rip), %rsi     # 0x6efed
pushq $0x7
popq %rdx
callq 0x8f45
leaq 0x58db4(%rip), %r11     # 0x6b523
movabsq $0x100000001, %r10      # imm = 0x100000001
movabsq $-0x100000000, %r9      # imm = 0xFFFFFFFF00000000
pushq $0x2
popq %r8
leaq 0x55a22(%rip), %rdi     # 0x681b0
pushq $0x1
popq %rsi
pushq $0x6
jmp 0x1294f
movb 0x1(%rbx), %dl
incq %rbx
testb %dl, %dl
je 0x127a6
cmpb %al, %dl
jne 0x12798
movq %r8, %rcx
testb %dl, %dl
jne 0x1295e
jmp 0x12972
movzbl 0x1(%rbx), %eax
testl %eax, %eax
je 0x12972
incq %rbx
cmpl $0x5d, %eax
jne 0x127b6
jmp 0x1281a
cmpb $0x2d, 0x1(%rbx)
jne 0x1281a
movb $0x2d, %al
testb %al, %al
je 0x12976
movzbl %al, %eax
cmpl $0xa, %eax
je 0x12812
movb 0x1(%rbx), %al
incq %rbx
jmp 0x127d4
cmpb $0x2a, 0x1(%rbx)
jne 0x1281a
addq $0x3, %rbx
movzbl -0x1(%rbx), %eax
cmpl $0x2a, %eax
je 0x12808
testl %eax, %eax
jne 0x1280d
jmp 0x12972
cmpb $0x2f, (%rbx)
je 0x12812
incq %rbx
jmp 0x127f6
movq %rsi, %rcx
jmp 0x1295e
movq %r8, %rcx
jmp 0x1295e
xorl %ecx, %ecx
jmp 0x1295e
cmpl $0x7, %edx
je 0x128c5
cmpl $0x3, %edx
jne 0x12954
movq %rbx, %rdi
leaq 0x58cf4(%rip), %rsi     # 0x6b539
pushq $0x3
popq %rdx
callq 0x8f45
leaq 0x58ccf(%rip), %r11     # 0x6b523
movabsq $0x100000001, %r10      # imm = 0x100000001
movabsq $-0x100000000, %r9      # imm = 0xFFFFFFFF00000000
pushq $0x2
popq %r8
leaq 0x5593d(%rip), %rdi     # 0x681b0
pushq $0x1
popq %rsi
pushq $0x7
jmp 0x1294f
cmpq $0x6, %rdx
jne 0x12954
movq %rbx, %rdi
movq %r11, %rsi
pushq $0x6
popq %rdx
callq 0x8f45
leaq 0x58c87(%rip), %r11     # 0x6b523
movabsq $0x100000001, %r10      # imm = 0x100000001
movabsq $-0x100000000, %r9      # imm = 0xFFFFFFFF00000000
pushq $0x2
popq %r8
leaq 0x558f5(%rip), %rdi     # 0x681b0
pushq $0x1
popq %rsi
pushq $0x4
jmp 0x1294f
movq %rbx, %rdi
leaq 0x58c6e(%rip), %rsi     # 0x6b53d
pushq $0x7
popq %rdx
callq 0x8f45
leaq 0x58c45(%rip), %r11     # 0x6b523
movabsq $0x100000001, %r10      # imm = 0x100000001
movabsq $-0x100000000, %r9      # imm = 0xFFFFFFFF00000000
pushq $0x2
popq %r8
leaq 0x558b3(%rip), %rdi     # 0x681b0
pushq $0x1
popq %rsi
pushq $0x3
jmp 0x1294f
movq %rbx, %rdi
leaq 0x58c21(%rip), %rsi     # 0x6b52f
pushq $0x9
jmp 0x1291e
movq %rbx, %rdi
leaq 0x58c0e(%rip), %rsi     # 0x6b52a
pushq $0x4
popq %rdx
callq 0x8f45
leaq 0x58bf8(%rip), %r11     # 0x6b523
movabsq $0x100000001, %r10      # imm = 0x100000001
movabsq $-0x100000000, %r9      # imm = 0xFFFFFFFF00000000
pushq $0x2
popq %r8
leaq 0x55866(%rip), %rdi     # 0x681b0
pushq $0x1
popq %rsi
pushq $0x5
popq %rcx
testl %eax, %eax
je 0x12957
movq %r8, %rcx
sarq $0x20, %r14
addq %r14, %rbx
movzbl %r12b, %eax
leaq (%rdi,%rax,8), %rax
movb (%rcx,%rax), %r12b
incq %rbx
jmp 0x1266a
xorl %eax, %eax
jmp 0x1297d
cmpb $0x1, %r12b
sete %al
movzbl %al, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq