// File: /workspace/github_c_makefile_star2_O0/mvermeulen[P]wspy/topdown.c
// Function: launch_child
int launch_child(int argc,char *const argv[],char *const envp[]){
  pid_t child;
  int len;
  char *p,*path;
  char pathbuf[1024];

  if (pipe(child_pipe) == -1) fatal("pipe creation failed\n");
  switch(child = fork()){
  case 0: // child
    if (treeflag){
      debug("ptrace(PTRACE_TRACEME,0)\n");
      ptrace(PTRACE_TRACEME,0,NULL,NULL);
    }
    close(child_pipe[1]); // close writing end
    read(child_pipe[0],pathbuf,sizeof(pathbuf)); // wait until the parent has written
    execve(argv[0],argv,envp);
    // if argv[0] fails, look in path
    path = strdup(getenv("PATH"));
    len = strlen(argv[0]);
    p = strtok(path,":\n");
    if (p){
      do {
	strncpy(pathbuf,p,sizeof(pathbuf)-len-2);
	strcat(pathbuf,"/");
	strcat(pathbuf,argv[0]);
	execve(pathbuf,argv,envp);
	p = strtok(NULL,":\n");
      } while (p);
      // exec failed
      return 1;
    }
    break;
  case -1:
    fatal("fork failed\n");
    return 1;
  default:
    // parent
    close(child_pipe[0]); // close reading end
    child_pid = child;
    is_still_running = 1;
    break;
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x440, %rsp            # imm = 0x440
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq 0xeaff(%rip), %rdi      # 0x1313c
callq 0x3160
cmpl $-0x1, %eax
jne 0x4655
leaq 0x9fdc(%rip), %rdi      # 0xe62a
movb $0x0, %al
callq 0xbaf0
callq 0x3340
movl %eax, -0x1c(%rbp)
movl %eax, %ecx
movl %ecx, -0x434(%rbp)
subl $-0x1, %eax
je 0x47aa
jmp 0x4670
movl -0x434(%rbp), %eax
testl %eax, %eax
jne 0x47c1
jmp 0x4680
leaq 0xea69(%rip), %rax      # 0x130f0
cmpl $0x0, (%rax)
je 0x46ac
leaq 0x9fad(%rip), %rdi      # 0xe640
movb $0x0, %al
callq 0xbfe0
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %ecx
movl %esi, %edi
movq %rcx, %rdx
movb $0x0, %al
callq 0x3240
movl 0xea8e(%rip), %edi      # 0x13140
callq 0x3150
movl 0xea7f(%rip), %edi      # 0x1313c
leaq -0x430(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x3170
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x3190
leaq 0x9f71(%rip), %rdi      # 0xe65a
callq 0x3030
movq %rax, %rdi
callq 0x32f0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x30c0
movl %eax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x9f4b(%rip), %rsi      # 0xe65f
callq 0x3290
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x47a8
jmp 0x472a
leaq -0x430(%rbp), %rdi
movq -0x28(%rbp), %rsi
movslq -0x20(%rbp), %rax
movl $0x400, %edx            # imm = 0x400
subq %rax, %rdx
subq $0x2, %rdx
callq 0x3050
leaq -0x430(%rbp), %rdi
leaq 0x9f0a(%rip), %rsi      # 0xe662
callq 0x32c0
leaq -0x430(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x32c0
leaq -0x430(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x3190
xorl %eax, %eax
movl %eax, %edi
leaq 0x9ed0(%rip), %rsi      # 0xe65f
callq 0x3290
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x472a
movl $0x1, -0x4(%rbp)
jmp 0x47e6
jmp 0x47df
leaq 0x9eb3(%rip), %rdi      # 0xe664
movb $0x0, %al
callq 0xbaf0
movl $0x1, -0x4(%rbp)
jmp 0x47e6
movl 0xe975(%rip), %edi      # 0x1313c
callq 0x3150
movl -0x1c(%rbp), %eax
movl %eax, 0xe963(%rip)      # 0x13138
movl $0x1, 0xe965(%rip)      # 0x13144
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x440, %rsp            # imm = 0x440
popq %rbp
retq
nopw %cs:(%rax,%rax)