// File: /workspace/github_c_makefile_star2_O3/nimble-code[P]Modex/Src/xtract.c
// Function: has_instrumented
static char *
has_instrumented(treenode *root, char *s)
{	char *efn;

	if (!root) return NULL;

	// printf("%s\t%s\n", s, name_of_node(root->hdr.type));
	if (root->hdr.type == TN_EXPR
	||  root->hdr.type == TN_ASSIGN)
	{	efn = has_instrumented(root->lnode, "L ");
		if ((efn = has_instrumented(root->lnode, "L ")) != NULL)
		{	return efn;
		}
		if ((efn = has_instrumented(root->rnode, "R ")) != NULL)
		{	return efn;
	}	}
	if (root->hdr.type == TN_FUNC_CALL)
	{	char *lft, *rgt;
		// XXX check func call for pthread_creat
		lft = has_instrumented(root->lnode, "L ");
		rgt = has_instrumented(root->rnode, "R ");
		if (lft) // fct is pthread_create, pthread_join, or pthread_mutex_init
		{	// capture the call + args here, from rnode...
			keep_root = &root;
			keep_pars = root->rnode;
			if (0)
			{	fprintf(stderr, "Set keep_root to %p -> %p (%s)\n",
					keep_root, root, lft);
			}
			return lft;
		}
		return rgt;
	} else  if (root->hdr.type == TN_IDENT)
	{
		if (strcmp(((leafnode *)root)->data.sval->str, "pthread_create") == 0)
		{	// fprintf(stderr, "XXX\t\t%s\n", ((leafnode *)root)->data.sval->str);
			return "pthread_create";
		}
		if (strcmp(((leafnode *)root)->data.sval->str, "pthread_join") == 0)
		{	// fprintf(stderr, "XXX\t\t%s\n", ((leafnode *)root)->data.sval->str);
			return "pthread_join";
		}
		if (strcmp(((leafnode *)root)->data.sval->str, "pthread_mutex_init") == 0)
		{	// fprintf(stderr, "XXX\t\t%s\n", ((leafnode *)root)->data.sval->str);
			return "pthread_mutex_init";
		}
		if (strcmp(((leafnode *)root)->data.sval->str, "pthread_mutex_lock") == 0)
		{	// fprintf(stderr, "XXX\t\t%s\n", ((leafnode *)root)->data.sval->str);
			return "pthread_mutex_lock";
		}
		if (strcmp(((leafnode *)root)->data.sval->str, "pthread_mutex_unlock") == 0)
		{	// fprintf(stderr, "XXX\t\t%s\n", ((leafnode *)root)->data.sval->str);
			return "pthread_mutex_unlock";
		}
	}
	return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x15748
movq %rdi, %r14
movl 0x1c(%rdi), %eax
cmpl $0x28, %eax
je 0x1566c
cmpl $0x1c, %eax
jne 0x15695
movq 0x30(%r14), %rdi
callq 0x1564e
movq 0x30(%r14), %rdi
callq 0x1564e
testq %rax, %rax
jne 0x156cd
movq 0x38(%r14), %rdi
callq 0x1564e
testq %rax, %rax
jne 0x156cd
movl 0x1c(%r14), %eax
cmpl $0x2d, %eax
je 0x156d2
cmpl $0x3, %eax
jne 0x15748
movq 0x30(%r14), %rdi
callq 0x1564e
movq %rax, %r15
movq 0x38(%r14), %rdi
callq 0x1564e
testq %r15, %r15
je 0x156cd
movq 0x38(%r14), %rax
movq %rax, 0x32738(%rip)     # 0x47e00
movq %r15, %rbx
jmp 0x1574a
movq %rax, %rbx
jmp 0x1574a
movq 0x30(%r14), %rax
movq 0x8(%rax), %r14
leaq 0x1045e(%rip), %rbx     # 0x25b3f
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41c0
testl %eax, %eax
je 0x1574a
leaq 0x10492(%rip), %rbx     # 0x25b89
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41c0
testl %eax, %eax
je 0x1574a
leaq 0x10441(%rip), %rbx     # 0x25b4e
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41c0
testl %eax, %eax
je 0x1574a
leaq 0x1043e(%rip), %rbx     # 0x25b61
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41c0
testl %eax, %eax
je 0x1574a
leaq 0x1043b(%rip), %rbx     # 0x25b74
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41c0
testl %eax, %eax
je 0x1574a
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq