// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movq 0x20(%rdi), %rax
movq 0x10(%rax), %rax
movq 0x60(%rax), %rax
movq $0x0, 0x10(%rsp)
movq 0x88(%rax), %r12
testq %r12, %r12
je 0x3021e
movq %r12, %r13
cmpb $0x0, (%r13)
jg 0x30227
movq 0x10(%r13), %r13
cmpq %r12, %r13
jne 0x3020a
xorl %eax, %eax
jmp 0x30223
xorl %eax, %eax
xorl %r13d, %r13d
xorl %ebx, %ebx
jmp 0x30234
movq 0x18(%r13), %rax
andq $-0x4, %rax
movl $0x1, %ebx
movq %rdi, 0x18(%rsp)
movq 0x28(%rdi), %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
je 0x303c0
movq %rdx, %r14
movq $0x0, 0x8(%rsp)
movq %rdx, 0x20(%rsp)
movzwl (%r14), %edx
testb %dl, %dl
jle 0x303a8
xorl %ebp, %ebp
movq 0x18(%r14,%rbp,8), %r15
movzwl %dx, %edx
cmpl $0x100, %edx            # imm = 0x100
jb 0x30283
testq %r15, %r15
jne 0x30283
movl %ecx, %edi
jmp 0x30391
leal 0x1(%rcx), %edx
testl %ecx, %ecx
je 0x302d7
movl %edx, 0x4(%rsp)
cmpb $0x3, (%rax)
movq %rax, %rcx
jne 0x3029a
movq 0x60(%rax), %rcx
movq 0x8(%rsp), %r15
cmpq 0x2fc9a(%rip), %rcx     # 0x5ff40
je 0x302b8
movq %rax, %r15
cmpq 0x2fcc6(%rip), %rax     # 0x5ff78
je 0x3037f
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x227b4
testq %r15, %r15
je 0x3038b
movl 0x4(%rsp), %edi
jmp 0x30357
movq 0x10(%r15), %rsi
xorl %eax, %eax
testq %rsi, %rsi
je 0x30435
movzbl (%rsi), %ecx
cmpl $0x3, %ecx
jne 0x302fe
movq 0x60(%rsi), %rsi
testq %rsi, %rsi
je 0x30435
movzbl (%rsi), %ecx
cmpl $0x4, %ecx
jne 0x303ee
movq 0x60(%rsi), %rcx
testq %rcx, %rcx
je 0x30435
movzbl (%rcx), %edi
cmpl $0x3, %edi
jne 0x3032c
movq 0x60(%rcx), %rcx
testq %rcx, %rcx
je 0x30435
movzbl (%rcx), %edi
cmpl $0x4, %edi
je 0x30342
leaq 0x3ab40(%rip), %rax     # 0x6ae78
cmpq %rax, 0x60(%rcx)
jne 0x303ee
movq %rcx, 0x8(%rsp)
movl %edx, %r15d
leaq 0x10(%rsp), %rdi
callq 0x227b4
movl %r15d, %edi
movsbl (%r13), %eax
cmpl %eax, %ebx
jl 0x3036f
movq 0x10(%r13), %r13
xorl %ebx, %ebx
cmpq %r12, %r13
jne 0x30357
xorl %eax, %eax
jmp 0x30391
movslq %ebx, %rax
movq 0x18(%r13,%rax,8), %rax
andq $-0x4, %rax
incl %ebx
jmp 0x30391
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x227b4
xorl %eax, %eax
movl 0x4(%rsp), %edi
incq %rbp
movl (%r14), %edx
movsbq %dl, %rsi
movl %edi, %ecx
cmpq %rsi, %rbp
jl 0x30267
jmp 0x303aa
movl %ecx, %edi
movq 0x10(%r14), %r14
movl %edi, %ecx
movq 0x20(%rsp), %rdx
cmpq %rdx, %r14
jne 0x30259
jmp 0x303c9
movq $0x0, 0x8(%rsp)
movq 0x18(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x303de
movq 0x8(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq 0x10(%rsp), %rdi
movq 0x28(%rax), %rsi
callq 0x31eba
jmp 0x30435
movq 0x8(%r15), %rdi
leaq 0x19307(%rip), %rsi     # 0x49700
movl $0x1, %edx
xorl %eax, %eax
callq 0x11a80
movq 0x10(%r15), %rdi
callq 0x237c5
movq 0x8(%r15), %rdi
leaq 0x18469(%rip), %rsi     # 0x48882
movq %rax, %rdx
xorl %eax, %eax
callq 0x1178c
xorl %eax, %eax
leaq 0x3c48c(%rip), %rdx     # 0x6c8b8
movq 0x18(%rsp), %rcx
movq %rdx, 0x10(%rcx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq