// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/6/isel.c
// Function: addarglocs
void
addarglocs(Isel *s, Func *fn)
{
	size_t i, nints, nfloats, nargs;
	size_t argoff;
	int vararg;
	Node *arg;
	Type *t;

	argoff = 0;
	nfloats = 0;
	nints = 0;
	vararg = 0;
	nargs = countargs(fn->type);
	for (i = 0; i < fn->nargs; i++) {
		arg = fn->args[i];
		t = decltype(arg);
		argoff = alignto(argoff, t);
		ArgType a = ArgBig;
		Loc *l = NULL;
		if (i >= nargs)
			vararg = 1;
		else
			argoff = align(argoff, 8);

		if (!vararg) {
			a = classify(t);
		}

		if (!sufficientregs(a, nfloats, nints)) {
			a = ArgBig;
		}

		switch(a) {
		case ArgVoid:
			break;
		case ArgReg:
		case ArgBig:
			/* retrievearg can figure this out */
			retrievearg(s, arg, vararg, &nfloats, &nints, &argoff);
			break;
		case ArgAggrI:
			l = loc(s, arg);
			movearg(s, l, PassInInt, ModeQ, &nfloats, &nints, &argoff);
			break;
		case ArgAggrF:
			l = loc(s, arg);
			movearg(s, l, PassInSSE, ModeD, &nfloats, &nints, &argoff);
			break;
		case ArgAggrII:
			l = loc(s, arg);
			movearg(s,          l , PassInInt, ModeQ, &nfloats, &nints, &argoff);
			movearg(s, plus8(s, l), PassInInt, ModeQ, &nfloats, &nints, &argoff);
			break;
		case ArgAggrIF:
			l = loc(s, arg);
			movearg(s,          l , PassInInt, ModeQ, &nfloats, &nints, &argoff);
			movearg(s, plus8(s, l), PassInSSE, ModeD, &nfloats, &nints, &argoff);
			break;
		case ArgAggrFI:
			l = loc(s, arg);
			movearg(s,          l , PassInSSE, ModeD, &nfloats, &nints, &argoff);
			movearg(s, plus8(s, l), PassInInt, ModeQ, &nfloats, &nints, &argoff);
			break;
		case ArgAggrFF:
			l = loc(s, arg);
			movearg(s,          l , PassInSSE, ModeD, &nfloats, &nints, &argoff);
			movearg(s, plus8(s, l), PassInSSE, ModeD, &nfloats, &nints, &argoff);
			break;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, 0x10(%rsp)
leaq 0x18(%rsp), %rax
andq $0x0, (%rax)
leaq 0x20(%rsp), %rax
andq $0x0, (%rax)
movq 0x10(%rsi), %rdi
callq 0x11211
movq %rax, 0x30(%rsp)
xorl %r12d, %r12d
movl $0x0, 0x2c(%rsp)
xorl %r13d, %r13d
movq %rbx, 0x8(%rsp)
cmpq 0x20(%rbx), %r13
jae 0x8eb2
movq 0x18(%rbx), %rax
movq (%rax,%r13,8), %r15
movq %r15, %rdi
callq 0x1bf2d
movq %rax, %rbp
movq %r12, %rdi
movq %rax, %rsi
callq 0xd890
movq %rax, %r12
cmpq 0x30(%rsp), %r13
jae 0x8c03
movq %r12, %rdi
pushq $0x8
popq %rsi
callq 0x2ac13
movq %rax, %r12
xorl %r14d, %r14d
cmpl $0x0, 0x2c(%rsp)
jne 0x8c0d
movq %rbp, %rdi
callq 0x11260
movb $0x1, %r14b
movl $0x0, 0x2c(%rsp)
jmp 0x8c10
xorl %r14d, %r14d
pushq $0x1
popq %rax
movl %eax, 0x2c(%rsp)
pushq $0x8
popq %rax
movq 0x18(%rsp), %rbx
movq 0x20(%rsp), %rbp
movl %eax, %eax
leaq 0x23d8d(%rip), %rcx     # 0x2c9b0
movslq 0x4(%rcx,%rax,8), %rcx
addq %rbx, %rcx
cmpq $0x8, %rcx
ja 0x8c49
leaq 0x23d78(%rip), %rcx     # 0x2c9b0
movslq (%rcx,%rax,8), %rcx
addq %rbp, %rcx
cmpq $0x6, %rcx
jbe 0x8ccd
movq %r15, %rdi
callq 0xd8a8
testl %eax, %eax
je 0x8c7c
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rdi
pushq $-0x10
popq %rdx
subq %r12, %rdx
movq %r15, %rsi
callq 0x2a22a
movq %r15, %rdi
callq 0x10f54
addq %rax, %r12
jmp 0x8ea5
testb %r14b, %r14b
je 0x8d7a
movq %r15, %rdi
callq 0x8769
movl %eax, %edi
callq 0x9cab
cmpq $0x7, %rbx
ja 0x8d08
testl %eax, %eax
je 0x8d08
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8925
movq %rax, %rbp
movq %r15, %rdi
callq 0x8769
movl %eax, %edi
callq 0x9c37
movq %rbx, %rdi
movq %rbp, %rsi
pushq $0x1
jmp 0x8d54
decl %eax
cmpl $0x7, %eax
ja 0x8ea5
leaq 0x23c4d(%rip), %rcx     # 0x2c92c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8925
movq %rbx, %rdi
movq %rax, %rsi
pushq $0x2
popq %rdx
pushq $0x4
jmp 0x8dd3
movq %r15, %rdi
callq 0x8769
movl %eax, %edi
callq 0x9ca0
testl %eax, %eax
setne %al
cmpq $0x6, %rbp
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x8d7a
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8925
movq %rax, %rbp
movq %r15, %rdi
callq 0x8769
movl %eax, %edi
callq 0x9c6a
movq %rbx, %rdi
movq %rbp, %rsi
pushq $0x2
popq %rdx
movl %eax, %ecx
leaq 0x18(%rsp), %r8
leaq 0x20(%rsp), %r9
callq 0x8ec1
movq 0x48(%rbx), %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2a22a
jmp 0x8ea5
movq %r15, %rdi
callq 0x1bf2d
movq %rax, %rdi
callq 0x1fcd8
cmpl $0x1, (%rax)
jne 0x8c55
jmp 0x8ea5
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8925
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
pushq $0x2
popq %rdx
pushq $0x4
jmp 0x8e21
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8925
movq %rbx, %rdi
movq %rax, %rsi
pushq $0x1
popq %rdx
pushq $0x6
popq %rcx
leaq 0x18(%rsp), %r8
leaq 0x20(%rsp), %r9
jmp 0x8ea0
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8925
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
pushq $0x1
popq %rdx
pushq $0x6
jmp 0x8e6d
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8925
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
pushq $0x1
popq %rdx
pushq $0x6
popq %rcx
leaq 0x18(%rsp), %r14
movq %r14, %r8
leaq 0x20(%rsp), %rbp
movq %rbp, %r9
callq 0x8ec1
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8f51
movq %rbx, %rdi
movq %rax, %rsi
pushq $0x2
popq %rdx
pushq $0x4
jmp 0x8e99
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8925
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
pushq $0x2
popq %rdx
pushq $0x4
popq %rcx
leaq 0x18(%rsp), %r14
movq %r14, %r8
leaq 0x20(%rsp), %rbp
movq %rbp, %r9
callq 0x8ec1
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8f51
movq %rbx, %rdi
movq %rax, %rsi
pushq $0x1
popq %rdx
pushq $0x6
popq %rcx
movq %r14, %r8
movq %rbp, %r9
callq 0x8ec1
movq 0x8(%rsp), %rbx
incq %r13
jmp 0x8ba4
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq