// File: /workspace/github_c_makefile_star2_O0/kobolt[P]curses-collection/difftree/navi.c
// Function: diff_navi_call_program
static void diff_navi_call_program(diff_node_t *node, int node_no, char *root1, char *root2)
{
  diff_node_t *found;
  pid_t pid1, pid2;
  int pipe_fd[2];
  int size, status;
  char path1[PATH_MAX], path2[PATH_MAX], temp[PATH_MAX];

  size = 0;
  found = diff_navi_node_get(node, node_no, &size);
  if (found == NULL)
    return;

  switch (found->type) {
  case DIFF_TYPE_FILE_DIFFERS:
    endwin();

    pid1 = fork();
    if (pid1 == -1) {
      /* Nothing to do... */

    } else if (pid1 > 0) {
      waitpid(pid1, &status, 0);

    } else {

      pipe(pipe_fd);
      pid2 = fork();
      if (pid2 == -1) {
        _exit(0);

      } else if (pid2 > 0) {
        dup2(pipe_fd[0], STDIN_FILENO);
        close(pipe_fd[0]);
        close(pipe_fd[1]);
        execlp(PAGER_PROGRAM, PAGER_PROGRAM, NULL);
        _exit(0);

      } else {
        snprintf(path1, PATH_MAX, "%s/%s",
          root1, diff_node_path(found, temp, PATH_MAX)),
        snprintf(path2, PATH_MAX, "%s/%s",
          root2, diff_node_path(found, temp, PATH_MAX)),

        dup2(pipe_fd[1], STDOUT_FILENO);
        close(pipe_fd[0]);
        close(pipe_fd[1]);
        execlp(DIFF_PROGRAM, DIFF_PROGRAM, DIFF_ARG, path1, path2, NULL);
        _exit(0);
      }
    }

    flushinp();
    keypad(stdscr, TRUE);
    break;

  default:
    break;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3060, %rsp           # imm = 0x3060
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq -0x3c(%rbp), %rdx
callq 0x41f0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x3a81
jmp 0x3c30
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
subl $0x2, %eax
jne 0x3c2e
jmp 0x3a93
callq 0x2290
callq 0x22c0
movl %eax, -0x2c(%rbp)
cmpl $-0x1, -0x2c(%rbp)
jne 0x3aab
jmp 0x3c13
cmpl $0x0, -0x2c(%rbp)
jle 0x3ac4
movl -0x2c(%rbp), %edi
leaq -0x40(%rbp), %rsi
xorl %edx, %edx
callq 0x2230
jmp 0x3c11
leaq -0x38(%rbp), %rdi
callq 0x2180
callq 0x22c0
movl %eax, -0x30(%rbp)
cmpl $-0x1, -0x30(%rbp)
jne 0x3ae2
xorl %edi, %edi
callq 0x2090
cmpl $0x0, -0x30(%rbp)
jle 0x3b1e
movl -0x38(%rbp), %edi
xorl %esi, %esi
callq 0x2110
movl -0x38(%rbp), %edi
callq 0x2170
movl -0x34(%rbp), %edi
callq 0x2170
leaq 0x15df(%rip), %rsi      # 0x50e8
xorl %eax, %eax
movl %eax, %edx
movq %rsi, %rdi
movb $0x0, %al
callq 0x22a0
xorl %edi, %edi
callq 0x2090
leaq -0x1040(%rbp), %rax
movq %rax, -0x3060(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x3058(%rbp)
movq -0x28(%rbp), %rdi
leaq -0x3040(%rbp), %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x2600
movq -0x3060(%rbp), %rdi
movq -0x3058(%rbp), %rcx
movq %rax, %r8
movl $0x1000, %esi           # imm = 0x1000
leaq 0x14bb(%rip), %rdx      # 0x5024
movb $0x0, %al
callq 0x2130
leaq -0x2040(%rbp), %rax
movq %rax, -0x3050(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x3048(%rbp)
movq -0x28(%rbp), %rdi
leaq -0x3040(%rbp), %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x2600
movq -0x3050(%rbp), %rdi
movq -0x3048(%rbp), %rcx
movq %rax, %r8
movl $0x1000, %esi           # imm = 0x1000
leaq 0x1469(%rip), %rdx      # 0x5024
movb $0x0, %al
callq 0x2130
movl -0x34(%rbp), %edi
movl $0x1, %esi
callq 0x2110
movl -0x38(%rbp), %edi
callq 0x2170
movl -0x34(%rbp), %edi
callq 0x2170
leaq -0x1040(%rbp), %rcx
leaq -0x2040(%rbp), %r8
leaq 0x14f9(%rip), %rsi      # 0x50ed
leaq 0x14f7(%rip), %rdx      # 0x50f2
xorl %eax, %eax
movl %eax, %r9d
movq %rsi, %rdi
movb $0x0, %al
callq 0x22a0
xorl %edi, %edi
callq 0x2090
jmp 0x3c13
callq 0x2070
movq 0x33b9(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
movl $0x1, %esi
callq 0x21a0
jmp 0x3c30
jmp 0x3c30
addq $0x3060, %rsp           # imm = 0x3060
popq %rbp
retq
nopl (%rax)