#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 */
unsigned long long current_time_ns();
int /*<<< orphan*/ printf(char *, unsigned long long const);
void bpnn_adjust_weights(float *delta, int ndelta, float *ly, int nly,
                         float **w, float **oldw) {
  float new_dw;
  int k, j;
  ly[0] = 1.0;
  {
    const unsigned long long parallel_for_start = current_time_ns();
#pragma omp parallel for shared(oldw, w, delta) private(j, k, new_dw)          \
    firstprivate(ndelta, nly)
    for (j = 1; j <= ndelta; j++) {
      for (k = 0; k <= nly; k++) {
        new_dw = ((0.3 * delta[j] * ly[k]) + (0.3 * oldw[k][j]));
        w[k][j] += new_dw;
        oldw[k][j] = new_dw;
      }
    };
    const unsigned long long parallel_for_end = current_time_ns();
    printf("pragma297_omp_parallel %llu ns\n",
           parallel_for_end - parallel_for_start);
  }
}


x86 assembly (clang, -O0):
<bpnn_adjust_weights>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movss  0xeb6(%rip),%xmm0
movss  %xmm0,(%rax)
mov    $0x0,%al
call   1040 <current_time_ns@plt>
mov    %rax,-0x48(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     123d <bpnn_adjust_weights+0x11d>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     122a <bpnn_adjust_weights+0x10a>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe70(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm2
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm3
movsd  0xe3a(%rip),%xmm1
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
movss  %xmm0,(%rax,%rcx,4)
movss  -0x34(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1173 <bpnn_adjust_weights+0x53>
jmp    122f <bpnn_adjust_weights+0x10f>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1160 <bpnn_adjust_weights+0x40>
mov    $0x0,%al
call   1040 <current_time_ns@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rsi
sub    -0x48(%rbp),%rsi
lea    0xdb9(%rip),%rdi
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpnn_adjust_weights>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8,%r12
mov    %ecx,%r15d
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r13
movl   $0x3f800000,(%rdx)
xor    %eax,%eax
call   1040 <current_time_ns@plt>
mov    %rax,(%rsp)
test   %ebp,%ebp
jle    11d7 <bpnn_adjust_weights+0xb7>
lea    0x1(%r15),%eax
add    $0x1,%ebp
mov    $0x1,%ecx
movsd  0xe97(%rip),%xmm0
jmp    1179 <bpnn_adjust_weights+0x59>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rcx
cmp    %rbp,%rcx
je     11d7 <bpnn_adjust_weights+0xb7>
test   %r15d,%r15d
js     1170 <bpnn_adjust_weights+0x50>
xor    %edx,%edx
movss  0x0(%r13,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
movss  (%rbx,%rdx,4),%xmm2
cvtss2sd %xmm2,%xmm2
mulsd  %xmm1,%xmm2
mov    (%r14,%rdx,8),%rsi
movss  (%rsi,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
mov    (%r12,%rdx,8),%rdi
movss  (%rdi,%rcx,4),%xmm2
addss  %xmm1,%xmm2
movss  %xmm2,(%rdi,%rcx,4)
movss  %xmm1,(%rsi,%rcx,4)
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1180 <bpnn_adjust_weights+0x60>
jmp    1170 <bpnn_adjust_weights+0x50>
xor    %eax,%eax
call   1040 <current_time_ns@plt>
sub    (%rsp),%rax
lea    0xe1f(%rip),%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"pragma297_omp_parallel %llu ns\0A\00"
define void @bpnn_adjust_weights(float* %0, i32 %1, float* %2, i32 %3, float** %4, float** %5) {
%7 = alloca float*
%8 = alloca i32
%9 = alloca float*
%10 = alloca i32
%11 = alloca float**
%12 = alloca float**
%13 = alloca float
%14 = alloca i32
%15 = alloca i32
%16 = alloca i64
%17 = alloca i64
store float* %0, float** %7
store i32 %1, i32* %8
store float* %2, float** %9
store i32 %3, i32* %10
store float** %4, float*** %11
store float** %5, float*** %12
%18 = load float*, float** %9
%19 = getelementptr inbounds float, float* %18, i64 0
store float 1.000000e+00, float* %19
%20 = call i64 (...) @current_time_ns()
store i64 %20, i64* %16
store i32 1, i32* %15
br label %21
21: ; preds = %81, %6
%22 = load i32, i32* %15
%23 = load i32, i32* %8
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %84
25: ; preds = %21
store i32 0, i32* %14
br label %26
26: ; preds = %77, %25
%27 = load i32, i32* %14
%28 = load i32, i32* %10
%29 = icmp sle i32 %27, %28
br i1 %29, label %30, label %80
30: ; preds = %26
%31 = load float*, float** %7
%32 = load i32, i32* %15
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds float, float* %31, i64 %33
%35 = load float, float* %34
%36 = fpext float %35 to double
%37 = fmul double 3.000000e-01, %36
%38 = load float*, float** %9
%39 = load i32, i32* %14
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %38, i64 %40
%42 = load float, float* %41
%43 = fpext float %42 to double
%44 = load float**, float*** %12
%45 = load i32, i32* %14
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds float*, float** %44, i64 %46
%48 = load float*, float** %47
%49 = load i32, i32* %15
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds float, float* %48, i64 %50
%52 = load float, float* %51
%53 = fpext float %52 to double
%54 = fmul double 3.000000e-01, %53
%55 = call double @llvm.fmuladd.f64(double %37, double %43, double %54)
%56 = fptrunc double %55 to float
store float %56, float* %13
%57 = load float, float* %13
%58 = load float**, float*** %11
%59 = load i32, i32* %14
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds float*, float** %58, i64 %60
%62 = load float*, float** %61
%63 = load i32, i32* %15
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds float, float* %62, i64 %64
%66 = load float, float* %65
%67 = fadd float %66, %57
store float %67, float* %65
%68 = load float, float* %13
%69 = load float**, float*** %12
%70 = load i32, i32* %14
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds float*, float** %69, i64 %71
%73 = load float*, float** %72
%74 = load i32, i32* %15
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds float, float* %73, i64 %75
store float %68, float* %76
br label %77
77: ; preds = %30
%78 = load i32, i32* %14
%79 = add nsw i32 %78, 1
store i32 %79, i32* %14
br label %26
80: ; preds = %26
br label %81
81: ; preds = %80
%82 = load i32, i32* %15
%83 = add nsw i32 %82, 1
store i32 %83, i32* %15
br label %21
84: ; preds = %21
%85 = call i64 (...) @current_time_ns()
store i64 %85, i64* %17
%86 = load i64, i64* %17
%87 = load i64, i64* %16
%88 = sub i64 %86, %87
%89 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %88)
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"pragma297_omp_parallel %llu ns\0A\00"
define void @bpnn_adjust_weights(float* nocapture %0, i32 %1, float* nocapture %2, i32 %3, float** nocapture %4, float** nocapture %5) {
store float 1.000000e+00, float* %2
%7 = tail call i64 (...) @current_time_ns()
%8 = icmp slt i32 %1, 1
br i1 %8, label %45, label %9
9: ; preds = %6
%10 = icmp slt i32 %3, 0
%11 = add i32 %3, 1
%12 = add nuw i32 %1, 1
%13 = zext i32 %12 to i64
%14 = zext i32 %11 to i64
br label %15
15: ; preds = %9, %42
%16 = phi i64 [ 1, %9 ], [ %43, %42 ]
br i1 %10, label %42, label %17
17: ; preds = %15
%18 = getelementptr inbounds float, float* %0, i64 %16
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ 0, %17 ], [ %40, %19 ]
%21 = load float, float* %18
%22 = fpext float %21 to double
%23 = fmul double %22, 3.000000e-01
%24 = getelementptr inbounds float, float* %2, i64 %20
%25 = load float, float* %24
%26 = fpext float %25 to double
%27 = getelementptr inbounds float*, float** %5, i64 %20
%28 = load float*, float** %27
%29 = getelementptr inbounds float, float* %28, i64 %16
%30 = load float, float* %29
%31 = fpext float %30 to double
%32 = fmul double %31, 3.000000e-01
%33 = tail call double @llvm.fmuladd.f64(double %23, double %26, double %32)
%34 = fptrunc double %33 to float
%35 = getelementptr inbounds float*, float** %4, i64 %20
%36 = load float*, float** %35
%37 = getelementptr inbounds float, float* %36, i64 %16
%38 = load float, float* %37
%39 = fadd float %38, %34
store float %39, float* %37
store float %34, float* %29
%40 = add nuw nsw i64 %20, 1
%41 = icmp eq i64 %40, %14
br i1 %41, label %42, label %19
42: ; preds = %19, %15
%43 = add nuw nsw i64 %16, 1
%44 = icmp eq i64 %43, %13
br i1 %44, label %45, label %15
45: ; preds = %42, %6
%46 = tail call i64 (...) @current_time_ns()
%47 = sub i64 %46, %7
%48 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %47)
ret void
}