// File: /workspace/github_c_makefile_star2_O0/nimble-code[P]Modex/Src/xtract.c
// Function: handle_instrumented
static void
handle_instrumented(treenode *root, char *my_fname)
{	int noreset = 0;

	if (in_pars == 1)	/* parentheses */
	{	par_cnt = 0;

		setup_fct_call(root, my_fname);

		// handle a possible return value from the call

		if (strncmp(OrigBuf, "A: ", 3) == 0)	// called in assignment
		{	char *pq1, *pq2;
			pq1 = strrchr(OrigBuf, '[');
			pq2 = strrchr(OrigBuf, ']');
			if (pq1 && (!pq2 || pq1 > pq2))
			{	goto here;
			}

			strcat(OrigBuf, " now.res_p_");
			strcat(OrigBuf, my_fname);
		} else if (strncmp(OrigBuf, "C: ", 3) == 0) // called in condition
		{	strcat(OrigBuf, " now.res_p_");
			strcat(OrigBuf, my_fname);

			// already generated the return value of the call
			// fprintf(fp, " ret_%s?eval(_pid);\n", my_fname);
			// reset the return lock early -- it is otherwise done below
			// this risks a race-condition if another caller of the function
			// completes, and sets the return value to a different value
			// before this caller can read the current one
			// we have to reset early though, because this cannot appear inside
			// the condition

			fprintf(fp, " lck_p_%s_ret = 0;\n", my_fname);
			noreset = 1;	// dont reset again
			if ((Verbose&2) && is_do_condition)
			{	fprintf(stderr, "%s: %s:%d: warning, calling instrumented ",
					progname, root->hdr.fnm, root->hdr.line);
				fprintf(stderr, "function %s() in a loop-condition\n", my_fname);

			}

		} else if (strncmp(OrigBuf, "D: ", 3) == 0) // called in declaration
		{	strcat(OrigBuf, " now.res_p_");
			strcat(OrigBuf, my_fname);
			
			fprintf(stderr, "%s: %s:%d: error, cannot use instrumented ",
				progname, root->hdr.fnm, root->hdr.line);
			fprintf(stderr, "function call %s() inside a declaration\n",
				my_fname);
		} else if (strncmp(OrigBuf, "R: ", 3) == 0)	// called in return stmnt */
		{	// fprintf(stderr, "No problem: %s\n", OrigBuf);
			goto here;
		} else	/* F: */
		{	char *p1, *p2;
here:			p1 = strrchr(OrigBuf, '[');
			p2 = strrchr(OrigBuf, ']');
			if (p1 && (!p2 || p1 > p2))
			{
				fprintf(stderr, "%s: %s:%d: warning, using instrumented ",
					progname, root->hdr.fnm, root->hdr.line);
				fprintf(stderr, "function call %s() in array index (%s)\n",
					my_fname, OrigBuf);

				fprintf(fp, " lck_p_%s_ret = 0;\n", my_fname);
				noreset = 1;	// dont reset again

				/* assuming there's just one function call... */
				strcat(OrigBuf, " now.res_p_");
				strcat(OrigBuf, my_fname);
				strcat(OrigBuf, " ");
			}
		//	strcat(OrigBuf, " /* ");
		//	strcat(OrigBuf, my_fname); /* no return val */
		//	strcat(OrigBuf, "()  */");
		}

		// lck_ is set when the function returns a value
		// the lock should be reset, whether or not the return
		// value is picked up by the caller, i.e., for both A: and F:

		if (!noreset)	// if not already done
		{	strcat(OrigBuf, "; now.lck_p_");
			strcat(OrigBuf, my_fname);
			strcat(OrigBuf, "_ret = 0");
		}
		strcpy(OutBuf, OrigBuf);
	} else
	{	fprintf(fp, "\t/* fct call in paramlist: %s */", my_fname);
		fprintf(stderr, "%s: %s:%d: error, cannot use call to ",
			progname, root->hdr.fnm, root->hdr.line);
		fprintf(stderr, "instrumented fct %s() in a param list\n", my_fname);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x1, 0x357be(%rip)     # 0x4dc9c
jne 0x1885a
movl $0x0, 0x3eada(%rip)     # 0x56fc8
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x18de0
leaq 0x3dabe(%rip), %rdi     # 0x55fc0
leaq 0x1cd41(%rip), %rsi     # 0x3524a
movl $0x3, %edx
callq 0x4090
cmpl $0x0, %eax
jne 0x18587
leaq 0x3daa1(%rip), %rdi     # 0x55fc0
movl $0x5b, %esi
callq 0x4130
movq %rax, -0x20(%rbp)
leaq 0x3da8c(%rip), %rdi     # 0x55fc0
movl $0x5d, %esi
callq 0x4130
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1855f
cmpq $0x0, -0x28(%rbp)
je 0x1855a
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jbe 0x1855f
jmp 0x1870c
leaq 0x3da5a(%rip), %rdi     # 0x55fc0
leaq 0x1ebe8(%rip), %rsi     # 0x37155
callq 0x4250
movq -0x10(%rbp), %rsi
leaq 0x3da43(%rip), %rdi     # 0x55fc0
callq 0x4250
jmp 0x18809
leaq 0x3da32(%rip), %rdi     # 0x55fc0
leaq 0x1cca7(%rip), %rsi     # 0x3523c
movl $0x3, %edx
callq 0x4090
cmpl $0x0, %eax
jne 0x18658
leaq 0x3da11(%rip), %rdi     # 0x55fc0
leaq 0x1eb9f(%rip), %rsi     # 0x37155
callq 0x4250
movq -0x10(%rbp), %rsi
leaq 0x3d9fa(%rip), %rdi     # 0x55fc0
callq 0x4250
movq 0x2ff6e(%rip), %rdi     # 0x48540
movq -0x10(%rbp), %rdx
leaq 0x1eb84(%rip), %rsi     # 0x37161
movb $0x0, %al
callq 0x4190
movl $0x1, -0x14(%rbp)
leaq 0x2f65a(%rip), %rax     # 0x47c4c
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x18653
cmpl $0x0, 0x3e9c9(%rip)     # 0x56fcc
je 0x18653
movq 0x2c9ec(%rip), %rax     # 0x44ff8
movq (%rax), %rdi
leaq 0x2cb5a(%rip), %rax     # 0x45170
movq (%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movl 0x10(%rax), %r8d
leaq 0x1eb45(%rip), %rsi     # 0x37175
movb $0x0, %al
callq 0x4190
movq 0x2c9ba(%rip), %rax     # 0x44ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1eb53(%rip), %rsi     # 0x3719f
movb $0x0, %al
callq 0x4190
jmp 0x18807
leaq 0x3d961(%rip), %rdi     # 0x55fc0
leaq 0x1ee40(%rip), %rsi     # 0x374a6
movl $0x3, %edx
callq 0x4090
cmpl $0x0, %eax
jne 0x186eb
leaq 0x3d944(%rip), %rdi     # 0x55fc0
leaq 0x1ead2(%rip), %rsi     # 0x37155
callq 0x4250
movq -0x10(%rbp), %rsi
leaq 0x3d92d(%rip), %rdi     # 0x55fc0
callq 0x4250
movq 0x2c959(%rip), %rax     # 0x44ff8
movq (%rax), %rdi
leaq 0x2cac7(%rip), %rax     # 0x45170
movq (%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movl 0x10(%rax), %r8d
leaq 0x1eaff(%rip), %rsi     # 0x371c2
movb $0x0, %al
callq 0x4190
movq 0x2c927(%rip), %rax     # 0x44ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1eb0e(%rip), %rsi     # 0x371ed
movb $0x0, %al
callq 0x4190
jmp 0x18805
leaq 0x3d8ce(%rip), %rdi     # 0x55fc0
leaq 0x1d6f4(%rip), %rsi     # 0x35ded
movl $0x3, %edx
callq 0x4090
cmpl $0x0, %eax
jne 0x1870a
jmp 0x1870c
jmp 0x1870c
leaq 0x3d8ad(%rip), %rdi     # 0x55fc0
movl $0x5b, %esi
callq 0x4130
movq %rax, -0x30(%rbp)
leaq 0x3d898(%rip), %rdi     # 0x55fc0
movl $0x5d, %esi
callq 0x4130
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x18801
cmpq $0x0, -0x38(%rbp)
je 0x18756
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jbe 0x18801
movq 0x2c89b(%rip), %rax     # 0x44ff8
movq (%rax), %rdi
leaq 0x2ca09(%rip), %rax     # 0x45170
movq (%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movl 0x10(%rax), %r8d
leaq 0x1ea95(%rip), %rsi     # 0x37216
movb $0x0, %al
callq 0x4190
movq 0x2c869(%rip), %rax     # 0x44ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1eaa1(%rip), %rsi     # 0x3723e
leaq 0x3d81c(%rip), %rcx     # 0x55fc0
movb $0x0, %al
callq 0x4190
movq 0x2fd8e(%rip), %rdi     # 0x48540
movq -0x10(%rbp), %rdx
leaq 0x1e9a4(%rip), %rsi     # 0x37161
movb $0x0, %al
callq 0x4190
movl $0x1, -0x14(%rbp)
leaq 0x3d7ee(%rip), %rdi     # 0x55fc0
leaq 0x1e97c(%rip), %rsi     # 0x37155
callq 0x4250
movq -0x10(%rbp), %rsi
leaq 0x3d7d7(%rip), %rdi     # 0x55fc0
callq 0x4250
leaq 0x3d7cb(%rip), %rdi     # 0x55fc0
leaq 0x1d864(%rip), %rsi     # 0x36060
callq 0x4250
jmp 0x18803
jmp 0x18805
jmp 0x18807
jmp 0x18809
cmpl $0x0, -0x14(%rbp)
jne 0x18845
leaq 0x3d7aa(%rip), %rdi     # 0x55fc0
leaq 0x1ea49(%rip), %rsi     # 0x37266
callq 0x4250
movq -0x10(%rbp), %rsi
leaq 0x3d793(%rip), %rdi     # 0x55fc0
callq 0x4250
leaq 0x3d787(%rip), %rdi     # 0x55fc0
leaq 0x1ea33(%rip), %rsi     # 0x37273
callq 0x4250
leaq 0x2fd04(%rip), %rdi     # 0x48550
leaq 0x3d76d(%rip), %rsi     # 0x55fc0
callq 0x40a0
jmp 0x188c1
movq 0x2fcdf(%rip), %rdi     # 0x48540
movq -0x10(%rbp), %rdx
leaq 0x1ea10(%rip), %rsi     # 0x3727c
movb $0x0, %al
callq 0x4190
movq 0x2c77e(%rip), %rax     # 0x44ff8
movq (%rax), %rdi
leaq 0x2c8ec(%rip), %rax     # 0x45170
movq (%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movl 0x10(%rax), %r8d
leaq 0x1e9ff(%rip), %rsi     # 0x3729d
movb $0x0, %al
callq 0x4190
movq 0x2c74c(%rip), %rax     # 0x44ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1ea09(%rip), %rsi     # 0x372c3
movb $0x0, %al
callq 0x4190
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)