// File: attractivechaos[P]udb2/stb/./stb.h
// Function: stb__get_dfa_node
stb_int16 stb__get_dfa_node(stb_matcher *m, stb_uint16 *list)
{
   stb_uint16 node;
   stb_uint32 data[8], *state, *newstate;
   int i,j,n;

   state = (stb_uint32 *) stb_temp(data, m->num_words_per_dfa * 4);
   memset(state, 0, m->num_words_per_dfa*4);

   n = stb_arr_len(list);
   for (i=0; i < n; ++i) {
      int x = list[i];
      state[x >> 5] |= 1 << (x & 31);
   }

   // @TODO use a hash table
   n = stb_arr_len(m->dfa_mapping);
   i=j=0;
   for(; j < n; ++i, j += m->num_words_per_dfa) {
      // @TODO special case for <= 32
      if (!memcmp(state, m->dfa_mapping + j, m->num_words_per_dfa*4)) {
         node = i;
         goto done;
      }
   }

   assert(stb_arr_len(m->dfa) == i);
   node = i;

   newstate = stb_arr_addn(m->dfa_mapping, m->num_words_per_dfa);
   memcpy(newstate, state, m->num_words_per_dfa*4);

   // set all transitions to 'unknown'
   stb_arr_add(m->dfa);
   memset(m->dfa[i].transition, -1, sizeof(m->dfa[i].transition));

   if (m->does_lex) {
      int result = -1;
      n = stb_arr_len(list);
      for (i=0; i < n; ++i) {
         if (m->nodes[(int) list[i]].goal > result)
            result = m->nodes[(int) list[i]].goal;
      }

      stb_arr_push(m->dfa_result, result);
   }

done:
   stb_tempfree(data, state);
   return node;
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movq %rsi, 0xa8(%rsp)
leaq 0x80(%rsp), %rdi
movq 0xb0(%rsp), %rax
movl 0x40(%rax), %edx
shll $0x2, %edx
movl $0x20, %esi
callq 0x3c90
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
movq 0xb0(%rsp), %rax
movl 0x40(%rax), %eax
shll $0x2, %eax
movslq %eax, %rdx
xorl %esi, %esi
callq 0x2160
cmpq $0x0, 0xa8(%rsp)
je 0x17fe5
movq 0xa8(%rsp), %rax
movl -0x10(%rax), %eax
movl %eax, 0x58(%rsp)
jmp 0x17fed
xorl %eax, %eax
movl %eax, 0x58(%rsp)
jmp 0x17fed
movl 0x58(%rsp), %eax
movl %eax, 0x64(%rsp)
movl $0x0, 0x6c(%rsp)
movl 0x6c(%rsp), %eax
cmpl 0x64(%rsp), %eax
jge 0x1804c
movq 0xa8(%rsp), %rax
movslq 0x6c(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, 0x60(%rsp)
movl 0x60(%rsp), %ecx
andl $0x1f, %ecx
movl $0x1, %edx
shll %cl, %edx
movq 0x78(%rsp), %rax
movl 0x60(%rsp), %ecx
sarl $0x5, %ecx
movslq %ecx, %rcx
orl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x17ffd
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x30(%rax)
je 0x18070
movq 0xb0(%rsp), %rax
movq 0x30(%rax), %rax
movl -0x10(%rax), %eax
movl %eax, 0x54(%rsp)
jmp 0x18078
xorl %eax, %eax
movl %eax, 0x54(%rsp)
jmp 0x18078
movl 0x54(%rsp), %eax
movl %eax, 0x64(%rsp)
movl $0x0, 0x68(%rsp)
movl $0x0, 0x6c(%rsp)
movl 0x68(%rsp), %eax
cmpl 0x64(%rsp), %eax
jge 0x18105
movq 0x78(%rsp), %rdi
movq 0xb0(%rsp), %rax
movq 0x30(%rax), %rsi
movslq 0x68(%rsp), %rax
shlq $0x2, %rax
addq %rax, %rsi
movq 0xb0(%rsp), %rax
movl 0x40(%rax), %eax
shll $0x2, %eax
movslq %eax, %rdx
callq 0x21c0
cmpl $0x0, %eax
jne 0x180e3
movl 0x6c(%rsp), %eax
movw %ax, 0xa6(%rsp)
jmp 0x18574
jmp 0x180e5
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
movq 0xb0(%rsp), %rax
movl 0x40(%rax), %eax
addl 0x68(%rsp), %eax
movl %eax, 0x68(%rsp)
jmp 0x18090
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x28(%rax)
je 0x18129
movq 0xb0(%rsp), %rax
movq 0x28(%rax), %rax
movl -0x10(%rax), %eax
movl %eax, 0x50(%rsp)
jmp 0x18131
xorl %eax, %eax
movl %eax, 0x50(%rsp)
jmp 0x18131
movl 0x50(%rsp), %eax
cmpl 0x6c(%rsp), %eax
jne 0x1813d
jmp 0x1815c
leaq 0x7aec(%rip), %rdi      # 0x1fc30
leaq 0x723e(%rip), %rsi      # 0x1f389
movl $0x25a4, %edx           # imm = 0x25A4
leaq 0x7af2(%rip), %rcx      # 0x1fc49
callq 0x2140
movl 0x6c(%rsp), %eax
movw %ax, 0xa6(%rsp)
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x30(%rax)
je 0x1818c
movq 0xb0(%rsp), %rax
movq 0x30(%rax), %rax
movl -0x10(%rax), %eax
movl %eax, 0x4c(%rsp)
jmp 0x18194
xorl %eax, %eax
movl %eax, 0x4c(%rsp)
jmp 0x18194
movl 0x4c(%rsp), %eax
movq 0xb0(%rsp), %rcx
addl 0x40(%rcx), %eax
movl %eax, 0x48(%rsp)
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x30(%rax)
je 0x181cb
movq 0xb0(%rsp), %rax
movq 0x30(%rax), %rax
movl -0xc(%rax), %eax
movl %eax, 0x44(%rsp)
jmp 0x181d3
xorl %eax, %eax
movl %eax, 0x44(%rsp)
jmp 0x181d3
movl 0x48(%rsp), %eax
movl 0x44(%rsp), %ecx
cmpl %ecx, %eax
jle 0x18202
movq 0xb0(%rsp), %rdi
addq $0x30, %rdi
movq 0xb0(%rsp), %rax
movl 0x40(%rax), %edx
movl $0x4, %esi
callq 0x8030
jmp 0x1821f
movq 0xb0(%rsp), %rax
movl 0x40(%rax), %ecx
movq 0xb0(%rsp), %rax
movq 0x30(%rax), %rax
addl -0x10(%rax), %ecx
movl %ecx, -0x10(%rax)
movq 0xb0(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x30(%rax)
je 0x18254
movq 0xb0(%rsp), %rax
movq 0x30(%rax), %rax
movl -0x10(%rax), %eax
movl %eax, 0x34(%rsp)
jmp 0x1825c
xorl %eax, %eax
movl %eax, 0x34(%rsp)
jmp 0x1825c
movq 0x38(%rsp), %rax
movl 0x34(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq 0xb0(%rsp), %rcx
movslq 0x40(%rcx), %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rsi
movq 0xb0(%rsp), %rax
movl 0x40(%rax), %eax
shll $0x2, %eax
movslq %eax, %rdx
callq 0x2230
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x28(%rax)
je 0x182d0
movq 0xb0(%rsp), %rax
movq 0x28(%rax), %rax
movl -0x10(%rax), %eax
movl %eax, 0x30(%rsp)
jmp 0x182d8
xorl %eax, %eax
movl %eax, 0x30(%rsp)
jmp 0x182d8
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x28(%rax)
je 0x18307
movq 0xb0(%rsp), %rax
movq 0x28(%rax), %rax
movl -0xc(%rax), %eax
movl %eax, 0x28(%rsp)
jmp 0x1830f
xorl %eax, %eax
movl %eax, 0x28(%rsp)
jmp 0x1830f
movl 0x2c(%rsp), %eax
movl 0x28(%rsp), %ecx
cmpl %ecx, %eax
jle 0x18338
movq 0xb0(%rsp), %rdi
addq $0x28, %rdi
movl $0x200, %esi            # imm = 0x200
movl $0x1, %edx
callq 0x8030
jmp 0x1834d
movq 0xb0(%rsp), %rax
movq 0x28(%rax), %rax
movl -0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, -0x10(%rax)
movq 0xb0(%rsp), %rax
movq 0x28(%rax), %rax
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x28(%rax)
je 0x1837d
movq 0xb0(%rsp), %rax
movq 0x28(%rax), %rax
movl -0x10(%rax), %eax
movl %eax, 0x24(%rsp)
jmp 0x18385
xorl %eax, %eax
movl %eax, 0x24(%rsp)
jmp 0x18385
movl 0x24(%rsp), %eax
movq 0xb0(%rsp), %rax
movq 0x28(%rax), %rdi
movslq 0x6c(%rsp), %rax
shlq $0x9, %rax
addq %rax, %rdi
movl $0xff, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x2160
movq 0xb0(%rsp), %rax
cmpl $0x0, 0x20(%rax)
je 0x18572
movl $0xffffffff, 0x5c(%rsp) # imm = 0xFFFFFFFF
cmpq $0x0, 0xa8(%rsp)
je 0x183e6
movq 0xa8(%rsp), %rax
movl -0x10(%rax), %eax
movl %eax, 0x20(%rsp)
jmp 0x183ee
xorl %eax, %eax
movl %eax, 0x20(%rsp)
jmp 0x183ee
movl 0x20(%rsp), %eax
movl %eax, 0x64(%rsp)
movl $0x0, 0x6c(%rsp)
movl 0x6c(%rsp), %eax
cmpl 0x64(%rsp), %eax
jge 0x18475
movq 0xb0(%rsp), %rax
movq 0x18(%rax), %rax
movq 0xa8(%rsp), %rcx
movslq 0x6c(%rsp), %rdx
movzwl (%rcx,%rdx,2), %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movswl (%rax), %eax
cmpl 0x5c(%rsp), %eax
jle 0x18466
movq 0xb0(%rsp), %rax
movq 0x18(%rax), %rax
movq 0xa8(%rsp), %rcx
movslq 0x6c(%rsp), %rdx
movzwl (%rcx,%rdx,2), %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movswl (%rax), %eax
movl %eax, 0x5c(%rsp)
jmp 0x18468
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x183fe
movl 0x5c(%rsp), %eax
movw %ax, 0x1e(%rsp)
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x38(%rax)
je 0x184a2
movq 0xb0(%rsp), %rax
movq 0x38(%rax), %rax
movl -0x10(%rax), %eax
movl %eax, 0x18(%rsp)
jmp 0x184aa
xorl %eax, %eax
movl %eax, 0x18(%rsp)
jmp 0x184aa
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x38(%rax)
je 0x184d9
movq 0xb0(%rsp), %rax
movq 0x38(%rax), %rax
movl -0xc(%rax), %eax
movl %eax, 0x10(%rsp)
jmp 0x184e1
xorl %eax, %eax
movl %eax, 0x10(%rsp)
jmp 0x184e1
movl 0x14(%rsp), %eax
movl 0x10(%rsp), %ecx
cmpl %ecx, %eax
jle 0x1850a
movq 0xb0(%rsp), %rdi
addq $0x38, %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x8030
jmp 0x1851f
movq 0xb0(%rsp), %rax
movq 0x38(%rax), %rax
movl -0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, -0x10(%rax)
movq 0xb0(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x38(%rax)
je 0x18554
movq 0xb0(%rsp), %rax
movq 0x38(%rax), %rax
movl -0x10(%rax), %eax
movl %eax, 0x4(%rsp)
jmp 0x1855c
xorl %eax, %eax
movl %eax, 0x4(%rsp)
jmp 0x1855c
movq 0x8(%rsp), %rax
movw 0x1e(%rsp), %dx
movl 0x4(%rsp), %ecx
movslq %ecx, %rcx
movw %dx, -0x2(%rax,%rcx,2)
jmp 0x18574
leaq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x3cd0
movw 0xa6(%rsp), %ax
addq $0xb8, %rsp
retq
nopw %cs:(%rax,%rax)