#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);
float squash(float);
void bpnn_layerforward(float *l1, float *l2, float **conn, int n1, int n2) {
  float sum;
  int j, k;
  l1[0] = 1.0;
  {
    const unsigned long long parallel_for_start = current_time_ns();
#pragma omp parallel for shared(conn, n1, n2, l1) private(k, j) reduction(+: sum) schedule(static)
    for (j = 1; j <= n2; j++) {
      sum = 0.0;
      for (k = 0; k <= n1; k++) {
        sum += conn[k][j] * l1[k];
      }
      l2[j] = squash(sum);
    };
    const unsigned long long parallel_for_end = current_time_ns();
    printf("pragma232_omp_parallel %llu ns\n",
           parallel_for_end - parallel_for_start);
  }
}


x86 assembly (clang, -O0):
<bpnn_layerforward>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movss  0xea9(%rip),%xmm0
movss  %xmm0,(%rax)
mov    $0x0,%al
call   1050 <current_time_ns@plt>
mov    %rax,-0x38(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     11fb <bpnn_layerforward+0xcb>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     11d6 <bpnn_layerforward+0xa6>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
movss  -0x24(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1188 <bpnn_layerforward+0x58>
movss  -0x24(%rbp),%xmm0
call   1040 <squash@plt>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    116d <bpnn_layerforward+0x3d>
mov    $0x0,%al
call   1050 <current_time_ns@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
sub    -0x38(%rbp),%rsi
lea    0xdef(%rip),%rdi
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpnn_layerforward>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,%r15d
mov    %rcx,0x8(%rsp)
mov    %rdx,%rbx
mov    %rsi,0x20(%rsp)
mov    %rdi,%rbp
movl   $0x3f800000,(%rdi)
xor    %eax,%eax
call   1050 <current_time_ns@plt>
mov    %rax,0x10(%rsp)
test   %r15d,%r15d
jle    1291 <bpnn_layerforward+0x161>
mov    0x8(%rsp),%rax
lea    0x1(%rax),%r13d
add    $0x1,%r15d
lea    -0x1(%r13),%rax
mov    %rax,0x18(%rsp)
mov    %r13d,%r12d
and    $0x3,%r12d
and    $0xfffffffc,%r13d
mov    $0x1,%r14d
jmp    11c0 <bpnn_layerforward+0x90>
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm0,%xmm0
call   1040 <squash@plt>
mov    0x20(%rsp),%rax
movss  %xmm0,(%rax,%r14,4)
add    $0x1,%r14
cmp    %r15,%r14
je     1291 <bpnn_layerforward+0x161>
cmpl   $0x0,0x8(%rsp)
js     11a0 <bpnn_layerforward+0x70>
cmpq   $0x3,0x18(%rsp)
jae    11e0 <bpnn_layerforward+0xb0>
xorps  %xmm0,%xmm0
xor    %eax,%eax
jmp    124c <bpnn_layerforward+0x11c>
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx,%rax,8),%rcx
mov    0x8(%rbx,%rax,8),%rdx
movss  (%rcx,%r14,4),%xmm1
mulss  0x0(%rbp,%rax,4),%xmm1
addss  %xmm0,%xmm1
movss  (%rdx,%r14,4),%xmm2
mulss  0x4(%rbp,%rax,4),%xmm2
addss  %xmm1,%xmm2
mov    0x10(%rbx,%rax,8),%rcx
movss  (%rcx,%r14,4),%xmm1
mulss  0x8(%rbp,%rax,4),%xmm1
mov    0x18(%rbx,%rax,8),%rcx
movss  (%rcx,%r14,4),%xmm0
mulss  0xc(%rbp,%rax,4),%xmm0
addss  %xmm2,%xmm1
addss  %xmm1,%xmm0
add    $0x4,%rax
cmp    %rax,%r13
jne    11f0 <bpnn_layerforward+0xc0>
test   %r12,%r12
je     11a3 <bpnn_layerforward+0x73>
lea    0x0(,%rax,4),%rcx
add    %rbp,%rcx
lea    (%rbx,%rax,8),%rax
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
mov    (%rax,%rdx,8),%rsi
movss  (%rsi,%r14,4),%xmm1
mulss  (%rcx,%rdx,4),%xmm1
addss  %xmm1,%xmm0
add    $0x1,%rdx
cmp    %rdx,%r12
jne    1270 <bpnn_layerforward+0x140>
jmp    11a3 <bpnn_layerforward+0x73>
xor    %eax,%eax
call   1050 <current_time_ns@plt>
sub    0x10(%rsp),%rax
lea    0xd5c(%rip),%rdi
mov    %rax,%rsi
add    $0x28,%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"pragma232_omp_parallel %llu ns\0A\00"
define void @bpnn_layerforward(float* %0, float* %1, float** %2, i32 %3, i32 %4) {
%6 = alloca float*
%7 = alloca float*
%8 = alloca float**
%9 = alloca i32
%10 = alloca i32
%11 = alloca float
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca i64
store float* %0, float** %6
store float* %1, float** %7
store float** %2, float*** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%16 = load float*, float** %6
%17 = getelementptr inbounds float, float* %16, i64 0
store float 1.000000e+00, float* %17
%18 = call i64 (...) @current_time_ns()
store i64 %18, i64* %14
store i32 1, i32* %12
br label %19
19: ; preds = %55, %5
%20 = load i32, i32* %12
%21 = load i32, i32* %10
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %58
23: ; preds = %19
store float 0.000000e+00, float* %11
store i32 0, i32* %13
br label %24
24: ; preds = %45, %23
%25 = load i32, i32* %13
%26 = load i32, i32* %9
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %48
28: ; preds = %24
%29 = load float**, float*** %8
%30 = load i32, i32* %13
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float*, float** %29, i64 %31
%33 = load float*, float** %32
%34 = load i32, i32* %12
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds float, float* %33, i64 %35
%37 = load float, float* %36
%38 = load float*, float** %6
%39 = load i32, i32* %13
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %38, i64 %40
%42 = load float, float* %41
%43 = load float, float* %11
%44 = call float @llvm.fmuladd.f32(float %37, float %42, float %43)
store float %44, float* %11
br label %45
45: ; preds = %28
%46 = load i32, i32* %13
%47 = add nsw i32 %46, 1
store i32 %47, i32* %13
br label %24
48: ; preds = %24
%49 = load float, float* %11
%50 = call float @squash(float %49)
%51 = load float*, float** %7
%52 = load i32, i32* %12
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds float, float* %51, i64 %53
store float %50, float* %54
br label %55
55: ; preds = %48
%56 = load i32, i32* %12
%57 = add nsw i32 %56, 1
store i32 %57, i32* %12
br label %19
58: ; preds = %19
%59 = call i64 (...) @current_time_ns()
store i64 %59, i64* %15
%60 = load i64, i64* %15
%61 = load i64, i64* %14
%62 = sub i64 %60, %61
%63 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %62)
ret void
}

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