// File: /workspace/github_c_makefile_star2_O2/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 0x13a3e
movq %rdi, %r14
movl 0x1c(%rdi), %eax
cmpl $0x28, %eax
je 0x13962
cmpl $0x1c, %eax
jne 0x1398b
movq 0x30(%r14), %rdi
callq 0x13944
movq 0x30(%r14), %rdi
callq 0x13944
testq %rax, %rax
jne 0x139c3
movq 0x38(%r14), %rdi
callq 0x13944
testq %rax, %rax
jne 0x139c3
movl 0x1c(%r14), %eax
cmpl $0x2d, %eax
je 0x139c8
cmpl $0x3, %eax
jne 0x13a3e
movq 0x30(%r14), %rdi
callq 0x13944
movq %rax, %r15
movq 0x38(%r14), %rdi
callq 0x13944
testq %r15, %r15
je 0x139c3
movq 0x38(%r14), %rax
movq %rax, 0x32442(%rip)     # 0x45e00
movq %r15, %rbx
jmp 0x13a40
movq %rax, %rbx
jmp 0x13a40
movq 0x30(%r14), %rax
movq 0x8(%rax), %r14
leaq 0x10068(%rip), %rbx     # 0x23a3f
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0x13a40
leaq 0x1009c(%rip), %rbx     # 0x23a89
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0x13a40
leaq 0x1004b(%rip), %rbx     # 0x23a4e
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0x13a40
leaq 0x10048(%rip), %rbx     # 0x23a61
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0x13a40
leaq 0x10045(%rip), %rbx     # 0x23a74
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0x13a40
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq