#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 */
double cos(double);
int /*<<< orphan*/ dgemm_(char *, char *, int *, int *, int *, double *,
                          double *, int *, double *, int *, double *, double *,
                          int *);
double sqrt(double);
void ComputeFeatureMatrix(int n, int d, int r, double *X, double *w, double *b,
                          double *Z, double sigma) {
  int i, j;
#pragma omp parallel for private(i, j)
  for (i = 0; i < n; i++) {
    for (j = 0; j < r; j++) {
      Z[i + j * n] = b[j];
    }
  }
  double ONE = 1.0;
  char TRANS_N = 'N';
  dgemm_(&TRANS_N, &TRANS_N, &n, &r, &d, &ONE, X, &n, w, &d, &ONE, Z, &n);
  double two = 2;
  double fac = sqrt(two / r);
#pragma omp parallel for private(i)
  for (i = 0; i < n * r; i++) {
    Z[i] = cos(Z[i]) * fac;
  }
}


x86 assembly (clang, -O0):
<ComputeFeatureMatrix>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x1c(%rbp)
mov    %esi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11ca <ComputeFeatureMatrix+0x9a>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11b7 <ComputeFeatureMatrix+0x87>
mov    -0x40(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x10(%rbp),%rax
mov    -0x4c(%rbp),%ecx
mov    -0x50(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1178 <ComputeFeatureMatrix+0x48>
jmp    11bc <ComputeFeatureMatrix+0x8c>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1165 <ComputeFeatureMatrix+0x35>
movsd  0xe36(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movb   $0x4e,-0x59(%rbp)
mov    -0x30(%rbp),%r15
mov    -0x38(%rbp),%r14
mov    0x10(%rbp),%r10
lea    -0x59(%rbp),%rsi
lea    -0x1c(%rbp),%rax
lea    -0x24(%rbp),%rcx
lea    -0x20(%rbp),%rbx
lea    -0x58(%rbp),%r11
mov    %rsi,%rdi
mov    %rax,%rdx
mov    %rbx,%r8
mov    %r11,%r9
mov    %r15,(%rsp)
mov    %rax,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1030 <dgemm_@plt>
movsd  0xdca(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x70(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    129e <ComputeFeatureMatrix+0x16e>
mov    0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <cos@plt>
mulsd  -0x70(%rbp),%xmm0
mov    0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    125a <ComputeFeatureMatrix+0x12a>
add    $0x98,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<ComputeFeatureMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,0x20(%rsp)
mov    %rcx,0x28(%rsp)
mov    %edi,0xc(%rsp)
mov    %esi,0x1c(%rsp)
mov    %edx,0x8(%rsp)
test   %edi,%edi
jle    126b <ComputeFeatureMatrix+0x13b>
mov    %edi,%r12d
mov    %edx,%r15d
lea    -0x1(%r15),%rax
mov    %rax,0x10(%rsp)
mov    %r15d,%esi
and    $0x3,%esi
and    $0xfffffffc,%r15d
mov    %r12,%r8
shl    $0x4,%r8
mov    %r12,%r11
shl    $0x5,%r11
lea    0x0(,%r12,8),%rax
lea    (%rax,%rax,2),%rdi
xor    %r13d,%r13d
mov    0x70(%rsp),%r14
jmp    11b1 <ComputeFeatureMatrix+0x81>
nopl   0x0(%rax)
add    $0x1,%r13
add    $0x8,%r14
cmp    %r12,%r13
je     126b <ComputeFeatureMatrix+0x13b>
test   %edx,%edx
jle    11a0 <ComputeFeatureMatrix+0x70>
cmpq   $0x3,0x10(%rsp)
jae    11d0 <ComputeFeatureMatrix+0xa0>
xor    %r10d,%r10d
jmp    1220 <ComputeFeatureMatrix+0xf0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rbp
xor    %r10d,%r10d
cs nopw 0x0(%rax,%rax,1)
movsd  (%r9,%r10,8),%xmm0
movsd  %xmm0,0x0(%rbp)
movsd  0x8(%r9,%r10,8),%xmm0
movsd  %xmm0,0x0(%rbp,%r12,8)
movsd  0x10(%r9,%r10,8),%xmm0
movsd  %xmm0,0x0(%rbp,%r8,1)
movsd  0x18(%r9,%r10,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rdi,1)
add    $0x4,%r10
add    %r11,%rbp
cmp    %r10,%r15
jne    11e0 <ComputeFeatureMatrix+0xb0>
test   %rsi,%rsi
je     11a0 <ComputeFeatureMatrix+0x70>
mov    %r12,%rcx
imul   %r10,%rcx
add    %r13,%rcx
mov    0x70(%rsp),%rbx
lea    (%rbx,%rcx,8),%rbp
lea    (%r9,%r10,8),%rbx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rbx,%rcx,8),%xmm0
movsd  %xmm0,0x0(%rbp)
add    $0x1,%rcx
add    %rax,%rbp
cmp    %rcx,%rsi
jne    1250 <ComputeFeatureMatrix+0x120>
jmp    11a0 <ComputeFeatureMatrix+0x70>
movabs $0x3ff0000000000000,%rax
mov    %rax,0x30(%rsp)
movb   $0x4e,0x7(%rsp)
sub    $0x8,%rsp
lea    0x14(%rsp),%rdx
lea    0x38(%rsp),%r9
lea    0x24(%rsp),%r8
lea    0xf(%rsp),%rdi
lea    0x10(%rsp),%rcx
mov    %rdi,%rsi
push   %rdx
mov    0x80(%rsp),%rbp
push   %rbp
push   %r9
push   %r8
push   0x48(%rsp)
push   %rdx
push   0x60(%rsp)
call   1030 <dgemm_@plt>
add    $0x40,%rsp
cvtsi2sdl 0x8(%rsp),%xmm1
movsd  0xd33(%rip),%xmm0
divsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     12e4 <ComputeFeatureMatrix+0x1b4>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    12ed <ComputeFeatureMatrix+0x1bd>
call   1050 <sqrt@plt>
movapd %xmm0,%xmm1
mov    0x8(%rsp),%eax
imul   0xc(%rsp),%eax
test   %eax,%eax
jle    1342 <ComputeFeatureMatrix+0x212>
xor    %ebx,%ebx
movsd  %xmm1,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x0(%rbp,%rbx,8),%xmm0
call   1040 <cos@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x0(%rbp,%rbx,8)
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
movslq 0x8(%rsp),%rcx
imul   %rax,%rcx
cmp    %rcx,%rbx
jl     1310 <ComputeFeatureMatrix+0x1e0>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ComputeFeatureMatrix(i32 %0, i32 %1, i32 %2, double* %3, double* %4, double* %5, double* %6, double %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double
%17 = alloca i32
%18 = alloca i32
%19 = alloca double
%20 = alloca i8
%21 = alloca double
%22 = alloca double
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store double* %3, double** %12
store double* %4, double** %13
store double* %5, double** %14
store double* %6, double** %15
store double %7, double* %16
store i32 0, i32* %17
br label %23
23: ; preds = %50, %8
%24 = load i32, i32* %17
%25 = load i32, i32* %9
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %53
27: ; preds = %23
store i32 0, i32* %18
br label %28
28: ; preds = %46, %27
%29 = load i32, i32* %18
%30 = load i32, i32* %11
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %49
32: ; preds = %28
%33 = load double*, double** %14
%34 = load i32, i32* %18
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = load double, double* %36
%38 = load double*, double** %15
%39 = load i32, i32* %17
%40 = load i32, i32* %18
%41 = load i32, i32* %9
%42 = mul nsw i32 %40, %41
%43 = add nsw i32 %39, %42
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %38, i64 %44
store double %37, double* %45
br label %46
46: ; preds = %32
%47 = load i32, i32* %18
%48 = add nsw i32 %47, 1
store i32 %48, i32* %18
br label %28
49: ; preds = %28
br label %50
50: ; preds = %49
%51 = load i32, i32* %17
%52 = add nsw i32 %51, 1
store i32 %52, i32* %17
br label %23
53: ; preds = %23
store double 1.000000e+00, double* %19
store i8 78, i8* %20
%54 = load double*, double** %12
%55 = load double*, double** %13
%56 = load double*, double** %15
%57 = call i32 @dgemm_(i8* %20, i8* %20, i32* %9, i32* %11, i32* %10, double* %19, double* %54, i32* %9, double* %55, i32* %10, double* %19, double* %56, i32* %9)
store double 2.000000e+00, double* %21
%58 = load double, double* %21
%59 = load i32, i32* %11
%60 = sitofp i32 %59 to double
%61 = fdiv double %58, %60
%62 = call double @sqrt(double %61)
store double %62, double* %22
store i32 0, i32* %17
br label %63
63: ; preds = %82, %53
%64 = load i32, i32* %17
%65 = load i32, i32* %9
%66 = load i32, i32* %11
%67 = mul nsw i32 %65, %66
%68 = icmp slt i32 %64, %67
br i1 %68, label %69, label %85
69: ; preds = %63
%70 = load double*, double** %15
%71 = load i32, i32* %17
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double, double* %70, i64 %72
%74 = load double, double* %73
%75 = call double @cos(double %74)
%76 = load double, double* %22
%77 = fmul double %75, %76
%78 = load double*, double** %15
%79 = load i32, i32* %17
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %78, i64 %80
store double %77, double* %81
br label %82
82: ; preds = %69
%83 = load i32, i32* %17
%84 = add nsw i32 %83, 1
store i32 %84, i32* %17
br label %63
85: ; preds = %63
ret void
}

LLVM IR (-O2):
define void @ComputeFeatureMatrix(i32 %0, i32 %1, i32 %2, double* %3, double* %4, double* nocapture %5, double* %6, double %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca i8
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
%14 = icmp sgt i32 %0, 0
br i1 %14, label %15, label %73
15: ; preds = %8
%16 = icmp sgt i32 %2, 0
%17 = zext i32 %0 to i64
%18 = zext i32 %0 to i64
%19 = zext i32 %2 to i64
%20 = add nsw i64 %19, -1
%21 = and i64 %19, 3
%22 = icmp ult i64 %20, 3
%23 = and i64 %19, 4294967292
%24 = icmp eq i64 %21, 0
br label %25
25: ; preds = %15, %70
%26 = phi i64 [ 0, %15 ], [ %71, %70 ]
br i1 %16, label %27, label %70
27: ; preds = %25
br i1 %22, label %57, label %28
28: ; preds = %27, %28
%29 = phi i64 [ %54, %28 ], [ 0, %27 ]
%30 = phi i64 [ %55, %28 ], [ 0, %27 ]
%31 = getelementptr inbounds double, double* %5, i64 %29
%32 = load double, double* %31
%33 = mul nsw i64 %29, %17
%34 = add nuw nsw i64 %33, %26
%35 = getelementptr inbounds double, double* %6, i64 %34
store double %32, double* %35
%36 = or i64 %29, 1
%37 = getelementptr inbounds double, double* %5, i64 %36
%38 = load double, double* %37
%39 = mul nsw i64 %36, %17
%40 = add nuw nsw i64 %39, %26
%41 = getelementptr inbounds double, double* %6, i64 %40
store double %38, double* %41
%42 = or i64 %29, 2
%43 = getelementptr inbounds double, double* %5, i64 %42
%44 = load double, double* %43
%45 = mul nsw i64 %42, %17
%46 = add nuw nsw i64 %45, %26
%47 = getelementptr inbounds double, double* %6, i64 %46
store double %44, double* %47
%48 = or i64 %29, 3
%49 = getelementptr inbounds double, double* %5, i64 %48
%50 = load double, double* %49
%51 = mul nsw i64 %48, %17
%52 = add nuw nsw i64 %51, %26
%53 = getelementptr inbounds double, double* %6, i64 %52
store double %50, double* %53
%54 = add nuw nsw i64 %29, 4
%55 = add i64 %30, 4
%56 = icmp eq i64 %55, %23
br i1 %56, label %57, label %28
57: ; preds = %28, %27
%58 = phi i64 [ 0, %27 ], [ %54, %28 ]
br i1 %24, label %70, label %59
59: ; preds = %57, %59
%60 = phi i64 [ %67, %59 ], [ %58, %57 ]
%61 = phi i64 [ %68, %59 ], [ 0, %57 ]
%62 = getelementptr inbounds double, double* %5, i64 %60
%63 = load double, double* %62
%64 = mul nsw i64 %60, %17
%65 = add nuw nsw i64 %64, %26
%66 = getelementptr inbounds double, double* %6, i64 %65
store double %63, double* %66
%67 = add nuw nsw i64 %60, 1
%68 = add i64 %61, 1
%69 = icmp eq i64 %68, %21
br i1 %69, label %70, label %59
70: ; preds = %57, %59, %25
%71 = add nuw nsw i64 %26, 1
%72 = icmp eq i64 %71, %18
br i1 %72, label %73, label %25
73: ; preds = %70, %8
%74 = bitcast double* %12 to i8*
store double 1.000000e+00, double* %12
store i8 78, i8* %13
%75 = call i32 @dgemm_(i8* %13, i8* %13, i32* %9, i32* %11, i32* %10, double* %12, double* %3, i32* %9, double* %4, i32* %10, double* %12, double* %6, i32* %9)
%76 = load i32, i32* %11
%77 = sitofp i32 %76 to double
%78 = fdiv double 2.000000e+00, %77
%79 = call double @sqrt(double %78)
%80 = load i32, i32* %9
%81 = load i32, i32* %11
%82 = mul nsw i32 %81, %80
%83 = icmp sgt i32 %82, 0
br i1 %83, label %84, label %96
84: ; preds = %73, %84
%85 = phi i64 [ %90, %84 ], [ 0, %73 ]
%86 = getelementptr inbounds double, double* %6, i64 %85
%87 = load double, double* %86
%88 = call double @cos(double %87)
%89 = fmul double %79, %88
store double %89, double* %86
%90 = add nuw nsw i64 %85, 1
%91 = load i32, i32* %9
%92 = load i32, i32* %11
%93 = mul nsw i32 %92, %91
%94 = sext i32 %93 to i64
%95 = icmp slt i64 %90, %94
br i1 %95, label %84, label %96
96: ; preds = %84, %73
ret void
}