#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 */
scalar_t__ fork();
int /*<<< orphan*/ parallel();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ secvential();
scalar_t__ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ wait(long *);
int main(int argc, char **argv) {
  long int start, end, pid;
  double cpu_time_used;
  if (fork() == 0) {
    start = (unsigned)time(NULL);
    parallel();
    end = (unsigned)time(NULL);
    printf("paralel time: %d seconds\n", end - start);
  } else if (fork() == 0) {
    start = (unsigned)time(NULL);
    secvential();
    end = (unsigned)time(NULL);
    printf("secvential time: %d seconds\n", end - start);
  } else {
    printf("wait for kids");
    wait(&start);
    wait(&start);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1080 <fork@plt>
cmp    $0x0,%rax
jne    11c7 <main+0x67>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%eax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <parallel@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%eax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123d <main+0xdd>
mov    $0x0,%al
call   1080 <fork@plt>
cmp    $0x0,%rax
jne    1218 <main+0xb8>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%eax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <secvential@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%eax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1238 <main+0xd8>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1070 <wait@plt>
lea    -0x18(%rbp),%rdi
call   1070 <wait@plt>
jmp    123d <main+0xdd>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
je     11a2 <main+0x42>
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
je     11c7 <main+0x67>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <wait@plt>
mov    %rbx,%rdi
call   1070 <wait@plt>
jmp    11f1 <main+0x91>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <parallel@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%esi
sub    %rbx,%rsi
lea    0xe3b(%rip),%rdi
jmp    11ea <main+0x8a>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <secvential@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%esi
sub    %rbx,%rsi
lea    0xe30(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"paralel time: %d seconds\0A\00"
@.str.1 = [29 x i8] c"secvential time: %d seconds\0A\00"
@.str.2 = [14 x i8] c"wait for kids\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i64 (...) @fork()
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %2
%13 = call i64 @time(i32* null)
%14 = trunc i64 %13 to i32
%15 = zext i32 %14 to i64
store i64 %15, i64* %6
%16 = call i32 (...) @parallel()
%17 = call i64 @time(i32* null)
%18 = trunc i64 %17 to i32
%19 = zext i32 %18 to i64
store i64 %19, i64* %7
%20 = load i64, i64* %7
%21 = load i64, i64* %6
%22 = sub nsw i64 %20, %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i64 %22)
br label %44
24: ; preds = %2
%25 = call i64 (...) @fork()
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %39
27: ; preds = %24
%28 = call i64 @time(i32* null)
%29 = trunc i64 %28 to i32
%30 = zext i32 %29 to i64
store i64 %30, i64* %6
%31 = call i32 (...) @secvential()
%32 = call i64 @time(i32* null)
%33 = trunc i64 %32 to i32
%34 = zext i32 %33 to i64
store i64 %34, i64* %7
%35 = load i64, i64* %7
%36 = load i64, i64* %6
%37 = sub nsw i64 %35, %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i64 %37)
br label %43
39: ; preds = %24
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @wait(i64* %6)
%42 = call i32 @wait(i64* %6)
br label %43
43: ; preds = %39, %27
br label %44
44: ; preds = %43, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"paralel time: %d seconds\0A\00"
@.str.1 = [29 x i8] c"secvential time: %d seconds\0A\00"
@.str.2 = [14 x i8] c"wait for kids\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = tail call i64 (...) @fork()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %2
%8 = tail call i64 @time(i32* null)
%9 = and i64 %8, 4294967295
%10 = tail call i32 (...) @parallel()
%11 = tail call i64 @time(i32* null)
%12 = and i64 %11, 4294967295
%13 = sub nsw i64 %12, %9
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i64 %13)
br label %30
15: ; preds = %2
%16 = tail call i64 (...) @fork()
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = tail call i64 @time(i32* null)
%20 = and i64 %19, 4294967295
%21 = tail call i32 (...) @secvential()
%22 = tail call i64 @time(i32* null)
%23 = and i64 %22, 4294967295
%24 = sub nsw i64 %23, %20
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i64 %24)
br label %30
26: ; preds = %15
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @wait(i64* %3)
%29 = call i32 @wait(i64* %3)
br label %30
30: ; preds = %18, %26, %7
ret i32 0
}