// File: /workspace/github_c_makefile_star2_O0/crcx[P]retroforth/vm/nga-c/./dev-unix.c
// Function: unix_run_external
V unix_run_external(NgaState *vm) {
  char *line, *args[128];
  int i, status;
  pid_t pid;

  char **argv = args;
  line = string_extract(vm, stack_pop(vm));

  for(i = 0; i < 128; i++)
    args[i] = 0;

  while (*line != '\0') {
    while (*line == ' ' || *line == '\t' || *line == '\n')
      *line++ = '\0';
    *argv++ = line;
    while (*line != '\0' && *line != ' ' && *line != '\t' && *line != '\n')
      line++;
  }

  if ((pid = fork()) < 0) {
    printf("*** ERROR: forking child process failed\n");
    exit(1);
  }
  else if (pid == 0) {
    int e = execvp(*args, args);
    if (e < 0) {
      printf("*** ERROR: exec failed with %d\n", e);
      exit(1);
    }
  } else {
  while (wait(&status) != pid)
    ;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x440, %rsp            # imm = 0x440
movq %rdi, -0x8(%rbp)
leaq -0x410(%rbp), %rax
movq %rax, -0x428(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x438(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3b30
movq -0x438(%rbp), %rdi
movl %eax, %esi
callq 0x40c0
movq %rax, -0x10(%rbp)
movl $0x0, -0x414(%rbp)
cmpl $0x80, -0x414(%rbp)
jge 0x66dd
movslq -0x414(%rbp), %rax
movq $0x0, -0x410(%rbp,%rax,8)
movl -0x414(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x414(%rbp)
jmp 0x66ad
jmp 0x66df
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x67d6
jmp 0x66f1
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x20, %ecx
movb %al, -0x439(%rbp)
je 0x672c
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x9, %ecx
movb %al, -0x439(%rbp)
je 0x672c
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
sete %al
movb %al, -0x439(%rbp)
movb -0x439(%rbp), %al
testb $0x1, %al
jne 0x6738
jmp 0x674c
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb $0x0, (%rax)
jmp 0x66f1
movq -0x10(%rbp), %rcx
movq -0x428(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x428(%rbp)
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x43a(%rbp)
je 0x67b7
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x20, %ecx
movb %al, -0x43a(%rbp)
je 0x67b7
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x9, %ecx
movb %al, -0x43a(%rbp)
je 0x67b7
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
setne %al
movb %al, -0x43a(%rbp)
movb -0x43a(%rbp), %al
testb $0x1, %al
jne 0x67c3
jmp 0x67d1
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x6768
jmp 0x66df
callq 0x3430
movl %eax, -0x41c(%rbp)
cmpl $0x0, %eax
jge 0x67fe
leaq 0x6a97(%rip), %rdi      # 0xd284
movb $0x0, %al
callq 0x3130
movl $0x1, %edi
callq 0x33a0
cmpl $0x0, -0x41c(%rbp)
jne 0x6849
movq -0x410(%rbp), %rdi
leaq -0x410(%rbp), %rsi
callq 0x3380
movl %eax, -0x42c(%rbp)
cmpl $0x0, -0x42c(%rbp)
jge 0x6847
movl -0x42c(%rbp), %esi
leaq 0x6a77(%rip), %rdi      # 0xd2ad
movb $0x0, %al
callq 0x3130
movl $0x1, %edi
callq 0x33a0
jmp 0x6863
jmp 0x684b
leaq -0x418(%rbp), %rdi
callq 0x3410
cmpl -0x41c(%rbp), %eax
je 0x6861
jmp 0x684b
jmp 0x6863
jmp 0x6865
addq $0x440, %rsp            # imm = 0x440
popq %rbp
retq
nop