// File: /workspace/github_c_makefile_star2_O1/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 0x28da8(%rip), %eax     # 0x3a370
movzbl 0x28da3(%rip), %ecx     # 0x3a372
xorl $0x20, %ecx
orw %ax, %cx
je 0x116f6
movl $0x65736163, %eax       # imm = 0x65736163
xorl 0x28d8a(%rip), %eax     # 0x3a370
movzbl 0x28d87(%rip), %ecx     # 0x3a374
xorl $0x20, %ecx
orl %eax, %ecx
je 0x11738
movl $0x3a52, %eax           # imm = 0x3A52
xorl 0x28d6d(%rip), %eax     # 0x3a370
movzbl 0x28d68(%rip), %ecx     # 0x3a372
xorl $0x20, %ecx
orw %ax, %cx
je 0x117c3
cmpb $0x3a, 0x28d54(%rip)    # 0x3a371
jne 0x11760
cmpb $0x20, 0x28d48(%rip)    # 0x3a372
jne 0x11760
movzbl 0x28d39(%rip), %eax     # 0x3a370
cmpl $0x46, %eax
je 0x11645
cmpl $0x41, %eax
jne 0x11760
movl $0x65737361, %eax       # imm = 0x65737361
xorl 0x28d23(%rip), %eax     # 0x3a373
movl $0x28747265, %ecx       # imm = 0x28747265
xorl 0x28d1b(%rip), %ecx     # 0x3a376
orl %eax, %ecx
jne 0x1168c
leaq 0x28d0a(%rip), %r14     # 0x3a370
movq %r14, %rdi
callq 0x4110
movq %rax, %rbx
leaq (%rax,%r14), %rdi
decq %rdi
leaq 0x1417d(%rip), %rsi     # 0x257fc
callq 0x41b0
testl %eax, %eax
je 0x118dd
movl $0x6e697270, %eax       # imm = 0x6E697270
xorl 0x28cdc(%rip), %eax     # 0x3a373
movl $0x2866746e, %ecx       # imm = 0x2866746E
xorl 0x28cd4(%rip), %ecx     # 0x3a376
orl %eax, %ecx
movl $0x3, %ebx
jne 0x11780
leaq 0x28cbd(%rip), %rdi     # 0x3a373
callq 0x4110
leal 0xe(%rax), %edi
callq 0x6469
movq %rax, %rbx
leaq 0x14577(%rip), %rsi     # 0x25c44
leaq 0x28ca0(%rip), %rdx     # 0x3a374
movq %rax, %rdi
xorl %eax, %eax
callq 0x4290
movq %rbx, %rdi
callq 0x4110
movw $0x7d20, (%rbx,%rax)    # imm = 0x7D20
movb $0x0, 0x2(%rbx,%rax)
jmp 0x118ca
leaq 0x28c73(%rip), %rdi     # 0x3a370
leaq 0x15336(%rip), %rsi     # 0x26a3a
callq 0x42c0
leaq 0x138c8(%rip), %rbx     # 0x24fd8
testq %rax, %rax
jne 0x118ca
cmpw $0x31, 0x28c52(%rip)    # 0x3a373
je 0x118ca
leaq 0x1445a(%rip), %r15     # 0x25b88
movl $0x3, %ebx
jmp 0x11818
leaq 0x28c31(%rip), %rdi     # 0x3a370
leaq 0x152f4(%rip), %rsi     # 0x26a3a
callq 0x42c0
testq %rax, %rax
je 0x1180c
leaq 0x1387d(%rip), %rbx     # 0x24fd8
jmp 0x118ca
movl $0x3a44, %eax           # imm = 0x3A44
xorl 0x28c05(%rip), %eax     # 0x3a370
movzbl 0x28c00(%rip), %ecx     # 0x3a372
xorl $0x20, %ecx
xorl %ebx, %ebx
orw %ax, %cx
je 0x11821
leaq 0x2e349(%rip), %rdi     # 0x3fad0
callq 0x4110
leaq 0x158e6(%rip), %r14     # 0x27079
testq %rax, %rax
je 0x1182d
addl $0xd, %eax
movl %eax, %edi
callq 0x6469
movq %rax, %r15
leaq 0x144a2(%rip), %rsi     # 0x25c52
leaq 0x2e319(%rip), %rdx     # 0x3fad0
movq %rax, %rdi
xorl %eax, %eax
callq 0x4290
jmp 0x11834
movl %edi, %ebp
leaq 0x28ba4(%rip), %rdi     # 0x3a370
callq 0x4110
leaq 0x143ba(%rip), %rbx     # 0x25b92
cmpq $0xa, %rax
jb 0x118ca
leaq 0x2849b(%rip), %rax     # 0x39c84
cmpl $0x0, (%rax)
je 0x118ab
leaq 0x28b80(%rip), %r14     # 0x3a379
movzbl (%r14), %eax
cmpl $0x20, %eax
je 0x11807
cmpl $0x9, %eax
jne 0x11850
incq %r14
jmp 0x117f9
leaq 0x14375(%rip), %r15     # 0x25b88
movl $0x5, %ebx
leaq 0x15875(%rip), %r14     # 0x27094
jmp 0x11834
leaq 0x18db6(%rip), %rbx     # 0x2a5de
jmp 0x118ca
leaq 0x1442d(%rip), %r15     # 0x25c61
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 0x11449
leaq 0x14347(%rip), %rsi     # 0x25b9e
leaq 0x25b22(%rip), %rcx     # 0x37380
movq %rsp, %r15
movq %r15, %rdi
movq %rcx, %rdx
xorl %eax, %eax
callq 0x4290
movq %r15, %rdi
callq 0xebec
cmpb $0x0, (%r14)
je 0x118c3
leaq 0x1434c(%rip), %rsi     # 0x25bcf
leaq 0x25af6(%rip), %rdx     # 0x37380
leaq 0x25eef(%rip), %rcx     # 0x37780
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %r8
xorl %eax, %eax
callq 0x4290
movq %r15, %rdi
callq 0xebec
jmp 0x118c3
leaq 0x281ae(%rip), %rax     # 0x39a60
cmpl $0x0, (%rax)
jne 0x118c3
leaq 0x281b2(%rip), %rax     # 0x39a70
cmpl $0x0, (%rax)
jne 0x1191d
movb $0x1, 0x2e1f6(%rip)     # 0x3fac0
movq %rbx, %rax
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
decq %rbx
movslq %ebx, %r12
movb $0x0, (%r12,%r14)
leaq 0x28a8b(%rip), %r15     # 0x3a37a
movq %r15, %rdi
callq 0x4110
leal 0x11(%rax), %edi
callq 0x6469
movq %rax, %rbx
leaq 0x14321(%rip), %rsi     # 0x25c2a
movq %rax, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x4290
movb $0x29, (%r12,%r14)
jmp 0x118ca
movl %ebp, %edi
callq 0x4ca1
jmp 0x118c3