// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_start_process
static int mg_start_process(const char *interp, const char *cmd,
                            const char *env, const char *envp[],
                            const char *dir, sock_t sock) {
  char buf[500];
  pid_t pid = fork();
  (void) env;

  if (pid == 0) {
    /*
     * In Linux `chdir` declared with `warn_unused_result` attribute
     * To shutup compiler we have yo use result in some way
     */
    int tmp = chdir(dir);
    (void) tmp;
    (void) dup2(sock, 0);
    (void) dup2(sock, 1);
    closesocket(sock);

    /*
     * After exec, all signal handlers are restored to their default values,
     * with one exception of SIGCHLD. According to POSIX.1-2001 and Linux's
     * implementation, SIGCHLD's handler will leave unchanged after exec
     * if it was set to be ignored. Restore it to default action.
     */
    signal(SIGCHLD, SIG_DFL);

    if (interp == NULL) {
      execle(cmd, cmd, (char *) 0, envp); /* (char *) 0 to squash warning */
    } else {
      execle(interp, interp, cmd, (char *) 0, envp);
    }
    snprintf(buf, sizeof(buf),
             "Status: 500\r\n\r\n"
             "500 Server Error: %s%s%s: %s",
             interp == NULL ? "" : interp, interp == NULL ? "" : " ", cmd,
             strerror(errno));
    send(1, buf, strlen(buf), 0);
    _exit(EXIT_FAILURE); /* exec call failed */
  }

  return (pid != 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
callq 0x3680
movl %eax, -0x224(%rbp)
cmpl $0x0, -0x224(%rbp)
jne 0x1b175
movq -0x28(%rbp), %rdi
callq 0x3190
movl %eax, -0x228(%rbp)
movl -0x2c(%rbp), %edi
xorl %esi, %esi
callq 0x31b0
movl -0x2c(%rbp), %edi
movl $0x1, %esi
callq 0x31b0
movl -0x2c(%rbp), %edi
callq 0x32a0
movl $0x11, %edi
xorl %eax, %eax
movl %eax, %esi
callq 0x33c0
cmpq $0x0, -0x8(%rbp)
jne 0x1b077
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x3610
jmp 0x1b092
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x20(%rbp), %r8
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x3610
leaq -0x220(%rbp), %rax
movq %rax, -0x230(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x1b0b7
leaq 0x56fd(%rip), %rax      # 0x207ab
movq %rax, -0x238(%rbp)
jmp 0x1b0c2
movq -0x8(%rbp), %rax
movq %rax, -0x238(%rbp)
movq -0x238(%rbp), %rax
movq %rax, -0x258(%rbp)
movq -0x8(%rbp), %rdx
leaq 0x6519(%rip), %rax      # 0x215f4
leaq 0x56c9(%rip), %rcx      # 0x207ab
cmpq $0x0, %rdx
cmoveq %rcx, %rax
movq %rax, -0x250(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x248(%rbp)
callq 0x3090
movl (%rax), %edi
callq 0x3650
movq -0x230(%rbp), %rdi
movq -0x258(%rbp), %rcx
movq -0x250(%rbp), %r8
movq -0x248(%rbp), %r9
movl $0x1f4, %esi            # imm = 0x1F4
leaq 0x587d(%rip), %rdx      # 0x209ad
movq %rax, (%rsp)
movb $0x0, %al
callq 0x31f0
leaq -0x220(%rbp), %rax
movq %rax, -0x240(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x3180
movq -0x240(%rbp), %rsi
movq %rax, %rdx
movl $0x1, %edi
xorl %ecx, %ecx
callq 0x31d0
movl $0x1, %edi
callq 0x30c0
cmpl $0x0, -0x224(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %eax
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
nopl (%rax)