// File: /workspace/github_c_makefile_star2_O3/Cloudef[P]dwm-fork/dwm.c
// Function: spawn
void
spawn(const Arg *arg) {
   pid_t pid;

   if((pid = fork()) != 0)
      return;
   if(dpy)
      close(ConnectionNumber(dpy));

   /* open new programs in same working directory
    * as focused application */
   if (selmon->sel)
   {
         const char *home = getenv("HOME");
         assert(home && strchr(home, '/'));
         const size_t homelen= strlen(home);
         char *cwd, *pathbuf = NULL;
         struct stat statbuf;
         int check_again = 0;

         /* Check first if the whole thing is a path */
         cwd = selmon->sel->name;
         if (*cwd == '~') { /* expand to $HOME */
            if(!(pathbuf = malloc(homelen + strlen(cwd))))
               die("fatal: you are out of memory dummy!\n");
            strcpy(strcpy(pathbuf, home) + homelen, cwd + 1);
            cwd = pathbuf;
         }

         if (strchr(cwd, '/') && !stat(cwd, &statbuf))
         {
            if (!S_ISDIR(statbuf.st_mode))
               cwd = dirname(cwd);

            if (!chdir(cwd))
               check_again = 1;
         }
         if (pathbuf) free(pathbuf);
         pathbuf = NULL;

         if (!check_again)
         {
            /* NOTE: this needs the application to show path
             * in it's name */
            cwd = strtok(selmon->sel->name, SPAWN_CWD_DELIM);
            while (cwd) {
               if (*cwd == '~') { /* expand to $HOME */
                  if(!(pathbuf = malloc(homelen + strlen(cwd))))
                     die("fatal: you are out of memory dummy!\n");
                  strcpy(strcpy(pathbuf, home) + homelen, cwd + 1);
                  cwd = pathbuf;
               }

               if (strchr(cwd, '/') && !stat(cwd, &statbuf))
               {
                  if (!S_ISDIR(statbuf.st_mode))
                     cwd = dirname(cwd);

                  if (!chdir(cwd))
                     break;
               }

               cwd = strtok(NULL, SPAWN_CWD_DELIM);
            }
         }

         /* our memory shall be gone */
         if (pathbuf) free(pathbuf);
         pathbuf = NULL;
   }

   setsid();
   freopen("/dev/null", "w", stdout); freopen("/dev/null", "w", stderr);
   execvp(((char **)arg->v)[0], (char **)arg->v);
   fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
   perror(" failed");
   _exit(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
callq 0x5690
testl %eax, %eax
je 0x86ea
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xad97(%rip), %rax      # 0x13488
testq %rax, %rax
je 0x86fe
movl 0x10(%rax), %edi
callq 0x50c0
movq 0xad6b(%rip), %rax      # 0x13470
movq 0x80(%rax), %r12
testq %r12, %r12
jne 0x8719
movq %rbx, %rdi
callq 0x5870
leaq 0x5834(%rip), %rdi      # 0xdf54
callq 0x5480
movq %rax, (%rsp)
testq %rax, %rax
je 0x8741
movq (%rsp), %rdi
movl $0x2f, %esi
callq 0x5450
testq %rax, %rax
jne 0x8760
leaq 0x4ceb(%rip), %rdi      # 0xd433
leaq 0x4cfe(%rip), %rsi      # 0xd44d
leaq 0x4cfd(%rip), %rcx      # 0xd453
movl $0xab5, %edx            # imm = 0xAB5
callq 0x5140
movq (%rsp), %rdi
callq 0x52c0
movq %rax, %r15
cmpb $0x7e, (%r12)
jne 0x8797
movq %r12, %rdi
callq 0x52c0
leaq (%rax,%r15), %rdi
callq 0x51d0
testq %rax, %rax
jne 0x879c
leaq 0x4cdb(%rip), %rdi      # 0xd46b
xorl %eax, %eax
callq 0x6408
xorl %r14d, %r14d
jmp 0x87bf
movq %rax, %r14
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x5540
movq %r14, %rdi
addq %r15, %rdi
incq %r12
movq %r12, %rsi
callq 0x5540
movq %r14, %r12
movq %r12, %rdi
movl $0x2f, %esi
callq 0x5450
movb $0x1, %bpl
testq %rax, %rax
je 0x880e
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x5740
testl %eax, %eax
jne 0x880e
movl $0xf000, %eax           # imm = 0xF000
andl 0x20(%rsp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
je 0x8800
movq %r12, %rdi
callq 0x5050
movq %rax, %r12
movq %r12, %rdi
callq 0x5040
testl %eax, %eax
setne %bpl
testq %r14, %r14
je 0x881b
movq %r14, %rdi
callq 0x52a0
testb %bpl, %bpl
je 0x8711
movq 0xac45(%rip), %rax      # 0x13470
movq 0x80(%rax), %rdi
leaq 0x4c57(%rip), %rsi      # 0xd490
callq 0x5550
testq %rax, %rax
je 0x8711
movq %rax, %rbp
xorl %r14d, %r14d
leaq 0x4c3c(%rip), %r12      # 0xd490
leaq 0x8(%rsp), %r13
cmpb $0x7e, (%rbp)
jne 0x889c
movq %rbp, %rdi
callq 0x52c0
leaq (%rax,%r15), %rdi
callq 0x51d0
testq %rax, %rax
je 0x8789
movq %rax, %r14
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x5540
movq %r14, %rdi
addq %r15, %rdi
incq %rbp
movq %rbp, %rsi
callq 0x5540
movq %r14, %rbp
movq %rbp, %rdi
movl $0x2f, %esi
callq 0x5450
testq %rax, %rax
je 0x88e6
movq %rbp, %rdi
movq %r13, %rsi
callq 0x5740
testl %eax, %eax
jne 0x88e6
movl 0x20(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0x4000, %eax           # imm = 0x4000
je 0x88da
movq %rbp, %rdi
callq 0x5050
movq %rax, %rbp
movq %rbp, %rdi
callq 0x5040
testl %eax, %eax
je 0x88fc
xorl %edi, %edi
movq %r12, %rsi
callq 0x5550
movq %rax, %rbp
testq %rax, %rax
jne 0x8859
testq %r14, %r14
je 0x8711
movq %r14, %rdi
callq 0x52a0
jmp 0x8711