#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 */
scalar_t__ cos(double);
scalar_t__ sin(double);
double sqrt(double);
void rho_k(const double x_vec[][3], int N_x, const double k_vec[][3], int N_k,
           double (*restrict rho_k)[2]) {
  int x_i, k_i;
  double rho_ki_0, rho_ki_1;
  double factor = (1.0 / sqrt((double)N_x));
  register double alpha;
#pragma omp parallel for shared(rho_k, x_vec, k_vec, factor) private(          \
    k_i, x_i, alpha, rho_ki_0, rho_ki_1)
  for (k_i = 0; k_i < N_k; k_i++) {
    rho_ki_0 = 0.0;
    rho_ki_1 = 0.0;
    for (x_i = 0; x_i < N_x; x_i++) {
      alpha = x_vec[x_i][0] * k_vec[k_i][0] + x_vec[x_i][1] * k_vec[k_i][1] +
              x_vec[x_i][2] * k_vec[k_i][2];
      rho_ki_0 += cos(alpha);
      rho_ki_1 += sin(alpha);
    }
    rho_k[k_i][0] = factor * rho_ki_0;
    rho_k[k_i][1] = factor * rho_ki_1;
  }
}


x86 assembly (clang, -O0):
<rho_k>:
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)
cvtsi2sdl -0xc(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xea1(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12b2 <rho_k+0x182>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1269 <rho_k+0x139>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1040 <cos@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1030 <sin@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1192 <rho_k+0x62>
movsd  -0x48(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movsd  %xmm0,0x8(%rax)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    116f <rho_k+0x3f>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rho_k>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %esi,0x4(%rsp)
cvtsi2sd %esi,%xmm0
mov    %r8,%r13
mov    %ecx,%r12d
mov    %rdx,0x10(%rsp)
mov    %rdi,%rbp
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     116c <rho_k+0x3c>
sqrtsd %xmm0,%xmm0
test   %r12d,%r12d
jg     117a <rho_k+0x4a>
jmp    12a2 <rho_k+0x172>
call   1050 <sqrt@plt>
test   %r12d,%r12d
jle    12a2 <rho_k+0x172>
movsd  0xe7e(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
mov    %r12d,%eax
mov    %rax,0x18(%rsp)
mov    0x4(%rsp),%eax
shl    $0x3,%rax
lea    (%rax,%rax,2),%rbx
xor    %r14d,%r14d
jmp    11f6 <rho_k+0xc6>
cs nopw 0x0(%rax,%rax,1)
nop
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm1,%xmm1
movsd  0x20(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
mulsd  %xmm0,%xmm2
mov    %r14,%rax
shl    $0x4,%rax
movsd  %xmm2,0x0(%r13,%rax,1)
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r13,%rax,1)
add    $0x1,%r14
cmp    0x18(%rsp),%r14
je     12a2 <rho_k+0x172>
cmpl   $0x0,0x4(%rsp)
jle    11b0 <rho_k+0x80>
lea    (%r14,%r14,2),%rax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%r15
xorpd  %xmm1,%xmm1
xor    %r12d,%r12d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x30(%rsp)
movsd  0x8(%rbp,%r12,1),%xmm0
mulsd  0x8(%r15),%xmm0
movsd  0x0(%rbp,%r12,1),%xmm1
mulsd  (%r15),%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rbp,%r12,1),%xmm0
mulsd  0x10(%r15),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x28(%rsp)
call   1040 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x30(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm1
add    $0x18,%r12
cmp    %r12,%rbx
jne    1220 <rho_k+0xf0>
jmp    11be <rho_k+0x8e>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @rho_k([3 x double]* nocapture %0, i32 %1, [3 x double]* nocapture %2, i32 %3, [2 x double]* noalias nocapture writeonly %4) {
%6 = sitofp i32 %1 to double
%7 = tail call double @sqrt(double %6)
%8 = fdiv double 1.000000e+00, %7
%9 = icmp sgt i32 %3, 0
br i1 %9, label %10, label %53
10: ; preds = %5
%11 = icmp sgt i32 %1, 0
%12 = zext i32 %3 to i64
%13 = zext i32 %1 to i64
br label %14
14: ; preds = %10, %44
%15 = phi i64 [ 0, %10 ], [ %51, %44 ]
br i1 %11, label %16, label %44
16: ; preds = %14
%17 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 %15, i64 0
%18 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 %15, i64 1
%19 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 %15, i64 2
br label %20
20: ; preds = %16, %20
%21 = phi i64 [ 0, %16 ], [ %42, %20 ]
%22 = phi double [ 0.000000e+00, %16 ], [ %41, %20 ]
%23 = phi double [ 0.000000e+00, %16 ], [ %38, %20 ]
%24 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %21, i64 0
%25 = load double, double* %24
%26 = load double, double* %17
%27 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %21, i64 1
%28 = load double, double* %27
%29 = load double, double* %18
%30 = fmul double %28, %29
%31 = tail call double @llvm.fmuladd.f64(double %25, double %26, double %30)
%32 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %21, i64 2
%33 = load double, double* %32
%34 = load double, double* %19
%35 = tail call double @llvm.fmuladd.f64(double %33, double %34, double %31)
%36 = tail call i64 @cos(double %35)
%37 = sitofp i64 %36 to double
%38 = fadd double %23, %37
%39 = tail call i64 @sin(double %35)
%40 = sitofp i64 %39 to double
%41 = fadd double %22, %40
%42 = add nuw nsw i64 %21, 1
%43 = icmp eq i64 %42, %13
br i1 %43, label %44, label %20
44: ; preds = %20, %14
%45 = phi double [ 0.000000e+00, %14 ], [ %38, %20 ]
%46 = phi double [ 0.000000e+00, %14 ], [ %41, %20 ]
%47 = fmul double %8, %45
%48 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 %15, i64 0
store double %47, double* %48
%49 = fmul double %8, %46
%50 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 %15, i64 1
store double %49, double* %50
%51 = add nuw nsw i64 %15, 1
%52 = icmp eq i64 %51, %12
br i1 %52, label %53, label %14
53: ; preds = %44, %5
ret void
}