#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 */
float *cpu_proccall_overhead(float);
scalar_t__ cpu_process_creation(float);
float cpu_syscall_overhead(float);
scalar_t__ cpu_thread_creation(float);
float get_overhead();
int /*<<< orphan*/ pmcr_init();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i, j;
  float *proccall_test_result;
  float syscall_test_result;
  pmcr_init();
  float ccnt_overhead;
  ccnt_overhead = get_overhead();
  printf("Reading overhead time is : %f\n", ccnt_overhead);
  float proccall_test_temp[7 + 1];
  const int TRIALS = 1;
  const int CALLS = 1;
  for (i = 0; i < TRIALS; i++) {
    proccall_test_result = cpu_proccall_overhead(ccnt_overhead);
    for (j = 0; j <= 7; j++) {
      proccall_test_temp[j] += proccall_test_result[j];
    }
    for (j = 0; j <= 7; j++) {
      printf("%d: %f\t", j, (float)proccall_test_result[j]);
    }
    printf("\n");
  }
  for (i = 0; i <= 7; i++) {
    printf("procedure call with %d arguments: %f\n", i,
           proccall_test_temp[i] / (TRIALS * CALLS));
  }
  syscall_test_result = cpu_syscall_overhead(ccnt_overhead);
  printf("system call overhead time : %f\n", (float)syscall_test_result);
  printf("Process creation time : %f\n",
         (float)cpu_process_creation(ccnt_overhead));
  printf("Thread creation time : %f\n",
         (float)cpu_thread_creation(ccnt_overhead));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1090 <pmcr_init@plt>
