// File: jsteemann[P]jshund/src/./Validator.h
// Function: jshund::Validator::validate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<jshund::Token, std::allocator<jshund::Token>> const&)
int validate (std::string const& filename, std::vector<Token> const& tokens) {
        int errors = 0;
        int brackets = 0;

        _filename = filename;

        State startState(STATE_NOTHING, 1, brackets);

        std::vector<State> states;
        states.push_back(startState);

        for (size_t i = 0, n = tokens.size(); i < n; ++i) {
          State& currentState = states[states.size() - 1];
          Token const& currentToken = tokens[i];
            
          if (currentState.type == STATE_VARDECL && 
              ! currentState.expectDeclaration && 
              currentToken.type == TOKEN_COMMA &&
              currentState.brackets == brackets) {
            // std::cout << "FOUND COMMA\n";
            currentState.expectDeclaration = true;
          }

          else if (currentToken.type == TOKEN_NAME) {
            if (i > 0 && tokens[i - 1].type == TOKEN_DOT) {
              // compound name, e.g. foo.bar
              //                         ^^^
              continue;
            }

            const std::string name = currentToken.value;

            if (currentState.type == STATE_FUNCARG) {
              // std::cout << "FOUND FUNCTION ARGUMENT '" << name << "'" << std::endl;

              currentState.declaredVariables.insert(std::pair<std::string, Variable>(name, Variable(currentToken.line, true)));
            }
            else if (currentState.type == STATE_VARDECL && currentState.expectDeclaration) {
              // std::cout << "FOUND DECLARATION OF VAR '" << name << "'" << std::endl;

              if (states.size() <= 1) {
                std::cerr << _filename << ':' << currentToken.line << ": encountered an invalid state during parsing" << std::endl;
                return 1;
              }

              bool wasPhantom = states[states.size() - 2].phantoms.erase(name);
              // if (wasPhantom) {
              //   std::cout << "IGNORING PHANTOM '" << name << "'\n";
              // }
              states[states.size() - 2].declaredVariables.insert(std::pair<std::string, Variable>(name, Variable(currentToken.line, wasPhantom)));

              Token next = tokens[i + 1];
              if (next.type == TOKEN_ASSIGN || next.type == TOKEN_IN) {
                currentState.expectDeclaration = false;
              }
              else if (next.type == TOKEN_COMMA) {
                // skip one token
                ++i;
                currentState.expectDeclaration = true;
              }
            }
            else {
              size_t j = states.size() - 1;

              // std::cout << "FOUND USAGE OF VAR '" << name << "'" << std::endl;
              while (1) {
                State& s = states[j];

                std::map<std::string, Variable>::iterator it = s.declaredVariables.find(name);

                if (it != s.declaredVariables.end()) {
                  (*it).second.used = true;
                  break;
                }

                if (j-- == 0) {
                  currentState.phantoms.insert(std::pair<std::string, Variable>(name, Variable(currentToken.line, false)));
                  break;
                }
              }
            }
          }

          else if (currentToken.type == TOKEN_FUNCTION) {
            Token next = tokens[i + 1];
            if (next.type == TOKEN_NAME) {
              // skip one token
              ++i;
            }
            
            State funcState(STATE_FUNCARG, currentToken.line, brackets);
            states.push_back(funcState);
          }
          
          else if (currentToken.type == TOKEN_VAR) {
            State varState(STATE_VARDECL, currentToken.line, brackets);
            varState.expectDeclaration = true;
            states.push_back(varState);
          }

          else if (currentToken.type == TOKEN_SEMICOLON) {
            if (currentState.type == STATE_VARDECL) {
              states.pop_back();
            }
          }
          
          else if (currentToken.type == TOKEN_PARENS_OPEN || 
                   currentToken.type == TOKEN_CURLY_OPEN || 
                   currentToken.type == TOKEN_ANGULAR_OPEN) {
            brackets++;
          }

          else if (currentToken.type == TOKEN_PARENS_CLOSE || 
                   currentToken.type == TOKEN_CURLY_CLOSE || 
                   currentToken.type == TOKEN_ANGULAR_CLOSE) {
            --brackets;
            
            if (currentState.type == STATE_FUNCARG && currentState.brackets == brackets) {
              // end of function argument list
              State funcState(STATE_FUNCBODY, currentToken.line, brackets);

              std::map<std::string, Variable>::const_iterator it = currentState.declaredVariables.begin();
              while (it != currentState.declaredVariables.end()) {
                // std::cout << "PUSHING FUNCTION ARG '" << (*it).first << "'" << std::endl;
                funcState.declaredVariables.insert(std::pair<std::string, Variable>((*it).first, (*it).second));
                ++it;
              }

              states.pop_back();
              states.push_back(funcState);
            }
            else if (currentState.type == STATE_FUNCBODY && currentState.brackets == brackets) {
              // end of function body
              std::map<std::string, Variable>::const_iterator it = currentState.declaredVariables.begin();

              while (it != currentState.declaredVariables.end()) {
                if (! (*it).second.used) {
                  reportError((*it).second.line, (*it).first, false);
                  ++errors;
                }
                ++it;
              }

              // insert phantoms
              if (states.size() > 1) {
                State& prevState = states[states.size() - 2];

                it = currentState.phantoms.begin();

                while (it != currentState.phantoms.end()) {
                  // std::cout << "PUSHING PHANTOM '" << (*it).first << "'" << std::endl;
                  prevState.phantoms.insert(std::pair<std::string, Variable>((*it).first, (*it).second));
                  ++it;
                }
              }
              states.pop_back();
            }
          }

          else if (currentToken.type == TOKEN_EOF && _globals) {
            // end of file
            std::map<std::string, Variable>::const_iterator it = currentState.declaredVariables.begin();

            while (it != currentState.declaredVariables.end()) {
              if (! (*it).second.used) {
                reportError((*it).second.line, (*it).first, true);
                ++errors;
              }
              ++it;
            }
            states.pop_back();
          }
        }

        return errors;
      }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5c0, %rsp            # imm = 0x5C0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x4c8(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rsi
