// File: /workspace/github_c_makefile_star2_O2/darwin-on-arm[P]darwin-sdk/developer_cmds/unifdef/unifdef.c
// Function: eval_unary
static Linetype
eval_unary(const struct ops *ops, int *valp, const char **cpp)
{
	const char *cp;
	char *ep;
	int sym;
	bool defparen;
	Linetype lt;

	cp = skipcomment(*cpp);
	if (*cp == '!') {
		debug("eval%d !", ops - eval_ops);
		cp++;
		lt = eval_unary(ops, valp, &cp);
		if (lt == LT_ERROR)
			return (LT_ERROR);
		if (lt != LT_IF) {
			*valp = !*valp;
			lt = *valp ? LT_TRUE : LT_FALSE;
		}
	} else if (*cp == '(') {
		cp++;
		debug("eval%d (", ops - eval_ops);
		lt = eval_table(eval_ops, valp, &cp);
		if (lt == LT_ERROR)
			return (LT_ERROR);
		cp = skipcomment(cp);
		if (*cp++ != ')')
			return (LT_ERROR);
	} else if (isdigit((unsigned char)*cp)) {
		debug("eval%d number", ops - eval_ops);
		*valp = strtol(cp, &ep, 0);
		if (ep == cp)
			return (LT_ERROR);
		lt = *valp ? LT_TRUE : LT_FALSE;
		cp = skipsym(cp);
	} else if (strncmp(cp, "defined", 7) == 0 && endsym(cp[7])) {
		cp = skipcomment(cp+7);
		debug("eval%d defined", ops - eval_ops);
		if (*cp == '(') {
			cp = skipcomment(cp+1);
			defparen = true;
		} else {
			defparen = false;
		}
		sym = findsym(cp);
		if (sym < 0) {
			lt = LT_IF;
		} else {
			*valp = (value[sym] != NULL);
			lt = *valp ? LT_TRUE : LT_FALSE;
		}
		cp = skipsym(cp);
		cp = skipcomment(cp);
		if (defparen && *cp++ != ')')
			return (LT_ERROR);
		constexpr = false;
	} else if (!endsym(*cp)) {
		debug("eval%d symbol", ops - eval_ops);
		sym = findsym(cp);
		cp = skipsym(cp);
		if (sym < 0) {
			lt = LT_IF;
			cp = skipargs(cp);
		} else if (value[sym] == NULL) {
			*valp = 0;
			lt = LT_FALSE;
		} else {
			*valp = strtol(value[sym], &ep, 0);
			if (*ep != '\0' || ep == value[sym])
				return (LT_ERROR);
			lt = *valp ? LT_TRUE : LT_FALSE;
			cp = skipargs(cp);
		}
		constexpr = false;
	} else {
		debug("eval%d bad expr", ops - eval_ops);
		return (LT_ERROR);
	}

	*cpp = cp;
	debug("eval%d = %d", ops - eval_ops, *valp);
	return (lt);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r13
movq (%rdx), %rdi
callq 0x3da1
movq %rax, %r12
movzbl (%rax), %ebp
cmpl $0x28, %ebp
je 0x46b7
cmpl $0x21, %ebp
jne 0x4729
leaq 0x3617(%rip), %rcx      # 0x7c70
movq %r13, %rax
subq %rcx, %rax
pushq $0x58
popq %rcx
cqto
idivq %rcx
movq %rax, %r15
leaq 0xe59(%rip), %rdi       # 0x54ca
movq %rax, %rsi
xorl %eax, %eax
callq 0x3caf
incq %r12
movq %rsp, %rdx
movq %r12, (%rdx)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x461f
movl %eax, %ebp
cmpl $0x2, %eax
je 0x4981
cmpl $0x16, %ebp
je 0x49a0
xorl %eax, %eax
cmpl $0x0, (%rbx)
sete %al
movl %eax, (%rbx)
pushq $0x4
popq %rbp
subl %eax, %ebp
jmp 0x4981
incq %r12
movq %rsp, %rbp
movq %r12, (%rbp)
leaq 0x35a8(%rip), %r12      # 0x7c70
subq %r12, %r13
pushq $0x58
popq %rcx
movq %r13, %rax
cqto
idivq %rcx
movq %rax, %r15
leaq 0xdf3(%rip), %rdi       # 0x54d3
movq %rax, %rsi
xorl %eax, %eax
callq 0x3caf
movq %r12, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x43d2
pushq $0x16
popq %rbp
cmpl $0x16, %eax
je 0x49a0
movl %eax, %r12d
movq (%rsp), %rdi
callq 0x3da1
leaq 0x1(%rax), %rcx
movq %rcx, (%rsp)
cmpb $0x29, (%rax)
jne 0x49a0
movl %r12d, %ebp
jmp 0x4981
movq %r14, 0x8(%rsp)
callq 0x3280
movq (%rax), %r15
movzwl (%r15,%rbp,2), %r14d
btl $0xb, %r14d
jb 0x4799
leaq 0xda8(%rip), %rsi       # 0x54f1
pushq $0x7
popq %rdx
movq %r12, %rdi
callq 0x3070
testl %eax, %eax
je 0x4897
leaq 0x350d(%rip), %rax      # 0x7c70
subq %rax, %r13
pushq $0x58
popq %rcx
movq %r13, %rax
cqto
idivq %rcx
movq %rax, %r15
cmpl $0x5f, %ebp
je 0x47fe
andl $0x8, %r14d
jne 0x47fe
leaq 0xd7d(%rip), %rdi       # 0x5507
movq %r15, %rsi
xorl %eax, %eax
callq 0x3caf
jmp 0x499d
leaq 0x34d0(%rip), %rax      # 0x7c70
subq %rax, %r13
pushq $0x58
popq %rcx
movq %r13, %rax
cqto
idivq %rcx
movq %rax, %r15
leaq 0xd24(%rip), %rdi       # 0x54dc
xorl %ebp, %ebp
movq %rax, %rsi
xorl %eax, %eax
callq 0x3caf
leaq 0x10(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x31a0
movl %eax, (%rbx)
cmpq %r12, (%r13)
movq 0x8(%rsp), %r14
je 0x499d
cmpl $0x1, %eax
adcl $0x3, %ebp
movq %r12, %rdi
callq 0x40f9
movq %rax, (%rsp)
jmp 0x4981
leaq 0xcf4(%rip), %rdi       # 0x54f9
movq %r15, %rsi
xorl %eax, %eax
callq 0x3caf
movq %r12, %rdi
callq 0x4162
movl %eax, %ebp
movq %r12, %rdi
callq 0x40f9
movq %rax, %r12
movq %rax, (%rsp)
testl %ebp, %ebp
js 0x4931
movl %ebp, %r14d
leaq 0x5ac6(%rip), %rax      # 0xa300
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x4941
leaq 0x10(%rsp), %r13
movq %r13, %rsi
xorl %edx, %edx
callq 0x31a0
movl %eax, (%rbx)
movq (%r13), %rcx
pushq $0x16
popq %rbp
cmpb $0x0, (%rcx)
jne 0x49a0
leaq 0x5a91(%rip), %rdx      # 0xa300
cmpq (%rdx,%r14,8), %rcx
movq 0x8(%rsp), %r14
je 0x49a0
xorl %ebp, %ebp
cmpl $0x1, %eax
adcl $0x3, %ebp
movq %r12, %rdi
callq 0x4a41
movq %rax, (%rsp)
jmp 0x497a
movzbl 0x7(%r12), %eax
cmpl $0x5f, %eax
je 0x475c
movzwl (%r15,%rax,2), %eax
andl $0x8, %eax
jne 0x475c
addq $0x7, %r12
movq %r12, %rdi
callq 0x3da1
movq %rax, %r12
leaq 0x33a6(%rip), %rax      # 0x7c70
subq %rax, %r13
pushq $0x58
popq %rcx
movq %r13, %rax
cqto
idivq %rcx
movq %rax, %r15
leaq 0xc08(%rip), %rdi       # 0x54ea
movq %rax, %rsi
xorl %eax, %eax
callq 0x3caf
movb (%r12), %r13b
cmpb $0x28, %r13b
jne 0x4904
incq %r12
movq %r12, %rdi
callq 0x3da1
movq %rax, %r12
movq %r12, %rdi
callq 0x4162
testl %eax, %eax
movq 0x8(%rsp), %r14
js 0x494e
movl %eax, %eax
leaq 0x59e2(%rip), %rcx      # 0xa300
xorl %edx, %edx
cmpq $0x0, (%rcx,%rax,8)
setne %dl
movl %edx, (%rbx)
pushq $0x4
popq %rbp
subl %edx, %ebp
jmp 0x4951
movq %r12, %rdi
callq 0x4a41
movq %rax, (%rsp)
pushq $0x2
jmp 0x4946
andl $0x0, (%rbx)
pushq $0x4
popq %rbp
movq 0x8(%rsp), %r14
jmp 0x497a
pushq $0x2
popq %rbp
movq %r12, %rdi
callq 0x40f9
movq %rax, %rdi
callq 0x3da1
movq %rax, (%rsp)
cmpb $0x28, %r13b
jne 0x497a
movq %rax, %rcx
incq %rcx
movq %rcx, (%rsp)
cmpb $0x29, (%rax)
jne 0x499d
movb $0x0, 0x16adf(%rip)     # 0x1b460
movq (%rsp), %rax
movq %rax, (%r14)
movl (%rbx), %edx
leaq 0xb08(%rip), %rdi       # 0x5499
movq %r15, %rsi
xorl %eax, %eax
callq 0x3caf
jmp 0x49a0
pushq $0x16
popq %rbp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq