#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct timeval {
  int /*<<< orphan*/ tv_usec;
  int /*<<< orphan*/ tv_sec;
};
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ WNOHANG;
scalar_t__ errno;
scalar_t__ fork();
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ getppid();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
char *strerror(scalar_t__);
int waitpid(int, int *, int /*<<< orphan*/);
int no_child_exists(int argc, char *argv[]) {
  do {
    struct timeval tv;
    gettimeofday(&tv, NULL);
    printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(), getpid());
    printf("to test no child exists");
    printf("\n");
  } while (0);
  int ret = 0;
  int st = 0;
  errno = 0;
  ret = waitpid(-1, &st, WNOHANG);
  if (ret < 0) {
    do {
      struct timeval tv;
      gettimeofday(&tv, NULL);
      printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
             getpid());
      printf("error happend : [%s]", strerror(errno));
      printf("\n");
    } while (0);
  } else if (0 == ret) {
    do {
      struct timeval tv;
      gettimeofday(&tv, NULL);
      printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
             getpid());
      printf("no child change state");
      printf("\n");
    } while (0);
  } else {
    do {
      struct timeval tv;
      gettimeofday(&tv, NULL);
      printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
             getpid());
      printf("child [%d] exit", ret);
      printf("\n");
    } while (0);
  }
  pid_t pid = fork();
  if (pid < 0) {
    do {
      struct timeval tv;
      gettimeofday(&tv, NULL);
      printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
             getpid());
      printf("fork failed");
      printf("\n");
    } while (0);
    return -1;
  } else if (0 == pid) {
    do {
      struct timeval tv;
      gettimeofday(&tv, NULL);
      printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
             getpid());
      printf("in child process");
      printf("\n");
    } while (0);
    pid_t pid = fork();
    if (pid < 0) {
      do {
        struct timeval tv;
        gettimeofday(&tv, NULL);
        printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
               getpid());
        printf("fork failed");
        printf("\n");
      } while (0);
    } else if (0 == pid) {
      do {
        struct timeval tv;
        gettimeofday(&tv, NULL);
        printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
               getpid());
        printf("sleep 2 ...");
        printf("\n");
      } while (0);
      sleep(2);
    } else {
      do {
        struct timeval tv;
        gettimeofday(&tv, NULL);
        printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
               getpid());
        printf("sleep 3 ...");
        printf("\n");
      } while (0);
      sleep(3);
    }
    do {
      struct timeval tv;
      gettimeofday(&tv, NULL);
      printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
             getpid());
      printf("exit ...");
      printf("\n");
    } while (0);
    return 0;
  } else {
    do {
      struct timeval tv;
      gettimeofday(&tv, NULL);
      printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
             getpid());
      printf("in parent");
      printf("\n");
    } while (0);
    sleep(1);
    while (1) {
      int st = 0;
      errno = 0;
      if (0 != waitpid(-1, &st, WNOHANG)) {
        do {
          struct timeval tv;
          gettimeofday(&tv, NULL);
          printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
                 getpid());
          printf("no child process exists");
          printf("\n");
        } while (0);
        break;
      } else {
        do {
          struct timeval tv;
          gettimeofday(&tv, NULL);
          printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
                 getpid());
          printf("some child exists");
          printf("\n");
        } while (0);
      }
      do {
        struct timeval tv;
        gettimeofday(&tv, NULL);
        printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
               getpid());
        printf("wait for children ...");
        printf("\n");
      } while (0);
      int ret = waitpid(-1, &st, 0);
      if (ret < 0) {
        do {
          struct timeval tv;
          gettimeofday(&tv, NULL);
          printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
                 getpid());
          printf("error = [%s]", strerror(errno));
          printf("\n");
        } while (0);
        break;
      } else if (0 == ret) {
        do {
          struct timeval tv;
          gettimeofday(&tv, NULL);
          printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
                 getpid());
          printf("what happend ?");
          printf("\n");
        } while (0);
      } else {
        do {
          struct timeval tv;
          gettimeofday(&tv, NULL);
          printf("%ld.%6ld [%d->%d] -- ", tv.tv_sec, tv.tv_usec, getppid(),
                 getpid());
          printf("child [%d] exit", ret);
          printf("\n");
        } while (0);
      }
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<no_child_exists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0xcc(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0xc8(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0xc4(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xcc(%rbp),%esi
mov    -0xc8(%rbp),%edx
mov    -0xc4(%rbp),%ecx
mov    %eax,%r8d
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    0x2dbf(%rip),%rax
movq   $0x0,(%rax)
mov    0x2dc1(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%edi
lea    -0x20(%rbp),%rsi
call   1060 <waitpid@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    12d2 <no_child_exists+0x152>
jmp    1249 <no_child_exists+0xc9>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0xd8(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0xd4(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0xd0(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xd8(%rbp),%esi
mov    -0xd4(%rbp),%edx
mov    -0xd0(%rbp),%ecx
mov    %eax,%r8d
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d32(%rip),%rax
mov    (%rax),%rdi
call   1080 <strerror@plt>
mov    %rax,%rsi
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13dd <no_child_exists+0x25d>
xor    %eax,%eax
cmp    -0x1c(%rbp),%eax
jne    1359 <no_child_exists+0x1d9>
jmp    12e2 <no_child_exists+0x162>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0xe4(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0xe0(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0xdc(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xe4(%rbp),%esi
mov    -0xe0(%rbp),%edx
mov    -0xdc(%rbp),%ecx
mov    %eax,%r8d
lea    0xccf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xce1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13d8 <no_child_exists+0x258>
jmp    135e <no_child_exists+0x1de>
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0xf0(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0xec(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0xe8(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xf0(%rbp),%esi
mov    -0xec(%rbp),%edx
mov    -0xe8(%rbp),%ecx
mov    %eax,%r8d
lea    0xc53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xc9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13d8 <no_child_exists+0x258>
jmp    13dd <no_child_exists+0x25d>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jge    1476 <no_child_exists+0x2f6>
jmp    13f8 <no_child_exists+0x278>
lea    -0x48(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x44(%rbp),%eax
mov    %eax,-0xfc(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0xf8(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0xf4(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xfc(%rbp),%esi
mov    -0xf8(%rbp),%edx
mov    -0xf4(%rbp),%ecx
mov    %eax,%r8d
lea    0xbb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xbcb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1b64 <no_child_exists+0x9e4>
xor    %eax,%eax
cmp    -0x40(%rbp),%rax
jne    1726 <no_child_exists+0x5a6>
jmp    1487 <no_child_exists+0x307>
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x108(%rbp)
mov    -0x50(%rbp),%eax
mov    %eax,-0x104(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x100(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x108(%rbp),%esi
mov    -0x104(%rbp),%edx
mov    -0x100(%rbp),%ecx
mov    %eax,%r8d
lea    0xb2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jge    158b <no_child_exists+0x40b>
jmp    1514 <no_child_exists+0x394>
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x114(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x110(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x10c(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x114(%rbp),%esi
mov    -0x110(%rbp),%edx
mov    -0x10c(%rbp),%ecx
mov    %eax,%r8d
lea    0xa9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xafa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xaaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16a3 <no_child_exists+0x523>
xor    %eax,%eax
cmp    -0x58(%rbp),%rax
jne    161d <no_child_exists+0x49d>
jmp    159c <no_child_exists+0x41c>
lea    -0x68(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x64(%rbp),%eax
mov    %eax,-0x120(%rbp)
mov    -0x68(%rbp),%eax
mov    %eax,-0x11c(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x118(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x120(%rbp),%esi
mov    -0x11c(%rbp),%edx
mov    -0x118(%rbp),%ecx
mov    %eax,%r8d
lea    0xa15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xa8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xa27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x2,%edi
call   1090 <sleep@plt>
jmp    169e <no_child_exists+0x51e>
jmp    1622 <no_child_exists+0x4a2>
lea    -0x70(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x12c(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0x128(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x124(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x12c(%rbp),%esi
mov    -0x128(%rbp),%edx
mov    -0x124(%rbp),%ecx
mov    %eax,%r8d
lea    0x98f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xa15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x9a1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x3,%edi
call   1090 <sleep@plt>
jmp    16a3 <no_child_exists+0x523>
jmp    16a8 <no_child_exists+0x528>
lea    -0x78(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x74(%rbp),%eax
mov    %eax,-0x138(%rbp)
mov    -0x78(%rbp),%eax
mov    %eax,-0x134(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x130(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x138(%rbp),%esi
mov    -0x134(%rbp),%edx
mov    -0x130(%rbp),%ecx
mov    %eax,%r8d
lea    0x909(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x99b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x91b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1b64 <no_child_exists+0x9e4>
jmp    172b <no_child_exists+0x5ab>
lea    -0x80(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x7c(%rbp),%eax
mov    %eax,-0x144(%rbp)
mov    -0x80(%rbp),%eax
mov    %eax,-0x140(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x13c(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x144(%rbp),%esi
mov    -0x140(%rbp),%edx
mov    -0x13c(%rbp),%ecx
mov    %eax,%r8d
lea    0x886(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x921(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x898(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
movl   $0x0,-0x84(%rbp)
mov    0x2820(%rip),%rax
movq   $0x0,(%rax)
mov    0x2822(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%edi
lea    -0x84(%rbp),%rsi
call   1060 <waitpid@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     186a <no_child_exists+0x6ea>
jmp    17ea <no_child_exists+0x66a>
lea    -0x90(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x8c(%rbp),%eax
mov    %eax,-0x150(%rbp)
mov    -0x90(%rbp),%eax
mov    %eax,-0x14c(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x148(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x150(%rbp),%esi
mov    -0x14c(%rbp),%edx
mov    -0x148(%rbp),%ecx
mov    %eax,%r8d
lea    0x7be(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x863(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x7d0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1b54 <no_child_exists+0x9d4>
jmp    186f <no_child_exists+0x6ef>
lea    -0x98(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x94(%rbp),%eax
mov    %eax,-0x15c(%rbp)
mov    -0x98(%rbp),%eax
mov    %eax,-0x158(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x154(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x15c(%rbp),%esi
mov    -0x158(%rbp),%edx
mov    -0x154(%rbp),%ecx
mov    %eax,%r8d
lea    0x739(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x7f6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x74b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    18ef <no_child_exists+0x76f>
jmp    18f4 <no_child_exists+0x774>
lea    -0xa0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x9c(%rbp),%eax
mov    %eax,-0x168(%rbp)
mov    -0xa0(%rbp),%eax
mov    %eax,-0x164(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x160(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x168(%rbp),%esi
mov    -0x164(%rbp),%edx
mov    -0x160(%rbp),%ecx
mov    %eax,%r8d
lea    0x6b4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x783(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x6c6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
lea    -0x84(%rbp),%rsi
xor    %edx,%edx
call   1060 <waitpid@plt>
mov    %eax,-0xa4(%rbp)
cmpl   $0x0,-0xa4(%rbp)
jge    1a2c <no_child_exists+0x8ac>
jmp    199a <no_child_exists+0x81a>
lea    -0xb0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0xac(%rbp),%eax
mov    %eax,-0x174(%rbp)
mov    -0xb0(%rbp),%eax
mov    %eax,-0x170(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x16c(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x174(%rbp),%esi
mov    -0x170(%rbp),%edx
mov    -0x16c(%rbp),%ecx
mov    %eax,%r8d
lea    0x60e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x25d8(%rip),%rax
mov    (%rax),%rdi
call   1080 <strerror@plt>
mov    %rax,%rsi
lea    0x6e1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x60e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1b54 <no_child_exists+0x9d4>
xor    %eax,%eax
cmp    -0xa4(%rbp),%eax
jne    1abf <no_child_exists+0x93f>
jmp    1a3f <no_child_exists+0x8bf>
lea    -0xb8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0xb4(%rbp),%eax
mov    %eax,-0x180(%rbp)
mov    -0xb8(%rbp),%eax
mov    %eax,-0x17c(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x178(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x180(%rbp),%esi
mov    -0x17c(%rbp),%edx
mov    -0x178(%rbp),%ecx
mov    %eax,%r8d
lea    0x569(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x65b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x57b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1b4a <no_child_exists+0x9ca>
jmp    1ac4 <no_child_exists+0x944>
lea    -0xc0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0xbc(%rbp),%eax
mov    %eax,-0x18c(%rbp)
mov    -0xc0(%rbp),%eax
mov    %eax,-0x188(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x184(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x18c(%rbp),%esi
mov    -0x188(%rbp),%edx
mov    -0x184(%rbp),%ecx
mov    %eax,%r8d
lea    0x4e4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xa4(%rbp),%esi
lea    0x52b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x4f0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1b4a <no_child_exists+0x9ca>
jmp    1b4f <no_child_exists+0x9cf>
jmp    17a7 <no_child_exists+0x627>
jmp    1b59 <no_child_exists+0x9d9>
jmp    1b5e <no_child_exists+0x9de>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<no_child_exists>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsp,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r14d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe39(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,0xc(%rsp)
mov    0x2dd9(%rip),%rax
movq   $0x0,(%rax)
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rsi
mov    $0xffffffff,%edi
call   1070 <waitpid@plt>
mov    %eax,%r14d
mov    %rsp,%rdi
test   %eax,%eax
js     127b <no_child_exists+0xeb>
je     12d4 <no_child_exists+0x144>
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r15d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xdac(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xded(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1319 <no_child_exists+0x189>
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r15d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xd5f(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d1f(%rip),%rax
mov    (%rax),%rdi
call   1090 <strerror@plt>
lea    0xd66(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1319 <no_child_exists+0x189>
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r15d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xd06(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd31(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
test   %rax,%rax
js     142c <no_child_exists+0x29c>
je     1488 <no_child_exists+0x2f8>
mov    %r14,0x10(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r15d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xc99(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd28(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
movl   $0x0,0x8(%rsp)
mov    0x2c2f(%rip),%rax
movq   $0x0,(%rax)
mov    0x2c31(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rsi
mov    $0xffffffff,%edi
call   1070 <waitpid@plt>
test   %eax,%eax
je     154c <no_child_exists+0x3bc>
mov    %rsp,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r15d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xc07(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xca0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x10(%rsp),%rbp
jmp    186a <no_child_exists+0x6da>
mov    %rsp,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r14d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xbab(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xbfc(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xffffffff,%ebp
jmp    186a <no_child_exists+0x6da>
mov    %rsp,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r14d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xb4f(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xbac(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
mov    %rsp,%rdi
test   %rax,%rax
js     1708 <no_child_exists+0x578>
je     17bb <no_child_exists+0x62b>
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r14d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xae7(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xb61(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x3,%edi
jmp    180f <no_child_exists+0x67f>
mov    %rsp,%r13
lea    0x8(%rsp),%r14
jmp    15f5 <no_child_exists+0x465>
nopl   0x0(%rax)
mov    %eax,%r12d
mov    %r13,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%ebx
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %r13,%r14
mov    %eax,%r13d
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xa71(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r13d,%ecx
mov    %r14,%r13
mov    %r15,%r14
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xaac(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,0x8(%rsp)
mov    0x2a08(%rip),%rax
movq   $0x0,(%rax)
mov    0x2a0a(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%edi
mov    %r14,%rsi
call   1070 <waitpid@plt>
test   %eax,%eax
jne    13d0 <no_child_exists+0x240>
mov    %r13,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r12d
mov    0x4(%rsp),%ebx
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %r14,%r15
lea    0x9df(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r12d,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xa8d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r13,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r12d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %r14,%rdi
mov    %r15,%r14
mov    %ebp,%esi
mov    %r12d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xa4e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xffffffff,%edi
mov    %r15,%rsi
xor    %edx,%edx
call   1070 <waitpid@plt>
test   %eax,%eax
js     175c <no_child_exists+0x5cc>
jne    1560 <no_child_exists+0x3d0>
mov    %r13,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r12d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0x91c(%rip),%rdi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xa02(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    15b7 <no_child_exists+0x427>
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r14d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0x8d2(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x923(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1814 <no_child_exists+0x684>
mov    %rsp,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r14d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0x87b(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x283b(%rip),%rax
mov    (%rax),%rdi
call   1090 <strerror@plt>
lea    0x945(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1418 <no_child_exists+0x288>
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r14d
mov    0x4(%rsp),%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0x81f(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x88d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
xor    %ebp,%ebp
mov    %rsp,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    (%rsp),%r15d
mov    0x4(%rsp),%r14d
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0x7c0(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x845(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [22 x i8] c"%ld.%6ld [%d->%d] -- \00"
@.str.1 = [24 x i8] c"to test no child exists\00"
@.str.2 = [2 x i8] c"\0A\00"
@errno = global i64 0
@WNOHANG = global i32 0
@.str.3 = [21 x i8] c"error happend : [%s]\00"
@.str.4 = [22 x i8] c"no child change state\00"
@.str.5 = [16 x i8] c"child [%d] exit\00"
@.str.6 = [12 x i8] c"fork failed\00"
@.str.7 = [17 x i8] c"in child process\00"
@.str.8 = [12 x i8] c"sleep 2 ...\00"
@.str.9 = [12 x i8] c"sleep 3 ...\00"
@.str.10 = [9 x i8] c"exit ...\00"
@.str.11 = [10 x i8] c"in parent\00"
@.str.12 = [24 x i8] c"no child process exists\00"
@.str.13 = [18 x i8] c"some child exists\00"
@.str.14 = [22 x i8] c"wait for children ...\00"
@.str.15 = [13 x i8] c"error = [%s]\00"
@.str.16 = [15 x i8] c"what happend ?\00"
define i32 @no_child_exists(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.timeval
%10 = alloca %struct.timeval
%11 = alloca %struct.timeval
%12 = alloca i64
%13 = alloca %struct.timeval
%14 = alloca %struct.timeval
%15 = alloca i64
%16 = alloca %struct.timeval
%17 = alloca %struct.timeval
%18 = alloca %struct.timeval
%19 = alloca %struct.timeval
%20 = alloca %struct.timeval
%21 = alloca i32
%22 = alloca %struct.timeval
%23 = alloca %struct.timeval
%24 = alloca %struct.timeval
%25 = alloca i32
%26 = alloca %struct.timeval
%27 = alloca %struct.timeval
%28 = alloca %struct.timeval
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %29
29: ; preds = %2
%30 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%32 = load i32, i32* %31
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%34 = load i32, i32* %33
%35 = call i32 (...) @getppid()
%36 = call i32 (...) @getpid()
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %32, i32 %34, i32 %35, i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %40
40: ; preds = %29
store i32 0, i32* %7
store i32 0, i32* %8
store i64 0, i64* @errno
%41 = load i32, i32* @WNOHANG
%42 = call i32 @waitpid(i32 -1, i32* %8, i32 %41)
store i32 %42, i32* %7
%43 = load i32, i32* %7
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %60
45: ; preds = %40
br label %46
46: ; preds = %45
%47 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%48 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
%49 = load i32, i32* %48
%50 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%51 = load i32, i32* %50
%52 = call i32 (...) @getppid()
%53 = call i32 (...) @getpid()
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %49, i32 %51, i32 %52, i32 %53)
%55 = load i64, i64* @errno
%56 = call i8* @strerror(i64 %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %59
59: ; preds = %46
br label %91
60: ; preds = %40
%61 = load i32, i32* %7
%62 = icmp eq i32 0, %61
br i1 %62, label %63, label %76
63: ; preds = %60
br label %64
64: ; preds = %63
%65 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
%66 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 1
%67 = load i32, i32* %66
%68 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%69 = load i32, i32* %68
%70 = call i32 (...) @getppid()
%71 = call i32 (...) @getpid()
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %67, i32 %69, i32 %70, i32 %71)
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %75
75: ; preds = %64
br label %90
76: ; preds = %60
br label %77
77: ; preds = %76
%78 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
%79 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
%80 = load i32, i32* %79
%81 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%82 = load i32, i32* %81
%83 = call i32 (...) @getppid()
%84 = call i32 (...) @getpid()
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %80, i32 %82, i32 %83, i32 %84)
%86 = load i32, i32* %7
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %86)
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %89
89: ; preds = %77
br label %90
90: ; preds = %89, %75
br label %91
91: ; preds = %90, %59
%92 = call i64 (...) @fork()
store i64 %92, i64* %12
%93 = load i64, i64* %12
%94 = icmp slt i64 %93, 0
br i1 %94, label %95, label %108
95: ; preds = %91
br label %96
96: ; preds = %95
%97 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%98 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%99 = load i32, i32* %98
%100 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%101 = load i32, i32* %100
%102 = call i32 (...) @getppid()
%103 = call i32 (...) @getpid()
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %99, i32 %101, i32 %102, i32 %103)
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %107
107: ; preds = %96
store i32 -1, i32* %3
br label %296
108: ; preds = %91
%109 = load i64, i64* %12
%110 = icmp eq i64 0, %109
br i1 %110, label %111, label %185
111: ; preds = %108
br label %112
112: ; preds = %111
%113 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
%114 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%115 = load i32, i32* %114
%116 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%117 = load i32, i32* %116
%118 = call i32 (...) @getppid()
%119 = call i32 (...) @getpid()
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %115, i32 %117, i32 %118, i32 %119)
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %123
123: ; preds = %112
%124 = call i64 (...) @fork()
store i64 %124, i64* %15
%125 = load i64, i64* %15
%126 = icmp slt i64 %125, 0
br i1 %126, label %127, label %140
127: ; preds = %123
br label %128
128: ; preds = %127
%129 = call i32 @gettimeofday(%struct.timeval* %16, i32* null)
%130 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
%131 = load i32, i32* %130
%132 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
%133 = load i32, i32* %132
%134 = call i32 (...) @getppid()
%135 = call i32 (...) @getpid()
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %131, i32 %133, i32 %134, i32 %135)
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %139
139: ; preds = %128
br label %172
140: ; preds = %123
%141 = load i64, i64* %15
%142 = icmp eq i64 0, %141
br i1 %142, label %143, label %157
143: ; preds = %140
br label %144
144: ; preds = %143
%145 = call i32 @gettimeofday(%struct.timeval* %17, i32* null)
%146 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 1
%147 = load i32, i32* %146
%148 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 0
%149 = load i32, i32* %148
%150 = call i32 (...) @getppid()
%151 = call i32 (...) @getpid()
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %147, i32 %149, i32 %150, i32 %151)
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %155
155: ; preds = %144
%156 = call i32 @sleep(i32 2)
br label %171
157: ; preds = %140
br label %158
158: ; preds = %157
%159 = call i32 @gettimeofday(%struct.timeval* %18, i32* null)
%160 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 1
%161 = load i32, i32* %160
%162 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 0
%163 = load i32, i32* %162
%164 = call i32 (...) @getppid()
%165 = call i32 (...) @getpid()
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %161, i32 %163, i32 %164, i32 %165)
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %169
169: ; preds = %158
%170 = call i32 @sleep(i32 3)
br label %171
171: ; preds = %169, %155
br label %172
172: ; preds = %171, %139
br label %173
173: ; preds = %172
%174 = call i32 @gettimeofday(%struct.timeval* %19, i32* null)
%175 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
%176 = load i32, i32* %175
%177 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
%178 = load i32, i32* %177
%179 = call i32 (...) @getppid()
%180 = call i32 (...) @getpid()
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %176, i32 %178, i32 %179, i32 %180)
%182 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %184
184: ; preds = %173
store i32 0, i32* %3
br label %296
185: ; preds = %108
br label %186
186: ; preds = %185
%187 = call i32 @gettimeofday(%struct.timeval* %20, i32* null)
%188 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 1
%189 = load i32, i32* %188
%190 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 0
%191 = load i32, i32* %190
%192 = call i32 (...) @getppid()
%193 = call i32 (...) @getpid()
%194 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %189, i32 %191, i32 %192, i32 %193)
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%196 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %197
197: ; preds = %186
%198 = call i32 @sleep(i32 1)
br label %199
199: ; preds = %197, %291
store i32 0, i32* %21
store i64 0, i64* @errno
%200 = load i32, i32* @WNOHANG
%201 = call i32 @waitpid(i32 -1, i32* %21, i32 %200)
%202 = icmp ne i32 0, %201
br i1 %202, label %203, label %216
203: ; preds = %199
br label %204
204: ; preds = %203
%205 = call i32 @gettimeofday(%struct.timeval* %22, i32* null)
%206 = getelementptr inbounds %struct.timeval, %struct.timeval* %22, i32 0, i32 1
%207 = load i32, i32* %206
%208 = getelementptr inbounds %struct.timeval, %struct.timeval* %22, i32 0, i32 0
%209 = load i32, i32* %208
%210 = call i32 (...) @getppid()
%211 = call i32 (...) @getpid()
%212 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %207, i32 %209, i32 %210, i32 %211)
%213 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
%214 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %215
215: ; preds = %204
br label %292
216: ; preds = %199
br label %217
217: ; preds = %216
%218 = call i32 @gettimeofday(%struct.timeval* %23, i32* null)
%219 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 1
%220 = load i32, i32* %219
%221 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 0
%222 = load i32, i32* %221
%223 = call i32 (...) @getppid()
%224 = call i32 (...) @getpid()
%225 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %220, i32 %222, i32 %223, i32 %224)
%226 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0))
%227 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %228
228: ; preds = %217
br label %229
229: ; preds = %228
br label %230
230: ; preds = %229
%231 = call i32 @gettimeofday(%struct.timeval* %24, i32* null)
%232 = getelementptr inbounds %struct.timeval, %struct.timeval* %24, i32 0, i32 1
%233 = load i32, i32* %232
%234 = getelementptr inbounds %struct.timeval, %struct.timeval* %24, i32 0, i32 0
%235 = load i32, i32* %234
%236 = call i32 (...) @getppid()
%237 = call i32 (...) @getpid()
%238 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %233, i32 %235, i32 %236, i32 %237)
%239 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0))
%240 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %241
241: ; preds = %230
%242 = call i32 @waitpid(i32 -1, i32* %21, i32 0)
store i32 %242, i32* %25
%243 = load i32, i32* %25
%244 = icmp slt i32 %243, 0
br i1 %244, label %245, label %260
245: ; preds = %241
br label %246
246: ; preds = %245
%247 = call i32 @gettimeofday(%struct.timeval* %26, i32* null)
%248 = getelementptr inbounds %struct.timeval, %struct.timeval* %26, i32 0, i32 1
%249 = load i32, i32* %248
%250 = getelementptr inbounds %struct.timeval, %struct.timeval* %26, i32 0, i32 0
%251 = load i32, i32* %250
%252 = call i32 (...) @getppid()
%253 = call i32 (...) @getpid()
%254 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %249, i32 %251, i32 %252, i32 %253)
%255 = load i64, i64* @errno
%256 = call i8* @strerror(i64 %255)
%257 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.15, i64 0, i64 0), i8* %256)
%258 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %259
259: ; preds = %246
br label %292
260: ; preds = %241
%261 = load i32, i32* %25
%262 = icmp eq i32 0, %261
br i1 %262, label %263, label %276
263: ; preds = %260
br label %264
264: ; preds = %263
%265 = call i32 @gettimeofday(%struct.timeval* %27, i32* null)
%266 = getelementptr inbounds %struct.timeval, %struct.timeval* %27, i32 0, i32 1
%267 = load i32, i32* %266
%268 = getelementptr inbounds %struct.timeval, %struct.timeval* %27, i32 0, i32 0
%269 = load i32, i32* %268
%270 = call i32 (...) @getppid()
%271 = call i32 (...) @getpid()
%272 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %267, i32 %269, i32 %270, i32 %271)
%273 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.16, i64 0, i64 0))
%274 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %275
275: ; preds = %264
br label %290
276: ; preds = %260
br label %277
277: ; preds = %276
%278 = call i32 @gettimeofday(%struct.timeval* %28, i32* null)
%279 = getelementptr inbounds %struct.timeval, %struct.timeval* %28, i32 0, i32 1
%280 = load i32, i32* %279
%281 = getelementptr inbounds %struct.timeval, %struct.timeval* %28, i32 0, i32 0
%282 = load i32, i32* %281
%283 = call i32 (...) @getppid()
%284 = call i32 (...) @getpid()
%285 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %280, i32 %282, i32 %283, i32 %284)
%286 = load i32, i32* %25
%287 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %286)
%288 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %289
289: ; preds = %277
br label %290
290: ; preds = %289, %275
br label %291
291: ; preds = %290
br label %199
292: ; preds = %259, %215
br label %293
293: ; preds = %292
br label %294
294: ; preds = %293
%295 = load i32, i32* %7
store i32 %295, i32* %3
br label %296
296: ; preds = %294, %184, %107
%297 = load i32, i32* %3
ret i32 %297
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [22 x i8] c"%ld.%6ld [%d->%d] -- \00"
@.str.1 = [24 x i8] c"to test no child exists\00"
@errno = global i64 0
@WNOHANG = global i32 0
@.str.3 = [21 x i8] c"error happend : [%s]\00"
@.str.4 = [22 x i8] c"no child change state\00"
@.str.5 = [16 x i8] c"child [%d] exit\00"
@.str.6 = [12 x i8] c"fork failed\00"
@.str.7 = [17 x i8] c"in child process\00"
@.str.8 = [12 x i8] c"sleep 2 ...\00"
@.str.9 = [12 x i8] c"sleep 3 ...\00"
@.str.10 = [9 x i8] c"exit ...\00"
@.str.11 = [10 x i8] c"in parent\00"
@.str.12 = [24 x i8] c"no child process exists\00"
@.str.13 = [18 x i8] c"some child exists\00"
@.str.14 = [22 x i8] c"wait for children ...\00"
@.str.15 = [13 x i8] c"error = [%s]\00"
@.str.16 = [15 x i8] c"what happend ?\00"
define i32 @no_child_exists(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timeval
%4 = alloca i32
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca %struct.timeval
%9 = alloca %struct.timeval
%10 = alloca %struct.timeval
%11 = alloca %struct.timeval
%12 = alloca %struct.timeval
%13 = alloca %struct.timeval
%14 = alloca %struct.timeval
%15 = alloca i32
%16 = alloca %struct.timeval
%17 = alloca %struct.timeval
%18 = alloca %struct.timeval
%19 = alloca %struct.timeval
%20 = alloca %struct.timeval
%21 = alloca %struct.timeval
%22 = bitcast %struct.timeval* %3 to i8*
%23 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%27 = load i32, i32* %26
%28 = tail call i32 (...) @getppid()
%29 = tail call i32 (...) @getpid()
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %27, i32 %28, i32 %29)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%32 = tail call i32 @putchar(i32 10)
%33 = bitcast i32* %4 to i8*
store i32 0, i32* %4
store i64 0, i64* @errno
%34 = load i32, i32* @WNOHANG
%35 = call i32 @waitpid(i32 -1, i32* %4, i32 %34)
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %51
37: ; preds = %2
%38 = bitcast %struct.timeval* %5 to i8*
%39 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%43 = load i32, i32* %42
%44 = call i32 (...) @getppid()
%45 = call i32 (...) @getpid()
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %41, i32 %43, i32 %44, i32 %45)
%47 = load i64, i64* @errno
%48 = call i8* @strerror(i64 %47)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %48)
%50 = call i32 @putchar(i32 10)
br label %77
51: ; preds = %2
%52 = icmp eq i32 %35, 0
br i1 %52, label %53, label %65
53: ; preds = %51
%54 = bitcast %struct.timeval* %6 to i8*
%55 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%56 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%57 = load i32, i32* %56
%58 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%59 = load i32, i32* %58
%60 = call i32 (...) @getppid()
%61 = call i32 (...) @getpid()
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %57, i32 %59, i32 %60, i32 %61)
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%64 = call i32 @putchar(i32 10)
br label %77
65: ; preds = %51
%66 = bitcast %struct.timeval* %7 to i8*
%67 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%68 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
%69 = load i32, i32* %68
%70 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
%71 = load i32, i32* %70
%72 = call i32 (...) @getppid()
%73 = call i32 (...) @getpid()
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %69, i32 %71, i32 %72, i32 %73)
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%76 = call i32 @putchar(i32 10)
br label %77
77: ; preds = %53, %65, %37
%78 = call i64 (...) @fork()
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %92
80: ; preds = %77
%81 = bitcast %struct.timeval* %8 to i8*
%82 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%83 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 1
%84 = load i32, i32* %83
%85 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 0
%86 = load i32, i32* %85
%87 = call i32 (...) @getppid()
%88 = call i32 (...) @getpid()
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %84, i32 %86, i32 %87, i32 %88)
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%91 = call i32 @putchar(i32 10)
br label %260
92: ; preds = %77
%93 = icmp eq i64 %78, 0
br i1 %93, label %94, label %160
94: ; preds = %92
%95 = bitcast %struct.timeval* %9 to i8*
%96 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%97 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i64 0, i32 1
%98 = load i32, i32* %97
%99 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i64 0, i32 0
%100 = load i32, i32* %99
%101 = call i32 (...) @getppid()
%102 = call i32 (...) @getpid()
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %98, i32 %100, i32 %101, i32 %102)
%104 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%105 = call i32 @putchar(i32 10)
%106 = call i64 (...) @fork()
%107 = icmp slt i64 %106, 0
br i1 %107, label %108, label %120
108: ; preds = %94
%109 = bitcast %struct.timeval* %10 to i8*
%110 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
%111 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 1
%112 = load i32, i32* %111
%113 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 0
%114 = load i32, i32* %113
%115 = call i32 (...) @getppid()
%116 = call i32 (...) @getpid()
%117 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %112, i32 %114, i32 %115, i32 %116)
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%119 = call i32 @putchar(i32 10)
br label %148
120: ; preds = %94
%121 = icmp eq i64 %106, 0
br i1 %121, label %122, label %135
122: ; preds = %120
%123 = bitcast %struct.timeval* %11 to i8*
%124 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
%125 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i64 0, i32 1
%126 = load i32, i32* %125
%127 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i64 0, i32 0
%128 = load i32, i32* %127
%129 = call i32 (...) @getppid()
%130 = call i32 (...) @getpid()
%131 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %126, i32 %128, i32 %129, i32 %130)
%132 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%133 = call i32 @putchar(i32 10)
%134 = call i32 @sleep(i32 2)
br label %148
135: ; preds = %120
%136 = bitcast %struct.timeval* %12 to i8*
%137 = call i32 @gettimeofday(%struct.timeval* %12, i32* null)
%138 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i64 0, i32 1
%139 = load i32, i32* %138
%140 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i64 0, i32 0
%141 = load i32, i32* %140
%142 = call i32 (...) @getppid()
%143 = call i32 (...) @getpid()
%144 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %139, i32 %141, i32 %142, i32 %143)
%145 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%146 = call i32 @putchar(i32 10)
%147 = call i32 @sleep(i32 3)
br label %148
148: ; preds = %108, %135, %122
%149 = bitcast %struct.timeval* %13 to i8*
%150 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%151 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i64 0, i32 1
%152 = load i32, i32* %151
%153 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i64 0, i32 0
%154 = load i32, i32* %153
%155 = call i32 (...) @getppid()
%156 = call i32 (...) @getpid()
%157 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %152, i32 %154, i32 %155, i32 %156)
%158 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
%159 = call i32 @putchar(i32 10)
br label %260
160: ; preds = %92
%161 = bitcast %struct.timeval* %14 to i8*
%162 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
%163 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i64 0, i32 1
%164 = load i32, i32* %163
%165 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i64 0, i32 0
%166 = load i32, i32* %165
%167 = call i32 (...) @getppid()
%168 = call i32 (...) @getpid()
%169 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %164, i32 %166, i32 %167, i32 %168)
%170 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%171 = call i32 @putchar(i32 10)
%172 = call i32 @sleep(i32 1)
%173 = bitcast i32* %15 to i8*
store i32 0, i32* %15
store i64 0, i64* @errno
%174 = load i32, i32* @WNOHANG
%175 = call i32 @waitpid(i32 -1, i32* %15, i32 %174)
%176 = icmp eq i32 %175, 0
br i1 %176, label %177, label %190
177: ; preds = %160
%178 = bitcast %struct.timeval* %17 to i8*
%179 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i64 0, i32 1
%180 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i64 0, i32 0
%181 = bitcast %struct.timeval* %18 to i8*
%182 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i64 0, i32 1
%183 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i64 0, i32 0
%184 = bitcast %struct.timeval* %21 to i8*
%185 = getelementptr inbounds %struct.timeval, %struct.timeval* %21, i64 0, i32 1
%186 = getelementptr inbounds %struct.timeval, %struct.timeval* %21, i64 0, i32 0
%187 = bitcast %struct.timeval* %20 to i8*
%188 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i64 0, i32 1
%189 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i64 0, i32 0
br label %202
190: ; preds = %256, %160
%191 = bitcast %struct.timeval* %16 to i8*
%192 = call i32 @gettimeofday(%struct.timeval* %16, i32* null)
%193 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i64 0, i32 1
%194 = load i32, i32* %193
%195 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i64 0, i32 0
%196 = load i32, i32* %195
%197 = call i32 (...) @getppid()
%198 = call i32 (...) @getpid()
%199 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %194, i32 %196, i32 %197, i32 %198)
%200 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
%201 = call i32 @putchar(i32 10)
br label %255
202: ; preds = %177, %256
%203 = call i32 @gettimeofday(%struct.timeval* %17, i32* null)
%204 = load i32, i32* %179
%205 = load i32, i32* %180
%206 = call i32 (...) @getppid()
%207 = call i32 (...) @getpid()
%208 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %204, i32 %205, i32 %206, i32 %207)
%209 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0))
%210 = call i32 @putchar(i32 10)
%211 = call i32 @gettimeofday(%struct.timeval* %18, i32* null)
%212 = load i32, i32* %182
%213 = load i32, i32* %183
%214 = call i32 (...) @getppid()
%215 = call i32 (...) @getpid()
%216 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %212, i32 %213, i32 %214, i32 %215)
%217 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0))
%218 = call i32 @putchar(i32 10)
%219 = call i32 @waitpid(i32 -1, i32* %15, i32 0)
%220 = icmp slt i32 %219, 0
br i1 %220, label %221, label %235
221: ; preds = %202
%222 = bitcast %struct.timeval* %19 to i8*
%223 = call i32 @gettimeofday(%struct.timeval* %19, i32* null)
%224 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i64 0, i32 1
%225 = load i32, i32* %224
%226 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i64 0, i32 0
%227 = load i32, i32* %226
%228 = call i32 (...) @getppid()
%229 = call i32 (...) @getpid()
%230 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %225, i32 %227, i32 %228, i32 %229)
%231 = load i64, i64* @errno
%232 = call i8* @strerror(i64 %231)
%233 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.15, i64 0, i64 0), i8* %232)
%234 = call i32 @putchar(i32 10)
br label %255
235: ; preds = %202
%236 = icmp eq i32 %219, 0
br i1 %236, label %237, label %246
237: ; preds = %235
%238 = call i32 @gettimeofday(%struct.timeval* %20, i32* null)
%239 = load i32, i32* %188
%240 = load i32, i32* %189
%241 = call i32 (...) @getppid()
%242 = call i32 (...) @getpid()
%243 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %239, i32 %240, i32 %241, i32 %242)
%244 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.16, i64 0, i64 0))
%245 = call i32 @putchar(i32 10)
br label %256
246: ; preds = %235
%247 = call i32 @gettimeofday(%struct.timeval* %21, i32* null)
%248 = load i32, i32* %185
%249 = load i32, i32* %186
%250 = call i32 (...) @getppid()
%251 = call i32 (...) @getpid()
%252 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %248, i32 %249, i32 %250, i32 %251)
%253 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %219)
%254 = call i32 @putchar(i32 10)
br label %256
255: ; preds = %190, %221
br label %260
256: ; preds = %237, %246
store i32 0, i32* %15
store i64 0, i64* @errno
%257 = load i32, i32* @WNOHANG
%258 = call i32 @waitpid(i32 -1, i32* %15, i32 %257)
%259 = icmp eq i32 %258, 0
br i1 %259, label %202, label %190
260: ; preds = %255, %148, %80
%261 = phi i32 [ -1, %80 ], [ 0, %148 ], [ %35, %255 ]
ret i32 %261
}