// File: Heptagon196[P]Gos/GosASTCompiler.cpp
// Function: Gos::AST::ClassDef::CompileAST(Gos::Compiler::VMCompiler&)
Compile(ClassDef) {
    START();
    int start = 0;
    if (branch & 1) {
        SUB(start++);
    }
    if (branch & 2) {
        // Func
        code.MoveToNew();
        code.funcScope = code.currentScope;
        std::string name = nodes[start++]->token.str;
        std::vector<std::string> argTypes;
        std::vector<std::string> argNames;
        if (branch & 8) {
            // DefArgList
            auto* ast = nodes[start++];
            for (auto* arg : ast->nodes) {
                argNames.push_back(arg->nodes[0]->token.str);
                argTypes.push_back(arg->nodes[1]->token.str);
            }
        }
        std::string ret = nodes[start++]->token.str;
        auto jmp = vm.WriteCommandDefFunc(name, ret, argTypes);

        auto setMemsize = vm.WriteAlloc();
        code.ClearTmp();
        pc = 1;

        int id = pc++;
        code.currentScope->varID["this"] = id;
        vm.WriteCommandArg(id, 0);

        for (int i = 0; i < argNames.size(); i++) {
            id = pc++;
            code.currentScope->varID[argNames[i]] = id;
            code.currentScope->varType[argNames[i]] = argTypes[i];
            vm.WriteCommandArg(id, i + 1);
        }

        SUB(start++);
        vm.WriteCommandRet(0);
        jmp(vm.GetProgress());
        setMemsize(pc);
        pc = 1;
        code.MoveBack();
    } else if (branch & 4) {
        // Field
        std::string varName = nodes[start++]->token.str;
        std::string typeName = nodes[start++]->token.str;
        compilingClassVars.push_back(varName);
        compilingClassVarTypes.push_back(typeName);
        vm.WriteCommandDefVar(typeName, varName);
        pc--;
        code.currentScope->varID.erase(varName);
        code.currentScope->varType.erase(typeName);
    } else if (branch & 16) {
        // using
        std::string name = nodes[start++]->token.str;
        compilingClassVars.push_back(name);
        compilingClassVarTypes.push_back(name);
        vm.WriteCommandNamespace(name);
        pc--;
        code.currentScope->varID.erase(name);
        code.currentScope->varType.erase(name);
    }
    return 0;
}

// Assembly:
subq $0x218, %rsp            # imm = 0x218
movq %rdi, 0x208(%rsp)
movq %rsi, 0x200(%rsp)
movq 0x208(%rsp), %rdi
movq %rdi, 0x78(%rsp)
movl 0x2c(%rdi), %eax
movl %eax, 0x126c6b(%rip)    # 0x3022f8
addq $0x10, %rdi
callq 0x1d1e80
cmpq $0x0, %rax
jne 0x1db6ac
movl $0x0, 0x214(%rsp)
jmp 0x1dc051
movq 0x78(%rsp), %rax
movl $0x0, 0x1fc(%rsp)
movl 0x8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1db6fb
movq 0x78(%rsp), %rdi
addq $0x10, %rdi
movl 0x1fc(%rsp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x1fc(%rsp)
movslq %eax, %rsi
callq 0x1d1e60
movq (%rax), %rdi
movq 0x200(%rsp), %rsi
movq (%rdi), %rax
callq *(%rax)
movq 0x78(%rsp), %rax
movl 0x8(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1dbd8c
movq 0x200(%rsp), %rdi
callq 0x1d50f0
movq 0x78(%rsp), %rdi
movq 0x200(%rsp), %rax
movq 0xd0(%rax), %rcx
movq 0x200(%rsp), %rax
movq %rcx, 0xd8(%rax)
addq $0x10, %rdi
movl 0x1fc(%rsp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x1fc(%rsp)
movslq %eax, %rsi
callq 0x1d1e60
movq (%rax), %rsi
addq $0x28, %rsi
addq $0x18, %rsi
leaq 0x1d8(%rsp), %rdi
callq 0x6f070
leaq 0x1c0(%rsp), %rdi
callq 0x1b4f70
leaq 0x1a8(%rsp), %rdi
callq 0x1b4f70
movq 0x78(%rsp), %rax
movl 0x8(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1db8cf
movq 0x78(%rsp), %rdi
addq $0x10, %rdi
movl 0x1fc(%rsp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x1fc(%rsp)
movslq %eax, %rsi
callq 0x1d1e60
movq (%rax), %rax
movq %rax, 0x1a0(%rsp)
movq 0x1a0(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x198(%rsp)
movq 0x198(%rsp), %rdi
callq 0x1d1b70
movq %rax, 0x190(%rsp)
movq 0x198(%rsp), %rdi
callq 0x1d1ba0
movq %rax, 0x188(%rsp)
leaq 0x190(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x1d1bd0
xorb $-0x1, %al
testb $0x1, %al
jne 0x1db831
jmp 0x1db8cd
leaq 0x190(%rsp), %rdi
callq 0x1d1c10
movq (%rax), %rax
movq %rax, 0x180(%rsp)
movq 0x180(%rsp), %rdi
addq $0x10, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1d1e60
movq (%rax), %rsi
addq $0x40, %rsi
leaq 0x1a8(%rsp), %rdi
callq 0x1b4f80
jmp 0x1db874
movq 0x180(%rsp), %rdi
addq $0x10, %rdi
movl $0x1, %esi
callq 0x1d1e60
movq (%rax), %rsi
addq $0x40, %rsi
leaq 0x1c0(%rsp), %rdi
callq 0x1b4f80
jmp 0x1db8a0
jmp 0x1db8a2
leaq 0x190(%rsp), %rdi
callq 0x1d1c20
jmp 0x1db811
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0x1dbd60
jmp 0x1db8cf
movq 0x78(%rsp), %rdi
addq $0x10, %rdi
movslq 0x1fc(%rsp), %rsi
movl %esi, %eax
incl %eax
movl %eax, 0x1fc(%rsp)
callq 0x1d1e60
movq (%rax), %rsi
addq $0x40, %rsi
leaq 0x150(%rsp), %rdi
callq 0x6f070
jmp 0x1db906
movq 0x200(%rsp), %rax
movq 0xe8(%rax), %rsi
leaq 0x130(%rsp), %rdi
leaq 0x1d8(%rsp), %rdx
leaq 0x150(%rsp), %rcx
leaq 0x1c0(%rsp), %r8
callq 0x1b0880
jmp 0x1db93c
movq 0x200(%rsp), %rax
movq 0xe8(%rax), %rsi
leaq 0x110(%rsp), %rdi
callq 0x1b1ba0
jmp 0x1db95a
movq 0x200(%rsp), %rdi
callq 0x1d5320
movq 0x200(%rsp), %rax
movl $0x1, 0xe0(%rax)
movq 0x200(%rsp), %rcx
movl 0xe0(%rcx), %eax
movl %eax, %edx
incl %edx
movl %edx, 0xe0(%rcx)
movl %eax, 0x10c(%rsp)
movl 0x10c(%rsp), %eax
movl %eax, 0x64(%rsp)
movq 0x200(%rsp), %rax
movq 0xd0(%rax), %rax
addq $0x28, %rax
movq %rax, 0x68(%rsp)
leaq 0xe7(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x13570
movq 0x70(%rsp), %rdx
leaq 0x4666a(%rip), %rsi     # 0x222043
leaq 0xe8(%rsp), %rdi
callq 0x165520
jmp 0x1db9e8
movq 0x68(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x1dd760
movq %rax, 0x58(%rsp)
jmp 0x1dba01
movq 0x58(%rsp), %rax
movl 0x64(%rsp), %ecx
movl %ecx, (%rax)
leaq 0xe8(%rsp), %rdi
callq 0x52f50
leaq 0xe7(%rsp), %rdi
callq 0x136a0
movq 0x200(%rsp), %rax
movq 0xe8(%rax), %rdi
movl 0x10c(%rsp), %esi
xorl %edx, %edx
callq 0x1b1240
jmp 0x1dba45
movl $0x0, 0xe0(%rsp)
movslq 0xe0(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x6f4b0
movq %rax, %rcx
movq 0x50(%rsp), %rax
cmpq %rcx, %rax
jae 0x1dbc2f
movq 0x200(%rsp), %rcx
movl 0xe0(%rcx), %eax
movl %eax, %edx
incl %edx
movl %edx, 0xe0(%rcx)
movl %eax, 0x10c(%rsp)
movl 0x10c(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0x200(%rsp), %rax
movq 0xd0(%rax), %rax
addq $0x28, %rax
movq %rax, 0x40(%rsp)
movslq 0xe0(%rsp), %rsi
leaq 0x1a8(%rsp), %rdi
callq 0x1dd580
movq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0x1b4880
movq %rax, 0x48(%rsp)
jmp 0x1dbae6
movq 0x48(%rsp), %rax
movl 0x3c(%rsp), %ecx
movl %ecx, (%rax)
movslq 0xe0(%rsp), %rsi
leaq 0x1c0(%rsp), %rdi
callq 0x1dd580
movq %rax, 0x20(%rsp)
movq 0x200(%rsp), %rax
movq 0xd0(%rax), %rax
addq $0x60, %rax
movq %rax, 0x28(%rsp)
movslq 0xe0(%rsp), %rsi
leaq 0x1a8(%rsp), %rdi
callq 0x1dd580
movq 0x28(%rsp), %rdi
movq %rax, %rsi
callq 0x1dcf70
movq %rax, 0x30(%rsp)
jmp 0x1dbb4c
movq 0x20(%rsp), %rsi
movq 0x30(%rsp), %rdi
callq 0x1187a0
jmp 0x1dbb5d
movq 0x200(%rsp), %rax
movq 0xe8(%rax), %rdi
movl 0x10c(%rsp), %esi
movl 0xe0(%rsp), %edx
incl %edx
callq 0x1b1240
jmp 0x1dbb83
jmp 0x1dbb85
movl 0xe0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe0(%rsp)
jmp 0x1dba50
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0x1dbd53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0x1dbd46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0x1dbc04
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x52f50
leaq 0xe7(%rsp), %rdi
callq 0x136a0
jmp 0x1dbd39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0x1dbd39
movq 0x78(%rsp), %rdi
addq $0x10, %rdi
movslq 0x1fc(%rsp), %rsi
movl %esi, %eax
incl %eax
movl %eax, 0x1fc(%rsp)
callq 0x1d1e60
movq (%rax), %rdi
movq 0x200(%rsp), %rsi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x1dbc65
movq 0x200(%rsp), %rax
movq 0xe8(%rax), %rdi
xorl %esi, %esi
callq 0x1b15f0
jmp 0x1dbc7d
movq 0x200(%rsp), %rax
movq 0xe8(%rax), %rdi
callq 0x1b1b80
movl %eax, 0x1c(%rsp)
jmp 0x1dbc97
movl 0x1c(%rsp), %esi
leaq 0x130(%rsp), %rdi
callq 0x1d1c40
jmp 0x1dbcaa
movq 0x200(%rsp), %rax
movl 0xe0(%rax), %esi
leaq 0x110(%rsp), %rdi
callq 0x1d1c40
jmp 0x1dbcc7
movq 0x200(%rsp), %rax
movl $0x1, 0xe0(%rax)
movq 0x200(%rsp), %rdi
callq 0x1d5230
leaq 0x110(%rsp), %rdi
callq 0x1d1c80
leaq 0x130(%rsp), %rdi
callq 0x1d1c80
leaq 0x150(%rsp), %rdi
callq 0x52f50
leaq 0x1a8(%rsp), %rdi
callq 0x6ed80
leaq 0x1c0(%rsp), %rdi
callq 0x6ed80
leaq 0x1d8(%rsp), %rdi
callq 0x52f50
jmp 0x1dc046
leaq 0x110(%rsp), %rdi
callq 0x1d1c80
leaq 0x130(%rsp), %rdi
callq 0x1d1c80
leaq 0x150(%rsp), %rdi
callq 0x52f50
leaq 0x1a8(%rsp), %rdi
callq 0x6ed80
leaq 0x1c0(%rsp), %rdi
callq 0x6ed80
leaq 0x1d8(%rsp), %rdi
callq 0x52f50
jmp 0x1dc060
movq 0x78(%rsp), %rax
movl 0x8(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1dbf21
movq 0x78(%rsp), %rdi
addq $0x10, %rdi
movq %rdi, 0x10(%rsp)
movslq 0x1fc(%rsp), %rsi
movl %esi, %eax
incl %eax
movl %eax, 0x1fc(%rsp)
callq 0x1d1e60
movq (%rax), %rsi
addq $0x40, %rsi
leaq 0xc0(%rsp), %rdi
callq 0x6f070
movq 0x10(%rsp), %rdi
movslq 0x1fc(%rsp), %rsi
movl %esi, %eax
incl %eax
movl %eax, 0x1fc(%rsp)
callq 0x1d1e60
movq (%rax), %rsi
addq $0x40, %rsi
leaq 0xa0(%rsp), %rdi
callq 0x6f070
jmp 0x1dbe0d
leaq 0x12649c(%rip), %rdi    # 0x3022b0
leaq 0xc0(%rsp), %rsi
callq 0x1b4f80
jmp 0x1dbe23
leaq 0x12649e(%rip), %rdi    # 0x3022c8
leaq 0xa0(%rsp), %rsi
callq 0x1b4f80
jmp 0x1dbe39
movq 0x200(%rsp), %rax
movq 0xe8(%rax), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x1b07a0
jmp 0x1dbe5f
movq 0x200(%rsp), %rax
movl 0xe0(%rax), %ecx
decl %ecx
movl %ecx, 0xe0(%rax)
movq 0x200(%rsp), %rax
movq 0xd0(%rax), %rdi
addq $0x28, %rdi
leaq 0xc0(%rsp), %rsi
callq 0x1dd790
jmp 0x1dbe97
movq 0x200(%rsp), %rax
movq 0xd0(%rax), %rdi
addq $0x60, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x1dd7c0
jmp 0x1dbeb9
leaq 0xa0(%rsp), %rdi
callq 0x52f50
leaq 0xc0(%rsp), %rdi
callq 0x52f50
jmp 0x1dc044
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0x1dbf0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x52f50
leaq 0xc0(%rsp), %rdi
callq 0x52f50
jmp 0x1dc060
movq 0x78(%rsp), %rax
movl 0x8(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x1dc042
movq 0x78(%rsp), %rdi
addq $0x10, %rdi
movslq 0x1fc(%rsp), %rsi
movl %esi, %eax
incl %eax
movl %eax, 0x1fc(%rsp)
callq 0x1d1e60
movq (%rax), %rsi
addq $0x40, %rsi
leaq 0x80(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x6f070
movq 0x8(%rsp), %rsi
leaq 0x126335(%rip), %rdi    # 0x3022b0
callq 0x1b4f80
jmp 0x1dbf82
leaq 0x12633f(%rip), %rdi    # 0x3022c8
leaq 0x80(%rsp), %rsi
callq 0x1b4f80
jmp 0x1dbf98
movq 0x200(%rsp), %rax
movq 0xe8(%rax), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1b0ec0
jmp 0x1dbfb6
movq 0x200(%rsp), %rax
movl 0xe0(%rax), %ecx
decl %ecx
movl %ecx, 0xe0(%rax)
movq 0x200(%rsp), %rax
movq 0xd0(%rax), %rdi
addq $0x28, %rdi
leaq 0x80(%rsp), %rsi
callq 0x1dd790
jmp 0x1dbfee
movq 0x200(%rsp), %rax
movq 0xd0(%rax), %rdi
addq $0x60, %rdi
leaq 0x80(%rsp), %rsi
callq 0x1dd7c0
jmp 0x1dc010
leaq 0x80(%rsp), %rdi
callq 0x52f50
jmp 0x1dc042
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x52f50
jmp 0x1dc060
jmp 0x1dc044
jmp 0x1dc046
movl $0x0, 0x214(%rsp)
movl 0x214(%rsp), %eax
addq $0x218, %rsp            # imm = 0x218
retq
movq 0x178(%rsp), %rdi
callq 0x133f0
nopl (%rax)