mov    $0x0,%al
call   1060 <get_overhead@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe62(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x1,-0x44(%rbp)
movl   $0x1,-0x48(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    126f <main+0xff>
movss  -0x20(%rbp),%xmm0
call   1030 <cpu_proccall_overhead@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x7,-0xc(%rbp)
jg     1212 <main+0xa2>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movslq -0xc(%rbp),%rax
addss  -0x40(%rbp,%rax,4),%xmm0
movss  %xmm0,-0x40(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11dd <main+0x6d>
movl   $0x0,-0xc(%rbp)
cmpl   $0x7,-0xc(%rbp)
jg     1253 <main+0xe3>
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1219 <main+0xa9>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11be <main+0x4e>
movl   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jg     12b9 <main+0x149>
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rax
movss  -0x40(%rbp,%rax,4),%xmm0
movss  0xd6b(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd87(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1276 <main+0x106>
movss  -0x20(%rbp),%xmm0
call   1050 <cpu_syscall_overhead@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd79(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  -0x20(%rbp),%xmm0
call   1080 <cpu_process_creation@plt>
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd78(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  -0x20(%rbp),%xmm0
call   1070 <cpu_thread_creation@plt>
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd73(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   10a0 <pmcr_init@plt>
xor    %eax,%eax
call   1070 <get_overhead@plt>
movss  %xmm0,0x4(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xe65(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rsp),%xmm0
call   1040 <cpu_proccall_overhead@plt>
mov    %rax,%rbx
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe60(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x8(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0xc(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x10(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x14(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x5,%esi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x18(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x6,%esi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x1c(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x7,%esi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xda3(%rip),%rbx
movsd  0xd6c(%rip),%xmm0
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
movsd  0xd50(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
movsd  0xd39(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
movsd  0xd22(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
movsd  0xd0b(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
movsd  0xcf4(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
movsd  0xcdd(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
movsd  0xcc6(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rsp),%xmm0
call   1060 <cpu_syscall_overhead@plt>
cvtss2sd %xmm0,%xmm0
lea    0xcfe(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rsp),%xmm0
call   1090 <cpu_process_creation@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xcf9(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rsp),%xmm0
call   1080 <cpu_thread_creation@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xcf0(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Reading overhead time is : %f\0A\00"
@.str.1 = [8 x i8] c"%d: %f\09\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [38 x i8] c"procedure call with %d arguments: %f\0A\00"
@.str.4 = [32 x i8] c"system call overhead time : %f\0A\00"
@.str.5 = [28 x i8] c"Process creation time : %f\0A\00"
@.str.6 = [27 x i8] c"Thread creation time : %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float*
%5 = alloca float
%6 = alloca float
%7 = alloca [8 x float]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 (...) @pmcr_init()
%11 = call float (...) @get_overhead()
store float %11, float* %6
%12 = load float, float* %6
%13 = fpext float %12 to double
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), double %13)
store i32 1, i32* %8
store i32 1, i32* %9
store i32 0, i32* %2
br label %15
15: ; preds = %56, %0
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 1
br i1 %17, label %18, label %59
18: ; preds = %15
%19 = load float, float* %6
%20 = call float* @cpu_proccall_overhead(float %19)
store float* %20, float** %4
store i32 0, i32* %3
br label %21
21: ; preds = %35, %18
%22 = load i32, i32* %3
%23 = icmp sle i32 %22, 7
br i1 %23, label %24, label %38
24: ; preds = %21
%25 = load float*, float** %4
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds float, float* %25, i64 %27
%29 = load float, float* %28
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [8 x float], [8 x float]* %7, i64 0, i64 %31
%33 = load float, float* %32
%34 = fadd float %33, %29
store float %34, float* %32
br label %35
35: ; preds = %24
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %21
38: ; preds = %21
store i32 0, i32* %3
br label %39
39: ; preds = %51, %38
%40 = load i32, i32* %3
%41 = icmp sle i32 %40, 7
br i1 %41, label %42, label %54
42: ; preds = %39
%43 = load i32, i32* %3
%44 = load float*, float** %4
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds float, float* %44, i64 %46
%48 = load float, float* %47
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %43, double %49)
br label %51
51: ; preds = %42
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 1
store i32 %53, i32* %3
br label %39
54: ; preds = %39
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %56
56: ; preds = %54
%57 = load i32, i32* %2
%58 = add nsw i32 %57, 1
store i32 %58, i32* %2
br label %15
59: ; preds = %15
store i32 0, i32* %2
br label %60
60: ; preds = %72, %59
%61 = load i32, i32* %2
%62 = icmp sle i32 %61, 7
br i1 %62, label %63, label %75
63: ; preds = %60
%64 = load i32, i32* %2
%65 = load i32, i32* %2
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [8 x float], [8 x float]* %7, i64 0, i64 %66
%68 = load float, float* %67
%69 = fdiv float %68, 1.000000e+00
%70 = fpext float %69 to double
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %64, double %70)
br label %72
72: ; preds = %63
%73 = load i32, i32* %2
%74 = add nsw i32 %73, 1
store i32 %74, i32* %2
br label %60
75: ; preds = %60
%76 = load float, float* %6
%77 = call float @cpu_syscall_overhead(float %76)
store float %77, float* %5
%78 = load float, float* %5
%79 = fpext float %78 to double
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), double %79)
%81 = load float, float* %6
%82 = call i64 @cpu_process_creation(float %81)
%83 = sitofp i64 %82 to float
%84 = fpext float %83 to double
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), double %84)
%86 = load float, float* %6
%87 = call i64 @cpu_thread_creation(float %86)
%88 = sitofp i64 %87 to float
%89 = fpext float %88 to double
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %89)
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"Reading overhead time is : %f\0A\00"
@.str.1 = [8 x i8] c"%d: %f\09\00"
@.str.3 = [38 x i8] c"procedure call with %d arguments: %f\0A\00"
@.str.4 = [32 x i8] c"system call overhead time : %f\0A\00"
@.str.5 = [28 x i8] c"Process creation time : %f\0A\00"
@.str.6 = [27 x i8] c"Thread creation time : %f\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @pmcr_init()
%2 = tail call float (...) @get_overhead()
%3 = fpext float %2 to double
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), double %3)
%5 = tail call float* @cpu_proccall_overhead(float %2)
%6 = load float, float* %5
%7 = getelementptr inbounds float, float* %5, i64 1
%8 = getelementptr inbounds float, float* %5, i64 2
%9 = getelementptr inbounds float, float* %5, i64 3
%10 = getelementptr inbounds float, float* %5, i64 4
%11 = getelementptr inbounds float, float* %5, i64 5
%12 = getelementptr inbounds float, float* %5, i64 6
%13 = getelementptr inbounds float, float* %5, i64 7
%14 = fpext float %6 to double
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 0, double %14)
%16 = load float, float* %7
%17 = fpext float %16 to double
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 1, double %17)
%19 = load float, float* %8
%20 = fpext float %19 to double
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 2, double %20)
%22 = load float, float* %9
%23 = fpext float %22 to double
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 3, double %23)
%25 = load float, float* %10
%26 = fpext float %25 to double
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 4, double %26)
%28 = load float, float* %11
%29 = fpext float %28 to double
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 5, double %29)
%31 = load float, float* %12
%32 = fpext float %31 to double
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 6, double %32)
%34 = load float, float* %13
%35 = fpext float %34 to double
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7, double %35)
%37 = tail call i32 @putchar(i32 10)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 0, double 0x7FF8000000000000)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 1, double 0x7FF8000000000000)
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 2, double 0x7FF8000000000000)
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 3, double 0x7FF8000000000000)
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 4, double 0x7FF8000000000000)
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 5, double 0x7FF8000000000000)
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 6, double 0x7FF8000000000000)
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 7, double 0x7FF8000000000000)
%46 = tail call float @cpu_syscall_overhead(float %2)
%47 = fpext float %46 to double
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), double %47)
%49 = tail call i64 @cpu_process_creation(float %2)
%50 = sitofp i64 %49 to float
%51 = fpext float %50 to double
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), double %51)
%53 = tail call i64 @cpu_thread_creation(float %2)
%54 = sitofp i64 %53 to float
%55 = fpext float %54 to double
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %55)
ret i32 0
}