// File: /workspace/github_cpp_makefile_star2_O1/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 0x23f5
movq %rax, %r15
leaq 0x1077d(%rip), %rax     # 0x19a48
movq (%rax), %rax
movq %rax, (%r15)
movq 0x18(%rbx), %rsi
movq %r15, %r12
addq $0x18, %r12
movq %r12, %rdi
callq 0xf2ea
movq %rbx, 0x10(%rsp)
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x9435
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 0x939e
movq 0x18(%rsi), %rdx
testq %rdx, %rdx
je 0x94a2
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 0x9364
testq %r9, %r9
je 0x939e
incq %rdi
cmpq %rax, %rdi
movl $0x0, %r9d
cmoveq %r9, %rdi
cmpq %rcx, %rdi
jne 0x933f
jmp 0x939e
movq 0x28(%r15), %rax
cmpq $0x0, (%rax,%rdi,8)
je 0x939e
movl (%rsi), %edi
movq (%r15), %r9
leaq 0x86f6(%rip), %rax      # 0x11a71
movq %rax, (%rsp)
leaq 0x95b0(%rip), %rsi      # 0x12936
leaq 0x9587(%rip), %rcx      # 0x12914
leaq 0x9595(%rip), %r8       # 0x12929
callq 0x9cc6
jmp 0x9428
movq %r14, %rdi
callq 0x9da2
movq 0x38(%r15), %rcx
cmpq 0x40(%r15), %rcx
je 0x9428
movq (%rax), %rsi
testq %rsi, %rsi
je 0x94c1
movq (%r12), %rdx
testq %rdx, %rdx
je 0x94e0
imull $0x5f5e505, %esi, %edi  # imm = 0x5F5E505
imulq %rdx, %rdi
shrq $0x20, %rdi
movq 0x20(%r15), %r8
movq (%r8,%rdi,8), %r10
movq %rdi, %r9
testq %r10, %r10
je 0x940a
cmpq %rsi, %r10
je 0x9475
incq %r9
cmpq %rdx, %r9
cmoveq %rbx, %r9
cmpq %rdi, %r9
je 0x9428
movq (%r8,%r9,8), %r10
testq %r10, %r10
jne 0x93e7
jmp 0x940d
movq %rdi, %r9
movq %rsi, (%r8,%r9,8)
movq 0x28(%r15), %rdx
movq %rax, (%rdx,%r9,8)
movq 0x30(%r15), %rdx
movq %rax, (%rdx,%rcx,8)
incq %rcx
movq %rcx, 0x38(%r15)
addq $0x8, %rbp
cmpq %r13, %rbp
jne 0x930c
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 0xa925(%rip), %rdi      # 0x13da1
xorl %eax, %eax
callq 0x2030
leaq 0x82ce(%rip), %rdi      # 0x11758
leaq 0xa387(%rip), %rsi      # 0x13818
leaq 0xa978(%rip), %rcx      # 0x13e10
movl $0x53, %edx
callq 0x20b0
leaq 0xa36b(%rip), %rdi      # 0x13814
leaq 0xa368(%rip), %rsi      # 0x13818
leaq 0xa8fa(%rip), %rcx      # 0x13db1
movl $0x5e, %edx
callq 0x20b0
leaq 0xa34c(%rip), %rdi      # 0x13814
leaq 0xa349(%rip), %rsi      # 0x13818
leaq 0xa93a(%rip), %rcx      # 0x13e10
movl $0x46, %edx
callq 0x20b0
leaq 0xa8b1(%rip), %rdi      # 0x13d98
leaq 0xa32a(%rip), %rsi      # 0x13818
leaq 0xa91b(%rip), %rcx      # 0x13e10
movl $0x47, %edx
callq 0x20b0
nop