#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 */
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int main(void) {
  pid_t pids[10];
  int i;
  signal(SIGCHLD, SIG_IGN);
  for (i = 9; i >= 0; --i) {
    pids[i] = fork();
    if (pids[i] == 0) {
      sleep(i + 1);
      _exit(0);
    }
  }
  while (1)
    ;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
call   1040 <signal@plt>
movl   $0x9,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jl     11bf <main+0x7f>
mov    $0x0,%al
call   1060 <fork@plt>
mov    %rax,%rcx
movslq -0x64(%rbp),%rax
mov    %rcx,-0x60(%rbp,%rax,8)
movslq -0x64(%rbp),%rax
cmpq   $0x0,-0x60(%rbp,%rax,8)
jne    11ac <main+0x6c>
mov    -0x64(%rbp),%edi
add    $0x1,%edi
call   1050 <sleep@plt>
xor    %edi,%edi
call   1030 <_exit@plt>
jmp    11b1 <main+0x71>
mov    -0x64(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x64(%rbp)
jmp    116d <main+0x2d>
jmp    11c4 <main+0x84>
jmp    11c4 <main+0x84>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
mov    0x2e8f(%rip),%rax
mov    (%rax),%esi
call   1040 <signal@plt>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     11d2 <main+0x92>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     11d9 <main+0x99>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     11e0 <main+0xa0>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     11e7 <main+0xa7>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     11ee <main+0xae>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     11f5 <main+0xb5>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     11fc <main+0xbc>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     1203 <main+0xc3>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     120a <main+0xca>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     1211 <main+0xd1>
jmp    11d0 <main+0x90>
mov    $0xa,%edi
jmp    1216 <main+0xd6>
mov    $0x9,%edi
jmp    1216 <main+0xd6>
mov    $0x8,%edi
jmp    1216 <main+0xd6>
mov    $0x7,%edi
jmp    1216 <main+0xd6>
mov    $0x6,%edi
jmp    1216 <main+0xd6>
mov    $0x5,%edi
jmp    1216 <main+0xd6>
mov    $0x4,%edi
jmp    1216 <main+0xd6>
mov    $0x3,%edi
jmp    1216 <main+0xd6>
mov    $0x2,%edi
jmp    1216 <main+0xd6>
mov    $0x1,%edi
call   1050 <sleep@plt>
xor    %edi,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i64]
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @SIGCHLD
%5 = load i32, i32* @SIG_IGN
%6 = call i32 @signal(i32 %4, i32 %5)
store i32 9, i32* %3
br label %7
7: ; preds = %26, %0
%8 = load i32, i32* %3
%9 = icmp sge i32 %8, 0
br i1 %9, label %10, label %29
10: ; preds = %7
%11 = call i64 (...) @fork()
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [10 x i64], [10 x i64]* %2, i64 0, i64 %13
store i64 %11, i64* %14
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [10 x i64], [10 x i64]* %2, i64 0, i64 %16
%18 = load i64, i64* %17
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %10
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
%23 = call i32 @sleep(i32 %22)
%24 = call i32 @_exit(i32 0)
unreachable
25: ; preds = %10
br label %26
26: ; preds = %25
%27 = load i32, i32* %3
%28 = add nsw i32 %27, -1
store i32 %28, i32* %3
br label %7
29: ; preds = %7
br label %30
30: ; preds = %29, %30
br label %30
}

LLVM IR (-O2):
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
define i32 @main() {
%1 = load i32, i32* @SIGCHLD
%2 = load i32, i32* @SIG_IGN
%3 = tail call i32 @signal(i32 %1, i32 %2)
%4 = tail call i64 (...) @fork()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %34, %31, %28, %25, %22, %19, %16, %13, %10, %0
%7 = phi i32 [ 10, %0 ], [ 9, %10 ], [ 8, %13 ], [ 7, %16 ], [ 6, %19 ], [ 5, %22 ], [ 4, %25 ], [ 3, %28 ], [ 2, %31 ], [ 1, %34 ]
%8 = tail call i32 @sleep(i32 %7)
%9 = tail call i32 @_exit(i32 0)
unreachable
10: ; preds = %0
%11 = tail call i64 (...) @fork()
%12 = icmp eq i64 %11, 0
br i1 %12, label %6, label %13
13: ; preds = %10
%14 = tail call i64 (...) @fork()
%15 = icmp eq i64 %14, 0
br i1 %15, label %6, label %16
16: ; preds = %13
%17 = tail call i64 (...) @fork()
%18 = icmp eq i64 %17, 0
br i1 %18, label %6, label %19
19: ; preds = %16
%20 = tail call i64 (...) @fork()
%21 = icmp eq i64 %20, 0
br i1 %21, label %6, label %22
22: ; preds = %19
%23 = tail call i64 (...) @fork()
%24 = icmp eq i64 %23, 0
br i1 %24, label %6, label %25
25: ; preds = %22
%26 = tail call i64 (...) @fork()
%27 = icmp eq i64 %26, 0
br i1 %27, label %6, label %28
28: ; preds = %25
%29 = tail call i64 (...) @fork()
%30 = icmp eq i64 %29, 0
br i1 %30, label %6, label %31
31: ; preds = %28
%32 = tail call i64 (...) @fork()
%33 = icmp eq i64 %32, 0
br i1 %33, label %6, label %34
34: ; preds = %31
%35 = tail call i64 (...) @fork()
%36 = icmp eq i64 %35, 0
br i1 %36, label %6, label %37
37: ; preds = %34, %37
br label %37
}