// File: /workspace/github_c_makefile_star2_O1/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 %r14
pushq %rbx
pushq %rax
movq %rdi, (%rsp)
testq %rdi, %rdi
je 0x155f4
movl 0x1c(%rdi), %eax
cmpl $0x28, %eax
je 0x154fc
cmpl $0x1c, %eax
jne 0x15529
movq 0x30(%rdi), %rdi
callq 0x154de
movq (%rsp), %rax
movq 0x30(%rax), %rdi
callq 0x154de
testq %rax, %rax
jne 0x15579
movq (%rsp), %rax
movq 0x38(%rax), %rdi
callq 0x154de
testq %rax, %rax
jne 0x15579
movq (%rsp), %rax
movl 0x1c(%rax), %ecx
cmpl $0x2d, %ecx
je 0x1557e
cmpl $0x3, %ecx
jne 0x155f4
movq 0x30(%rax), %rdi
callq 0x154de
movq %rax, %r14
movq (%rsp), %rax
movq 0x38(%rax), %rdi
callq 0x154de
testq %r14, %r14
je 0x15579
movq %rsp, %rax
movq %rax, 0x33892(%rip)     # 0x48df8
movq (%rax), %rax
movq 0x38(%rax), %rax
movq %rax, 0x3387c(%rip)     # 0x48df0
movq %r14, %rbx
jmp 0x155f6
movq %rax, %rbx
jmp 0x155f6
movq 0x30(%rax), %rax
movq 0x8(%rax), %r14
leaq 0x115b2(%rip), %rbx     # 0x26b3f
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0x155f6
leaq 0x115e6(%rip), %rbx     # 0x26b89
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0x155f6
leaq 0x11595(%rip), %rbx     # 0x26b4e
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0x155f6
leaq 0x11592(%rip), %rbx     # 0x26b61
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0x155f6
leaq 0x1158f(%rip), %rbx     # 0x26b74
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0x155f6
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq