#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 timezone {
  int dummy;
};
struct timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
int /*<<< orphan*/ omp_set_num_threads(int);
int /*<<< orphan*/ printf(char *);
double Matrix_Multiplication_Three(double **Matrix_A, double **Matrix_B,
                                   double **Result, int N_size,
                                   int Total_threads) {
  int i, j, k;
  struct timeval TimeValue_Start;
  struct timezone TimeZone_Start;
  struct timeval TimeValue_Final;
  struct timezone TimeZone_Final;
  long time_start, time_end;
  double time_overhead;
  gettimeofday(&TimeValue_Start, &TimeZone_Start);
  omp_set_num_threads(Total_threads);
#pragma omp parallel for private(j, k)                                         \
    shared(Matrix_A, Matrix_B, Result, N_size) num_threads(Total_threads)
  for (i = 0; i < N_size; i = i + 1) {
#pragma omp parallel for private(k) shared(Matrix_A, Matrix_B, Result, N_size) \
    num_threads(Total_threads)
    for (j = 0; j < N_size; j = j + 1) {
      Result[i][j] = 0.0;
#pragma omp parallel for private(k) shared(Matrix_A, Matrix_B, Result, N_size) \
    num_threads(Total_threads)
      for (k = 0; k < N_size; k = k + 1)
        Result[i][j] = Result[i][j] + Matrix_A[i][k] * Matrix_B[k][j];
    }
  }
  gettimeofday(&TimeValue_Final, &TimeZone_Final);
  time_start = TimeValue_Start.tv_sec * 1000000 + TimeValue_Start.tv_usec;
  time_end = TimeValue_Final.tv_sec * 1000000 + TimeValue_Final.tv_usec;
  time_overhead = (time_end - time_start) / 1000000.0;
  printf("\n\t\t Matrix into Matrix Multiplication using three Parallel for "
         "pragma......Done \n");
  return time_overhead;
}


