// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x4(%rbp)
callq 0x16900
callq 0x169b0
callq 0x16ae0
movq 0x3c26f(%rip), %rdi     # 0x54350
movq 0x3c270(%rip), %rsi     # 0x54358
callq 0x16bc0
cmpq $0x0, 0x3044b(%rip)     # 0x48540
jne 0x180fc
jmp 0x183b5
cmpq $0x0, 0x3c254(%rip)     # 0x54358
je 0x1822a
cmpq $0x0, 0x3c24e(%rip)     # 0x54360
je 0x1822a
leaq 0x2fae1(%rip), %rax     # 0x47c00
cmpl $0x0, (%rax)
je 0x18149
movq 0x30415(%rip), %rdi     # 0x48540
leaq 0x2face(%rip), %rax     # 0x47c00
movl (%rax), %edx
movq 0x3c21d(%rip), %rcx     # 0x54358
leaq 0x1eeda(%rip), %rsi     # 0x3701c
movb $0x0, %al
callq 0x4190
movq 0x303f0(%rip), %rdi     # 0x48540
leaq 0x1f1a4(%rip), %rsi     # 0x372fb
movb $0x0, %al
callq 0x4190
movq 0x303db(%rip), %rdi     # 0x48540
movq 0x3c1ec(%rip), %rdx     # 0x54358
movq 0x3c1e5(%rip), %rcx     # 0x54358
movq 0x3c1de(%rip), %r8      # 0x54358
leaq 0x1eec3(%rip), %rsi     # 0x37044
movb $0x0, %al
callq 0x4190
movq 0x3c1c9(%rip), %rdi     # 0x54358
callq 0x18c20
cmpl $0x0, %eax
je 0x181bc
movq 0x303a0(%rip), %rdi     # 0x48540
movq 0x3c1b1(%rip), %rdx     # 0x54358
movq 0x3c1b2(%rip), %rcx     # 0x54360
leaq 0x1eecd(%rip), %rsi     # 0x37082
movb $0x0, %al
callq 0x4190
movq 0x3037d(%rip), %rdi     # 0x48540
movq 0x3c18e(%rip), %rdx     # 0x54358
leaq 0x1eed2(%rip), %rsi     # 0x370a3
movb $0x0, %al
callq 0x4190
movq 0x30361(%rip), %rdi     # 0x48540
leaq 0x1eed3(%rip), %rsi     # 0x370b9
movb $0x0, %al
callq 0x4190
movq 0x3034c(%rip), %rdi     # 0x48540
movq 0x3c15d(%rip), %rdx     # 0x54358
leaq 0x1eebb(%rip), %rsi     # 0x370bd
movb $0x0, %al
callq 0x4190
movq 0x30330(%rip), %rdi     # 0x48540
movq 0x3c141(%rip), %rdx     # 0x54358
leaq 0x1eeb8(%rip), %rsi     # 0x370d6
movb $0x0, %al
callq 0x4190
jmp 0x183ae
leaq 0x3031f(%rip), %rax     # 0x48550
addq $0x14, %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x18245
jmp 0x182e7
movq -0x10(%rbp), %rdi
movl $0x29, %esi
callq 0x4110
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x18263
jmp 0x182e7
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movq -0x18(%rbp), %rdi
addq $0x1, %rdi
movl $0x22, %esi
callq 0x4110
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x18289
jmp 0x182e7
movq -0x20(%rbp), %rdi
addq $0x1, %rdi
movl $0x22, %esi
callq 0x4110
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x182a8
jmp 0x182e7
movq -0x28(%rbp), %rax
movb $0x0, (%rax)
movq 0x3028a(%rip), %rdi     # 0x48540
movq -0x10(%rbp), %rdx
movq -0x10(%rbp), %rax
movsbl (%rax), %esi
movl $0x20, %ecx
movl $0x29, %eax
cmpl $0x28, %esi
cmovel %eax, %ecx
movq -0x20(%rbp), %r8
addq $0x1, %r8
leaq 0x1ee1c(%rip), %rsi     # 0x370fc
movb $0x0, %al
callq 0x4190
leaq 0x30262(%rip), %rdi     # 0x48550
callq 0x40f0
cmpq $0x0, %rax
jbe 0x183ac
movq 0x2ccf4(%rip), %rax     # 0x44ff8
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, 0x3c045(%rip)     # 0x54358
je 0x18322
movq 0x3c03c(%rip), %rax     # 0x54358
movq %rax, -0x38(%rbp)
jmp 0x1832f
leaq 0x1c92a(%rip), %rax     # 0x34c53
movq %rax, -0x38(%rbp)
jmp 0x1832f
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, 0x3c021(%rip)     # 0x54360
je 0x1834e
movq 0x3c018(%rip), %rax     # 0x54360
movq %rax, -0x48(%rbp)
jmp 0x1835b
leaq 0x1c8fe(%rip), %rax     # 0x34c53
movq %rax, -0x48(%rbp)
jmp 0x1835b
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, 0x3bfe5(%rip)     # 0x54350
je 0x1837a
movq 0x3bfdc(%rip), %rax     # 0x54350
movq %rax, -0x58(%rbp)
jmp 0x18387
leaq 0x1c8d2(%rip), %rax     # 0x34c53
movq %rax, -0x58(%rbp)
jmp 0x18387
movq -0x50(%rbp), %r8
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %rdi
movq -0x58(%rbp), %r9
leaq 0x1ed73(%rip), %rsi     # 0x37111
leaq 0x301ab(%rip), %rdx     # 0x48550
movb $0x0, %al
callq 0x4190
jmp 0x183ae
movb $0x0, 0x3019b(%rip)     # 0x48550
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)