// File: /workspace/github_cpp_makefile_star2_O1/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 0x143f8(%rip), %r15     # 0x19a28
leaq 0x1(%r15), %rax
movq %rax, 0x143ed(%rip)     # 0x19a28
movq %rdi, (%rsp)
movq %r15, 0x18(%rdi)
movl $0x4, %r13d
leaq 0xba8a(%rip), %r12      # 0x110da
movq %r12, %rdi
xorl %eax, %eax
callq 0x479d
decl %r13d
jne 0x5650
leaq 0xbee8(%rip), %rdi      # 0x1154e
movq %r15, %rsi
xorl %eax, %eax
callq 0x479d
movq %r14, %rdi
callq 0x4b55
leaq 0xba5b(%rip), %rdi      # 0x110da
xorl %eax, %eax
callq 0x479d
cmpl $0x2, (%rbp)
jne 0x57b6
movq 0x18(%rbp), %rsi
leaq 0xbf3d(%rip), %rdi      # 0x115d8
xorl %eax, %eax
callq 0x479d
movq 0x18(%rbx), %rsi
cmpl $0x1, (%rbx)
leaq 0x80(%rsp), %r14
jne 0x56c3
leaq 0xc3a2(%rip), %rdi      # 0x11a5c
xorl %eax, %eax
callq 0x479d
jmp 0x56d1
leaq 0xc02e(%rip), %rdi      # 0x116f8
xorl %eax, %eax
callq 0x479d
movq 0x8(%r14), %rbp
testq %rbp, %rbp
je 0x56e8
leaq 0xd6de(%rip), %rdi      # 0x12dbf
xorl %eax, %eax
callq 0x479d
leaq 0x98(%rsp), %rax
movq 0x8(%rax), %rbx
cmpq %rbx, %rbp
jne 0x57d5
testq %rbp, %rbp
je 0x5776
movq 0x10(%r14), %r15
movq 0x10(%rax), %r12
leaq -0x1(%rbp), %r13
xorl %r14d, %r14d
movq (%r15,%r14,8), %rdi
callq 0x4b55
leaq 0xb9b9(%rip), %rdi      # 0x110da
xorl %eax, %eax
callq 0x479d
cmpq %r14, %rbx
je 0x5797
movq 0x18(%r12), %rsi
cmpl $0x1, (%r12)
jne 0x5749
leaq 0xc31c(%rip), %rdi      # 0x11a5c
xorl %eax, %eax
callq 0x479d
jmp 0x5757
leaq 0xbfa8(%rip), %rdi      # 0x116f8
xorl %eax, %eax
callq 0x479d
cmpq %r14, %r13
je 0x576a
leaq 0xd65c(%rip), %rdi      # 0x12dbf
xorl %eax, %eax
callq 0x479d
incq %r14
addq $0x20, %r12
cmpq %r14, %rbp
jne 0x5711
leaq 0xd9d6(%rip), %rdi      # 0x13153
xorl %eax, %eax
callq 0x479d
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbff8(%rip), %rdi      # 0x11796
leaq 0xbff9(%rip), %rsi      # 0x1179e
leaq 0xbffc(%rip), %rcx      # 0x117a8
movl $0x32, %edx
callq 0x20b0
leaq 0xbd9f(%rip), %rdi      # 0x1155c
leaq 0xb7c1(%rip), %rsi      # 0x10f85
leaq 0xbdae(%rip), %rcx      # 0x11579
movl $0x19b, %edx            # imm = 0x19B
callq 0x20b0
leaq 0xbe07(%rip), %rdi      # 0x115e3
leaq 0xb7a2(%rip), %rsi      # 0x10f85
leaq 0xbd8f(%rip), %rcx      # 0x11579
movl $0x1a4, %edx            # imm = 0x1A4
callq 0x20b0