// File: /workspace/github_c_makefile_star2_O1/lucvoo[P]sparse-dev/builtin.c
// Function: eval_atomic_common
static int eval_atomic_common(struct expression *expr)
{
	struct symbol *fntype = expr->fn->ctype->ctype.base_type;
	struct symbol_list *types = NULL;
	struct symbol *ctype = NULL;
	struct symbol *t;
	struct expression *arg;
	int n = 0;

	// The number of arguments has already be verified.
	// The first arg must be a pointer to an integral type.
	PREPARE_PTR_LIST(fntype->arguments, t);
	FOR_EACH_PTR(expr->args, arg) {
		struct symbol *ptrtype = NULL;

		if (++n == 1) {
			t = arg->ctype;
			if (!t)
				return 0;
			if (t->type == SYM_NODE)
				t = t->ctype.base_type;
			if (!t)
				return 0;
			if (t->type != SYM_PTR)
				goto err;
			ptrtype = t;
			t = t->ctype.base_type;
			if (!t)
				return 0;
			if (t->type == SYM_NODE)
				t = t->ctype.base_type;
			if (!t)
				return 0;
			if (t->type != SYM_PTR && t->ctype.base_type != &int_type)
				goto err;
			ctype = t;
			t = ptrtype;
		} else if (is_dynamic_type(t)) {
			t = ctype;
		} else if (t == &ptr_ctype) {
			t = ptrtype;
		}
		add_ptr_list(&types, t);
		NEXT_PTR_LIST(t);
	} END_FOR_EACH_PTR(arg);
	FINISH_PTR_LIST(t);

	if (!expr->ctype)	// set the return type, if needed
		expr->ctype = ctype;
	return evaluate_arguments(types, expr->args);

err:
	sparse_error(arg->pos, "invalid type for argument %d:", n);
	info(arg->pos, "        %s", show_typename(arg->ctype));
	expr->ctype = &bad_ctype;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq 0x20(%rdi), %rax
movq 0x10(%rax), %rax
movq 0x60(%rax), %rax
movq $0x0, 0x20(%rsp)
movq 0x88(%rax), %rax
xorl %r13d, %r13d
testq %rax, %rax
movq %rax, 0x30(%rsp)
je 0x308aa
movq %rax, %rbp
cmpb $0x0, (%rbp)
jg 0x308b4
movq 0x10(%rbp), %rbp
cmpq %rax, %rbp
jne 0x30896
xorl %r12d, %r12d
jmp 0x308af
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r15d, %r15d
jmp 0x308c2
movq 0x18(%rbp), %r12
andq $-0x4, %r12
movl $0x1, %r15d
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x30a5e
movq %rbx, 0x18(%rsp)
xorl %r13d, %r13d
movq %rax, %r8
movq $0x0, 0x8(%rsp)
movq %rax, 0x28(%rsp)
movzwl (%r8), %eax
testb %al, %al
jle 0x30a43
xorl %ebx, %ebx
movq %r8, 0x10(%rsp)
movq 0x18(%r8,%rbx,8), %r14
movzwl %ax, %eax
cmpl $0x100, %eax            # imm = 0x100
jb 0x30913
testq %r14, %r14
je 0x30a14
testl %r13d, %r13d
je 0x30946
cmpb $0x3, (%r12)
movq %r12, %rax
jne 0x30927
movq 0x60(%r12), %rax
cmpq 0x30602(%rip), %rax     # 0x60f30
je 0x309b9
cmpq 0x3062d(%rip), %r12     # 0x60f68
movl $0x0, %eax
cmoveq %rax, %r12
jmp 0x309be
movq 0x10(%r14), %r12
movl $0x1, %eax
testq %r12, %r12
je 0x309f5
cmpb $0x3, (%r12)
jne 0x30964
movq 0x60(%r12), %r12
testq %r12, %r12
je 0x309f5
cmpb $0x4, (%r12)
jne 0x30a29
movq 0x60(%r12), %rdi
testq %rdi, %rdi
je 0x30a32
cmpb $0x3, (%rdi)
jne 0x3098f
movq 0x60(%rdi), %rdi
testq %rdi, %rdi
je 0x30a32
cmpb $0x4, (%rdi)
je 0x30a39
leaq 0x3b4d0(%rip), %rax     # 0x6be78
cmpq %rax, 0x60(%rdi)
je 0x30a39
xorl %ecx, %ecx
movq %rdi, %r12
jmp 0x30a2b
movq 0x8(%rsp), %r12
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x2285b
xorl %eax, %eax
movb $0x1, %cl
testq %r12, %r12
je 0x30a08
movq 0x30(%rsp), %r8
movsbl (%rbp), %edi
cmpl %edi, %r15d
jl 0x309f9
movq 0x10(%rbp), %rbp
xorl %r15d, %r15d
cmpq %r8, %rbp
jne 0x309d9
xorl %r12d, %r12d
xorl %eax, %eax
jmp 0x30a08
xorl %ecx, %ecx
jmp 0x30a0d
movslq %r15d, %rdi
movq 0x18(%rbp,%rdi,8), %r12
andq $-0x4, %r12
incl %r15d
movq 0x10(%rsp), %r8
incl %r13d
testb %cl, %cl
je 0x30a57
incq %rbx
movl (%r8), %eax
movsbq %al, %rcx
cmpq %rcx, %rbx
jl 0x308fb
jmp 0x30a43
xorl %ecx, %ecx
movl $0xd, %eax
jmp 0x30a0d
xorl %ecx, %ecx
movq %rdi, %r12
jmp 0x30a0d
movq %rdi, 0x8(%rsp)
jmp 0x309be
movq 0x10(%r8), %r8
movq 0x28(%rsp), %rax
cmpq %rax, %r8
jne 0x308e8
xorl %eax, %eax
movq 0x18(%rsp), %rbx
jmp 0x30a6c
movl $0x6, %eax
movq $0x0, 0x8(%rsp)
cmpl $0x6, %eax
je 0x30a75
testl %eax, %eax
jne 0x30a77
xorl %eax, %eax
cmpl $0xd, %eax
je 0x30aa4
xorl %ebp, %ebp
testl %eax, %eax
jne 0x30ae4
cmpq $0x0, 0x10(%rbx)
jne 0x30a92
movq 0x8(%rsp), %rax
movq %rax, 0x10(%rbx)
movq 0x20(%rsp), %rdi
movq 0x28(%rbx), %rsi
callq 0x328e8
movl %eax, %ebp
jmp 0x30ae4
movq 0x8(%r14), %rdi
leaq 0x19ce1(%rip), %rsi     # 0x4a790
xorl %ebp, %ebp
movl %r13d, %edx
xorl %eax, %eax
callq 0x11a38
movq 0x10(%r14), %rdi
callq 0x2386c
movq 0x8(%r14), %rdi
leaq 0x18e43(%rip), %rsi     # 0x49912
movq %rax, %rdx
xorl %eax, %eax
callq 0x11744
leaq 0x3cdd8(%rip), %rax     # 0x6d8b8
movq %rax, 0x10(%rbx)
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq