// File: /workspace/github_c_makefile_star2_O0/Oric4ever[P]lcc65/6502/build/../src/expr.c
// Function: call
static Tree call(f, fty, src) Tree f; Type fty; Coordinate src; {
	int n = 0;
	Tree args = 0, r = 0;
	Type *proto = fty->u.proto;

	if (proto && *proto == voidtype)
		proto = 0;
	if (hascall(f))
		r = f;
	if (t != ')')
		do {
			Tree q = pointer(expr1(0));
			if (proto && *proto && *proto != voidtype) {
				Type aty;
				q = value(q);
				if (aty = assign(*proto, q)) {
					q = cast(q, aty);
					if ((isint(q->type) || isenum(q->type))
					&& q->type->size != inttype->size)
						q = cast(q, promote(q->type));
				} else
					error("type error in argument %d to %s; found `%t' expected `%t'\n",
						n + 1, funcname(f), q->type, *proto);
				proto++;
			} else {
				if (fty->u.proto && (proto == 0 || *proto == 0))
					error("too many arguments to %s\n", funcname(f));
				q = value(q);
				if (q->type == floattype)
					q = cast(q, doubletype);
				else if ((isint(q->type) || isenum(q->type))
				&& q->type->size != inttype->size)
					q = cast(q, promote(q->type));
				else if (isarray(q->type) || q->type->size == 0)
					error("type error in argument %d to %s; `%t' is illegal\n",
						n + 1, funcname(f), q->type);
			}
#ifdef NOARGB
			if (isstruct(q->type)) {
				Symbol t1;
				if (q->op == RIGHT && q->kids[0]
				&& q->kids[0]->op == CALL+B) {
					/*
					 * When the argument is f() where f
					 * returns a struct, simply use the
					 * temporary generated to hold f's
					 * return value.
					 */
					assert(q->kids[0]->kids[1]);
					t1 = q->kids[0]->kids[1]->u.sym;
					q = q->kids[0];
				} else {
					t1 = temporary(AUTO, unqual(q->type));
					q = asgn(t1, q);
				}
				q = tree(RIGHT, ptr(q->type), root(q), lvalue(idnode(t1)));
			}

#endif
			if (hascall(q))
				r = tree(RIGHT, voidtype, r, q);
			args = tree(ARG + widen(q->type), q->type, q, args);
			n++;
			if (Aflag >= 2 && n == 32)
				warning("more than 31 arguments in a call to %s\n", funcname(f));
		} while (t == ',' && (t = gettok()));
	expect(')');
	if (proto && *proto && *proto != voidtype)
		error("insufficient number of arguments to %s\n", funcname(f));
	if (r)
		args = tree(RIGHT, voidtype, r, args);
	if (events.calls)
		apply(events.calls, (Generic)&src, (Generic)&f);
	return callnode(f, freturn(fty), args);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdx, -0x10(%rbp)
movq %rcx, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x123b0
movq -0x40(%rbp), %rax
movq (%rax), %rax
leaq 0x31e9d(%rip), %rcx     # 0x44240
cmpq (%rcx), %rax
jne 0x123b0
movq $0x0, -0x40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x25830
cmpl $0x0, %eax
je 0x123c6
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq 0x2b7b3(%rip), %rax     # 0x3db80
cmpl $0x29, (%rax)
je 0x12906
jmp 0x123d8
xorl %edi, %edi
callq 0xfe00
movq %rax, %rdi
callq 0xf9f0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x1257a
movq -0x40(%rbp), %rax
cmpq $0x0, (%rax)
je 0x1257a
movq -0x40(%rbp), %rax
movq (%rax), %rax
leaq 0x31e2e(%rip), %rcx     # 0x44240
cmpq (%rcx), %rax
je 0x1257a
movq -0x48(%rbp), %rdi
callq 0xe030
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rsi
callq 0xe2d0
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x12534
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0xe9b0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xf, (%rax)
jb 0x12476
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x12482
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpl $0x3, (%rax)
jb 0x124bf
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xf, (%rax)
jb 0x124aa
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x124b6
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpl $0x6, (%rax)
jbe 0x124f3
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xf, (%rax)
jb 0x124de
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x124ea
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpl $0xd, (%rax)
jne 0x12532
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %eax
leaq 0x31cf3(%rip), %rcx     # 0x441f8
movq (%rcx), %rcx
cmpl 0x8(%rcx), %eax
je 0x12532
movq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xfae0
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0xe9b0
movq %rax, -0x48(%rbp)
jmp 0x12569
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movq -0x18(%rbp), %rdi
callq 0xfd40
movl -0x74(%rbp), %esi
movq %rax, %rdx
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x40(%rbp), %rax
movq (%rax), %r8
leaq 0x1ddf7(%rip), %rdi     # 0x30359
movb $0x0, %al
callq 0xd530
movq -0x40(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
jmp 0x1276a
movq -0x20(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x125b0
cmpq $0x0, -0x40(%rbp)
je 0x12596
movq -0x40(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x125b0
movq -0x18(%rbp), %rdi
callq 0xfd40
movq %rax, %rsi
leaq 0x1ddeb(%rip), %rdi     # 0x30394
movb $0x0, %al
callq 0xd530
movq -0x48(%rbp), %rdi
callq 0xe030
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
leaq 0x31c24(%rip), %rcx     # 0x441f0
cmpq (%rcx), %rax
jne 0x125ed
movq -0x48(%rbp), %rdi
leaq 0x31c0c(%rip), %rax     # 0x441e8
movq (%rax), %rsi
callq 0xe9b0
movq %rax, -0x48(%rbp)
jmp 0x12768
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xf, (%rax)
jb 0x1260c
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x80(%rbp)
jmp 0x12618
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
cmpl $0x3, (%rax)
jb 0x1265e
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xf, (%rax)
jb 0x12643
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0x12652
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpl $0x6, (%rax)
jbe 0x1269b
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xf, (%rax)
jb 0x12680
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x90(%rbp)
jmp 0x1268f
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
cmpl $0xd, (%rax)
jne 0x126e5
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %eax
leaq 0x31b4b(%rip), %rcx     # 0x441f8
movq (%rcx), %rcx
cmpl 0x8(%rcx), %eax
je 0x126e5
movq -0x48(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xfae0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0xe9b0
movq %rax, -0x48(%rbp)
jmp 0x12766
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xf, (%rax)
jb 0x12707
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0xa0(%rbp)
jmp 0x12716
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
cmpl $0xc, (%rax)
je 0x12730
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x0, 0x8(%rax)
jne 0x12764
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
movq -0x18(%rbp), %rdi
callq 0xfd40
movl -0xa4(%rbp), %esi
movq %rax, %rdx
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rcx
leaq 0x1dc51(%rip), %rdi     # 0x303ae
movb $0x0, %al
callq 0xd530
jmp 0x12766
jmp 0x12768
jmp 0x1276a
movq -0x48(%rbp), %rdi
callq 0x25830
cmpl $0x0, %eax
je 0x12798
leaq 0x31ac1(%rip), %rax     # 0x44240
movq (%rax), %rsi
movq -0x38(%rbp), %rdx
movq -0x48(%rbp), %rcx
movl $0x2a0, %edi            # imm = 0x2A0
callq 0x256f0
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xf, (%rax)
jb 0x127ba
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0x127c9
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
cmpl $0x3, (%rax)
jb 0x12812
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xf, (%rax)
jb 0x127f7
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0xb8(%rbp)
jmp 0x12806
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
cmpl $0x6, (%rax)
jbe 0x1284f
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xf, (%rax)
jb 0x12834
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0xc0(%rbp)
jmp 0x12843
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
cmpl $0xd, (%rax)
jne 0x1285c
movl $0x5, %eax
movl %eax, -0xc4(%rbp)
jmp 0x1286f
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x29e30
movl %eax, -0xc4(%rbp)
movl -0xc4(%rbp), %edi
addl $0x20, %edi
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x48(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x256f0
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
leaq 0x2b387(%rip), %rax     # 0x3dc28
cmpl $0x2, (%rax)
jl 0x128c6
cmpl $0x20, -0x24(%rbp)
jne 0x128c6
movq -0x18(%rbp), %rdi
callq 0xfd40
movq %rax, %rsi
leaq 0x1db21(%rip), %rdi     # 0x303e0
movb $0x0, %al
callq 0xdba0
jmp 0x128c8
xorl %eax, %eax
leaq 0x2b2af(%rip), %rcx     # 0x3db80
cmpl $0x2c, (%rcx)
movb %al, -0xc5(%rbp)
jne 0x128f6
callq 0x15170
leaq 0x2b298(%rip), %rcx     # 0x3db80
movl %eax, (%rcx)
cmpl $0x0, %eax
setne %al
movb %al, -0xc5(%rbp)
movb -0xc5(%rbp), %al
testb $0x1, %al
jne 0x123d8
jmp 0x12906
movl $0x29, %edi
callq 0xd670
cmpq $0x0, -0x40(%rbp)
je 0x1294e
movq -0x40(%rbp), %rax
cmpq $0x0, (%rax)
je 0x1294e
movq -0x40(%rbp), %rax
movq (%rax), %rax
leaq 0x31911(%rip), %rcx     # 0x44240
cmpq (%rcx), %rax
je 0x1294e
movq -0x18(%rbp), %rdi
callq 0xfd40
movq %rax, %rsi
leaq 0x1dac1(%rip), %rdi     # 0x30408
movb $0x0, %al
callq 0xd530
cmpq $0x0, -0x38(%rbp)
je 0x12975
leaq 0x318e4(%rip), %rax     # 0x44240
movq (%rax), %rsi
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %rcx
movl $0x2a0, %edi            # imm = 0x2A0
callq 0x256f0
movq %rax, -0x30(%rbp)
leaq 0x2b254(%rip), %rax     # 0x3dbd0
cmpq $0x0, 0x20(%rax)
je 0x1299b
leaq 0x2b246(%rip), %rax     # 0x3dbd0
movq 0x20(%rax), %rdi
leaq -0x10(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x18640
movq -0x18(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x28a30
movq -0xd0(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rdx
callq 0xc960
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax,%rax)