// File: /workspace/github_c_makefile_star2_O1/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 0x56a0
testl %eax, %eax
je 0x8733
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xad4e(%rip), %rax      # 0x13488
testq %rax, %rax
je 0x8747
movl 0x10(%rax), %edi
callq 0x50c0
movq 0xad22(%rip), %rax      # 0x13470
movq 0x80(%rax), %r12
testq %r12, %r12
jne 0x8762
movq %rbx, %rdi
callq 0x58cc
leaq 0x57de(%rip), %rdi      # 0xdf47
callq 0x5480
movq %rax, (%rsp)
testq %rax, %rax
je 0x878a
movq (%rsp), %rdi
movl $0x2f, %esi
callq 0x5450
testq %rax, %rax
jne 0x87a9
leaq 0x4c95(%rip), %rdi      # 0xd426
leaq 0x4ca8(%rip), %rsi      # 0xd440
leaq 0x4ca7(%rip), %rcx      # 0xd446
movl $0xab5, %edx            # imm = 0xAB5
callq 0x5140
movq (%rsp), %rdi
callq 0x52c0
movq %rax, %r15
cmpb $0x7e, (%r12)
jne 0x87e0
movq %r12, %rdi
callq 0x52c0
leaq (%rax,%r15), %rdi
callq 0x51d0
testq %rax, %rax
jne 0x87e5
leaq 0x4c85(%rip), %rdi      # 0xd45e
xorl %eax, %eax
callq 0x644f
xorl %r14d, %r14d
jmp 0x8808
movq %rax, %r14
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x5550
movq %r14, %rdi
addq %r15, %rdi
incq %r12
movq %r12, %rsi
callq 0x5550
movq %r14, %r12
movq %r12, %rdi
movl $0x2f, %esi
callq 0x5450
movb $0x1, %bpl
testq %rax, %rax
je 0x8857
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x5750
testl %eax, %eax
jne 0x8857
movl $0xf000, %eax           # imm = 0xF000
andl 0x20(%rsp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
je 0x8849
movq %r12, %rdi
callq 0x5050
movq %rax, %r12
movq %r12, %rdi
callq 0x5040
testl %eax, %eax
setne %bpl
testq %r14, %r14
je 0x8864
movq %r14, %rdi
callq 0x52a0
testb %bpl, %bpl
je 0x8888
movq 0xac00(%rip), %rax      # 0x13470
movq 0x80(%rax), %rdi
leaq 0x4c05(%rip), %rsi      # 0xd483
callq 0x5560
testq %rax, %rax
jne 0x88a1
xorl %r14d, %r14d
testq %r14, %r14
je 0x875a
movq %r14, %rdi
callq 0x52a0
jmp 0x875a
movq %rax, %r12
xorl %r14d, %r14d
leaq 0x4bd5(%rip), %r13      # 0xd483
leaq 0x8(%rsp), %rbp
cmpb $0x7e, (%r12)
jne 0x88f7
movq %r12, %rdi
callq 0x52c0
leaq (%rax,%r15), %rdi
callq 0x51d0
testq %rax, %rax
je 0x87d2
movq %rax, %r14
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x5550
movq %r14, %rdi
addq %r15, %rdi
incq %r12
movq %r12, %rsi
callq 0x5550
movq %r14, %r12
movq %r12, %rdi
movl $0x2f, %esi
callq 0x5450
testq %rax, %rax
je 0x8945
movq %r12, %rdi
movq %rbp, %rsi
callq 0x5750
testl %eax, %eax
jne 0x8945
movl 0x20(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0x4000, %eax           # imm = 0x4000
je 0x8935
movq %r12, %rdi
callq 0x5050
movq %rax, %r12
movq %r12, %rdi
callq 0x5040
testl %eax, %eax
je 0x888b
xorl %edi, %edi
movq %r13, %rsi
callq 0x5560
movq %rax, %r12
testq %rax, %rax
jne 0x88b3
jmp 0x888b