#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 mat_Dabs(double);
int mat_get_determinant_i3(int **);
int /*<<< orphan*/ mat_inverse_matrix_d3(double **, double **,
                                         int /*<<< orphan*/);
int /*<<< orphan*/ mat_multiply_matrix_d3(double **, double **, double **);
int /*<<< orphan*/ mat_multiply_matrix_id3(double **, int **, double **);
int /*<<< orphan*/ mat_multiply_matrix_vector_d3(double *, double **, double *);
int check_vector(const int j, const int k, const double *vectors, int rot[3][3],
                 double lattice[3][3], const int is_magnetic,
                 const double symprec) {
  int i, detR;
  double vec_j[3], vec_jp[3], diff[3];
  double inv_lat[3][3], rot_cart[3][3];
  mat_inverse_matrix_d3(inv_lat, lattice, 0);
  mat_multiply_matrix_id3(rot_cart, rot, inv_lat);
  mat_multiply_matrix_d3(rot_cart, lattice, rot_cart);
  for (i = 0; i < 3; i++) {
    vec_j[i] = vectors[j * 3 + i];
  }
  mat_multiply_matrix_vector_d3(vec_jp, rot_cart, vec_j);
  if (is_magnetic) {
    detR = mat_get_determinant_i3(rot);
    for (i = 0; i < 3; i++) {
      diff[i] = mat_Dabs(detR * vec_jp[i] - vectors[k * 3 + i]);
    }
  } else {
    for (i = 0; i < 3; i++) {
      diff[i] = mat_Dabs(vec_jp[i] - vectors[k * 3 + i]);
    }
  }
  if (diff[0] < symprec && diff[1] < symprec && diff[2] < symprec) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<check_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movsd  %xmm0,-0x38(%rbp)
lea    -0xf0(%rbp),%rdi
mov    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1040 <mat_inverse_matrix_d3@plt>
lea    -0x140(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
call   1050 <mat_multiply_matrix_id3@plt>
lea    -0x140(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x140(%rbp),%rdx
call   1080 <mat_multiply_matrix_d3@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x3,-0x3c(%rbp)
jge    1202 <check_vector+0xa2>
mov    -0x18(%rbp),%rax
imul   $0x3,-0x8(%rbp),%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x3c(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11cd <check_vector+0x6d>
lea    -0x80(%rbp),%rdi
lea    -0x140(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1030 <mat_multiply_matrix_vector_d3@plt>
cmpl   $0x0,-0x2c(%rbp)
je     12a3 <check_vector+0x143>
mov    -0x20(%rbp),%rdi
call   1060 <mat_get_determinant_i3@plt>
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x3,-0x3c(%rbp)
jge    129e <check_vector+0x13e>
cvtsi2sdl -0x40(%rbp),%xmm0
movslq -0x3c(%rbp),%rax
movsd  -0x80(%rbp,%rax,8),%xmm2
mov    -0x18(%rbp),%rax
imul   $0x3,-0xc(%rbp),%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1070 <mat_Dabs@plt>
movslq -0x3c(%rbp),%rax
movsd  %xmm0,-0xa0(%rbp,%rax,8)
ff ff
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1233 <check_vector+0xd3>
jmp    12f6 <check_vector+0x196>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x3,-0x3c(%rbp)
jge    12f1 <check_vector+0x191>
movslq -0x3c(%rbp),%rax
movsd  -0x80(%rbp,%rax,8),%xmm0
mov    -0x18(%rbp),%rax
imul   $0x3,-0xc(%rbp),%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
call   1070 <mat_Dabs@plt>
movslq -0x3c(%rbp),%rax
movsd  %xmm0,-0xa0(%rbp,%rax,8)
ff ff
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12aa <check_vector+0x14a>
jmp    12f6 <check_vector+0x196>
movsd  -0xa0(%rbp),%xmm1
ff
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1347 <check_vector+0x1e7>
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1347 <check_vector+0x1e7>
movsd  -0x90(%rbp),%xmm1
ff
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1347 <check_vector+0x1e7>
movl   $0x1,-0x4(%rbp)
jmp    134e <check_vector+0x1ee>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_vector>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf8,%rsp
movsd  %xmm0,0x38(%rsp)
mov    %r9d,0x10(%rsp)
mov    %r8,%rbp
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,0x8(%rsp)
mov    %edi,%r13d
lea    0xb0(%rsp),%r14
mov    %r14,%rdi
mov    %r8,%rsi
xor    %edx,%edx
call   1040 <mat_inverse_matrix_d3@plt>
lea    0x60(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <mat_multiply_matrix_id3@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
call   1080 <mat_multiply_matrix_d3@plt>
lea    0x0(%r13,%r13,2),%eax
cltq
movups (%rbx,%rax,8),%xmm0
movaps %xmm0,0x40(%rsp)
mov    0x10(%rbx,%rax,8),%rax
mov    %rax,0x50(%rsp)
lea    0x20(%rsp),%rdi
lea    0x40(%rsp),%rdx
mov    %r12,%rsi
call   1030 <mat_multiply_matrix_vector_d3@plt>
cmpl   $0x0,0x10(%rsp)
je     1258 <check_vector+0xf8>
mov    %r15,%rdi
call   1060 <mat_get_determinant_i3@plt>
cvtsi2sd %eax,%xmm1
movsd  %xmm1,0x18(%rsp)
mov    0x8(%rsp),%rax
lea    (%rax,%rax,2),%eax
movslq %eax,%rbp
movsd  0x20(%rsp),%xmm0
mulsd  %xmm1,%xmm0
subsd  (%rbx,%rbp,8),%xmm0
call   1070 <mat_Dabs@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
subsd  0x8(%rbx,%rbp,8),%xmm0
call   1070 <mat_Dabs@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0x30(%rsp),%xmm0
jmp    1296 <check_vector+0x136>
mov    0x8(%rsp),%rax
lea    (%rax,%rax,2),%eax
movslq %eax,%rbp
movsd  0x20(%rsp),%xmm0
subsd  (%rbx,%rbp,8),%xmm0
call   1070 <mat_Dabs@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
subsd  0x8(%rbx,%rbp,8),%xmm0
call   1070 <mat_Dabs@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x30(%rsp),%xmm0
subsd  0x10(%rbx,%rbp,8),%xmm0
call   1070 <mat_Dabs@plt>
movsd  0x38(%rsp),%xmm1
ucomisd 0x8(%rsp),%xmm1
seta   %al
ucomisd 0x10(%rsp),%xmm1
seta   %cl
and    %al,%cl
ucomisd %xmm0,%xmm1
seta   %al
and    %cl,%al
movzbl %al,%eax
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @check_vector(i32 %0, i32 %1, double* %2, [3 x i32]* %3, [3 x double]* %4, i32 %5, double %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double*
%12 = alloca [3 x i32]*
%13 = alloca [3 x double]*
%14 = alloca i32
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
%18 = alloca [3 x double]
%19 = alloca [3 x double]
%20 = alloca [3 x double]
%21 = alloca [3 x [3 x double]]
%22 = alloca [3 x [3 x double]]
store i32 %0, i32* %9
store i32 %1, i32* %10
store double* %2, double** %11
store [3 x i32]* %3, [3 x i32]** %12
store [3 x double]* %4, [3 x double]** %13
store i32 %5, i32* %14
store double %6, double* %15
%23 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %21, i64 0, i64 0
%24 = bitcast [3 x double]* %23 to double**
%25 = load [3 x double]*, [3 x double]** %13
%26 = bitcast [3 x double]* %25 to double**
%27 = call i32 @mat_inverse_matrix_d3(double** %24, double** %26, i32 0)
%28 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %22, i64 0, i64 0
%29 = bitcast [3 x double]* %28 to double**
%30 = load [3 x i32]*, [3 x i32]** %12
%31 = bitcast [3 x i32]* %30 to i32**
%32 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %21, i64 0, i64 0
%33 = bitcast [3 x double]* %32 to double**
%34 = call i32 @mat_multiply_matrix_id3(double** %29, i32** %31, double** %33)
%35 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %22, i64 0, i64 0
%36 = bitcast [3 x double]* %35 to double**
%37 = load [3 x double]*, [3 x double]** %13
%38 = bitcast [3 x double]* %37 to double**
%39 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %22, i64 0, i64 0
%40 = bitcast [3 x double]* %39 to double**
%41 = call i32 @mat_multiply_matrix_d3(double** %36, double** %38, double** %40)
store i32 0, i32* %16
br label %42
42: ; preds = %57, %7
%43 = load i32, i32* %16
%44 = icmp slt i32 %43, 3
br i1 %44, label %45, label %60
45: ; preds = %42
%46 = load double*, double** %11
%47 = load i32, i32* %9
%48 = mul nsw i32 %47, 3
%49 = load i32, i32* %16
%50 = add nsw i32 %48, %49
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %46, i64 %51
%53 = load double, double* %52
%54 = load i32, i32* %16
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 %55
store double %53, double* %56
br label %57
57: ; preds = %45
%58 = load i32, i32* %16
%59 = add nsw i32 %58, 1
store i32 %59, i32* %16
br label %42
60: ; preds = %42
%61 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 0
%62 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %22, i64 0, i64 0
%63 = bitcast [3 x double]* %62 to double**
%64 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%65 = call i32 @mat_multiply_matrix_vector_d3(double* %61, double** %63, double* %64)
%66 = load i32, i32* %14
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %100
68: ; preds = %60
%69 = load [3 x i32]*, [3 x i32]** %12
%70 = bitcast [3 x i32]* %69 to i32**
%71 = call i32 @mat_get_determinant_i3(i32** %70)
store i32 %71, i32* %17
store i32 0, i32* %16
br label %72
72: ; preds = %96, %68
%73 = load i32, i32* %16
%74 = icmp slt i32 %73, 3
br i1 %74, label %75, label %99
75: ; preds = %72
%76 = load i32, i32* %17
%77 = sitofp i32 %76 to double
%78 = load i32, i32* %16
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 %79
%81 = load double, double* %80
%82 = load double*, double** %11
%83 = load i32, i32* %10
%84 = mul nsw i32 %83, 3
%85 = load i32, i32* %16
%86 = add nsw i32 %84, %85
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds double, double* %82, i64 %87
%89 = load double, double* %88
%90 = fneg double %89
%91 = call double @llvm.fmuladd.f64(double %77, double %81, double %90)
%92 = call double @mat_Dabs(double %91)
%93 = load i32, i32* %16
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [3 x double], [3 x double]* %20, i64 0, i64 %94
store double %92, double* %95
br label %96
96: ; preds = %75
%97 = load i32, i32* %16
%98 = add nsw i32 %97, 1
store i32 %98, i32* %16
br label %72
99: ; preds = %72
br label %126
100: ; preds = %60
store i32 0, i32* %16
br label %101
101: ; preds = %122, %100
%102 = load i32, i32* %16
%103 = icmp slt i32 %102, 3
br i1 %103, label %104, label %125
104: ; preds = %101
%105 = load i32, i32* %16
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 %106
%108 = load double, double* %107
%109 = load double*, double** %11
%110 = load i32, i32* %10
%111 = mul nsw i32 %110, 3
%112 = load i32, i32* %16
%113 = add nsw i32 %111, %112
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %109, i64 %114
%116 = load double, double* %115
%117 = fsub double %108, %116
%118 = call double @mat_Dabs(double %117)
%119 = load i32, i32* %16
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [3 x double], [3 x double]* %20, i64 0, i64 %120
store double %118, double* %121
br label %122
122: ; preds = %104
%123 = load i32, i32* %16
%124 = add nsw i32 %123, 1
store i32 %124, i32* %16
br label %101
125: ; preds = %101
br label %126
126: ; preds = %125, %99
%127 = getelementptr inbounds [3 x double], [3 x double]* %20, i64 0, i64 0
%128 = load double, double* %127
%129 = load double, double* %15
%130 = fcmp olt double %128, %129
br i1 %130, label %131, label %142
131: ; preds = %126
%132 = getelementptr inbounds [3 x double], [3 x double]* %20, i64 0, i64 1
%133 = load double, double* %132
%134 = load double, double* %15
%135 = fcmp olt double %133, %134
br i1 %135, label %136, label %142
136: ; preds = %131
%137 = getelementptr inbounds [3 x double], [3 x double]* %20, i64 0, i64 2
%138 = load double, double* %137
%139 = load double, double* %15
%140 = fcmp olt double %138, %139
br i1 %140, label %141, label %142
141: ; preds = %136
store i32 1, i32* %8
br label %143
142: ; preds = %136, %131, %126
store i32 0, i32* %8
br label %143
143: ; preds = %142, %141
%144 = load i32, i32* %8
ret i32 %144
}

LLVM IR (-O2):
define i32 @check_vector(i32 %0, i32 %1, double* nocapture %2, [3 x i32]* %3, [3 x double]* %4, i32 %5, double %6) {
%8 = alloca [3 x double]
%9 = bitcast [3 x double]* %8 to i8*
%10 = alloca [3 x double]
%11 = alloca [3 x [3 x double]]
%12 = alloca [3 x [3 x double]]
%13 = bitcast [3 x double]* %10 to i8*
%14 = bitcast [3 x [3 x double]]* %11 to i8*
%15 = bitcast [3 x [3 x double]]* %12 to i8*
%16 = bitcast [3 x [3 x double]]* %11 to double**
%17 = bitcast [3 x double]* %4 to double**
%18 = call i32 @mat_inverse_matrix_d3(double** %16, double** %17, i32 0)
%19 = bitcast [3 x [3 x double]]* %12 to double**
%20 = bitcast [3 x i32]* %3 to i32**
%21 = call i32 @mat_multiply_matrix_id3(double** %19, i32** %20, double** %16)
%22 = call i32 @mat_multiply_matrix_d3(double** %19, double** %17, double** %19)
%23 = mul nsw i32 %0, 3
%24 = sext i32 %23 to i64
%25 = getelementptr double, double* %2, i64 %24
%26 = bitcast double* %25 to i8*
%27 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%28 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%29 = call i32 @mat_multiply_matrix_vector_d3(double* %27, double** %19, double* %28)
%30 = icmp eq i32 %5, 0
br i1 %30, label %31, label %52
31: ; preds = %7
%32 = mul nsw i32 %1, 3
%33 = sext i32 %32 to i64
%34 = load double, double* %27
%35 = getelementptr inbounds double, double* %2, i64 %33
%36 = load double, double* %35
%37 = fsub double %34, %36
%38 = call double @mat_Dabs(double %37)
%39 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 1
%40 = load double, double* %39
%41 = add nsw i64 %33, 1
%42 = getelementptr inbounds double, double* %2, i64 %41
%43 = load double, double* %42
%44 = fsub double %40, %43
%45 = call double @mat_Dabs(double %44)
%46 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 2
%47 = load double, double* %46
%48 = add nsw i64 %33, 2
%49 = getelementptr inbounds double, double* %2, i64 %48
%50 = load double, double* %49
%51 = fsub double %47, %50
br label %78
52: ; preds = %7
%53 = call i32 @mat_get_determinant_i3(i32** %20)
%54 = sitofp i32 %53 to double
%55 = mul nsw i32 %1, 3
%56 = sext i32 %55 to i64
%57 = load double, double* %27
%58 = getelementptr inbounds double, double* %2, i64 %56
%59 = load double, double* %58
%60 = fneg double %59
%61 = call double @llvm.fmuladd.f64(double %54, double %57, double %60)
%62 = call double @mat_Dabs(double %61)
%63 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 1
%64 = load double, double* %63
%65 = add nsw i64 %56, 1
%66 = getelementptr inbounds double, double* %2, i64 %65
%67 = load double, double* %66
%68 = fneg double %67
%69 = call double @llvm.fmuladd.f64(double %54, double %64, double %68)
%70 = call double @mat_Dabs(double %69)
%71 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 2
%72 = load double, double* %71
%73 = add nsw i64 %56, 2
%74 = getelementptr inbounds double, double* %2, i64 %73
%75 = load double, double* %74
%76 = fneg double %75
%77 = call double @llvm.fmuladd.f64(double %54, double %72, double %76)
br label %78
78: ; preds = %52, %31
%79 = phi double [ %77, %52 ], [ %51, %31 ]
%80 = phi double [ %70, %52 ], [ %45, %31 ]
%81 = phi double [ %62, %52 ], [ %38, %31 ]
%82 = call double @mat_Dabs(double %79)
%83 = fcmp olt double %81, %6
%84 = fcmp olt double %80, %6
%85 = select i1 %83, i1 %84, i1 false
%86 = fcmp olt double %82, %6
%87 = select i1 %85, i1 %86, i1 false
%88 = zext i1 %87 to i32
ret i32 %88
}