// File: /workspace/github_c_makefile_star2_O2/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 0x8492
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xafef(%rip), %rax      # 0x13488
testq %rax, %rax
je 0x84a6
movl 0x10(%rax), %edi
callq 0x50c0
movq 0xafc3(%rip), %rax      # 0x13470
movq 0x80(%rax), %r12
testq %r12, %r12
jne 0x852d
callq 0x50b0
movq 0x9b33(%rip), %rax      # 0x11ff8
movq (%rax), %rdx
leaq 0x4fdf(%rip), %r14      # 0xd4ae
leaq 0x4fe2(%rip), %r15      # 0xd4b8
movq %r14, %rdi
movq %r15, %rsi
callq 0x55f0
movq 0x9b00(%rip), %r12      # 0x11fe8
movq (%r12), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x55f0
movq (%rbx), %rsi
movq (%rsi), %rdi
callq 0x5120
movq (%r12), %rdi
movq (%rbx), %rax
movq (%rax), %rdx
leaq 0x4fa7(%rip), %rsi      # 0xd4ba
xorl %eax, %eax
callq 0x5730
leaq 0x4fa8(%rip), %rdi      # 0xd4c9
callq 0x56f0
xorl %edi, %edi
callq 0x5210
leaq 0x5a30(%rip), %rdi      # 0xdf64
callq 0x5480
movq %rax, (%rsp)
testq %rax, %rax
je 0x8553
pushq $0x2f
popq %rsi
movq (%rsp), %rdi
callq 0x5450
testq %rax, %rax
jne 0x8572
leaq 0x4ee9(%rip), %rdi      # 0xd443
leaq 0x4efc(%rip), %rsi      # 0xd45d
leaq 0x4efb(%rip), %rcx      # 0xd463
movl $0xab5, %edx            # imm = 0xAB5
callq 0x5140
movq (%rsp), %rdi
callq 0x52c0
movq %rax, %r15
cmpb $0x7e, (%r12)
jne 0x85a9
movq %r12, %rdi
callq 0x52c0
leaq (%rax,%r15), %rdi
callq 0x51d0
testq %rax, %rax
jne 0x85ae
leaq 0x4ed9(%rip), %rdi      # 0xd47b
xorl %eax, %eax
callq 0x62ae
xorl %r14d, %r14d
jmp 0x85d1
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
pushq $0x2f
popq %rsi
movq %r12, %rdi
callq 0x5450
testq %rax, %rax
je 0x8633
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x5740
testl %eax, %eax
jne 0x8633
movl $0xf000, %eax           # imm = 0xF000
andl 0x20(%rsp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
je 0x860d
movq %r12, %rdi
callq 0x5050
movq %rax, %r12
movq %r12, %rdi
callq 0x5040
movl %eax, %ebp
movq %r14, %rdi
callq 0x52a0
testl %ebp, %ebp
jne 0x863b
xorl %r14d, %r14d
movq %r14, %rdi
callq 0x52a0
jmp 0x84b9
movq %r14, %rdi
callq 0x52a0
movq 0xae2e(%rip), %rax      # 0x13470
movq 0x80(%rax), %rdi
leaq 0x4e50(%rip), %r12      # 0xd4a0
movq %r12, %rsi
callq 0x5550
movq %rax, %r13
xorl %r14d, %r14d
pushq $0x2f
popq %rbp
testq %r13, %r13
je 0x8626
cmpb $0x7e, (%r13)
jne 0x86aa
movq %r13, %rdi
callq 0x52c0
leaq (%rax,%r15), %rdi
callq 0x51d0
testq %rax, %rax
je 0x859b
movq %rax, %r14
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x5540
movq %r14, %rdi
addq %r15, %rdi
incq %r13
movq %r13, %rsi
callq 0x5540
movq %r14, %r13
movq %r13, %rdi
movl %ebp, %esi
callq 0x5450
testq %rax, %rax
je 0x86f7
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq 0x5740
testl %eax, %eax
jne 0x86f7
movl 0x20(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0x4000, %eax           # imm = 0x4000
je 0x86e7
movq %r13, %rdi
callq 0x5050
movq %rax, %r13
movq %r13, %rdi
callq 0x5040
testl %eax, %eax
je 0x8626
xorl %edi, %edi
movq %r12, %rsi
callq 0x5550
movq %rax, %r13
jmp 0x8661