// File: /workspace/github_c_makefile_star2_O1/Encryptr[P]O-plus-plus/opp/compiler/compile_stmt.c
// Function: opp_compile_call
Opp_Obj opp_compile_call(struct Opp_Context* opp, struct Opp_Node* call, bool stmt)
{
	assert(call->call_expr.callee->type != EDOT);

	if (call->call_expr.callee->type == EUNARY) {
		struct Opp_Bucket* b = call->call_expr.callee->unary_expr.bidx;

		for (int i = call->call_expr.args->length-1; i >= 0; i--) {
			Opp_Obj t = opp_compile_expr(opp, call->call_expr.args->list[i]);

			opp_type_cast(opp, &b->args->args[i].var_stmt.type, &t);
		}
		
		OPCODE_START();
			OPCODE_TYPE(OPCODE_MOV_ARG);
			opp->ir.opcodes[opp->ir.instr_idx].arg.stop = true;
		OPCODE_END();

		int Iidx = 0;
		int Fidx = 0;
		for (int i = 0; i < call->call_expr.args->length; i++) {
			int idx = 0;

			if ((b->args->args[i].var_stmt.type.decl->t_type == TYPE_FLOAT || 
				b->args->args[i].var_stmt.type.decl->t_type == TYPE_DOUBLE) &&
				b->args->args[i].var_stmt.type.depth == 0)
				idx = Fidx++;
			else
				idx = Iidx++;


			OPCODE_START();
				OPCODE_TYPE(OPCODE_MOV_ARG);
				opp->ir.opcodes[opp->ir.instr_idx].arg.idx = idx;
				opp->ir.opcodes[opp->ir.instr_idx].arg.type = 
					opp_type_to_ir(&b->args->args[i].var_stmt.type);
			OPCODE_END();
		}

		OPCODE_START();
			OPCODE_TYPE(OPCODE_CALL);
			opp->ir.opcodes[opp->ir.instr_idx].call.name = 
				call->call_expr.callee->unary_expr.val.strval;
			opp->ir.opcodes[opp->ir.instr_idx].call.imm = 1;
			if (b->sym_type.decl->t_type == TYPE_VOID) {
				opp->ir.opcodes[opp->ir.instr_idx].call.ret = 0;
			}
			else {
				opp->ir.opcodes[opp->ir.instr_idx].call.ret = stmt;
				opp->ir.opcodes[opp->ir.instr_idx].call.ret_type = 
					opp_type_to_ir(&b->sym_type);
			}
			opp->ir.opcodes[opp->ir.instr_idx].call.extra_args = 
				call->call_expr.args->length;
		OPCODE_END();

		return b->sym_type;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0x10(%rsi), %rax
movl (%rax), %ecx
cmpl $0x5, %ecx
je 0x5365
cmpl $0xd, %ecx
je 0x556d
jmp 0x555e
movq %rsi, %rbp
movq %rdi, %rbx
movl %edx, 0x4(%rsp)
movq 0x20(%rax), %r12
movq 0x18(%rsi), %rax
movl (%rax), %eax
decl %eax
js 0x53d3
movl %eax, %r14d
leaq (%r14,%r14,8), %rax
incq %r14
leaq 0x10(,%rax,8), %r13
leaq 0x18(%rsp), %r15
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rax,%r14,8), %rsi
movq %rbx, %rdi
callq 0x3c28
movq %rax, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
movq 0x28(%r12), %rax
movq 0x28(%rax), %rsi
addq %r13, %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x3929
addq $-0x48, %r13
decq %r14
jg 0x5394
movq %rbx, %rdi
callq 0x385b
movq 0x48(%rbx), %rax
movq 0x58(%rbx), %rcx
leaq (%rax,%rax,4), %rax
movl $0x4, (%rcx,%rax,8)
movb $0x1, 0x10(%rcx,%rax,8)
incq 0x48(%rbx)
movq %rbp, 0x10(%rsp)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x54b9
xorl %r15d, %r15d
movl $0x10, %r13d
movq $0x0, 0x8(%rsp)
xorl %ebp, %ebp
movq 0x28(%r12), %rax
movq 0x28(%rax), %rax
movq (%rax,%r13), %rcx
movl 0x8(%rcx), %ecx
addl $-0x5, %ecx
cmpl $0x1, %ecx
ja 0x543e
cmpw $0x0, 0x8(%rax,%r13)
je 0x54a6
leal 0x1(%rbp), %r14d
movq %rbx, %rdi
callq 0x385b
movq 0x48(%rbx), %rax
movq 0x58(%rbx), %rcx
leaq (%rax,%rax,4), %rax
movl $0x4, (%rcx,%rax,8)
movl %ebp, 0xc(%rcx,%rax,8)
movq 0x28(%r12), %rax
movq 0x28(%rax), %rdi
addq %r13, %rdi
callq 0x38a4
movq 0x48(%rbx), %rcx
movq 0x58(%rbx), %rdx
leaq (%rcx,%rcx,4), %rcx
movl %eax, 0x8(%rdx,%rcx,8)
incq 0x48(%rbx)
incq %r15
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
addq $0x48, %r13
movl %r14d, %ebp
cmpq %rax, %r15
jb 0x541d
jmp 0x54b9
movl %ebp, %r14d
movq 0x8(%rsp), %rax
movl %eax, %ebp
incl %eax
movq %rax, 0x8(%rsp)
jmp 0x5442
movq %rbx, %rdi
callq 0x385b
movq 0x48(%rbx), %rax
movq 0x58(%rbx), %rcx
leaq (%rax,%rax,4), %rax
movl $0x1, (%rcx,%rax,8)
movq 0x10(%rsp), %r14
movq 0x10(%r14), %rdx
movq 0x18(%rdx), %rdx
movq %rdx, 0x18(%rcx,%rax,8)
movq 0x48(%rbx), %rax
movq 0x58(%rbx), %rcx
leaq (%rax,%rax,4), %rax
movb $0x1, 0xc(%rcx,%rax,8)
movq 0x10(%r12), %rax
cmpl $0x0, 0x8(%rax)
movq 0x48(%rbx), %rax
movq 0x58(%rbx), %rcx
leaq (%rax,%rax,4), %rax
leaq 0x8(%rcx,%rax,8), %rax
je 0x5536
leaq 0x10(%r12), %rdi
movl 0x4(%rsp), %ecx
movb %cl, 0x5(%rax)
callq 0x38a4
movq 0x48(%rbx), %rcx
movq 0x58(%rbx), %rdx
leaq (%rcx,%rcx,4), %rcx
movl %eax, 0x8(%rdx,%rcx,8)
jmp 0x553a
movb $0x0, 0x5(%rax)
movq 0x18(%r14), %rax
movl (%rax), %eax
movq 0x48(%rbx), %rcx
movq 0x58(%rbx), %rdx
leaq (%rcx,%rcx,4), %rcx
movl %eax, 0x10(%rdx,%rcx,8)
incq 0x48(%rbx)
movq 0x10(%r12), %rax
movq 0x18(%r12), %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6c64(%rip), %rdi      # 0xc1d8
leaq 0x6c82(%rip), %rsi      # 0xc1fd
leaq 0x6c97(%rip), %rcx      # 0xc219
movl $0x55, %edx
callq 0x1100