// File: /workspace/github_cpp_makefile_star2_O2/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
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %r12
andl $0x0, 0x10(%rdi)
movl $0x2, (%rdi)
movq 0x13b45(%rip), %r15     # 0x18a28
leaq 0x1(%r15), %rax
movq %rax, 0x13b3a(%rip)     # 0x18a28
movq %r15, 0x18(%rdi)
callq 0x44e4
leaq 0xa5a0(%rip), %rdi      # 0xf49e
movq %r15, %rsi
xorl %eax, %eax
callq 0x42fe
movq %r14, %rdi
callq 0x465e
leaq 0xa113(%rip), %rdi      # 0xf02a
xorl %eax, %eax
callq 0x42fe
cmpl $0x2, 0x80(%rsp)
jne 0x502e
leaq 0xb8(%rsp), %r14
leaq 0xa0(%rsp), %r15
leaq 0x80(%rsp), %rax
leaq 0x60(%rsp), %rbx
movq 0x18(%rax), %rsi
leaq 0xa5d4(%rip), %rdi      # 0xf528
xorl %eax, %eax
callq 0x42fe
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
xorl %edi, %edi
callq 0x442e
movq 0x8(%r15), %rbx
testq %rbx, %rbx
je 0x4f89
leaq 0xbd9e(%rip), %rdi      # 0x10d20
xorl %eax, %eax
callq 0x42fe
movq %r12, 0x20(%rsp)
cmpq 0x8(%r14), %rbx
jne 0x504d
leaq 0xa08b(%rip), %r12      # 0xf02a
leaq 0xbd7a(%rip), %r13      # 0x10d20
xorl %ebp, %ebp
cmpq %rbx, %rbp
je 0x500c
movq %r15, %rdi
movq %rbp, %rsi
callq 0x546e
movq (%rax), %rdi
callq 0x465e
movq %r12, %rdi
xorl %eax, %eax
callq 0x42fe
movq %r14, %rdi
movq %rbp, %rsi
callq 0x549e
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
xorl %edi, %edi
callq 0x442e
movq 0x8(%r15), %rbx
leaq -0x1(%rbx), %rax
cmpq %rax, %rbp
je 0x5007
movq %r13, %rdi
xorl %eax, %eax
callq 0x42fe
movq 0x8(%r15), %rbx
incq %rbp
jmp 0x4fa8
leaq 0xc0a1(%rip), %rdi      # 0x110b4
xorl %eax, %eax
callq 0x42fe
movq 0x20(%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa477(%rip), %rdi      # 0xf4ac
leaq 0x9e99(%rip), %rsi      # 0xeed5
leaq 0xa486(%rip), %rcx      # 0xf4c9
movl $0x19b, %edx            # imm = 0x19B
callq 0x20b0
leaq 0xa4df(%rip), %rdi      # 0xf533
leaq 0x9e7a(%rip), %rsi      # 0xeed5
leaq 0xa467(%rip), %rcx      # 0xf4c9
movl $0x1a4, %edx            # imm = 0x1A4
callq 0x20b0