#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 timespec {
  double tv_sec;
  double tv_nsec;
};
typedef int pid_t;
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
int /*<<< orphan*/ CLOCK_MONOTONIC;
int MAP_ANONYMOUS;
int MAP_SHARED;
int M_PI;
int PROT_READ;
int PROT_WRITE;
scalar_t__ clock();
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ exit(int);
int fork();
double *malloc(int);
struct child_data *mmap(int /*<<< orphan*/ *, int, int, int, int,
                        int /*<<< orphan*/);
int /*<<< orphan*/ munmap(struct child_data *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sin(int);
int main(int argc, char *argv[]) {
  struct timespec t_init_wall, t_end_wall;
  double elapsed_wall, elapsed_cpu;
  clock_t t_init_cpu, t_end_cpu;
  int i;
  int child_id;
  int flag;
  double res;
  pid_t pid;
  struct child_data {
    int res;
    int finished;
  };
  struct child_data *glob_data =
      mmap(NULL, 7 * sizeof(struct child_data), PROT_READ | PROT_WRITE,
           MAP_SHARED | MAP_ANONYMOUS, -1, 0);
  for (i = 0; i < 7; i++) {
    glob_data[i].res = 0;
    glob_data[i].finished = 0;
  }
  double *a = malloc(sizeof(double) * 20000000);
  clock_gettime(CLOCK_MONOTONIC, &t_init_wall);
  t_init_cpu = clock();
  for (child_id = 0; child_id < 7; child_id++) {
    pid = fork();
    if (pid == -1) {
      printf("Fork failed!\n");
      exit(-1);
    }
    if (pid == 0) {
      break;
    }
  }
  for (i = 0; i < 20000000; i++) {
    res += sin(M_PI * (1 + 4 * i) / 2);
  }
  if (pid == 0) {
    glob_data[child_id].res = res;
    glob_data[child_id].finished = 1;
    return 0;
  } else {
    for (;;) {
      flag = 0;
      for (i = 0; i < 7; i++) {
        flag += glob_data[i].finished;
      }
      if (flag == 7) {
        break;
      }
    }
    for (i = 0; i < 7; i++) {
      res += glob_data[i].res;
    }
    munmap(glob_data, 7 * sizeof(struct child_data));
    t_end_cpu = clock();
    clock_gettime(CLOCK_MONOTONIC, &t_end_wall);
    elapsed_cpu = (double)(t_end_cpu - t_init_cpu) / CLOCKS_PER_SEC;
    elapsed_wall = (t_end_wall.tv_sec - t_init_wall.tv_sec);
    elapsed_wall += (t_end_wall.tv_nsec - t_init_wall.tv_nsec) / 1000000000.0;
    printf("Result:  %g \n", res);
    printf("Total number of operations: %g\n", (double)(7 + 1) * 20000000);
    printf("Total wall-time: %g s\n", elapsed_wall);
    printf("Total cpu-time:  %g s\n", elapsed_cpu);
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e48(%rip),%rax
mov    (%rax),%edx
mov    0x2df7(%rip),%rax
or     (%rax),%edx
mov    0x2e26(%rip),%rax
mov    (%rax),%ecx
mov    0x2df5(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x38,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x78(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x7,-0x54(%rbp)
jge    1226 <main+0x96>
mov    -0x78(%rbp),%rax
movslq -0x54(%rbp),%rcx
movl   $0x0,(%rax,%rcx,8)
mov    -0x78(%rbp),%rax
movslq -0x54(%rbp),%rcx
movl   $0x0,0x4(%rax,%rcx,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11ef <main+0x5f>
mov    $0x9896800,%edi
call   1080 <malloc@plt>
mov    %rax,-0x80(%rbp)
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x58(%rbp)
cmpl   $0x7,-0x58(%rbp)
jge    12b0 <main+0x120>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0xffffffff,-0x6c(%rbp)
jne    128e <main+0xfe>
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
cmpl   $0x0,-0x6c(%rbp)
jne    129d <main+0x10d>
jmp    12b0 <main+0x120>
jmp    12a2 <main+0x112>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1258 <main+0xc8>
movl   $0x0,-0x54(%rbp)
cmpl   $0x1312d00,-0x54(%rbp)
jge    1305 <main+0x175>
mov    0x2d0d(%rip),%rax
mov    (%rax),%eax
mov    -0x54(%rbp),%ecx
shl    $0x2,%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1070 <sin@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    12b7 <main+0x127>
cmpl   $0x0,-0x6c(%rbp)
jne    133b <main+0x1ab>
cvttsd2si -0x68(%rbp),%edx
mov    -0x78(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    %edx,(%rax,%rcx,8)
mov    -0x78(%rbp),%rax
movslq -0x58(%rbp),%rcx
movl   $0x1,0x4(%rax,%rcx,8)
movl   $0x0,-0x4(%rbp)
jmp    148f <main+0x2ff>
jmp    1340 <main+0x1b0>
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x7,-0x54(%rbp)
jge    1378 <main+0x1e8>
mov    -0x78(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%eax
add    -0x5c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    134e <main+0x1be>
cmpl   $0x7,-0x5c(%rbp)
jne    1387 <main+0x1f7>
jmp    138c <main+0x1fc>
jmp    1340 <main+0x1b0>
movl   $0x0,-0x54(%rbp)
cmpl   $0x7,-0x54(%rbp)
jge    13c2 <main+0x232>
mov    -0x78(%rbp),%rax
movslq -0x54(%rbp),%rcx
cvtsi2sdl (%rax,%rcx,8),%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1393 <main+0x203>
mov    -0x78(%rbp),%rdi
mov    $0x38,%esi
call   1090 <munmap@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x50(%rbp)
mov    0x2bee(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x50(%rbp),%rax
sub    -0x48(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2bc7(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xbdd(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x68(%rbp),%xmm0
lea    0xbd9(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xbd9(%rip),%rdi
movsd  0xba5(%rip),%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0x38(%rbp),%xmm0
lea    0xbde(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0x40(%rbp),%xmm0
lea    0xbe2(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    0x2e43(%rip),%rax
mov    0x2df4(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e21(%rip),%rax
mov    0x2df2(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %r12d,%r12d
xor    %edi,%edi
mov    $0x38,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,%rbx
xorpd  %xmm0,%xmm0
movupd %xmm0,(%rax)
movupd %xmm0,0x10(%rax)
movupd %xmm0,0x20(%rax)
movq   $0x0,0x30(%rax)
mov    $0x9896800,%edi
call   1090 <malloc@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
lea    0x30(%rsp),%rsi
call   1040 <clock_gettime@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%r14
xor    %eax,%eax
call   10c0 <fork@plt>
mov    %eax,%r13d
test   %eax,%eax
je     1316 <main+0x176>
cmp    $0xffffffff,%r13d
je     14ea <main+0x34a>
xor    %eax,%eax
call   10c0 <fork@plt>
mov    %eax,%r13d
test   %eax,%eax
je     12f0 <main+0x150>
cmp    $0xffffffff,%r13d
je     14ea <main+0x34a>
xor    %eax,%eax
call   10c0 <fork@plt>
mov    %eax,%r13d
test   %eax,%eax
je     12f8 <main+0x158>
cmp    $0xffffffff,%r13d
je     14ea <main+0x34a>
xor    %eax,%eax
call   10c0 <fork@plt>
mov    %eax,%r13d
test   %eax,%eax
je     1300 <main+0x160>
cmp    $0xffffffff,%r13d
je     14ea <main+0x34a>
xor    %eax,%eax
call   10c0 <fork@plt>
mov    %eax,%r13d
test   %eax,%eax
je     1308 <main+0x168>
cmp    $0xffffffff,%r13d
je     14ea <main+0x34a>
xor    %eax,%eax
call   10c0 <fork@plt>
mov    %eax,%r13d
test   %eax,%eax
je     1310 <main+0x170>
cmp    $0xffffffff,%r13d
je     14ea <main+0x34a>
xor    %eax,%eax
call   10c0 <fork@plt>
mov    %eax,%r13d
mov    $0x6,%r12d
test   %eax,%eax
je     1316 <main+0x176>
cmp    $0xffffffff,%r13d
je     14ea <main+0x34a>
mov    $0x7,%r12d
jmp    1316 <main+0x176>
mov    $0x1,%r12d
jmp    1316 <main+0x176>
mov    $0x2,%r12d
jmp    1316 <main+0x176>
mov    $0x3,%r12d
jmp    1316 <main+0x176>
mov    $0x4,%r12d
jmp    1316 <main+0x176>
mov    $0x5,%r12d
mov    $0x5,%ebp
mov    0x2cb6(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm1,(%rsp)
lea    -0x4(%rbp),%eax
imul   (%r15),%eax
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
call   1080 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    (%r15),%eax
imul   %ebp,%eax
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
call   1080 <sin@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
addsd  (%rsp),%xmm1
add    $0x8,%ebp
cmp    $0x4c4b405,%ebp
jne    1330 <main+0x190>
test   %r13d,%r13d
je     14c8 <main+0x328>
mov    0xc(%rbx),%eax
add    0x4(%rbx),%eax
add    0x14(%rbx),%eax
add    0x1c(%rbx),%eax
add    0x24(%rbx),%eax
add    0x2c(%rbx),%eax
add    0x34(%rbx),%eax
cs nopw 0x0(%rax,%rax,1)
cmp    $0x7,%eax
jne    13b0 <main+0x210>
xorps  %xmm0,%xmm0
cvtsi2sdl (%rbx),%xmm0
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdl 0x8(%rbx),%xmm0
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0x10(%rbx),%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdl 0x18(%rbx),%xmm0
cvtsi2sdl 0x20(%rbx),%xmm2
addsd  %xmm1,%xmm0
addsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sdl 0x28(%rbx),%xmm0
addsd  %xmm2,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0x30(%rbx),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mov    %rbx,%rdi
mov    $0x38,%esi
call   10a0 <munmap@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%rbx
mov    0x2ba8(%rip),%rax
mov    (%rax),%edi
lea    0x20(%rsp),%rsi
call   1040 <clock_gettime@plt>
sub    %r14,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
mov    0x2b82(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd 0x20(%rsp),%xmm0
subpd  0x30(%rsp),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
divsd  0xb94(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
lea    0xb93(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
lea    0xb8e(%rip),%rdi
movsd  0xb70(%rip),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
lea    0xb98(%rip),%rdi
movaps 0x10(%rsp),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
lea    0xb9c(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
jmp    14d9 <main+0x339>
cvttsd2si %xmm1,%eax
mov    %eax,(%rbx,%r12,8)
movl   $0x1,0x4(%rbx,%r12,8)
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb7b(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.timespec = type { double, double }
%struct.child_data = type { i32, i32 }
%struct.child_data.0 = type opaque
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_ANONYMOUS = global i32 0
@CLOCK_MONOTONIC = global i32 0
@.str = [14 x i8] c"Fork failed!\0A\00"
@M_PI = global i32 0
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [14 x i8] c"Result: %g \0A\00"
@.str.2 = [32 x i8] c"Total number of operations: %g\0A\00"
@.str.3 = [23 x i8] c"Total wall-time: %g s\0A\00"
@.str.4 = [23 x i8] c"Total cpu-time: %g s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timespec
%7 = alloca %struct.timespec
%8 = alloca double
%9 = alloca double
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double
%16 = alloca i32
%17 = alloca %struct.child_data*
%18 = alloca double*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* @PROT_READ
%20 = load i32, i32* @PROT_WRITE
%21 = or i32 %19, %20
%22 = load i32, i32* @MAP_SHARED
%23 = load i32, i32* @MAP_ANONYMOUS
%24 = or i32 %22, %23
%25 = call %struct.child_data.0* @mmap(i32* null, i32 56, i32 %21, i32 %24, i32 -1, i32 0)
%26 = bitcast %struct.child_data.0* %25 to %struct.child_data*
store %struct.child_data* %26, %struct.child_data** %17
store i32 0, i32* %12
br label %27
27: ; preds = %41, %2
%28 = load i32, i32* %12
%29 = icmp slt i32 %28, 7
br i1 %29, label %30, label %44
30: ; preds = %27
%31 = load %struct.child_data*, %struct.child_data** %17
%32 = load i32, i32* %12
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds %struct.child_data, %struct.child_data* %31, i64 %33
%35 = getelementptr inbounds %struct.child_data, %struct.child_data* %34, i32 0, i32 0
store i32 0, i32* %35
%36 = load %struct.child_data*, %struct.child_data** %17
%37 = load i32, i32* %12
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds %struct.child_data, %struct.child_data* %36, i64 %38
%40 = getelementptr inbounds %struct.child_data, %struct.child_data* %39, i32 0, i32 1
store i32 0, i32* %40
br label %41
41: ; preds = %30
%42 = load i32, i32* %12
%43 = add nsw i32 %42, 1
store i32 %43, i32* %12
br label %27
44: ; preds = %27
%45 = call double* @malloc(i32 160000000)
store double* %45, double** %18
%46 = load i32, i32* @CLOCK_MONOTONIC
%47 = call i32 @clock_gettime(i32 %46, %struct.timespec* %6)
%48 = call i64 (...) @clock()
store i64 %48, i64* %10
store i32 0, i32* %13
br label %49
49: ; preds = %64, %44
%50 = load i32, i32* %13
%51 = icmp slt i32 %50, 7
br i1 %51, label %52, label %67
52: ; preds = %49
%53 = call i32 (...) @fork()
store i32 %53, i32* %16
%54 = load i32, i32* %16
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %59
56: ; preds = %52
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%58 = call i32 @exit(i32 -1)
unreachable
59: ; preds = %52
%60 = load i32, i32* %16
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %59
br label %67
63: ; preds = %59
br label %64
64: ; preds = %63
%65 = load i32, i32* %13
%66 = add nsw i32 %65, 1
store i32 %66, i32* %13
br label %49
67: ; preds = %62, %49
store i32 0, i32* %12
br label %68
68: ; preds = %82, %67
%69 = load i32, i32* %12
%70 = icmp slt i32 %69, 20000000
br i1 %70, label %71, label %85
71: ; preds = %68
%72 = load i32, i32* @M_PI
%73 = load i32, i32* %12
%74 = mul nsw i32 4, %73
%75 = add nsw i32 1, %74
%76 = mul nsw i32 %72, %75
%77 = sdiv i32 %76, 2
%78 = call i64 @sin(i32 %77)
%79 = sitofp i64 %78 to double
%80 = load double, double* %15
%81 = fadd double %80, %79
store double %81, double* %15
br label %82
82: ; preds = %71
%83 = load i32, i32* %12
%84 = add nsw i32 %83, 1
store i32 %84, i32* %12
br label %68
85: ; preds = %68
%86 = load i32, i32* %16
%87 = icmp eq i32 %86, 0
br i1 %87, label %88, label %101
88: ; preds = %85
%89 = load double, double* %15
%90 = fptosi double %89 to i32
%91 = load %struct.child_data*, %struct.child_data** %17
%92 = load i32, i32* %13
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds %struct.child_data, %struct.child_data* %91, i64 %93
%95 = getelementptr inbounds %struct.child_data, %struct.child_data* %94, i32 0, i32 0
store i32 %90, i32* %95
%96 = load %struct.child_data*, %struct.child_data** %17
%97 = load i32, i32* %13
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds %struct.child_data, %struct.child_data* %96, i64 %98
%100 = getelementptr inbounds %struct.child_data, %struct.child_data* %99, i32 0, i32 1
store i32 1, i32* %100
store i32 0, i32* %3
br label %173
101: ; preds = %85
br label %102
102: ; preds = %122, %101
store i32 0, i32* %14
store i32 0, i32* %12
br label %103
103: ; preds = %115, %102
%104 = load i32, i32* %12
%105 = icmp slt i32 %104, 7
br i1 %105, label %106, label %118
106: ; preds = %103
%107 = load %struct.child_data*, %struct.child_data** %17
%108 = load i32, i32* %12
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds %struct.child_data, %struct.child_data* %107, i64 %109
%111 = getelementptr inbounds %struct.child_data, %struct.child_data* %110, i32 0, i32 1
%112 = load i32, i32* %111
%113 = load i32, i32* %14
%114 = add nsw i32 %113, %112
store i32 %114, i32* %14
br label %115
115: ; preds = %106
%116 = load i32, i32* %12
%117 = add nsw i32 %116, 1
store i32 %117, i32* %12
br label %103
118: ; preds = %103
%119 = load i32, i32* %14
%120 = icmp eq i32 %119, 7
br i1 %120, label %121, label %122
121: ; preds = %118
br label %123
122: ; preds = %118
br label %102
123: ; preds = %121
store i32 0, i32* %12
br label %124
124: ; preds = %137, %123
%125 = load i32, i32* %12
%126 = icmp slt i32 %125, 7
br i1 %126, label %127, label %140
127: ; preds = %124
%128 = load %struct.child_data*, %struct.child_data** %17
%129 = load i32, i32* %12
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds %struct.child_data, %struct.child_data* %128, i64 %130
%132 = getelementptr inbounds %struct.child_data, %struct.child_data* %131, i32 0, i32 0
%133 = load i32, i32* %132
%134 = sitofp i32 %133 to double
%135 = load double, double* %15
%136 = fadd double %135, %134
store double %136, double* %15
br label %137
137: ; preds = %127
%138 = load i32, i32* %12
%139 = add nsw i32 %138, 1
store i32 %139, i32* %12
br label %124
140: ; preds = %124
%141 = load %struct.child_data*, %struct.child_data** %17
%142 = bitcast %struct.child_data* %141 to %struct.child_data.0*
%143 = call i32 @munmap(%struct.child_data.0* %142, i32 56)
%144 = call i64 (...) @clock()
store i64 %144, i64* %11
%145 = load i32, i32* @CLOCK_MONOTONIC
%146 = call i32 @clock_gettime(i32 %145, %struct.timespec* %7)
%147 = load i64, i64* %11
%148 = load i64, i64* %10
%149 = sub nsw i64 %147, %148
%150 = sitofp i64 %149 to double
%151 = load double, double* @CLOCKS_PER_SEC
%152 = fdiv double %150, %151
store double %152, double* %9
%153 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
%154 = load double, double* %153
%155 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%156 = load double, double* %155
%157 = fsub double %154, %156
store double %157, double* %8
%158 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 1
%159 = load double, double* %158
%160 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%161 = load double, double* %160
%162 = fsub double %159, %161
%163 = fdiv double %162, 1.000000e+09
%164 = load double, double* %8
%165 = fadd double %164, %163
store double %165, double* %8
%166 = load double, double* %15
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), double %166)
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), double 1.600000e+08)
%169 = load double, double* %8
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %169)
%171 = load double, double* %9
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), double %171)
store i32 0, i32* %3
br label %173
173: ; preds = %140, %88
%174 = load i32, i32* %3
ret i32 %174
}

LLVM IR (-O2):
%struct.timespec = type { double, double }
%struct.child_data.0 = type opaque
%struct.child_data = type { i32, i32 }
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_ANONYMOUS = global i32 0
@CLOCK_MONOTONIC = global i32 0
@M_PI = global i32 0
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [14 x i8] c"Result: %g \0A\00"
@.str.2 = [32 x i8] c"Total number of operations: %g\0A\00"
@.str.3 = [23 x i8] c"Total wall-time: %g s\0A\00"
@.str.4 = [23 x i8] c"Total cpu-time: %g s\0A\00"
@str = [13 x i8] c"Fork failed!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca <2 x double>
%4 = bitcast <2 x double>* %3 to %struct.timespec*
%5 = alloca <2 x double>
%6 = bitcast <2 x double>* %5 to %struct.timespec*
%7 = bitcast <2 x double>* %3 to i8*
%8 = bitcast <2 x double>* %5 to i8*
%9 = load i32, i32* @PROT_READ
%10 = load i32, i32* @PROT_WRITE
%11 = or i32 %10, %9
%12 = load i32, i32* @MAP_SHARED
%13 = load i32, i32* @MAP_ANONYMOUS
%14 = or i32 %13, %12
%15 = tail call %struct.child_data.0* @mmap(i32* null, i32 56, i32 %11, i32 %14, i32 -1, i32 0)
%16 = bitcast %struct.child_data.0* %15 to i8*
%17 = bitcast %struct.child_data.0* %15 to %struct.child_data*
%18 = tail call double* @malloc(i32 160000000)
%19 = load i32, i32* @CLOCK_MONOTONIC
%20 = call i32 @clock_gettime(i32 %19, %struct.timespec* %4)
%21 = call i64 (...) @clock()
%22 = call i32 (...) @fork()
switch i32 %22, label %26 [
i32 -1, label %23
i32 0, label %39
]
23: ; preds = %36, %34, %32, %30, %28, %26, %2
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%25 = call i32 @exit(i32 -1)
unreachable
26: ; preds = %2
%27 = call i32 (...) @fork()
switch i32 %27, label %28 [
i32 -1, label %23
i32 0, label %39
]
28: ; preds = %26
%29 = call i32 (...) @fork()
switch i32 %29, label %30 [
i32 -1, label %23
i32 0, label %39
]
30: ; preds = %28
%31 = call i32 (...) @fork()
switch i32 %31, label %32 [
i32 -1, label %23
i32 0, label %39
]
32: ; preds = %30
%33 = call i32 (...) @fork()
switch i32 %33, label %34 [
i32 -1, label %23
i32 0, label %39
]
34: ; preds = %32
%35 = call i32 (...) @fork()
switch i32 %35, label %36 [
i32 -1, label %23
i32 0, label %39
]
36: ; preds = %34
%37 = call i32 (...) @fork()
switch i32 %37, label %38 [
i32 -1, label %23
i32 0, label %39
]
38: ; preds = %36
br label %39
39: ; preds = %38, %36, %34, %32, %30, %28, %26, %2
%40 = phi i64 [ 0, %2 ], [ 1, %26 ], [ 2, %28 ], [ 3, %30 ], [ 4, %32 ], [ 5, %34 ], [ 6, %36 ], [ 7, %38 ]
%41 = phi i32 [ %22, %2 ], [ %27, %26 ], [ %29, %28 ], [ %31, %30 ], [ %33, %32 ], [ %35, %34 ], [ %37, %36 ], [ %37, %38 ]
br label %42
42: ; preds = %42, %39
%43 = phi i32 [ 0, %39 ], [ %61, %42 ]
%44 = phi double [ undef, %39 ], [ %60, %42 ]
%45 = load i32, i32* @M_PI
%46 = shl nuw nsw i32 %43, 2
%47 = or i32 %46, 1
%48 = mul nsw i32 %45, %47
%49 = sdiv i32 %48, 2
%50 = call i64 @sin(i32 %49)
%51 = sitofp i64 %50 to double
%52 = fadd double %44, %51
%53 = load i32, i32* @M_PI
%54 = shl i32 %43, 2
%55 = or i32 %54, 5
%56 = mul nsw i32 %53, %55
%57 = sdiv i32 %56, 2
%58 = call i64 @sin(i32 %57)
%59 = sitofp i64 %58 to double
%60 = fadd double %52, %59
%61 = add nuw nsw i32 %43, 2
%62 = icmp eq i32 %61, 20000000
br i1 %62, label %63, label %42
63: ; preds = %42
%64 = icmp eq i32 %41, 0
br i1 %64, label %87, label %65
65: ; preds = %63
%66 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 0, i32 1
%67 = load i32, i32* %66
%68 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 1, i32 1
%69 = load i32, i32* %68
%70 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 2, i32 1
%71 = load i32, i32* %70
%72 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 3, i32 1
%73 = load i32, i32* %72
%74 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 4, i32 1
%75 = load i32, i32* %74
%76 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 5, i32 1
%77 = load i32, i32* %76
%78 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 6, i32 1
%79 = load i32, i32* %78
%80 = add nsw i32 %69, %67
%81 = add nsw i32 %71, %80
%82 = add nsw i32 %73, %81
%83 = add nsw i32 %75, %82
%84 = add nsw i32 %77, %83
%85 = add nsw i32 %79, %84
%86 = icmp eq i32 %85, 7
br label %91
87: ; preds = %63
%88 = fptosi double %60 to i32
%89 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 %40, i32 0
store i32 %88, i32* %89
%90 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 %40, i32 1
store i32 1, i32* %90
br label %140
91: ; preds = %65, %91
br i1 %86, label %92, label %91
92: ; preds = %91
%93 = bitcast %struct.child_data.0* %15 to i32*
%94 = load i32, i32* %93
%95 = sitofp i32 %94 to double
%96 = fadd double %60, %95
%97 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 1, i32 0
%98 = load i32, i32* %97
%99 = sitofp i32 %98 to double
%100 = fadd double %96, %99
%101 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 2, i32 0
%102 = load i32, i32* %101
%103 = sitofp i32 %102 to double
%104 = fadd double %100, %103
%105 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 3, i32 0
%106 = load i32, i32* %105
%107 = sitofp i32 %106 to double
%108 = fadd double %104, %107
%109 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 4, i32 0
%110 = load i32, i32* %109
%111 = sitofp i32 %110 to double
%112 = fadd double %108, %111
%113 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 5, i32 0
%114 = load i32, i32* %113
%115 = sitofp i32 %114 to double
%116 = fadd double %112, %115
%117 = getelementptr inbounds %struct.child_data, %struct.child_data* %17, i64 6, i32 0
%118 = load i32, i32* %117
%119 = sitofp i32 %118 to double
%120 = fadd double %116, %119
%121 = call i32 @munmap(%struct.child_data.0* %15, i32 56)
%122 = call i64 (...) @clock()
%123 = load i32, i32* @CLOCK_MONOTONIC
%124 = call i32 @clock_gettime(i32 %123, %struct.timespec* %6)
%125 = sub nsw i64 %122, %21
%126 = sitofp i64 %125 to double
%127 = load double, double* @CLOCKS_PER_SEC
%128 = fdiv double %126, %127
%129 = load <2 x double>, <2 x double>* %5
%130 = load <2 x double>, <2 x double>* %3
%131 = fsub <2 x double> %129, %130
%132 = extractelement <2 x double> %131, i64 1
%133 = fdiv double %132, 1.000000e+09
%134 = extractelement <2 x double> %131, i64 0
%135 = fadd double %134, %133
%136 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), double %120)
%137 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), double 1.600000e+08)
%138 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %135)
%139 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), double %128)
br label %140
140: ; preds = %92, %87
ret i32 0
}