// File: yeonnic[P]solparser/./tree.cpp
// Function: S_Top(__gnu_cxx::__normal_iterator<Token const*, std::vector<Token, std::allocator<Token>>>, SolTree&)
int S_Top(Tokit begin, SolTree &out){
  unsigned int ret = 0;

  vector<SolTree> tmp;

  auto it = begin;

  cout << "S_Top() called!!" << endl;

  for(; it->type != TokenType::eof;){
    if(it->type == TokenType::contract || it->type == TokenType::library || it->type == TokenType::interface){
      SolTree p;
      if((it+1)->type != TokenType::eof){
        switch(it->type){
          case TokenType::contract:
            p = SolTree((it+1)->str, NodeType::contract);
            it+=2;
            break;
          case TokenType::library:
            p = SolTree((it+1)->str, NodeType::library);
            it+=2;
            break;
          case TokenType::interface:
            p = SolTree((it+1)->str, NodeType::interface);
            it+=2;
            break;
        }

        if(it->type == TokenType::is){
          it++;
          for(; it->type != TokenType::lbracket && it->type != TokenType::eof; it++)
            p.inherited.push_back(SolTree(it->str, NodeType::none));
          it += S_Parent(it, p);
        } else if(it->type == TokenType::lbracket){
          it += S_Parent(it, p);
        } else {
          cout << "Error!!! line : " << it->line << endl;
          return -1;
        }
        tmp.push_back(p);
        ret++;
      }
    } else {
      it++;
    }
  }

  out.children = tmp;

  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4a0, %rsp            # imm = 0x4A0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x34de0
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq 0x1892e(%rip), %rdi     # 0x4cfd0
leaq 0x3831(%rip), %rsi      # 0x37eda
callq 0x6320
movq %rax, -0x468(%rbp)
jmp 0x346b7
movq -0x468(%rbp), %rdi
movq 0x188fb(%rip), %rsi     # 0x4cfc0
callq 0x6360
jmp 0x346cc
jmp 0x346ce
leaq -0x40(%rbp), %rdi
callq 0x34e00
cmpl $0x1, 0x20(%rax)
je 0x34c51
leaq -0x40(%rbp), %rdi
callq 0x34e00
cmpl $0x7, 0x20(%rax)
je 0x34712
leaq -0x40(%rbp), %rdi
callq 0x34e00
cmpl $0x8, 0x20(%rax)
je 0x34712
leaq -0x40(%rbp), %rdi
callq 0x34e00
cmpl $0x9, 0x20(%rax)
jne 0x34c3a
leaq -0x110(%rbp), %rdi
movq %rdi, -0x470(%rbp)
callq 0x6510
movq -0x470(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
xorl %edx, %edx
callq 0x34ed0
jmp 0x3473c
leaq -0x110(%rbp), %rdi
callq 0x61f0
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x34e20
movq %rax, -0x118(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x34e00
cmpl $0x1, 0x20(%rax)
je 0x34c08
leaq -0x40(%rbp), %rdi
callq 0x34e00
movl 0x20(%rax), %eax
movl %eax, -0x474(%rbp)
subl $0x7, %eax
je 0x347df
jmp 0x3478c
movl -0x474(%rbp), %eax
subl $0x8, %eax
je 0x34897
jmp 0x3479d
movl -0x474(%rbp), %eax
subl $0x9, %eax
je 0x3493e
jmp 0x349e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x34c89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x61f0
jmp 0x34c89
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x34e20
movq %rax, -0x1e0(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x34e00
movq %rax, %rsi
leaq -0x1d8(%rbp), %rdi
callq 0x6150
jmp 0x34811
leaq -0x1b8(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
movl $0x2, %edx
callq 0x34ed0
jmp 0x3482b
leaq -0xf0(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x352d0
leaq -0x1b8(%rbp), %rdi
callq 0x80e0
leaq -0x1d8(%rbp), %rdi
callq 0x61f0
leaq -0x40(%rbp), %rdi
movl $0x2, %esi
callq 0x34fe0
jmp 0x349e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x34c2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x61f0
jmp 0x34c2c
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x34e20
movq %rax, -0x2a8(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x34e00
movq %rax, %rsi
leaq -0x2a0(%rbp), %rdi
callq 0x6150
jmp 0x348c9
leaq -0x280(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
movl $0x3, %edx
callq 0x34ed0
jmp 0x348e3
leaq -0xf0(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x352d0
leaq -0x280(%rbp), %rdi
callq 0x80e0
leaq -0x2a0(%rbp), %rdi
callq 0x61f0
leaq -0x40(%rbp), %rdi
movl $0x2, %esi
callq 0x34fe0
jmp 0x349e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x61f0
jmp 0x34c2c
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x34e20
movq %rax, -0x370(%rbp)
leaq -0x370(%rbp), %rdi
callq 0x34e00
movq %rax, %rsi
leaq -0x368(%rbp), %rdi
callq 0x6150
jmp 0x34970
leaq -0x348(%rbp), %rdi
leaq -0x368(%rbp), %rsi
movl $0x4, %edx
callq 0x34ed0
jmp 0x3498a
leaq -0xf0(%rbp), %rdi
leaq -0x348(%rbp), %rsi
callq 0x352d0
leaq -0x348(%rbp), %rdi
callq 0x80e0
leaq -0x368(%rbp), %rdi
callq 0x61f0
leaq -0x40(%rbp), %rdi
movl $0x2, %esi
callq 0x34fe0
jmp 0x349e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x368(%rbp), %rdi
callq 0x61f0
jmp 0x34c2c
leaq -0x40(%rbp), %rdi
callq 0x34e00
cmpl $0x39, 0x20(%rax)
jne 0x34b3d
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x34e60
movq %rax, -0x378(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x34e00
movq %rax, %rcx
xorl %eax, %eax
cmpl $0x19, 0x20(%rcx)
movb %al, -0x475(%rbp)
je 0x34a37
leaq -0x40(%rbp), %rdi
callq 0x34e00
cmpl $0x1, 0x20(%rax)
setne %al
movb %al, -0x475(%rbp)
movb -0x475(%rbp), %al
testb $0x1, %al
jne 0x34a46
jmp 0x34b00
leaq -0xb0(%rbp), %rax
movq %rax, -0x480(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x34e00
movq %rax, %rsi
leaq -0x438(%rbp), %rdi
callq 0x6150
jmp 0x34a6e
leaq -0x418(%rbp), %rdi
leaq -0x438(%rbp), %rsi
xorl %edx, %edx
callq 0x34ed0
jmp 0x34a85
movq -0x480(%rbp), %rdi
leaq -0x418(%rbp), %rsi
callq 0x34ea0
jmp 0x34a9a
leaq -0x418(%rbp), %rdi
callq 0x80e0
leaq -0x438(%rbp), %rdi
callq 0x61f0
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x34e60
movq %rax, -0x440(%rbp)
jmp 0x34a07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x34aef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x418(%rbp), %rdi
callq 0x80e0
leaq -0x438(%rbp), %rdi
callq 0x61f0
jmp 0x34c2c
movq -0x40(%rbp), %rax
movq %rax, -0x448(%rbp)
movq -0x448(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x34250
movl %eax, -0x484(%rbp)
jmp 0x34b26
movl -0x484(%rbp), %eax
movslq %eax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x34fe0
jmp 0x34bed
leaq -0x40(%rbp), %rdi
callq 0x34e00
cmpl $0x19, 0x20(%rax)
jne 0x34b86
movq -0x40(%rbp), %rax
movq %rax, -0x450(%rbp)
movq -0x450(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x34250
movl %eax, -0x488(%rbp)
jmp 0x34b72
movl -0x488(%rbp), %eax
movslq %eax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x34fe0
jmp 0x34beb
movq 0x18443(%rip), %rdi     # 0x4cfd0
leaq 0x3357(%rip), %rsi      # 0x37eeb
callq 0x6320
movq %rax, -0x490(%rbp)
jmp 0x34ba2
leaq -0x40(%rbp), %rdi
callq 0x34e00
movq -0x490(%rbp), %rdi
movl 0x24(%rax), %esi
callq 0x6600
movq %rax, -0x498(%rbp)
jmp 0x34bc3
movq -0x498(%rbp), %rdi
movq 0x183ef(%rip), %rsi     # 0x4cfc0
callq 0x6360
jmp 0x34bd8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x454(%rbp)
jmp 0x34c12
jmp 0x34bed
leaq -0x38(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x35000
jmp 0x34bff
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl $0x0, -0x454(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x80e0
movl -0x454(%rbp), %eax
testl %eax, %eax
jne 0x34c74
jmp 0x34c2a
jmp 0x34c4c
leaq -0xf0(%rbp), %rdi
callq 0x80e0
jmp 0x34c89
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x34e60
movq %rax, -0x460(%rbp)
jmp 0x346ce
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
leaq -0x38(%rbp), %rsi
callq 0x35070
jmp 0x34c64
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x454(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x8ef0
movl -0x4(%rbp), %eax
addq $0x4a0, %rsp            # imm = 0x4A0
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x8ef0
movq -0x48(%rbp), %rdi
callq 0x6620
nopl (%rax,%rax)