// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/6/isel.c
// Function: placearg
static void
placearg(Isel *s, Node *argn, Loc *argloc, PassIn p, Loc *rsp, int vararg, size_t *nfloats, size_t *nints, size_t *argoff)
{
	/*
	   placearg may be called when argn is stored at argloc, but it may also
	   be called when argloc is a small piece of argn, as in the case when
	   small structs are being passed. In those circumstances, p is PassInSSE
	   or PassInInt, and argn is irrelevant. Therefore, argn should not be
	   relied on when p is PassInSSE or PassInInt.
	 */
	Loc *src, *dst;
	size_t a;

	if (p == PassInNoPref) {
		if (stacknode(argn)) {
			p = PassInMemory;
		} else if (!vararg && isfloatmode(argloc->mode) && *nfloats < Nfloatregargs) {
			p = PassInSSE;
		} else if (!vararg && isintmode(argloc->mode) && *nints < Nintregargs) {
			p = PassInInt;
		} else {
			p = PassInMemory;
		}
	}

	switch (p) {
	case PassInMemory:
		if (stacknode(argn)) {
			src = locreg(ModeQ);
			g(s, Ilea, argloc, src, NULL);
			a = tyalign(exprtype(argn));
			blit(s, rsp, src, *argoff, 0, size(argn), a);
			*argoff += size(argn);
		} else {
			dst = locmem(*argoff, rsp, NULL, argloc->mode);
			argloc = inri(s, argloc);
			stor(s, argloc, dst);
			*argoff += size(argn);
		}
		break;
	case PassInSSE:
		dst = coreg(floatargregs[*nfloats], forcefltmode(argloc->mode));
		argloc = inri(s, argloc);
		if (isfloatmode(argloc->mode)) {
			g(s, Imovs, argloc, dst, NULL);
		} else {
			g(s, Imov, argloc, dst, NULL);
		}
		(*nfloats)++;
		break;
	case PassInInt:
		dst = coreg(intargregs[*nints], forceintmode(argloc->mode));
		argloc = inri(s, argloc);
		g(s, Imov, argloc, dst, NULL);
		(*nints)++;
		break;
	case PassInNoPref: /* impossible */
		die("cannot determine how to pass arg");
		break;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r12
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
movq 0x58(%rsp), %r13
movq 0x50(%rsp), %rbx
movl %ecx, %eax
leaq 0x230aa(%rip), %rcx     # 0x2c96c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %r9d, %ebp
movq %r14, %rdi
callq 0xd8a8
orl %ebp, %eax
je 0x9aa7
movq 0x60(%rsp), %rbx
movq %r14, %rdi
callq 0xd8a8
testl %eax, %eax
je 0x9a11
pushq $0x4
popq %rdi
callq 0x9da2
movq %rax, %r13
pushq $0x5
popq %rsi
movq %r12, 0x10(%rsp)
movq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x8633
movq %r14, %rdi
callq 0x1bf90
movq %rax, %rdi
callq 0x10f67
movq %rax, %r15
movq (%rbx), %rbp
movq %r14, %rdi
callq 0x10f54
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq %rax, %r8
movq %r15, %r9
callq 0x8a0d
jmp 0x9a8d
movq (%rbx), %rax
leaq 0x3787c(%rip), %rcx     # 0x411e0
movl (%rcx,%rax,8), %ebp
movl 0x4(%r15), %edi
callq 0x9c37
movl %ebp, %edi
movl %eax, %esi
callq 0x9f13
movq %rax, %r14
movq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x8911
movq %rax, %r15
movl 0x4(%rax), %edi
callq 0x9cab
testl %eax, %eax
pushq $0x1
popq %rax
pushq $0x27
popq %rsi
cmovel %eax, %esi
movq %r12, %rdi
movq %r15, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x8633
pushq $0x1
popq %rax
jmp 0x9a95
movq (%r13), %rax
leaq 0x37858(%rip), %rcx     # 0x41220
movl (%rcx,%rax,8), %ebp
movl 0x4(%r15), %edi
callq 0x9c6a
movl %ebp, %edi
movl %eax, %esi
callq 0x9f13
movq %rax, %r14
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8911
pushq $0x1
popq %rsi
movq %rbx, %rdi
movq %rax, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x8633
pushq $0x1
popq %rax
movq %r13, %rbx
jmp 0x9a95
movq (%rbx), %rdi
movl 0x4(%r15), %ecx
movq %r12, %rsi
xorl %edx, %edx
callq 0x9e39
movq %rax, %r12
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x8911
movq %rax, %r15
movl (%rax), %eax
cmpl $0x2, %eax
je 0x9a45
cmpl $0x5, %eax
jne 0x9ae5
cmpl $0x2, (%r12)
movq %r12, %r13
jne 0x9a63
movl 0x4(%r12), %ecx
xorl %edi, %edi
movq %r12, %rsi
xorl %edx, %edx
callq 0x9e39
movq %rax, %r13
movl 0x4(%r12), %edi
callq 0x9cab
testl %eax, %eax
pushq $0x1
popq %rax
pushq $0x27
popq %rsi
cmovel %eax, %esi
movq 0x8(%rsp), %rdi
movq %r15, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x8633
movq %r14, %rdi
callq 0x10f54
addq %rax, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%r15), %edi
callq 0x9cab
testl %eax, %eax
je 0x9ac1
movq (%rbx), %rax
cmpq $0x8, %rax
jb 0x995d
movl 0x4(%r15), %edi
callq 0x9ca0
testl %eax, %eax
je 0x98de
movq (%r13), %rax
cmpq $0x6, %rax
jae 0x98de
jmp 0x99c1
leaq 0x230b0(%rip), %rdi     # 0x2cb9c
leaq 0x22f83(%rip), %rsi     # 0x2ca76
leaq 0x230c9(%rip), %rcx     # 0x2cbc3
movl $0x11e, %edx            # imm = 0x11E
callq 0x4180