// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdx), %rdi
callq 0x4023
movq %rax, %r12
movq %rax, 0x8(%rsp)
movzbl (%rax), %ebp
cmpl $0x28, %ebp
je 0x4a21
cmpl $0x21, %ebp
jne 0x4a9a
leaq 0x42b7(%rip), %rax      # 0x8c70
movq %r14, %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $0x2e8ba2e8ba2e8ba3, %rsi # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rsi
leaq 0x1b05(%rip), %rdi      # 0x64dd
xorl %eax, %eax
callq 0x3f2f
incq %r12
leaq 0x8(%rsp), %rdx
movq %r12, (%rdx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x497a
movl %eax, %r13d
cmpl $0x2, %eax
je 0x4ba4
cmpl $0x16, %r13d
je 0x4dbc
xorl %eax, %eax
cmpl $0x0, (%rbx)
sete %al
movl %eax, (%rbx)
movl $0x4, %ebp
subl %eax, %ebp
jmp 0x4d85
incq %r12
leaq 0x8(%rsp), %r13
movq %r12, (%r13)
leaq 0x423c(%rip), %r12      # 0x8c70
movq %r14, %rax
subq %r12, %rax
sarq $0x3, %rax
movabsq $0x2e8ba2e8ba2e8ba3, %rsi # imm = 0x2E8BA2E8BA2E8BA3
imulq %rax, %rsi
leaq 0x1a93(%rip), %rdi      # 0x64e6
xorl %eax, %eax
callq 0x3f2f
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x4683
movl $0x16, %r13d
cmpl $0x16, %eax
je 0x4dbc
movl %eax, %ebp
movq 0x8(%rsp), %rdi
callq 0x4023
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
cmpb $0x29, (%rax)
je 0x4d85
jmp 0x4dbc
movq %r15, 0x10(%rsp)
callq 0x3290
movq %rax, 0x18(%rsp)
movq (%rax), %r15
movzwl (%r15,%rbp,2), %r13d
btl $0xb, %r13d
jb 0x4b19
leaq 0x1a45(%rip), %rsi      # 0x6504
movl $0x7, %edx
movq %r12, %rdi
callq 0x3070
testl %eax, %eax
je 0x4c57
leaq 0x4195(%rip), %rax      # 0x8c70
movq %r14, %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $0x2e8ba2e8ba2e8ba3, %rsi # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rsi
cmpl $0x5f, %ebp
je 0x4bac
andl $0x8, %r13d
jne 0x4bac
leaq 0x1a0d(%rip), %rdi      # 0x651a
xorl %eax, %eax
callq 0x3f2f
jmp 0x4b99
leaq 0x4150(%rip), %rax      # 0x8c70
movq %r14, %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $0x2e8ba2e8ba2e8ba3, %rsi # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rsi
leaq 0x19b0(%rip), %rdi      # 0x64ef
xorl %eax, %eax
callq 0x3f2f
leaq 0x20(%rsp), %rbp
movq %r12, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x31b0
movl %eax, (%rbx)
cmpq %r12, (%rbp)
je 0x4b99
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
decq %r12
movzbl 0x1(%r12), %edx
incq %r12
cmpl $0x5f, %edx
je 0x4b6b
movzwl (%rcx,%rdx,2), %edx
andl $0x8, %edx
jne 0x4b6b
xorl %ebp, %ebp
cmpl $0x1, %eax
adcl $0x3, %ebp
movq %r12, 0x8(%rsp)
movq 0x10(%rsp), %r15
jmp 0x4d85
movl $0x16, %r13d
jmp 0x4dbc
movl %r13d, %ebp
jmp 0x4d85
leaq 0x1959(%rip), %rdi      # 0x650c
xorl %eax, %eax
callq 0x3f2f
movq %r12, %rdi
callq 0x43f9
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
decq %r12
movzbl 0x1(%r12), %edx
incq %r12
cmpl $0x5f, %edx
je 0x4bcd
movzwl (%rcx,%rdx,2), %edx
andl $0x8, %edx
jne 0x4bcd
movq %r12, 0x8(%rsp)
testl %eax, %eax
js 0x4d03
movl %eax, %r15d
leaq 0x6705(%rip), %rbp      # 0xb300
movq (%rbp,%r15,8), %rdi
testq %rdi, %rdi
je 0x4d17
leaq 0x20(%rsp), %r13
movq %r13, %rsi
xorl %edx, %edx
callq 0x31b0
movl %eax, (%rbx)
movq (%r13), %rcx
movl $0x16, %r13d
cmpb $0x0, (%rcx)
jne 0x4dbc
cmpq (%rbp,%r15,8), %rcx
movq 0x10(%rsp), %r15
je 0x4dbc
xorl %ebp, %ebp
cmpl $0x1, %eax
adcl $0x3, %ebp
movq %r12, %rdi
callq 0x4e6a
movq %rax, 0x8(%rsp)
jmp 0x4d7e
movzbl 0x7(%r12), %eax
cmpl $0x5f, %eax
je 0x4ad4
movzwl (%r15,%rax,2), %eax
andl $0x8, %eax
jne 0x4ad4
addq $0x7, %r12
movq %r12, %rdi
callq 0x4023
movq %rax, %r12
movq %rax, 0x8(%rsp)
leaq 0x3fe1(%rip), %rax      # 0x8c70
movq %r14, %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $0x2e8ba2e8ba2e8ba3, %rsi # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rsi
leaq 0x184f(%rip), %rdi      # 0x64fd
xorl %eax, %eax
callq 0x3f2f
movb (%r12), %r13b
cmpb $0x28, %r13b
jne 0x4ccf
incq %r12
movq %r12, %rdi
callq 0x4023
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x43f9
testl %eax, %eax
movq 0x10(%rsp), %r15
js 0x4d29
movl %eax, %eax
leaq 0x6612(%rip), %rcx      # 0xb300
xorl %edx, %edx
cmpq $0x0, (%rcx,%rax,8)
setne %dl
movl %edx, (%rbx)
movl $0x4, %ebp
subl %edx, %ebp
jmp 0x4d2e
movq %r12, %rdi
callq 0x4e6a
movq %rax, 0x8(%rsp)
movl $0x2, %ebp
jmp 0x4d22
movl $0x0, (%rbx)
movl $0x4, %ebp
movq 0x10(%rsp), %r15
jmp 0x4d7e
movl $0x2, %ebp
movq 0x18(%rsp), %rax
movq (%rax), %rax
decq %r12
movzbl 0x1(%r12), %ecx
incq %r12
cmpl $0x5f, %ecx
je 0x4d39
movzwl (%rax,%rcx,2), %ecx
andl $0x8, %ecx
jne 0x4d39
movq %r12, 0x8(%rsp)
movq %r12, %rdi
callq 0x4023
movq %rax, 0x8(%rsp)
cmpb $0x28, %r13b
jne 0x4d7e
movq %rax, %rcx
incq %rcx
movq %rcx, 0x8(%rsp)
movl $0x16, %r13d
cmpb $0x29, (%rax)
jne 0x4dbc
movb $0x0, 0x176db(%rip)     # 0x1c460
movq 0x8(%rsp), %rax
movq %rax, (%r15)
leaq 0x3edc(%rip), %rax      # 0x8c70
subq %rax, %r14
sarq $0x3, %r14
movabsq $0x2e8ba2e8ba2e8ba3, %rsi # imm = 0x2E8BA2E8BA2E8BA3
imulq %r14, %rsi
movl (%rbx), %edx
leaq 0x16fa(%rip), %rdi      # 0x64ac
xorl %eax, %eax
callq 0x3f2f
movl %ebp, %r13d
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq