// File: /workspace/github_cpp_makefile_star2_O1/baziotis[P]minijava-cpp/typecheck.cpp
// Function: DeclarationVisitor::visit(MethodDeclaration*)
Method *DeclarationVisitor::visit(MethodDeclaration *method_decl) {
    // Note: It's responsibility of the one who calls this visit
    // to have assured that a method with the same id does not exist.
    LOG_SCOPE;
    assert(!method_decl->is_undefined());
    print_indentation();
    debug_log(method_decl->loc, "MethodDeclaration: ", method_decl->id, "\n");
    Method *method = new Method(method_decl);
    assert(method);
    method->ret_type = this->typespec_to_type(method_decl->typespec, method_decl->ret->loc);
    for (LocalDeclaration *par : method_decl->params) {
        // We accept the param anyway. But in the case that there is
        // another param with the same name, we still insert this
        // (so that the rest of type-checking can sort of continue) but
        // we have to generate a (dummy) id for it.
        Param *param = par->accept(this);
        if (method->locals.find(par->id)) {
            typecheck_error(par->loc, "Parameter `", par->id, "` is already defined",
                            " in method `", method_decl->id, "`");
            param->id = gen_id();
        }
        method->locals.insert(param->id, param);
    }
    for (LocalDeclaration *var : method_decl->vars) {
        if (method->locals.find(var->id)) {
            typecheck_error(var->loc, "Variable `", var->id, "` is already defined",
                            " in method `", method_decl->id, "`");
        } else {
            Var *v = var->accept(this);
            method->locals.insert(v->id, v);
        }
    }
    return method;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %rbx
movq %rdi, 0x20(%rsp)
leaq 0x17(%rsp), %rdi
callq 0x34d0
cmpq $0x0, 0x18(%rbx)
je 0xa3d6
callq 0x34f7
movl (%rbx), %edi
movq 0x18(%rbx), %rdx
leaq 0x8933(%rip), %rsi      # 0x128f4
callq 0x9ac9
movl $0x78, %edi
movl $0x3, %esi
callq 0x23f5
movq %rax, %r15
leaq 0x18(%rax), %r12
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rax)
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x58(%rax)
movq $0x0, 0x68(%rax)
movq 0x18(%rbx), %rax
movq %rax, (%r15)
movq 0x40(%rbx), %rsi
addq 0x28(%rbx), %rsi
movq %r12, %rdi
callq 0xf2ea
movq %r15, %rax
addq $0x58, %rax
movq 0x28(%rbx), %rcx
movq %rcx, 0x10(%r15)
movq 0x60(%rbx), %rcx
movq %rcx, 0x10(%rax)
movups 0x50(%rbx), %xmm0
movups %xmm0, (%rax)
movq 0x68(%rbx), %rax
movq %rax, 0x70(%r15)
movl (%rbx), %ecx
movl %ecx, 0x50(%r15)
movl 0x8(%rbx), %esi
movq 0x10(%rbx), %rdx
movl (%rax), %ecx
movq 0x20(%rsp), %rdi
callq 0x8fee
movq %rax, 0x8(%r15)
movq %rbx, 0x18(%rsp)
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0xa1e0
movq 0x18(%rsp), %rcx
movq 0x30(%rcx), %rbx
leaq (%rbx,%rax,8), %rax
movq %rax, 0x28(%rsp)
xorl %r14d, %r14d
movq (%rbx), %r13
movq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x9da2
movq %rax, %rbp
movq (%r12), %rax
testq %rax, %rax
je 0xa14e
movq 0x18(%r13), %rdx
testq %rdx, %rdx
je 0xa379
imull $0x5f5e505, %edx, %ecx  # imm = 0x5F5E505
imulq %rax, %rcx
shrq $0x20, %rcx
movq 0x20(%r15), %rdi
movq %rcx, %rsi
movq (%rdi,%rsi,8), %r8
cmpq %rdx, %r8
je 0xa0e3
testq %r8, %r8
je 0xa14e
incq %rsi
cmpq %rax, %rsi
movl $0x0, %r8d
cmoveq %r8, %rsi
cmpq %rcx, %rsi
jne 0xa0ba
jmp 0xa14e
movq 0x28(%r15), %rax
cmpq $0x0, (%rax,%rsi,8)
je 0xa14e
movl (%r13), %edi
movq 0x18(%rsp), %rax
movq 0x18(%rax), %r9
leaq 0x796f(%rip), %rax      # 0x11a71
movq %rax, (%rsp)
leaq 0x87fb(%rip), %rsi      # 0x12908
leaq 0x8800(%rip), %rcx      # 0x12914
leaq 0x880e(%rip), %r8       # 0x12929
callq 0x9cc6
movl 0x11966(%rip), %edx     # 0x1ba8c
leaq 0x30(%rsp), %r13
movq %r13, %rdi
leaq 0x8767(%rip), %rsi      # 0x1289c
xorl %eax, %eax
callq 0x2040
incl 0x1194a(%rip)           # 0x1ba8c
movq %r13, %rdi
callq 0x8238
movq %rax, (%rbp)
movq 0x38(%r15), %rax
cmpq 0x40(%r15), %rax
je 0xa1d1
movq (%rbp), %rsi
testq %rsi, %rsi
je 0xa398
movq (%r12), %rcx
testq %rcx, %rcx
je 0xa3b7
imull $0x5f5e505, %esi, %edx  # imm = 0x5F5E505
imulq %rcx, %rdx
shrq $0x20, %rdx
movq 0x20(%r15), %rdi
movq (%rdi,%rdx,8), %r9
movq %rdx, %r8
testq %r9, %r9
je 0xa1b3
cmpq %rsi, %r9
je 0xa34c
incq %r8
cmpq %rcx, %r8
cmoveq %r14, %r8
cmpq %rdx, %r8
je 0xa1d1
movq (%rdi,%r8,8), %r9
testq %r9, %r9
jne 0xa190
jmp 0xa1b6
movq %rdx, %r8
movq %rsi, (%rdi,%r8,8)
movq 0x28(%r15), %rcx
movq %rbp, (%rcx,%r8,8)
movq 0x30(%r15), %rcx
movq %rbp, (%rcx,%rax,8)
incq %rax
movq %rax, 0x38(%r15)
addq $0x8, %rbx
cmpq 0x28(%rsp), %rbx
jne 0xa078
movq 0x18(%rsp), %rax
movq 0x40(%rax), %rax
testq %rax, %rax
je 0xa330
movq 0x18(%rsp), %rcx
movq 0x48(%rcx), %rbx
leaq (%rbx,%rax,8), %r14
xorl %ebp, %ebp
leaq 0x8721(%rip), %r13      # 0x12929
movq (%rbx), %rsi
movq (%r12), %rax
testq %rax, %rax
je 0xa29b
movq 0x18(%rsi), %rdx
testq %rdx, %rdx
je 0xa379
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 0xa25f
testq %r9, %r9
je 0xa29b
incq %rdi
cmpq %rax, %rdi
movl $0x0, %r9d
cmoveq %r9, %rdi
cmpq %rcx, %rdi
jne 0xa23a
jmp 0xa29b
movq 0x28(%r15), %rax
cmpq $0x0, (%rax,%rdi,8)
je 0xa29b
movl (%rsi), %edi
movq 0x18(%rsp), %rax
movq 0x18(%rax), %r9
leaq 0x77f5(%rip), %rax      # 0x11a71
movq %rax, (%rsp)
leaq 0x86af(%rip), %rsi      # 0x12936
leaq 0x8686(%rip), %rcx      # 0x12914
movq %r13, %r8
callq 0x9cc6
jmp 0xa323
movq 0x20(%rsp), %rdi
callq 0x9da2
movq 0x38(%r15), %rcx
cmpq 0x40(%r15), %rcx
je 0xa323
movq (%rax), %rsi
testq %rsi, %rsi
je 0xa398
movq (%r12), %rdx
testq %rdx, %rdx
je 0xa3b7
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 0xa305
cmpq %rsi, %r10
je 0xa34c
incq %r9
cmpq %rdx, %r9
cmoveq %rbp, %r9
cmpq %rdi, %r9
je 0xa323
movq (%r8,%r9,8), %r10
testq %r10, %r10
jne 0xa2e6
jmp 0xa308
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, %rbx
cmpq %r14, %rbx
jne 0xa208
leaq 0x17(%rsp), %rdi
callq 0x34e4
movq %r15, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9a4e(%rip), %rdi      # 0x13da1
xorl %eax, %eax
callq 0x2030
leaq 0x73f7(%rip), %rdi      # 0x11758
leaq 0x94b0(%rip), %rsi      # 0x13818
leaq 0x9aa1(%rip), %rcx      # 0x13e10
movl $0x53, %edx
callq 0x20b0
leaq 0x9494(%rip), %rdi      # 0x13814
leaq 0x9491(%rip), %rsi      # 0x13818
leaq 0x9a23(%rip), %rcx      # 0x13db1
movl $0x5e, %edx
callq 0x20b0
leaq 0x9475(%rip), %rdi      # 0x13814
leaq 0x9472(%rip), %rsi      # 0x13818
leaq 0x9a63(%rip), %rcx      # 0x13e10
movl $0x46, %edx
callq 0x20b0
leaq 0x99da(%rip), %rdi      # 0x13d98
leaq 0x9453(%rip), %rsi      # 0x13818
leaq 0x9a44(%rip), %rcx      # 0x13e10
movl $0x47, %edx
callq 0x20b0
leaq 0x84c3(%rip), %rdi      # 0x128a0
leaq 0x80aa(%rip), %rsi      # 0x1248e
leaq 0x84d2(%rip), %rcx      # 0x128bd
movl $0x2ad, %edx            # imm = 0x2AD
callq 0x20b0
movq %rax, %rbx
movl $0x78, %esi
movq %r15, %rdi
callq 0x2100
jmp 0xa410
jmp 0xa40d
jmp 0xa40d
jmp 0xa40d
movq %rax, %rbx
leaq 0x17(%rsp), %rdi
callq 0x34e4
movq %rbx, %rdi
callq 0x21c0