// File: /workspace/github_c_makefile_star2_O3/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)
xorl %r14d, %r14d
movq %r14, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movq 0x10(%rsi), %rdi
callq 0x12965
movq %rax, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
cmpq %r14, 0x20(%rbx)
je 0x98a0
xorl %r14d, %r14d
xorl %r13d, %r13d
movq %rbx, 0x8(%rsp)
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %r12
movq %r12, %rdi
callq 0x1e31c
movq %rax, %r15
movq %r13, %rdi
movq %rax, %rsi
callq 0xec3c
movl $0x8, %r13d
cmpq 0x30(%rsp), %r14
jae 0x95af
movl $0x8, %esi
movq %rax, %rdi
callq 0x2e217
xorl %ebx, %ebx
cmpl $0x0, 0x28(%rsp)
movq %rax, (%rsp)
jne 0x95bf
movq %r15, %rdi
callq 0x129b4
movl %eax, %r13d
movb $0x1, %bl
movq $0x0, 0x28(%rsp)
jmp 0x95bf
movq %rax, (%rsp)
xorl %ebx, %ebx
movl $0x1, %eax
movq %rax, 0x28(%rsp)
movq 0x18(%rsp), %rbp
movq 0x20(%rsp), %r15
movl %r13d, %eax
leaq 0x273dd(%rip), %rcx     # 0x309b0
movslq 0x4(%rcx,%rax,8), %rcx
addq %rbp, %rcx
cmpq $0x8, %rcx
ja 0x95f9
leaq 0x273c8(%rip), %rcx     # 0x309b0
movslq (%rcx,%rax,8), %rcx
addq %r15, %rcx
cmpq $0x6, %rcx
jbe 0x968c
movq %r12, %rdi
callq 0xec54
testl %eax, %eax
je 0x9639
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rdi
movq $-0x10, %rdx
movq (%rsp), %r13
subq %r13, %rdx
movq %r12, %rsi
callq 0x2d71e
movq %r12, %rdi
callq 0x12664
addq %rax, %r13
movq 0x8(%rsp), %rbx
jmp 0x9893
testb %bl, %bl
je 0x9740
movq %r12, %rdi
callq 0x8efd
movl %eax, %edi
callq 0xa7a3
cmpq $0x7, %rbp
ja 0x96cc
testl %eax, %eax
je 0x96cc
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x91b0
movq %rax, %r15
movq %r12, %rdi
callq 0x8efd
movl %eax, %edi
callq 0xa720
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
jmp 0x971b
decl %eax
cmpl $0x7, %eax
ja 0x988a
leaq 0x2728e(%rip), %rcx     # 0x3092c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x91b0
movq %rbx, %rdi
movq %rax, %rsi
movl $0x2, %edx
movl $0x4, %ecx
jmp 0x97a3
movq %r12, %rdi
callq 0x8efd
movl %eax, %edi
callq 0xa798
testl %eax, %eax
setne %al
cmpq $0x6, %r15
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x9740
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x91b0
movq %rax, %r15
movq %r12, %rdi
callq 0x8efd
movl %eax, %edi
callq 0xa759
movq %rbx, %rdi
movq %r15, %rsi
movl $0x2, %edx
movl %eax, %ecx
leaq 0x18(%rsp), %r8
leaq 0x20(%rsp), %r9
callq 0x98af
movq 0x48(%rbx), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x2d71e
jmp 0x988a
movq %r12, %rdi
callq 0x1e31c
movq %rax, %rdi
callq 0x227ac
cmpl $0x1, (%rax)
jne 0x9605
jmp 0x988a
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x91b0
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
movl $0x2, %edx
movl $0x4, %ecx
jmp 0x97fa
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x91b0
movq %rbx, %rdi
movq %rax, %rsi
movl $0x1, %edx
movl $0x6, %ecx
leaq 0x18(%rsp), %r8
leaq 0x20(%rsp), %r9
jmp 0x9885
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x91b0
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
movl $0x1, %edx
movl $0x6, %ecx
jmp 0x984f
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x91b0
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
movl $0x1, %edx
movl $0x6, %ecx
leaq 0x18(%rsp), %r12
movq %r12, %r8
leaq 0x20(%rsp), %r13
movq %r13, %r9
callq 0x98af
movq %rbx, %rdi
movq %r15, %rsi
callq 0x9943
movq %rbx, %rdi
movq %rax, %rsi
movl $0x2, %edx
movl $0x4, %ecx
jmp 0x987f
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x91b0
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
movl $0x2, %edx
movl $0x4, %ecx
leaq 0x18(%rsp), %r12
movq %r12, %r8
leaq 0x20(%rsp), %r13
movq %r13, %r9
callq 0x98af
movq %rbx, %rdi
movq %r15, %rsi
callq 0x9943
movq %rbx, %rdi
movq %rax, %rsi
movl $0x1, %edx
movl $0x6, %ecx
movq %r12, %r8
movq %r13, %r9
callq 0x98af
movq 0x8(%rsp), %rbx
movq (%rsp), %r13
incq %r14
cmpq 0x20(%rbx), %r14
jb 0x9552
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq