// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxUnixUtil.c
// Function: Hax_Fork
int
Hax_Fork(
    Hax_Interp *interp,
    ClientData clientData)
{
    UnixClientData *unixClientData = (UnixClientData *) clientData;
    Hax_Memoryp *memoryp;
    WaitInfo *waitPtr;
    pid_t pid;

    memoryp = Hax_GetMemoryp(interp);

    /*
     * Disable SIGPIPE signals:  if they were allowed, this process
     * might go away unexpectedly if children misbehave.  This code
     * can potentially interfere with other application code that
     * expects to handle SIGPIPEs;  what's really needed is an
     * arbiter for signals to allow them to be "shared".
     */

    if (unixClientData->waitTable == NULL) {
	(void) signal(SIGPIPE, SIG_IGN);
    }

    /*
     * Enlarge the wait table if there isn't enough space for a new
     * entry.
     */

    if (unixClientData->waitTableUsed == unixClientData->waitTableSize) {
	int newSize;
	WaitInfo *newWaitTable;

	newSize = unixClientData->waitTableSize + WAIT_TABLE_GROW_BY;
	newWaitTable = (WaitInfo *) ckalloc(memoryp,
		newSize * sizeof(WaitInfo));
	memcpy(newWaitTable, unixClientData->waitTable,
		(unixClientData->waitTableSize * sizeof(WaitInfo)));
	if (unixClientData->waitTable != NULL) {
	    ckfree(memoryp, unixClientData->waitTable);
	}
	unixClientData->waitTable = newWaitTable;
	unixClientData->waitTableSize = newSize;
    }

    /*
     * Make a new process and enter it into the table if the fork
     * is successful.
     */

    waitPtr = &unixClientData->waitTable[unixClientData->waitTableUsed];
    pid = fork();
    if (pid > 0) {
	waitPtr->pid = pid;
	waitPtr->flags = 0;
	unixClientData->waitTableUsed++;
    }
    return pid;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3540
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x88(%rax)
jne 0x94c2
movl $0xd, %edi
movl $0x1, %esi
callq 0x3340
movq -0x18(%rbp), %rax
movl 0x94(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x90(%rcx), %eax
jne 0x957a
movq -0x18(%rbp), %rax
movl 0x90(%rax), %eax
addl $0x4, %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x30(%rbp), %rax
imulq $0xc, %rax, %rsi
leaq 0x2d4f(%rip), %rdx      # 0xc24e
movl $0xab, %ecx
callq 0x34c0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rsi
movq -0x18(%rbp), %rax
movslq 0x90(%rax), %rax
imulq $0xc, %rax, %rdx
callq 0x33c0
movq -0x18(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0x955e
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rsi
leaq 0x2cfa(%rip), %rdx      # 0xc24e
movl $0xaf, %ecx
callq 0x31f0
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x88(%rax)
movl -0x30(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x18(%rbp), %rcx
movslq 0x94(%rcx), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
callq 0x3610
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jle 0x95d0
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x18(%rbp), %rax
movl 0x94(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x94(%rax)
movl -0x2c(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)