#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 */

/* Variables and functions */
int fork();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int main(void) {
  printf("Start\n");
  int bomb_count = 0;
  while (1) {
    switch (fork()) {
    case -1:
      if (bomb_count == 98) {
        printf("Done\n");
        return 0;
      } else {
        return 1;
      }
      break;
    case 0:
      sleep(4);
      break;
    default:
      bomb_count++;
      break;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
call   1050 <fork@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
sub    $0xffffffff,%eax
je     117c <main+0x4c>
jmp    116c <main+0x3c>
mov    -0xc(%rbp),%eax
test   %eax,%eax
je     11aa <main+0x7a>
jmp    11b9 <main+0x89>
cmpl   $0x62,-0x8(%rbp)
jne    119e <main+0x6e>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <main+0x97>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <main+0x97>
mov    $0x4,%edi
call   1040 <sleep@plt>
jmp    11c2 <main+0x92>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1152 <main+0x22>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    115a <main+0x2a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x4,%edi
call   1040 <sleep@plt>
xor    %eax,%eax
call   1050 <fork@plt>
test   %eax,%eax
je     1150 <main+0x20>
cmp    $0xffffffff,%eax
je     116f <main+0x3f>
add    $0x1,%ebx
jmp    115a <main+0x2a>
mov    $0x1,%eax
cmp    $0x62,%ebx
jne    1187 <main+0x57>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Start\0A\00"
@.str.1 = [6 x i8] c"Done\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %4
4: ; preds = %0, %17
%5 = call i32 (...) @fork()
switch i32 %5, label %14 [
i32 -1, label %6
i32 0, label %12
]
6: ; preds = %4
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 98
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %18
11: ; preds = %6
store i32 1, i32* %1
br label %18
12: ; preds = %4
%13 = call i32 @sleep(i32 4)
br label %17
14: ; preds = %4
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
br label %17
17: ; preds = %14, %12
br label %4
18: ; preds = %11, %9
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@str = [6 x i8] c"Start\00"
@str.2 = [5 x i8] c"Done\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %12, %0
%3 = phi i32 [ %13, %12 ], [ 0, %0 ]
br label %4
4: ; preds = %2, %10
%5 = tail call i32 (...) @fork()
switch i32 %5, label %12 [
i32 -1, label %6
i32 0, label %10
]
6: ; preds = %4
%7 = icmp eq i32 %3, 98
br i1 %7, label %8, label %14
8: ; preds = %6
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.2, i64 0, i64 0))
br label %14
10: ; preds = %4
%11 = tail call i32 @sleep(i32 4)
br label %4
12: ; preds = %4
%13 = add nuw nsw i32 %3, 1
br label %2
14: ; preds = %6, %8
%15 = phi i32 [ 0, %8 ], [ 1, %6 ]
ret i32 %15
}