x86 assembly (clang, -O0):
<Matrix_Multiplication_Three>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
lea    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <gettimeofday@plt>
mov    -0x20(%rbp),%edi
call   1050 <omp_set_num_threads@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1241 <Matrix_Multiplication_Three+0x111>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    122e <Matrix_Multiplication_Three+0xfe>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    121b <Matrix_Multiplication_Three+0xeb>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a5 <Matrix_Multiplication_Three+0x75>
jmp    1220 <Matrix_Multiplication_Three+0xf0>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    117a <Matrix_Multiplication_Three+0x4a>
jmp    1233 <Matrix_Multiplication_Three+0x103>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1167 <Matrix_Multiplication_Three+0x37>
lea    -0x48(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <gettimeofday@plt>
imul   $0xf4240,-0x38(%rbp),%eax
add    -0x34(%rbp),%eax
cltq
mov    %rax,-0x58(%rbp)
imul   $0xf4240,-0x48(%rbp),%eax
add    -0x44(%rbp),%eax
cltq
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
sub    -0x58(%rbp),%rax
cvtsi2sd %rax,%xmm0
movsd  0xd7d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
lea    0xd75(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x68(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Matrix_Multiplication_Three>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,%r12d
mov    %ecx,%r13d
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0x8(%rsp),%rdi
lea    0x20(%rsp),%rsi
call   1040 <gettimeofday@plt>
mov    %r12d,%edi
call   1050 <omp_set_num_threads@plt>
test   %r13d,%r13d
jle    1218 <Matrix_Multiplication_Three+0xe8>
mov    %r13d,%r9d
mov    %r9d,%ecx
and    $0xfffffffe,%ecx
xor    %r8d,%r8d
jmp    118d <Matrix_Multiplication_Three+0x5d>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r8
cmp    %r9,%r8
je     1218 <Matrix_Multiplication_Three+0xe8>
mov    (%r14,%r8,8),%rsi
mov    (%r15,%r8,8),%rdi
xor    %edx,%edx
jmp    11a9 <Matrix_Multiplication_Three+0x79>
nopl   0x0(%rax)
add    $0x1,%rdx
cmp    %r9,%rdx
je     1180 <Matrix_Multiplication_Three+0x50>
movq   $0x0,(%rsi,%rdx,8)
xorpd  %xmm0,%xmm0
xor    %ebp,%ebp
cmp    $0x1,%r13d
je     11f9 <Matrix_Multiplication_Three+0xc9>
nopl   (%rax)
movsd  (%rdi,%rbp,8),%xmm1
mov    (%rbx,%rbp,8),%rax
mulsd  (%rax,%rdx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsi,%rdx,8)
movsd  0x8(%rdi,%rbp,8),%xmm0
mov    0x8(%rbx,%rbp,8),%rax
mulsd  (%rax,%rdx,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsi,%rdx,8)
add    $0x2,%rbp
cmp    %rbp,%rcx
jne    11c0 <Matrix_Multiplication_Three+0x90>
test   $0x1,%r9b
je     11a0 <Matrix_Multiplication_Three+0x70>
movsd  (%rdi,%rbp,8),%xmm1
mov    (%rbx,%rbp,8),%rax
mulsd  (%rax,%rdx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsi,%rdx,8)
jmp    11a0 <Matrix_Multiplication_Three+0x70>
mov    %rsp,%rdi
lea    0x18(%rsp),%rsi
call   1040 <gettimeofday@plt>
movslq 0x8(%rsp),%rax
imul   $0xf4240,%rax,%rax
movslq 0xc(%rsp),%rcx
add    %rax,%rcx
movslq (%rsp),%rax
imul   $0xf4240,%rax,%rax
movslq 0x4(%rsp),%rdx
add    %rax,%rdx
sub    %rcx,%rdx
xorps  %xmm0,%xmm0
cvtsi2sd %rdx,%xmm0
divsd  0xda1(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xd9c(%rip),%rdi
call   1030 <puts@plt>
movsd  0x10(%rsp),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
@.str = [82 x i8] c"\0A\09\09 Matrix into Matrix Multiplication using three Parallel for pragma......Done \0A\00"
define double @Matrix_Multiplication_Three(double** %0, double** %1, double** %2, i32 %3, i32 %4) {
%6 = alloca double**
%7 = alloca double**
%8 = alloca double**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.timeval
%15 = alloca %struct.timezone
%16 = alloca %struct.timeval
%17 = alloca %struct.timezone
%18 = alloca i64
%19 = alloca i64
%20 = alloca double
store double** %0, double*** %6
store double** %1, double*** %7
store double** %2, double*** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%21 = call i32 @gettimeofday(%struct.timeval* %14, %struct.timezone* %15)
%22 = load i32, i32* %10
%23 = call i32 @omp_set_num_threads(i32 %22)
store i32 0, i32* %11
br label %24
24: ; preds = %91, %5
%25 = load i32, i32* %11
%26 = load i32, i32* %9
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %94
28: ; preds = %24
store i32 0, i32* %12
br label %29
29: ; preds = %87, %28
%30 = load i32, i32* %12
%31 = load i32, i32* %9
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %90
33: ; preds = %29
%34 = load double**, double*** %8
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double*, double** %34, i64 %36
%38 = load double*, double** %37
%39 = load i32, i32* %12
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
store double 0.000000e+00, double* %41
store i32 0, i32* %13
br label %42
42: ; preds = %83, %33
%43 = load i32, i32* %13
%44 = load i32, i32* %9
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %86
46: ; preds = %42
%47 = load double**, double*** %8
%48 = load i32, i32* %11
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double*, double** %47, i64 %49
%51 = load double*, double** %50
%52 = load i32, i32* %12
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = load double**, double*** %6
%57 = load i32, i32* %11
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double*, double** %56, i64 %58
%60 = load double*, double** %59
%61 = load i32, i32* %13
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
%64 = load double, double* %63
%65 = load double**, double*** %7
%66 = load i32, i32* %13
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double*, double** %65, i64 %67
%69 = load double*, double** %68
%70 = load i32, i32* %12
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %69, i64 %71
%73 = load double, double* %72
%74 = call double @llvm.fmuladd.f64(double %64, double %73, double %55)
%75 = load double**, double*** %8
%76 = load i32, i32* %11
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds double*, double** %75, i64 %77
%79 = load double*, double** %78
%80 = load i32, i32* %12
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %79, i64 %81
store double %74, double* %82
br label %83
83: ; preds = %46
%84 = load i32, i32* %13
%85 = add nsw i32 %84, 1
store i32 %85, i32* %13
br label %42
86: ; preds = %42
br label %87
87: ; preds = %86
%88 = load i32, i32* %12
%89 = add nsw i32 %88, 1
store i32 %89, i32* %12
br label %29
90: ; preds = %29
br label %91
91: ; preds = %90
%92 = load i32, i32* %11
%93 = add nsw i32 %92, 1
store i32 %93, i32* %11
br label %24
94: ; preds = %24
%95 = call i32 @gettimeofday(%struct.timeval* %16, %struct.timezone* %17)
%96 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%97 = load i32, i32* %96
%98 = mul nsw i32 %97, 1000000
%99 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%100 = load i32, i32* %99
%101 = add nsw i32 %98, %100
%102 = sext i32 %101 to i64
store i64 %102, i64* %18
%103 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
%104 = load i32, i32* %103
%105 = mul nsw i32 %104, 1000000
%106 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
%107 = load i32, i32* %106
%108 = add nsw i32 %105, %107
%109 = sext i32 %108 to i64
store i64 %109, i64* %19
%110 = load i64, i64* %19
%111 = load i64, i64* %18
%112 = sub nsw i64 %110, %111
%113 = sitofp i64 %112 to double
%114 = fdiv double %113, 1.000000e+06
store double %114, double* %20
%115 = call i32 @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0))
%116 = load double, double* %20
ret double %116
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
@str = [81 x i8] c"\0A\09\09 Matrix into Matrix Multiplication using three Parallel for pragma......Done \00"
define double @Matrix_Multiplication_Three(double** nocapture %0, double** nocapture %1, double** nocapture %2, i32 %3, i32 %4) {
%6 = alloca %struct.timeval
%7 = alloca %struct.timezone
%8 = alloca %struct.timeval
%9 = alloca %struct.timezone
%10 = bitcast %struct.timeval* %6 to i8*
%11 = bitcast %struct.timezone* %7 to i8*
%12 = bitcast %struct.timeval* %8 to i8*
%13 = bitcast %struct.timezone* %9 to i8*
%14 = call i32 @gettimeofday(%struct.timeval* %6, %struct.timezone* %7)
%15 = tail call i32 @omp_set_num_threads(i32 %4)
%16 = icmp sgt i32 %3, 0
br i1 %16, label %17, label %71
17: ; preds = %5
%18 = zext i32 %3 to i64
%19 = and i64 %18, 1
%20 = icmp eq i32 %3, 1
%21 = and i64 %18, 4294967294
%22 = icmp eq i64 %19, 0
br label %23
23: ; preds = %68, %17
%24 = phi i64 [ 0, %17 ], [ %69, %68 ]
%25 = getelementptr inbounds double*, double** %2, i64 %24
%26 = load double*, double** %25
%27 = getelementptr inbounds double*, double** %0, i64 %24
%28 = load double*, double** %27
br label %29
29: ; preds = %65, %23
%30 = phi i64 [ 0, %23 ], [ %66, %65 ]
%31 = getelementptr inbounds double, double* %26, i64 %30
store double 0.000000e+00, double* %31
br i1 %20, label %54, label %32
32: ; preds = %29, %32
%33 = phi double [ %50, %32 ], [ 0.000000e+00, %29 ]
%34 = phi i64 [ %51, %32 ], [ 0, %29 ]
%35 = phi i64 [ %52, %32 ], [ 0, %29 ]
%36 = getelementptr inbounds double, double* %28, i64 %34
%37 = load double, double* %36
%38 = getelementptr inbounds double*, double** %1, i64 %34
%39 = load double*, double** %38
%40 = getelementptr inbounds double, double* %39, i64 %30
%41 = load double, double* %40
%42 = tail call double @llvm.fmuladd.f64(double %37, double %41, double %33)
store double %42, double* %31
%43 = or i64 %34, 1
%44 = getelementptr inbounds double, double* %28, i64 %43
%45 = load double, double* %44
%46 = getelementptr inbounds double*, double** %1, i64 %43
%47 = load double*, double** %46
%48 = getelementptr inbounds double, double* %47, i64 %30
%49 = load double, double* %48
%50 = tail call double @llvm.fmuladd.f64(double %45, double %49, double %42)
store double %50, double* %31
%51 = add nuw nsw i64 %34, 2
%52 = add i64 %35, 2
%53 = icmp eq i64 %52, %21
br i1 %53, label %54, label %32
54: ; preds = %32, %29
%55 = phi double [ 0.000000e+00, %29 ], [ %50, %32 ]
%56 = phi i64 [ 0, %29 ], [ %51, %32 ]
br i1 %22, label %65, label %57
57: ; preds = %54
%58 = getelementptr inbounds double, double* %28, i64 %56
%59 = load double, double* %58
%60 = getelementptr inbounds double*, double** %1, i64 %56
%61 = load double*, double** %60
%62 = getelementptr inbounds double, double* %61, i64 %30
%63 = load double, double* %62
%64 = tail call double @llvm.fmuladd.f64(double %59, double %63, double %55)
store double %64, double* %31
br label %65
65: ; preds = %54, %57
%66 = add nuw nsw i64 %30, 1
%67 = icmp eq i64 %66, %18
br i1 %67, label %68, label %29
68: ; preds = %65
%69 = add nuw nsw i64 %24, 1
%70 = icmp eq i64 %69, %18
br i1 %70, label %71, label %23
71: ; preds = %68, %5
%72 = call i32 @gettimeofday(%struct.timeval* %8, %struct.timezone* %9)
%73 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%74 = load i32, i32* %73
%75 = mul nsw i32 %74, 1000000
%76 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%77 = load i32, i32* %76
%78 = add nsw i32 %75, %77
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 0
%81 = load i32, i32* %80
%82 = mul nsw i32 %81, 1000000
%83 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 1
%84 = load i32, i32* %83
%85 = add nsw i32 %82, %84
%86 = sext i32 %85 to i64
%87 = sub nsw i64 %86, %79
%88 = sitofp i64 %87 to double
%89 = fdiv double %88, 1.000000e+06
%90 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @str, i64 0, i64 0))
ret double %89
}