#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ rdtsctask();
int /*<<< orphan*/ segvtask();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(void) {
  int n_tasks = 100, i;
  fprintf(stderr, "[No further output means we're allright]\n");
  for (i = 0; i < n_tasks; i++)
    if (fork() == 0) {
      if (i & 1)
        segvtask();
      else
        rdtsctask();
    }
  for (i = 0; i < n_tasks; i++)
    wait(NULL);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x8(%rbp)
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e9 <main+0x89>
mov    $0x0,%al
call   1080 <fork@plt>
cmp    $0x0,%rax
jne    11d6 <main+0x76>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11ca <main+0x6a>
mov    $0x0,%al
call   1040 <segvtask@plt>
jmp    11d1 <main+0x71>
mov    $0x0,%al
call   1030 <rdtsctask@plt>
jmp    11d6 <main+0x76>
jmp    11db <main+0x7b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1192 <main+0x32>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1213 <main+0xb3>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <wait@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11f0 <main+0x90>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
call   1050 <fprintf@plt>
xor    %ebx,%ebx
jmp    1188 <main+0x28>
call   1030 <rdtsctask@plt>
nop
add    $0x1,%ebx
cmp    $0x64,%ebx
je     11a2 <main+0x42>
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
jne    1180 <main+0x20>
xor    %eax,%eax
test   $0x1,%bl
je     117a <main+0x1a>
call   1040 <segvtask@plt>
jmp    1180 <main+0x20>
mov    $0x64,%ebx
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1070 <wait@plt>
add    $0xffffffff,%ebx
jne    11b0 <main+0x50>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [42 x i8] c"[No further output means we're allright]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 100, i32* %2
%4 = load i32, i32* @stderr
%5 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %6
6: ; preds = %23, %0
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = call i64 (...) @fork()
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = load i32, i32* %3
%15 = and i32 %14, 1
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 (...) @segvtask()
br label %21
19: ; preds = %13
%20 = call i32 (...) @rdtsctask()
br label %21
21: ; preds = %19, %17
br label %22
22: ; preds = %21, %10
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %6
26: ; preds = %6
store i32 0, i32* %3
br label %27
27: ; preds = %33, %26
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = call i32 @wait(i32* null)
br label %33
33: ; preds = %31
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %27
36: ; preds = %27
%37 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [42 x i8] c"[No further output means we're allright]\0A\00"
define i32 @main() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %0, %14
%4 = phi i32 [ 0, %0 ], [ %15, %14 ]
%5 = tail call i64 (...) @fork()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %3
%8 = and i32 %4, 1
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 (...) @segvtask()
br label %14
12: ; preds = %7
%13 = tail call i32 (...) @rdtsctask()
br label %14
14: ; preds = %3, %12, %10
%15 = add nuw nsw i32 %4, 1
%16 = icmp eq i32 %15, 100
br i1 %16, label %17, label %3
17: ; preds = %14, %17
%18 = phi i32 [ %20, %17 ], [ 0, %14 ]
%19 = tail call i32 @wait(i32* null)
%20 = add nuw nsw i32 %18, 1
%21 = icmp eq i32 %20, 100
br i1 %21, label %22, label %17
22: ; preds = %17
%23 = tail call i32 @exit(i32 0)
unreachable
}