// File: /workspace/github_c_makefile_star2_O1/nimble-code[P]Modex/Src/xtract.c
// Function: handle_pthread_create
static void
handle_pthread_create(int which)
{
	// F:  pthread_create(&(t2),0,"thr2",0);
	set_create_id();
	set_thread_id();
	set_thread_arg();
	remember(join_id, thread_id);

	if (!fp) return;

	// fprintf(stderr, "handle %d: %s\n", which, OutBuf);

	if (0)
	{	fprintf(stderr, "join_id '%s', thread_id '%s', thread_arg '%s'\n",
			join_id?join_id:"?",
			thread_id?thread_id:"?",
			thread_arg?thread_arg:"?");
	}

	if (thread_id && thread_arg)
	{	if (dynamic)
		{	fprintf(fp, "\tatomic { _nr_pr < %d -> run p_%s() };\n",
				dynamic, thread_id);
		}
		fprintf(fp, "\tatomic {\n");
		fprintf(fp, "\t	lck_p_%s == 0 && empty(req_cll_p_%s) -> req_cll_p_%s!_pid;\n",
			thread_id, thread_id, thread_id);

		if (thread_has_params(thread_id))
		{	fprintf(fp, "\t	c_code { now.par0_%s = %s; };\n",
				thread_id, thread_arg);
		}
		fprintf(fp, "\t	exc_cll_p_%s!_pid;\n", thread_id);
		fprintf(fp, "\t}\n");
		fprintf(fp, "//\tret_p_%s?eval(_pid);\n", thread_id);
		fprintf(fp, "//\tc_code { now.lck_p_%s_ret = 0; };\n", thread_id);
	} else
	{	char *q, *r, *s, *t;
		q = &OutBuf[strlen("F: pthread_create(&(")];
					if (!q) goto bad;
		r = strchr(q, ')');	if (!r) goto bad;
		*r = '\0';
		s = strchr((r+1), '"');	if (!s) goto bad;
		t = strchr((s+1), '"');	if (!t) goto bad;
		*t = '\0';
		fprintf(fp, "\t%s%c = run p_%s();\n",
			q,
			(*q == '(')?')':' ',
			s+1);
bad:
		if (strlen(OutBuf) > 0)
		{	fprintf(stderr, "warning: unhandled type of %s (%s/%s/%s)\n",
				OutBuf,
				thread_id?thread_id:"--",
				thread_arg?thread_arg:"--",
				join_id?join_id:"--");
		}
	}
	OutBuf[0] = '\0';
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
callq 0x138ab
callq 0x13926
callq 0x139ea
movq 0x316ac(%rip), %rbx     # 0x46170
movq 0x316ad(%rip), %r14     # 0x46178
movl $0x18, %edi
callq 0x6469
movq %rbx, (%rax)
movq %r14, 0x8(%rax)
movq 0x316a5(%rip), %rcx     # 0x46188
movq %rcx, 0x10(%rax)
movq %rax, 0x3169a(%rip)     # 0x46188
movq 0x2586b(%rip), %rbx     # 0x3a360
testq %rbx, %rbx
je 0x14cdd
movq 0x31673(%rip), %rcx     # 0x46178
testq %rcx, %rcx
je 0x14bb9
cmpq $0x0, 0x3166a(%rip)     # 0x46180
je 0x14bb9
leaq 0x24efd(%rip), %rax     # 0x39a20
movl (%rax), %edx
testl %edx, %edx
je 0x14b3a
leaq 0x120d1(%rip), %rsi     # 0x26c01
movq %rbx, %rdi
xorl %eax, %eax
callq 0x41c0
movq 0x2581f(%rip), %rcx     # 0x3a360
leaq 0x12398(%rip), %rdi     # 0x26ee0
movl $0xa, %esi
movl $0x1, %edx
callq 0x42b0
movq 0x25802(%rip), %rdi     # 0x3a360
movq 0x31613(%rip), %rcx     # 0x46178
leaq 0x120bd(%rip), %rsi     # 0x26c29
movq %rcx, %rdx
movq %rcx, %r8
xorl %eax, %eax
callq 0x41c0
movq 0x27840(%rip), %r14     # 0x3c3c0
testq %r14, %r14
je 0x14c65
movq 0x315e8(%rip), %rbx     # 0x46178
movq 0x8(%r14), %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
jne 0x14bab
cmpl $0x2, 0x30(%r14)
je 0x14c46
movq 0x38(%r14), %r14
testq %r14, %r14
jne 0x14b90
jmp 0x14c65
leaq 0x257c4(%rip), %rdi     # 0x3a384
movl $0x29, %esi
callq 0x4130
testq %rax, %rax
je 0x14c2f
movb $0x0, (%rax)
incq %rax
movq %rax, %rdi
movl $0x22, %esi
callq 0x4130
testq %rax, %rax
je 0x14c2f
movq %rax, %r14
incq %r14
movq %r14, %rdi
movl $0x22, %esi
callq 0x4130
testq %rax, %rax
je 0x14c2f
movb $0x0, (%rax)
leaq 0x2577b(%rip), %rdx     # 0x3a384
xorl %eax, %eax
cmpb $0x28, 0x25772(%rip)    # 0x3a384
sete %al
leal (%rax,%rax,8), %ecx
addl $0x20, %ecx
leaq 0x120bf(%rip), %rsi     # 0x26ce1
movq %rbx, %rdi
movq %r14, %r8
xorl %eax, %eax
callq 0x41c0
cmpb $0x0, 0x2573a(%rip)     # 0x3a370
je 0x14cd6
callq 0x4fae
jmp 0x14cd6
movq 0x25713(%rip), %rdi     # 0x3a360
movq 0x3152c(%rip), %rcx     # 0x46180
leaq 0x1200c(%rip), %rsi     # 0x26c67
movq %rbx, %rdx
xorl %eax, %eax
callq 0x41c0
movq 0x256f4(%rip), %rdi     # 0x3a360
movq 0x31505(%rip), %rdx     # 0x46178
leaq 0x1200e(%rip), %rsi     # 0x26c88
xorl %eax, %eax
callq 0x41c0
movq 0x256d8(%rip), %rcx     # 0x3a360
leaq 0x1200f(%rip), %rdi     # 0x26c9e
movl $0x3, %esi
movl $0x1, %edx
callq 0x42b0
movq 0x256bb(%rip), %rdi     # 0x3a360
movq 0x314cc(%rip), %rdx     # 0x46178
leaq 0x11fef(%rip), %rsi     # 0x26ca2
xorl %eax, %eax
callq 0x41c0
movq 0x2569f(%rip), %rdi     # 0x3a360
movq 0x314b0(%rip), %rdx     # 0x46178
leaq 0x11fec(%rip), %rsi     # 0x26cbb
xorl %eax, %eax
callq 0x41c0
movb $0x0, 0x25693(%rip)     # 0x3a370
addq $0x8, %rsp
popq %rbx
popq %r14
retq