// File: /workspace/github_cpp_makefile_star2_O3/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 0x34c8
cmpq $0x0, 0x18(%rbx)
je 0xa257
callq 0x34ef
movl (%rbx), %edi
movq 0x18(%rbx), %rdx
leaq 0x9a15(%rip), %rsi      # 0x13864
callq 0x9942
movl $0x78, %edi
movl $0x3, %esi
callq 0x23ef
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 0xfb16
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 0x8eae
movq %rax, 0x8(%r15)
movq %rbx, 0x18(%rsp)
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0xa064
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 0x9c28
movq %rax, %rbp
movq (%r12), %rax
testq %rax, %rax
je 0x9fde
movq 0x18(%r13), %rdx
testq %rdx, %rdx
je 0xa1fa
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 0x9f71
testq %r8, %r8
je 0x9fde
incq %rsi
cmpq %rax, %rsi
movl $0x0, %r8d
cmoveq %r8, %rsi
cmpq %rcx, %rsi
jne 0x9f48
jmp 0x9fde
movq 0x28(%r15), %rax
cmpq $0x0, (%rax,%rsi,8)
je 0x9fde
movl (%r13), %edi
movq 0x18(%rsp), %rax
movq 0x18(%rax), %r9
leaq 0x89c1(%rip), %rax      # 0x12951
movq %rax, (%rsp)
leaq 0x98dd(%rip), %rsi      # 0x13878
leaq 0x98e2(%rip), %rcx      # 0x13884
leaq 0x98f0(%rip), %r8       # 0x13899
callq 0x9b47
movl 0x12ad8(%rip), %edx     # 0x1ca8c
leaq 0x30(%rsp), %r13
movq %r13, %rdi
leaq 0x9849(%rip), %rsi      # 0x1380c
xorl %eax, %eax
callq 0x2040
incl 0x12abc(%rip)           # 0x1ca8c
movq %r13, %rdi
callq 0x8130
movq %rax, (%rbp)
jmp 0x9fe2
movq (%rbp), %rax
movq 0x38(%r15), %rcx
cmpq 0x40(%r15), %rcx
je 0xa055
testq %rax, %rax
je 0xa219
movq (%r12), %rdx
testq %rdx, %rdx
je 0xa238
imull $0x5f5e505, %eax, %esi  # imm = 0x5F5E505
imulq %rdx, %rsi
shrq $0x20, %rsi
movq 0x20(%r15), %r8
movq %rsi, %rdi
movq (%r8,%rdi,8), %r9
testq %r9, %r9
je 0xa03a
cmpq %rax, %r9
je 0xa1c1
incq %rdi
cmpq %rdx, %rdi
cmoveq %r14, %rdi
cmpq %rsi, %rdi
jne 0xa017
jmp 0xa055
movq %rax, (%r8,%rdi,8)
movq 0x28(%r15), %rax
movq %rbp, (%rax,%rdi,8)
movq 0x30(%r15), %rax
movq %rbp, (%rax,%rcx,8)
incq %rcx
movq %rcx, 0x38(%r15)
addq $0x8, %rbx
cmpq 0x28(%rsp), %rbx
jne 0x9f06
movq 0x18(%rsp), %rax
movq 0x40(%rax), %rax
testq %rax, %rax
je 0xa1a5
movq 0x18(%rsp), %rcx
movq 0x48(%rcx), %rbx
leaq (%rbx,%rax,8), %r14
xorl %ebp, %ebp
leaq 0x980d(%rip), %r13      # 0x13899
movq (%rbx), %rsi
movq (%r12), %rax
testq %rax, %rax
je 0xa11c
movq 0x18(%rsi), %rdx
testq %rdx, %rdx
je 0xa1fa
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 0xa0e3
testq %r9, %r9
je 0xa11c
incq %rdi
cmpq %rax, %rdi
movl $0x0, %r9d
cmoveq %r9, %rdi
cmpq %rcx, %rdi
jne 0xa0be
jmp 0xa11c
movq 0x28(%r15), %rax
cmpq $0x0, (%rax,%rdi,8)
je 0xa11c
movl (%rsi), %edi
movq 0x18(%rsp), %rax
movq 0x18(%rax), %r9
leaq 0x8851(%rip), %rax      # 0x12951
movq %rax, (%rsp)
leaq 0x979b(%rip), %rsi      # 0x138a6
leaq 0x9772(%rip), %rcx      # 0x13884
movq %r13, %r8
callq 0x9b47
jmp 0xa198
movq 0x20(%rsp), %rdi
callq 0x9c28
movq 0x38(%r15), %rcx
cmpq 0x40(%r15), %rcx
je 0xa198
movq (%rax), %rsi
testq %rsi, %rsi
je 0xa219
movq (%r12), %rdx
testq %rdx, %rdx
je 0xa238
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 0xa17d
cmpq %rsi, %r10
je 0xa1cd
incq %r8
cmpq %rdx, %r8
cmoveq %rbp, %r8
cmpq %rdi, %r8
jne 0xa15e
jmp 0xa198
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, %rbx
cmpq %r14, %rbx
jne 0xa08c
leaq 0x17(%rsp), %rdi
callq 0x34dc
movq %r15, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xab5c(%rip), %rdi      # 0x14d24
movq %rax, %rsi
jmp 0xa1d4
leaq 0xab50(%rip), %rdi      # 0x14d24
xorl %eax, %eax
callq 0x2030
leaq 0x84c0(%rip), %rdi      # 0x126a2
leaq 0xa5a0(%rip), %rsi      # 0x14789
leaq 0xaba3(%rip), %rcx      # 0x14d93
movl $0x53, %edx
callq 0x20b0
leaq 0xa584(%rip), %rdi      # 0x14785
leaq 0xa581(%rip), %rsi      # 0x14789
leaq 0xab25(%rip), %rcx      # 0x14d34
movl $0x5e, %edx
callq 0x20b0
leaq 0xa565(%rip), %rdi      # 0x14785
leaq 0xa562(%rip), %rsi      # 0x14789
leaq 0xab65(%rip), %rcx      # 0x14d93
movl $0x46, %edx
callq 0x20b0
leaq 0xaadc(%rip), %rdi      # 0x14d1b
leaq 0xa543(%rip), %rsi      # 0x14789
leaq 0xab46(%rip), %rcx      # 0x14d93
movl $0x47, %edx
callq 0x20b0
leaq 0x95b2(%rip), %rdi      # 0x13810
leaq 0x9199(%rip), %rsi      # 0x133fe
leaq 0x95c1(%rip), %rcx      # 0x1382d
movl $0x2ad, %edx            # imm = 0x2AD
callq 0x20b0
movq %rax, %rbx
movl $0x78, %esi
movq %r15, %rdi
callq 0x2100
jmp 0xa291
jmp 0xa28e
jmp 0xa28e
jmp 0xa28e
movq %rax, %rbx
leaq 0x17(%rsp), %rdi
callq 0x34dc
movq %rbx, %rdi
callq 0x21c0
nop