// File: /workspace/github_cpp_makefile_star2_O3/baziotis[P]minijava-cpp/llvm.cpp
// Function: llvm_call(Type*, Type*, llvalue_t, llvalue_t, Array<Type*, (MEM)4>, Array<llvalue_t, (MEM)4>)
llvalue_t llvm_call(Type *ret_type, Type *base_obj_ty, llvalue_t base_obj,
                    llvalue_t vmethod, FuncArr<Type*> types,
                    FuncArr<llvalue_t> values)
{
    llvalue_t v;
    v.kind = LLVALUE::REG;
    v.reg = gen_reg();
    print_codegen_indentation();
    emit("%%%ld = call ", v.reg);
    // Print the return type
    cgen_print_lltype(ret_type);
    emit(" ");  // space
    assert(vmethod.kind == LLVALUE::REG);
    // Print the register that points to the vmethod
    emit("%%%ld(i8* ", vmethod.reg);
    cgen_print_llvalue(base_obj);
    if (types.len) {
      emit(", ");
    }
    // Print the types of args along with the args themselves
    // as a comma-separate list
    assert(types.len == values.len);
    for (size_t i = 0; i != types.len; ++i) {
        cgen_print_lltype(types[i]);
        emit(" ");  // space
        cgen_print_llvalue(values[i]);
        if (i != types.len - 1) {
            emit(", ");
        }
    }
    emit(")\n");
    return v;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
leaq 0x60(%rsp), %rbp
leaq 0x40(%rsp), %rbx
movl $0x0, 0x10(%rdi)
movl $0x2, (%rdi)
movq 0x153df(%rip), %r15     # 0x1aa28
leaq 0x1(%r15), %rax
movq %rax, 0x153d4(%rip)     # 0x1aa28
movq %rdi, (%rsp)
movq %r15, 0x18(%rdi)
movl $0x4, %r13d
leaq 0xc9ed(%rip), %r12      # 0x12056
movq %r12, %rdi
xorl %eax, %eax
callq 0x47a5
decl %r13d
jne 0x5669
leaq 0xce4b(%rip), %rdi      # 0x124ca
movq %r15, %rsi
xorl %eax, %eax
callq 0x47a5
movq %r14, %rdi
callq 0x4b5d
leaq 0xc9be(%rip), %rdi      # 0x12056
xorl %eax, %eax
callq 0x47a5
cmpl $0x2, (%rbp)
jne 0x57b7
movq 0x18(%rbp), %rsi
leaq 0xcea0(%rip), %rdi      # 0x12554
xorl %eax, %eax
callq 0x47a5
movq 0x18(%rbx), %rsi
cmpl $0x1, (%rbx)
jne 0x56d4
leaq 0xd271(%rip), %rdi      # 0x1293c
xorl %eax, %eax
callq 0x47a5
jmp 0x56e2
leaq 0xcf67(%rip), %rdi      # 0x12642
xorl %eax, %eax
callq 0x47a5
leaq 0x80(%rsp), %rbx
movq 0x8(%rbx), %rbp
testq %rbp, %rbp
je 0x5788
leaq 0xe632(%rip), %rdi      # 0x13d30
xorl %eax, %eax
callq 0x47a5
leaq 0x98(%rsp), %rax
cmpq 0x8(%rax), %rbp
jne 0x57d6
movq 0x10(%rbx), %rbx
movq 0x10(%rax), %r15
leaq 0xc930(%rip), %r14      # 0x12056
leaq 0xcf15(%rip), %r13      # 0x12642
xorl %r12d, %r12d
movq (%rbx,%r12), %rdi
callq 0x4b5d
movq %r14, %rdi
xorl %eax, %eax
callq 0x47a5
movq 0x18(%r15,%r12,4), %rsi
cmpl $0x1, (%r15,%r12,4)
jne 0x575f
leaq 0xd1e6(%rip), %rdi      # 0x1293c
xorl %eax, %eax
callq 0x47a5
jmp 0x5769
movq %r13, %rdi
xorl %eax, %eax
callq 0x47a5
cmpq $0x1, %rbp
je 0x577d
leaq 0xe5ba(%rip), %rdi      # 0x13d30
xorl %eax, %eax
callq 0x47a5
addq $0x8, %r12
decq %rbp
jne 0x5730
jmp 0x5796
leaq 0x98(%rsp), %rax
cmpq 0x8(%rax), %rbp
jne 0x57d6
leaq 0xe927(%rip), %rdi      # 0x140c4
xorl %eax, %eax
callq 0x47a5
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcd1a(%rip), %rdi      # 0x124d8
leaq 0xc73c(%rip), %rsi      # 0x11f01
leaq 0xcd29(%rip), %rcx      # 0x124f5
movl $0x19b, %edx            # imm = 0x19B
callq 0x20b0
leaq 0xcd82(%rip), %rdi      # 0x1255f
leaq 0xc71d(%rip), %rsi      # 0x11f01
leaq 0xcd0a(%rip), %rcx      # 0x124f5
movl $0x1a4, %edx            # imm = 0x1A4
callq 0x20b0