// File: /workspace/github_c_makefile_star2_O1/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, %r14
movq %rsi, %r15
movq %rdi, 0x8(%rsp)
movq 0x58(%rsp), %r13
movq 0x50(%rsp), %rbx
testl %ecx, %ecx
jne 0xa48e
movl %r9d, %ebp
movq %r15, %rdi
callq 0xee80
movl $0x3, %ecx
testl %eax, %eax
jne 0xa48e
testl %ebp, %ebp
je 0xa6bd
movl $0x3, %ecx
cmpl $0x1, %ecx
je 0xa4ec
cmpl $0x2, %ecx
jne 0xa53b
movq (%r13), %rax
leaq 0x39d79(%rip), %rcx     # 0x44220
movl (%rcx,%rax,8), %ebp
movl 0x4(%r14), %edi
callq 0xa88e
movl %ebp, %edi
movl %eax, %esi
callq 0xac01
movq %rax, %r15
movl (%r14), %eax
cmpl $0x2, %eax
je 0xa64f
cmpl $0x5, %eax
movq 0x8(%rsp), %rbx
je 0xa654
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8f8a
movq %rax, %r14
jmp 0xa654
movq (%rbx), %rax
leaq 0x39cea(%rip), %rcx     # 0x441e0
movl (%rcx,%rax,8), %ebp
movl 0x4(%r14), %edi
callq 0xa855
movl %ebp, %edi
movl %eax, %esi
callq 0xac01
movq %rax, %r15
movl (%r14), %eax
cmpl $0x2, %eax
je 0xa676
cmpl $0x5, %eax
movq 0x8(%rsp), %r12
je 0xa67b
movq %r12, %rdi
movq %r14, %rsi
callq 0x8f8a
movq %rax, %r14
jmp 0xa67b
movq 0x60(%rsp), %rbx
movq %r15, %rdi
callq 0xee80
testl %eax, %eax
je 0xa5b7
movl $0x4, %edi
callq 0xaa0e
movq %rax, %r13
movq %r12, 0x10(%rsp)
movq 0x8(%rsp), %r12
movq %r12, %rdi
movl $0x5, %esi
movq %r14, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x8eb0
movq %r15, %rdi
callq 0x1e5d4
movq %rax, %rdi
callq 0x1282d
movq %rax, %r14
movq (%rbx), %rbp
movq %r15, %rdi
callq 0x1281a
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq %rax, %r8
movq %r14, %r9
callq 0x93b8
jmp 0xa645
movq (%rbx), %rdi
movl 0x4(%r14), %ecx
movq %r12, %rsi
xorl %edx, %edx
callq 0xaaa7
movq %rax, %r12
movl (%r14), %eax
cmpl $0x2, %eax
je 0xa5e8
cmpl $0x5, %eax
je 0xa5e8
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x8f8a
movq %rax, %r14
movl (%r14), %eax
cmpl $0x2, %eax
je 0xa5f9
cmpl $0x5, %eax
jne 0xa6ff
cmpl $0x2, (%r12)
movq %r12, %r13
jne 0xa617
movl 0x4(%r12), %ecx
xorl %edi, %edi
movq %r12, %rsi
xorl %edx, %edx
callq 0xaaa7
movq %rax, %r13
movl 0x4(%r12), %edi
callq 0xa8d7
testl %eax, %eax
movl $0x1, %eax
movl $0x27, %esi
cmovel %eax, %esi
movq 0x8(%rsp), %rdi
movq %r14, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x8eb0
movq %r15, %rdi
callq 0x1281a
jmp 0xa6ab
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x1, %esi
movq %r14, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x8eb0
movl $0x1, %eax
movq %r13, %rbx
jmp 0xa6ab
movq 0x8(%rsp), %r12
movl 0x4(%r14), %edi
callq 0xa8d7
testl %eax, %eax
movl $0x1, %eax
movl $0x27, %esi
cmovel %eax, %esi
movq %r12, %rdi
movq %r14, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x8eb0
movl $0x1, %eax
addq %rax, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%r14), %edi
callq 0xa8d7
testl %eax, %eax
je 0xa6d9
movl $0x1, %ecx
cmpq $0x8, (%rbx)
jb 0xa48e
movl 0x4(%r14), %edi
callq 0xa8cc
testl %eax, %eax
je 0xa489
movl $0x2, %ecx
cmpq $0x6, (%r13)
jae 0xa489
jmp 0xa48e
leaq 0x26486(%rip), %rdi     # 0x30b8c
leaq 0x26359(%rip), %rsi     # 0x30a66
leaq 0x2649f(%rip), %rcx     # 0x30bb3
movl $0x11e, %edx            # imm = 0x11E
callq 0x4180