// File: /workspace/github_c_makefile_star2_O3/nimble-code[P]Modex/Src/xtract.c
// Function: do_ccode
char *
do_ccode(int lno)
{	char *tag, *p, *lst = "";
	int i = 0, nn, mm;

	if (strncmp(OutBuf, "C: ", strlen("C: ")) == 0)
	{	i = strlen("C: ");
		tag = "c_expr { ";

		if (strstr(OutBuf, ND_CHOICE)
		||  strcmp(&OutBuf[i], "1") == 0)
		{	p = "true";
			goto sc;
		}
	} else if (strncmp(OutBuf, "case ", strlen("case ")) == 0)
	{	i = strlen("case ");
		tag = "c_expr { ";

		if (strstr(OutBuf, ND_CHOICE))
		{	p = "true";
			goto sc;
		}
	} else if (strncmp(OutBuf, "R: ", 3) == 0)
	{	p = "goto Return";

		if (strlen(OutBuf) > strlen("R: return"))
		{	if (extended)
			{	char *z, more[4096];

				for (z = &OutBuf[strlen("R: return")]; *z; z++)
				{	if (*z == ' ' || *z == '\t')
						continue;
					else
						break;
				}
				/*
				   if there are multiple instantiations of this proctype/function,
				   then we want to make sure that the return value that is
				   written into a global temporary var cannot change until it is
				   picked up by the caller -- so we use a lck_fctname_ret that the
				   caller resets to zero when the value has been retrieved.
				   assumes there is only one possible return value of type long
				   should instead:
					find the var reference - determine its type and
					declare the global res_%s accordingly
				 */
				sprintf(more, "\tatomic { !lck_p_%s_ret -> lck_p_%s_ret = 1 };\n\t",
					fct_name, fct_name);
				vis_direct(more);
				if (strlen(z) > 0)
				{
#if 0
					sprintf(more, "c_code { now.res_p_%s = (long) %s; }; ",
						fct_name, z);
#else
					sprintf(more, "c_code { now.res_p_%s = (%s) %s; }; ",
						fct_name, fct_type, z);
#endif
					vis_direct(more);
				}
			} else if (!show_deps && Warnings)
			{	fprintf(stderr, "%s: line %3d, warning, args on"
					" return not preserved: ", progname, lno);
				fprintf(stderr, " %s\n", rm_decor(OutBuf));
			}
			extra_comment = 1;
		}
		goto sc;
	} else  if (OutBuf[1] == ':' && OutBuf[2] == ' '
		&& (OutBuf[0] == 'A' || OutBuf[0] == 'F'))
	{	i = strlen("A: ");

		if (strncmp(&OutBuf[i], "assert(", strlen("assert(")) == 0
		&&   strcmp(&OutBuf[strlen(OutBuf)-1], ")") == 0)
		{	int nx = strlen(OutBuf)-1;
			OutBuf[nx] = '\0';
			mm =  strlen("F: assert(");
			nn =  strlen("c_code [] { ; };") + strlen(&OutBuf[mm]) + 1;
			p = (char *) e_malloc(nn * sizeof(char));
			sprintf(p, "c_code [%s] { ; }", &OutBuf[mm]);

			OutBuf[nx] = ')';
			goto sc;
		}

		if (strncmp(&OutBuf[i], "printf(", strlen("printf(")) == 0)
		{	nn =  strlen(&OutBuf[i]) + 1 + strlen("c_code { P") + strlen(" } ");
			p = (char *) e_malloc(nn * sizeof(char));
			sprintf(p, "c_code { P%s;", &OutBuf[i+1]);	/* map to Printf */
			strcat(p, " }");
			/* fprintf(stderr, "p length %d nn %d, p=%s\n", strlen(p), nn, p); */
			goto sc;
		}
		goto same;
	} else if (strncmp(OutBuf, "D: ", 3) == 0)
	{	p = "comment"; /* no locals in c_code fragments */
		goto sc;
	} else
	{	i = 0;
same:		if (strlen(PreBuf) > 0)
		{	tag = (char *) e_malloc(strlen("c_code [] { ")+strlen(PreBuf)+1);
			sprintf(tag, "c_code [%s] { ", PreBuf);
		} else
			tag = "c_code { ";
		lst = ";";
	}
	p = form_c_tag(tag, i, lst);
sc:
	return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1000, %rsp           # imm = 0x1000
movl $0x3a43, %eax           # imm = 0x3A43
xorl 0x27ce6(%rip), %eax     # 0x39380
movzbl 0x27ce1(%rip), %ecx     # 0x39382
xorl $0x20, %ecx
orw %ax, %cx
je 0x117bd
movl $0x65736163, %eax       # imm = 0x65736163
xorl 0x27cc8(%rip), %eax     # 0x39380
movzbl 0x27cc5(%rip), %ecx     # 0x39384
xorl $0x20, %ecx
orl %eax, %ecx
je 0x117ff
movl $0x3a52, %eax           # imm = 0x3A52
xorl 0x27cab(%rip), %eax     # 0x39380
movzbl 0x27ca6(%rip), %ecx     # 0x39382
xorl $0x20, %ecx
orw %ax, %cx
je 0x1188a
cmpb $0x3a, 0x27c92(%rip)    # 0x39381
jne 0x11827
cmpb $0x20, 0x27c86(%rip)    # 0x39382
jne 0x11827
movzbl 0x27c77(%rip), %eax     # 0x39380
cmpl $0x46, %eax
je 0x11717
cmpl $0x41, %eax
jne 0x11827
movl $0x65737361, %eax       # imm = 0x65737361
xorl 0x27c61(%rip), %eax     # 0x39383
movl $0x28747265, %ecx       # imm = 0x28747265
xorl 0x27c59(%rip), %ecx     # 0x39386
orl %eax, %ecx
jne 0x11753
leaq 0x27c48(%rip), %r14     # 0x39380
movq %r14, %rdi
callq 0x4110
cmpb $0x29, -0x1(%rax,%r14)
jne 0x11753
cmpb $0x0, (%rax,%r14)
je 0x119a4
movl $0x6e697270, %eax       # imm = 0x6E697270
xorl 0x27c25(%rip), %eax     # 0x39383
movl $0x2866746e, %ecx       # imm = 0x2866746E
xorl 0x27c1d(%rip), %ecx     # 0x39386
orl %eax, %ecx
movl $0x3, %ebx
jne 0x11847
leaq 0x27c06(%rip), %rdi     # 0x39383
callq 0x4110
leal 0xe(%rax), %edi
callq 0x6321
movq %rax, %rbx
leaq 0x134b0(%rip), %rsi     # 0x24c44
leaq 0x27be9(%rip), %rdx     # 0x39384
movq %rax, %rdi
xorl %eax, %eax
callq 0x42a0
movq %rbx, %rdi
callq 0x4110
movw $0x7d20, (%rbx,%rax)    # imm = 0x7D20
movb $0x0, 0x2(%rbx,%rax)
jmp 0x11991
leaq 0x27bbc(%rip), %rdi     # 0x39380
leaq 0x1426f(%rip), %rsi     # 0x25a3a
callq 0x42d0
leaq 0x12801(%rip), %rbx     # 0x23fd8
testq %rax, %rax
jne 0x11991
cmpw $0x31, 0x27b9b(%rip)    # 0x39383
je 0x11991
leaq 0x13393(%rip), %r15     # 0x24b88
movl $0x3, %ebx
jmp 0x118df
leaq 0x27b7a(%rip), %rdi     # 0x39380
leaq 0x1422d(%rip), %rsi     # 0x25a3a
callq 0x42d0
testq %rax, %rax
je 0x118d3
leaq 0x127b6(%rip), %rbx     # 0x23fd8
jmp 0x11991
movl $0x3a44, %eax           # imm = 0x3A44
xorl 0x27b4e(%rip), %eax     # 0x39380
movzbl 0x27b49(%rip), %ecx     # 0x39382
xorl $0x20, %ecx
xorl %ebx, %ebx
orw %ax, %cx
je 0x118e8
leaq 0x2d292(%rip), %rdi     # 0x3eae0
callq 0x4110
leaq 0x1481c(%rip), %r14     # 0x26076
testq %rax, %rax
je 0x118f4
addl $0xd, %eax
movl %eax, %edi
callq 0x6321
movq %rax, %r15
leaq 0x133db(%rip), %rsi     # 0x24c52
leaq 0x2d262(%rip), %rdx     # 0x3eae0
movq %rax, %rdi
xorl %eax, %eax
callq 0x42a0
jmp 0x118fb
movl %edi, %ebp
leaq 0x27aed(%rip), %rdi     # 0x39380
callq 0x4110
leaq 0x132f3(%rip), %rbx     # 0x24b92
cmpq $0xa, %rax
jb 0x11991
leaq 0x273e4(%rip), %rax     # 0x38c94
cmpl $0x0, (%rax)
je 0x11972
leaq 0x27ac9(%rip), %r14     # 0x39389
movzbl (%r14), %eax
cmpl $0x20, %eax
je 0x118ce
cmpl $0x9, %eax
jne 0x11917
incq %r14
jmp 0x118c0
leaq 0x132ae(%rip), %r15     # 0x24b88
movl $0x5, %ebx
leaq 0x147ab(%rip), %r14     # 0x26091
jmp 0x118fb
leaq 0x17cef(%rip), %rbx     # 0x295de
jmp 0x11991
leaq 0x13366(%rip), %r15     # 0x24c61
movq %r15, %rdi
movl %ebx, %esi
movq %r14, %rdx
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x11515
leaq 0x13280(%rip), %rsi     # 0x24b9e
leaq 0x24a6b(%rip), %rcx     # 0x36390
movq %rsp, %r15
movq %r15, %rdi
movq %rcx, %rdx
xorl %eax, %eax
callq 0x42a0
movq %r15, %rdi
callq 0xeab6
cmpb $0x0, (%r14)
je 0x1198a
leaq 0x13285(%rip), %rsi     # 0x24bcf
leaq 0x24a3f(%rip), %rdx     # 0x36390
leaq 0x24e38(%rip), %rcx     # 0x36790
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %r8
xorl %eax, %eax
callq 0x42a0
movq %r15, %rdi
callq 0xeab6
jmp 0x1198a
leaq 0x270f7(%rip), %rax     # 0x38a70
cmpl $0x0, (%rax)
jne 0x1198a
leaq 0x270fb(%rip), %rax     # 0x38a80
cmpl $0x0, (%rax)
jne 0x119e4
movb $0x1, 0x2d13f(%rip)     # 0x3ead0
movq %rbx, %rax
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
decq %rax
movslq %eax, %r12
movb $0x0, (%r12,%r14)
leaq 0x279d4(%rip), %r15     # 0x3938a
movq %r15, %rdi
callq 0x4110
leal 0x11(%rax), %edi
callq 0x6321
movq %rax, %rbx
leaq 0x1325a(%rip), %rsi     # 0x24c2a
movq %rax, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x42a0
movb $0x29, (%r12,%r14)
jmp 0x11991
movl %ebp, %edi
callq 0x4c7d
jmp 0x1198a