addq $0x60, %rdi
callq 0x3050
movl -0x28(%rbp), %ecx
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x4b8(%rbp)
xorl %esi, %esi
movl $0x1, %edx
callq 0xb320
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x4c0(%rbp)
callq 0xb380
movq -0x4c0(%rbp), %rdi
movq -0x4b8(%rbp), %rsi
callq 0xb3a0
jmp 0x8a42
movq $0x0, -0xd0(%rbp)
movq -0x20(%rbp), %rdi
callq 0xb410
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rax
cmpq -0xd8(%rbp), %rax
jae 0x980f
leaq -0xb8(%rbp), %rdi
callq 0xb460
movq %rax, %rsi
subq $0x1, %rsi
leaq -0xb8(%rbp), %rdi
callq 0xb440
movq %rax, -0xe0(%rbp)
movq -0x20(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0xb490
movq %rax, -0xe8(%rbp)
movq -0xe0(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x8b09
movq -0xe0(%rbp), %rax
testb $0x1, 0x70(%rax)
jne 0x8b09
movq -0xe8(%rbp), %rax
cmpl $0x33, (%rax)
jne 0x8b09
movq -0xe0(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x28(%rbp), %eax
jne 0x8b09
movq -0xe0(%rbp), %rax
movb $0x1, 0x70(%rax)
jmp 0x97f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x9843
movq -0xe8(%rbp), %rax
cmpl $0x4b, (%rax)
jne 0x9079
cmpq $0x0, -0xd0(%rbp)
jbe 0x8b41
movq -0x20(%rbp), %rdi
movq -0xd0(%rbp), %rsi
subq $0x1, %rsi
callq 0xb490
cmpl $0x32, (%rax)
jne 0x8b41
jmp 0x97f8
movq -0xe8(%rbp), %rsi
addq $0x8, %rsi
leaq -0x108(%rbp), %rdi
callq 0x3110
jmp 0x8b5a
movq -0xe0(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x8c3c
movq -0xe0(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x4d0(%rbp)
movq -0xe8(%rbp), %rax
movl 0x28(%rax), %esi
leaq -0x138(%rbp), %rdi
movl $0x1, %edx
callq 0xb4f0
jmp 0x8b99
leaq -0x130(%rbp), %rdi
leaq -0x108(%rbp), %rsi
leaq -0x138(%rbp), %rdx
callq 0xb520
jmp 0x8bb5
movq -0x4d0(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0xb4b0
movb %dl, -0x4d9(%rbp)
movq %rax, -0x4d8(%rbp)
jmp 0x8bd7
movb -0x4d9(%rbp), %al
movq -0x4d8(%rbp), %rcx
movq %rcx, -0x148(%rbp)
movb %al, -0x140(%rbp)
leaq -0x130(%rbp), %rdi
callq 0xb560
jmp 0x903d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x9068
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x130(%rbp), %rdi
callq 0xb560
jmp 0x9068
movq -0xe0(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x8ebd
movq -0xe0(%rbp), %rax
testb $0x1, 0x70(%rax)
je 0x8ebd
leaq -0xb8(%rbp), %rdi
callq 0xb460
cmpq $0x1, %rax
ja 0x8d14
movq -0x4c8(%rbp), %rsi
addq $0x60, %rsi
movq 0xf36b(%rip), %rdi      # 0x17ff0
callq 0x3220
movq %rax, -0x4e8(%rbp)
jmp 0x8c93
movq -0x4e8(%rbp), %rdi
movl $0x3a, %esi
callq 0x3320
movq %rax, -0x4f0(%rbp)
jmp 0x8cad
movq -0x4f0(%rbp), %rdi
movq -0xe8(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x3090
movq %rax, -0x4f8(%rbp)
jmp 0x8ccd
movq -0x4f8(%rbp), %rdi
leaq 0x8614(%rip), %rsi      # 0x112ef
callq 0x3240
movq %rax, -0x500(%rbp)
jmp 0x8ce9
movq -0x500(%rbp), %rdi
movq 0xf2c9(%rip), %rsi      # 0x17fc0
callq 0x32a0
jmp 0x8cfe
movl $0x1, -0x4(%rbp)
movl $0x1, -0x14c(%rbp)
jmp 0x9047
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x510(%rbp)
callq 0xb460
movq -0x510(%rbp), %rdi
movq %rax, %rsi
addq $-0x2, %rsi
callq 0xb440
movq %rax, %rdi
addq $0x40, %rdi
leaq -0x108(%rbp), %rsi
callq 0xb580
movq %rax, -0x508(%rbp)
jmp 0x8d56
movq -0x508(%rbp), %rax
testq %rax, %rax
setne -0x14d(%rbp)
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x520(%rbp)
callq 0xb460
movq -0x520(%rbp), %rdi
movq %rax, %rsi
addq $-0x2, %rsi
callq 0xb440
addq $0x10, %rax
movq %rax, -0x518(%rbp)
movq -0xe8(%rbp), %rax
movl 0x28(%rax), %esi
movzbl -0x14d(%rbp), %edx
andl $0x1, %edx
leaq -0x180(%rbp), %rdi
callq 0xb4f0
jmp 0x8dba
leaq -0x178(%rbp), %rdi
leaq -0x108(%rbp), %rsi
leaq -0x180(%rbp), %rdx
callq 0xb520
jmp 0x8dd6
movq -0x518(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0xb4b0
movb %dl, -0x529(%rbp)
movq %rax, -0x528(%rbp)
jmp 0x8df8
movb -0x529(%rbp), %al
movq -0x528(%rbp), %rcx
movq %rcx, -0x190(%rbp)
movb %al, -0x188(%rbp)
leaq -0x178(%rbp), %rdi
callq 0xb560
movq -0x20(%rbp), %rdi
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0xb490
movq %rax, %rsi
leaq -0x1c0(%rbp), %rdi
callq 0xb5b0
jmp 0x8e42
cmpl $0x64, -0x1c0(%rbp)
je 0x8e54
cmpl $0x1b, -0x1c0(%rbp)
jne 0x8e84
movq -0xe0(%rbp), %rax
movb $0x0, 0x70(%rax)
jmp 0x8eac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x178(%rbp), %rdi
callq 0xb560
jmp 0x9068
cmpl $0x33, -0x1c0(%rbp)
jne 0x8eaa
movq -0xd0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd0(%rbp)
movq -0xe0(%rbp), %rax
movb $0x1, 0x70(%rax)
jmp 0x8eac
leaq -0x1c0(%rbp), %rdi
callq 0xb120
jmp 0x903b
leaq -0xb8(%rbp), %rdi
callq 0xb460
subq $0x1, %rax
movq %rax, -0x1c8(%rbp)
jmp 0x8ed6
movq -0x1c8(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0xb440
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rdi
addq $0x10, %rdi
leaq -0x108(%rbp), %rsi
callq 0xb600
movq %rax, -0x538(%rbp)
jmp 0x8f10
movq -0x538(%rbp), %rax
movq %rax, -0x1d8(%rbp)
movq -0x1d0(%rbp), %rdi
addq $0x10, %rdi
callq 0xb660
movq %rax, -0x1e0(%rbp)
leaq -0x1d8(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0xb630
testb $0x1, %al
jne 0x8f4e
jmp 0x8f63
leaq -0x1d8(%rbp), %rdi
callq 0xb690
movb $0x1, 0x24(%rax)
jmp 0x9039
movq -0x1c8(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x1c8(%rbp)
cmpq $0x0, %rax
jne 0x9034
movq -0xe0(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x540(%rbp)
movq -0xe8(%rbp), %rax
movl 0x28(%rax), %esi
leaq -0x210(%rbp), %rdi
xorl %edx, %edx
callq 0xb4f0
jmp 0x8fae
leaq -0x208(%rbp), %rdi
leaq -0x108(%rbp), %rsi
leaq -0x210(%rbp), %rdx
callq 0xb520
jmp 0x8fca
movq -0x540(%rbp), %rdi
leaq -0x208(%rbp), %rsi
callq 0xb4b0
movb %dl, -0x549(%rbp)
movq %rax, -0x548(%rbp)
jmp 0x8fec
movb -0x549(%rbp), %al
movq -0x548(%rbp), %rcx
movq %rcx, -0x220(%rbp)
movb %al, -0x218(%rbp)
leaq -0x208(%rbp), %rdi
callq 0xb560
jmp 0x9039
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x208(%rbp), %rdi
callq 0xb560
jmp 0x9068
jmp 0x8ed4
jmp 0x903b
jmp 0x903d
movl $0x0, -0x14c(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x3170
movl -0x14c(%rbp), %eax
testl %eax, %eax
jne 0x981f
jmp 0x9063
jmp 0x97f4
leaq -0x108(%rbp), %rdi
callq 0x3170
jmp 0x9843
movq -0xe8(%rbp), %rax
cmpl $0x19, (%rax)
jne 0x915d
movq -0x20(%rbp), %rdi
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0xb490
movq %rax, %rsi
leaq -0x250(%rbp), %rdi
callq 0xb5b0
jmp 0x90ad
cmpl $0x4b, -0x250(%rbp)
jne 0x90c8
movq -0xd0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd0(%rbp)
movq -0xe8(%rbp), %rax
movl 0x28(%rax), %edx
movl -0x28(%rbp), %ecx
leaq -0x2c8(%rbp), %rdi
movl $0x2, %esi
callq 0xb320
jmp 0x90e8
leaq -0xb8(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0xb3a0
jmp 0x90fd
leaq -0x2c8(%rbp), %rdi
callq 0xb6b0
leaq -0x250(%rbp), %rdi
callq 0xb120
jmp 0x97f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x914c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0xb6b0
leaq -0x250(%rbp), %rdi
callq 0xb120
jmp 0x9843
movq -0xe8(%rbp), %rax
cmpl $0x1d, (%rax)
jne 0x91d9
movq -0xe8(%rbp), %rax
movl 0x28(%rax), %edx
movl -0x28(%rbp), %ecx
leaq -0x340(%rbp), %rdi
movl $0x1, %esi
callq 0xb320
jmp 0x9189
movb $0x1, -0x2d0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0xb3a0
jmp 0x91a5
leaq -0x340(%rbp), %rdi
callq 0xb6b0
jmp 0x97f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x340(%rbp), %rdi
callq 0xb6b0
jmp 0x9843
movq -0xe8(%rbp), %rax
cmpl $0x3c, (%rax)
jne 0x9202
movq -0xe0(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x91fd
leaq -0xb8(%rbp), %rdi
callq 0xb6e0
jmp 0x97ee
movq -0xe8(%rbp), %rax
cmpl $0x36, (%rax)
je 0x9226
movq -0xe8(%rbp), %rax
cmpl $0x34, (%rax)
je 0x9226
movq -0xe8(%rbp), %rax
cmpl $0x38, (%rax)
jne 0x9234
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x97ec
movq -0xe8(%rbp), %rax
cmpl $0x37, (%rax)
je 0x925c
movq -0xe8(%rbp), %rax
cmpl $0x35, (%rax)
je 0x925c
movq -0xe8(%rbp), %rax
cmpl $0x39, (%rax)
jne 0x96db
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
movq -0xe0(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x943f
movq -0xe0(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x28(%rbp), %eax
jne 0x943f
movq -0xe8(%rbp), %rax
movl 0x28(%rax), %edx
movl -0x28(%rbp), %ecx
leaq -0x3b8(%rbp), %rdi
movl $0x3, %esi
callq 0xb320
jmp 0x92a8
movq -0xe0(%rbp), %rdi
addq $0x10, %rdi
callq 0xb710
movq %rax, -0x3c8(%rbp)
leaq -0x3c0(%rbp), %rdi
leaq -0x3c8(%rbp), %rsi
callq 0xb740
movq -0xe0(%rbp), %rdi
addq $0x10, %rdi
callq 0xb660
movq %rax, -0x3d8(%rbp)
leaq -0x3d0(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
callq 0xb740
leaq -0x3c0(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0xb760
testb $0x1, %al
jne 0x9318
jmp 0x93f5
leaq -0x3a8(%rbp), %rax
movq %rax, -0x568(%rbp)
leaq -0x3c0(%rbp), %rdi
movq %rdi, -0x560(%rbp)
callq 0xb790
movq -0x560(%rbp), %rdi
movq %rax, -0x558(%rbp)
callq 0xb790
movq -0x558(%rbp), %rsi
movq %rax, %rdx
addq $0x20, %rdx
leaq -0x400(%rbp), %rdi
callq 0xb7b0
jmp 0x9368
movq -0x568(%rbp), %rdi
leaq -0x400(%rbp), %rsi
callq 0xb4b0
movb %dl, -0x571(%rbp)
movq %rax, -0x570(%rbp)
jmp 0x938a
movb -0x571(%rbp), %al
movq -0x570(%rbp), %rcx
movq %rcx, -0x410(%rbp)
movb %al, -0x408(%rbp)
leaq -0x400(%rbp), %rdi
callq 0xb560
leaq -0x3c0(%rbp), %rdi
callq 0xb7f0
jmp 0x92d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x942e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x400(%rbp), %rdi
callq 0xb560
jmp 0x942e
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x580(%rbp)
callq 0xb6e0
movq -0x580(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
callq 0xb3a0
jmp 0x941d
leaq -0x3b8(%rbp), %rdi
callq 0xb6b0
jmp 0x96d6
leaq -0x3b8(%rbp), %rdi
callq 0xb6b0
jmp 0x9843
movq -0xe0(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x96d4
movq -0xe0(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x28(%rbp), %eax
jne 0x96d4
movq -0xe0(%rbp), %rdi
addq $0x10, %rdi
callq 0xb710
movq %rax, -0x420(%rbp)
leaq -0x418(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0xb740
movq -0xe0(%rbp), %rdi
addq $0x10, %rdi
callq 0xb660
movq %rax, -0x430(%rbp)
leaq -0x428(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0xb740
leaq -0x418(%rbp), %rdi
leaq -0x428(%rbp), %rsi
callq 0xb760
testb $0x1, %al
jne 0x94cf
jmp 0x953c
leaq -0x418(%rbp), %rdi
callq 0xb790
testb $0x1, 0x24(%rax)
jne 0x952b
leaq -0x418(%rbp), %rdi
movq %rdi, -0x590(%rbp)
callq 0xb790
movq -0x590(%rbp), %rdi
movl 0x20(%rax), %eax
movl %eax, -0x584(%rbp)
callq 0xb790
movq -0x4c8(%rbp), %rdi
movl -0x584(%rbp), %esi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0xb820
jmp 0x9522
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
leaq -0x418(%rbp), %rdi
callq 0xb7f0
jmp 0x948c
leaq -0xb8(%rbp), %rdi
callq 0xb460
cmpq $0x1, %rax
jbe 0x96c8
leaq -0xb8(%rbp), %rdi
callq 0xb460
movq %rax, %rsi
subq $0x2, %rsi
leaq -0xb8(%rbp), %rdi
callq 0xb440
movq %rax, -0x438(%rbp)
movq -0xe0(%rbp), %rdi
addq $0x40, %rdi
callq 0xb710
movq %rax, -0x448(%rbp)
leaq -0x440(%rbp), %rdi
leaq -0x448(%rbp), %rsi
callq 0xb740
movq -0x440(%rbp), %rax
movq %rax, -0x418(%rbp)
movq -0xe0(%rbp), %rdi
addq $0x40, %rdi
callq 0xb660
movq %rax, -0x458(%rbp)
leaq -0x450(%rbp), %rdi
leaq -0x458(%rbp), %rsi
callq 0xb740
leaq -0x418(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0xb760
testb $0x1, %al
jne 0x95f6
jmp 0x96c6
movq -0x438(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x5a8(%rbp)
leaq -0x418(%rbp), %rdi
movq %rdi, -0x5a0(%rbp)
callq 0xb790
movq -0x5a0(%rbp), %rdi
movq %rax, -0x598(%rbp)
callq 0xb790
movq -0x598(%rbp), %rsi
movq %rax, %rdx
addq $0x20, %rdx
leaq -0x480(%rbp), %rdi
callq 0xb7b0
jmp 0x964a
movq -0x5a8(%rbp), %rdi
leaq -0x480(%rbp), %rsi
callq 0xb4b0
movb %dl, -0x5b1(%rbp)
movq %rax, -0x5b0(%rbp)
jmp 0x966c
movb -0x5b1(%rbp), %al
movq -0x5b0(%rbp), %rcx
movq %rcx, -0x490(%rbp)
movb %al, -0x488(%rbp)
leaq -0x480(%rbp), %rdi
callq 0xb560
leaq -0x418(%rbp), %rdi
callq 0xb7f0
jmp 0x95b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x480(%rbp), %rdi
callq 0xb560
jmp 0x9843
jmp 0x96c8
leaq -0xb8(%rbp), %rdi
callq 0xb6e0
jmp 0x96d6
jmp 0x97ea
movq -0xe8(%rbp), %rax
cmpl $0x72, (%rax)
jne 0x97e8
movq -0x4c8(%rbp), %rax
testb $0x1, 0x80(%rax)
je 0x97e8
movq -0xe0(%rbp), %rdi
addq $0x10, %rdi
callq 0xb710
movq %rax, -0x4a0(%rbp)
leaq -0x498(%rbp), %rdi
leaq -0x4a0(%rbp), %rsi
callq 0xb740
movq -0xe0(%rbp), %rdi
addq $0x10, %rdi
callq 0xb660
movq %rax, -0x4b0(%rbp)
leaq -0x4a8(%rbp), %rdi
leaq -0x4b0(%rbp), %rsi
callq 0xb740
leaq -0x498(%rbp), %rdi
leaq -0x4a8(%rbp), %rsi
callq 0xb760
testb $0x1, %al
jne 0x976c
jmp 0x97dc
leaq -0x498(%rbp), %rdi
callq 0xb790
testb $0x1, 0x24(%rax)
jne 0x97cb
leaq -0x498(%rbp), %rdi
movq %rdi, -0x5c0(%rbp)
callq 0xb790
movq -0x5c0(%rbp), %rdi
movl 0x20(%rax), %eax
movl %eax, -0x5b8(%rbp)
callq 0xb790
movq -0x4c8(%rbp), %rdi
movl -0x5b8(%rbp), %esi
movq %rax, %rdx
movl $0x1, %ecx
callq 0xb820
jmp 0x97c2
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
leaq -0x498(%rbp), %rdi
callq 0xb7f0
jmp 0x9729
leaq -0xb8(%rbp), %rdi
callq 0xb6e0
jmp 0x97ea
jmp 0x97ec
jmp 0x97ee
jmp 0x97f0
jmp 0x97f2
jmp 0x97f4
jmp 0x97f6
jmp 0x97f8
movq -0xd0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd0(%rbp)
jmp 0x8a5d
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x14c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xb920
leaq -0xa0(%rbp), %rdi
callq 0xb6b0
movl -0x4(%rbp), %eax
addq $0x5c0, %rsp            # imm = 0x5C0
popq %rbp
retq
leaq -0xb8(%rbp), %rdi
callq 0xb920
leaq -0xa0(%rbp), %rdi
callq 0xb6b0
movq -0xc0(%rbp), %rdi
callq 0x3460
nopw (%rax,%rax)