// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x19054
movq $0x0, -0x8(%rbp)
jmp 0x1923f
movq -0x10(%rbp), %rax
cmpl $0x28, 0x1c(%rax)
je 0x19068
movq -0x10(%rbp), %rax
cmpl $0x1c, 0x1c(%rax)
jne 0x190d8
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
leaq 0x25a83(%rip), %rsi     # 0x3eafa
callq 0x19030
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
leaq 0x25a6b(%rip), %rsi     # 0x3eafa
callq 0x19030
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x190ab
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1923f
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
leaq 0x1b6c6(%rip), %rsi     # 0x34780
callq 0x19030
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x190d6
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1923f
jmp 0x190d8
movq -0x10(%rbp), %rax
cmpl $0x3, 0x1c(%rax)
jne 0x1914d
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
leaq 0x25a09(%rip), %rsi     # 0x3eafa
callq 0x19030
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
leaq 0x1b677(%rip), %rsi     # 0x34780
callq 0x19030
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x19140
leaq -0x10(%rbp), %rax
movq %rax, 0x3deb4(%rip)     # 0x56fd8
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x3de9d(%rip)     # 0x56fd0
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1923f
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1923f
movq -0x10(%rbp), %rax
cmpl $0x2d, 0x1c(%rax)
jne 0x19235
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x1ddc1(%rip), %rsi     # 0x36f2f
callq 0x4180
cmpl $0x0, %eax
jne 0x19188
leaq 0x1ddb0(%rip), %rax     # 0x36f2f
movq %rax, -0x8(%rbp)
jmp 0x1923f
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x1ddde(%rip), %rsi     # 0x36f79
callq 0x4180
cmpl $0x0, %eax
jne 0x191b5
leaq 0x1ddcd(%rip), %rax     # 0x36f79
movq %rax, -0x8(%rbp)
jmp 0x1923f
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x1dd76(%rip), %rsi     # 0x36f3e
callq 0x4180
cmpl $0x0, %eax
jne 0x191df
leaq 0x1dd65(%rip), %rax     # 0x36f3e
movq %rax, -0x8(%rbp)
jmp 0x1923f
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x1dd5f(%rip), %rsi     # 0x36f51
callq 0x4180
cmpl $0x0, %eax
jne 0x19209
leaq 0x1dd4e(%rip), %rax     # 0x36f51
movq %rax, -0x8(%rbp)
jmp 0x1923f
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x1dd48(%rip), %rsi     # 0x36f64
callq 0x4180
cmpl $0x0, %eax
jne 0x19233
leaq 0x1dd37(%rip), %rax     # 0x36f64
movq %rax, -0x8(%rbp)
jmp 0x1923f
jmp 0x19235
jmp 0x19237
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)