// File: /workspace/github_cpp_makefile_star2_O3/baziotis[P]minijava-cpp/typecheck.cpp
// Function: Method::construct_main_method(DeclarationVisitor*, MainClass*)
Method *Method::construct_main_method(DeclarationVisitor *visitor, MainClass *main_class) {
    Method *method = (Method *) allocate_zero(sizeof(Method), MEM::TYPECHECK);
    method->id = main_method_string;
    size_t locals_size = main_class->vars.len;
    method->locals.reserve(locals_size);

    for (LocalDeclaration *var : main_class->vars) {
        if (method->locals.find(var->id)) {
            typecheck_error(var->loc, "Variable `", var->id, "` is already defined",
                            " in method `", method->id, "`");
        } else {
            Var *v = var->accept(visitor);
            method->locals.insert(v->id, v);
        }
    }

    method->param_len = 0;
    method->stmts = main_class->stmts;
    method->ret_type = visitor->type_table.int_type;
    method->ret_expr = NULL;
    method->loc = main_class->loc;
    return method;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl $0x78, %edi
movl $0x3, %esi
callq 0x23ef
movq %rax, %r15
leaq 0x118bb(%rip), %rax     # 0x1aa48
movq (%rax), %rax
movq %rax, (%r15)
movq 0x18(%rbx), %rsi
movq %r15, %r12
addq $0x18, %r12
movq %r12, %rdi
callq 0xfb16
movq %rbx, 0x10(%rsp)
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x92e0
movq 0x10(%rsp), %rcx
movq 0x20(%rcx), %rbp
leaq (,%rax,8), %r13
addq %rbp, %r13
xorl %ebx, %ebx
movq (%rbp), %rsi
movq (%r12), %rax
testq %rax, %rax
je 0x9259
movq 0x18(%rsi), %rdx
testq %rdx, %rdx
je 0x934d
imull $0x5f5e505, %edx, %ecx  # imm = 0x5F5E505
imulq %rax, %rcx
shrq $0x20, %rcx
movq 0x20(%r15), %r8
movq %rcx, %rdi
movq (%r8,%rdi,8), %r9
cmpq %rdx, %r9
je 0x9222
testq %r9, %r9
je 0x9259
incq %rdi
cmpq %rax, %rdi
movl $0x0, %r9d
cmoveq %r9, %rdi
cmpq %rcx, %rdi
jne 0x91fd
jmp 0x9259
movq 0x28(%r15), %rax
cmpq $0x0, (%rax,%rdi,8)
je 0x9259
movl (%rsi), %edi
movq (%r15), %r9
leaq 0x9718(%rip), %rax      # 0x12951
movq %rax, (%rsp)
leaq 0xa662(%rip), %rsi      # 0x138a6
leaq 0xa639(%rip), %rcx      # 0x13884
leaq 0xa647(%rip), %r8       # 0x13899
callq 0x9b47
jmp 0x92d3
movq %r14, %rdi
callq 0x9c28
movq 0x38(%r15), %rcx
cmpq 0x40(%r15), %rcx
je 0x92d3
movq (%rax), %rsi
testq %rsi, %rsi
je 0x936c
movq (%r12), %rdx
testq %rdx, %rdx
je 0x938b
imull $0x5f5e505, %esi, %edi  # imm = 0x5F5E505
imulq %rdx, %rdi
shrq $0x20, %rdi
movq 0x20(%r15), %r9
movq %rdi, %r8
movq (%r9,%r8,8), %r10
testq %r10, %r10
je 0x92b8
cmpq %rsi, %r10
je 0x9320
incq %r8
cmpq %rdx, %r8
cmoveq %rbx, %r8
cmpq %rdi, %r8
jne 0x9299
jmp 0x92d3
movq %rsi, (%r9,%r8,8)
movq 0x28(%r15), %rdx
movq %rax, (%rdx,%r8,8)
movq 0x30(%r15), %rdx
movq %rax, (%rdx,%rcx,8)
incq %rcx
movq %rcx, 0x38(%r15)
addq $0x8, %rbp
cmpq %r13, %rbp
jne 0x91ce
xorl %eax, %eax
movq %rax, 0x10(%r15)
movq 0x10(%rsp), %rdx
movups 0x28(%rdx), %xmm0
movups %xmm0, 0x58(%r15)
movq 0x38(%rdx), %rcx
movq %rcx, 0x68(%r15)
movq 0x10(%r14), %rcx
movq %rcx, 0x8(%r15)
movq %rax, 0x70(%r15)
movl (%rdx), %eax
movl %eax, 0x50(%r15)
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb9fd(%rip), %rdi      # 0x14d24
xorl %eax, %eax
callq 0x2030
leaq 0x936d(%rip), %rdi      # 0x126a2
leaq 0xb44d(%rip), %rsi      # 0x14789
leaq 0xba50(%rip), %rcx      # 0x14d93
movl $0x53, %edx
callq 0x20b0
leaq 0xb431(%rip), %rdi      # 0x14785
leaq 0xb42e(%rip), %rsi      # 0x14789
leaq 0xb9d2(%rip), %rcx      # 0x14d34
movl $0x5e, %edx
callq 0x20b0
leaq 0xb412(%rip), %rdi      # 0x14785
leaq 0xb40f(%rip), %rsi      # 0x14789
leaq 0xba12(%rip), %rcx      # 0x14d93
movl $0x46, %edx
callq 0x20b0
leaq 0xb989(%rip), %rdi      # 0x14d1b
leaq 0xb3f0(%rip), %rsi      # 0x14789
leaq 0xb9f3(%rip), %rcx      # 0x14d93
movl $0x47, %edx
callq 0x20b0