#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__ get_Delaunay_reduction_basis(double **, double const);
int /*<<< orphan*/ get_Delaunay_shortest_vectors(double **, double const);
int /*<<< orphan*/ get_exteneded_basis(double **, double **);
double const mat_Dabs(double);
double mat_get_determinant_d3(double **);
int get_Delaunay_reduction(double red_lattice[3][3], double lattice[3][3],
                           const double symprec) {
  int i, j;
  double volume, sum;
  double basis[4][3];
  get_exteneded_basis(basis, lattice);
  sum = 0;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 3; j++) {
      sum += basis[i][j] * basis[i][j];
    }
  }
  while (1) {
    if (get_Delaunay_reduction_basis(basis, symprec)) {
      break;
    }
  }
  get_Delaunay_shortest_vectors(basis, symprec);
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      red_lattice[i][j] = basis[j][i];
    }
  }
  volume = mat_get_determinant_d3(red_lattice);
  if (mat_Dabs(volume) < symprec) {
    ;
    goto err;
  }
  if (volume < 0) {
    for (i = 0; i < 3; i++) {
      for (j = 0; j < 3; j++) {
        red_lattice[i][j] = -red_lattice[i][j];
      }
    }
  }
  return 1;
err:
  return 0;
}


x86 assembly (clang, -O0):
<get_Delaunay_reduction>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <get_exteneded_basis@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    120b <get_Delaunay_reduction+0xbb>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    11f8 <get_Delaunay_reduction+0xa8>
movslq -0x24(%rbp),%rcx
lea    -0xa0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x24(%rbp),%rcx
lea    -0xa0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1198 <get_Delaunay_reduction+0x48>
jmp    11fd <get_Delaunay_reduction+0xad>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1187 <get_Delaunay_reduction+0x37>
jmp    1210 <get_Delaunay_reduction+0xc0>
lea    -0xa0(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
call   1060 <get_Delaunay_reduction_basis@plt>
cmp    $0x0,%rax
je     1230 <get_Delaunay_reduction+0xe0>
jmp    1235 <get_Delaunay_reduction+0xe5>
jmp    1210 <get_Delaunay_reduction+0xc0>
lea    -0xa0(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
call   1040 <get_Delaunay_shortest_vectors@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    12bc <get_Delaunay_reduction+0x16c>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    12a9 <get_Delaunay_reduction+0x159>
movslq -0x28(%rbp),%rcx
lea    -0xa0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    125e <get_Delaunay_reduction+0x10e>
jmp    12ae <get_Delaunay_reduction+0x15e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    124d <get_Delaunay_reduction+0xfd>
mov    -0x10(%rbp),%rdi
call   1030 <mat_get_determinant_d3@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1070 <mat_Dabs@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12eb <get_Delaunay_reduction+0x19b>
jmp    1394 <get_Delaunay_reduction+0x244>
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1388 <get_Delaunay_reduction+0x238>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    1383 <get_Delaunay_reduction+0x233>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    1370 <get_Delaunay_reduction+0x220>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1311 <get_Delaunay_reduction+0x1c1>
jmp    1375 <get_Delaunay_reduction+0x225>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1300 <get_Delaunay_reduction+0x1b0>
jmp    1388 <get_Delaunay_reduction+0x238>
movl   $0x1,-0x4(%rbp)
jmp    139b <get_Delaunay_reduction+0x24b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_Delaunay_reduction>:
push   %r14
push   %rbx
sub    $0x78,%rsp
movsd  %xmm0,(%rsp)
mov    %rdi,%r14
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <get_exteneded_basis@plt>
nopl   0x0(%rax)
mov    %rbx,%rdi
movsd  (%rsp),%xmm0
call   1060 <get_Delaunay_reduction_basis@plt>
test   %rax,%rax
je     1170 <get_Delaunay_reduction+0x20>
lea    0x10(%rsp),%rdi
movsd  (%rsp),%xmm0
call   1040 <get_Delaunay_shortest_vectors@plt>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r14)
movsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x8(%r14)
movsd  0x40(%rsp),%xmm0
movsd  %xmm0,0x10(%r14)
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x18(%r14)
movsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x20(%r14)
movsd  0x48(%rsp),%xmm0
movsd  %xmm0,0x28(%r14)
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x30(%r14)
movsd  0x38(%rsp),%xmm0
movsd  %xmm0,0x38(%r14)
movsd  0x50(%rsp),%xmm0
movsd  %xmm0,0x40(%r14)
mov    %r14,%rdi
call   1030 <mat_get_determinant_d3@plt>
movsd  %xmm0,0x8(%rsp)
call   1070 <mat_Dabs@plt>
xor    %eax,%eax
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1283 <get_Delaunay_reduction+0x133>
mov    $0x1,%eax
xorpd  %xmm0,%xmm0
ucomisd 0x8(%rsp),%xmm0
jbe    1283 <get_Delaunay_reduction+0x133>
movapd 0xdcb(%rip),%xmm0
movupd (%r14),%xmm1
movupd 0x10(%r14),%xmm2
movupd 0x20(%r14),%xmm3
movupd 0x30(%r14),%xmm4
xorpd  %xmm0,%xmm1
movupd %xmm1,(%r14)
xorpd  %xmm0,%xmm2
movupd %xmm2,0x10(%r14)
xorpd  %xmm0,%xmm3
movupd %xmm3,0x20(%r14)
xorpd  %xmm0,%xmm4
movupd %xmm4,0x30(%r14)
movsd  0x40(%r14),%xmm1
xorpd  %xmm0,%xmm1
movlpd %xmm1,0x40(%r14)
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @get_Delaunay_reduction([3 x double]* %0, [3 x double]* %1, double %2) {
%4 = alloca [4 x [3 x double]]
%5 = bitcast [4 x [3 x double]]* %4 to i8*
%6 = bitcast [4 x [3 x double]]* %4 to double**
%7 = bitcast [3 x double]* %1 to double**
%8 = call i32 @get_exteneded_basis(double** %6, double** %7)
br label %9
9: ; preds = %3, %9
%10 = call i64 @get_Delaunay_reduction_basis(double** %6, double %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %9, label %12
12: ; preds = %9
%13 = call i32 @get_Delaunay_shortest_vectors(double** %6, double %2)
%14 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %4, i64 0, i64 0, i64 0
%15 = load double, double* %14
%16 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
store double %15, double* %16
%17 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %4, i64 0, i64 1, i64 0
%18 = load double, double* %17
%19 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 1
store double %18, double* %19
%20 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %4, i64 0, i64 2, i64 0
%21 = load double, double* %20
%22 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
store double %21, double* %22
%23 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %4, i64 0, i64 0, i64 1
%24 = load double, double* %23
%25 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
store double %24, double* %25
%26 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %4, i64 0, i64 1, i64 1
%27 = load double, double* %26
%28 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
store double %27, double* %28
%29 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %4, i64 0, i64 2, i64 1
%30 = load double, double* %29
%31 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
store double %30, double* %31
%32 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %4, i64 0, i64 0, i64 2
%33 = load double, double* %32
%34 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
store double %33, double* %34
%35 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %4, i64 0, i64 1, i64 2
%36 = load double, double* %35
%37 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
store double %36, double* %37
%38 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %4, i64 0, i64 2, i64 2
%39 = load double, double* %38
%40 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
store double %39, double* %40
%41 = bitcast [3 x double]* %0 to double**
%42 = call double @mat_get_determinant_d3(double** %41)
%43 = call double @mat_Dabs(double %42)
%44 = fcmp olt double %43, %2
br i1 %44, label %66, label %45
45: ; preds = %12
%46 = fcmp olt double %42, 0.000000e+00
br i1 %46, label %47, label %66
47: ; preds = %45
%48 = bitcast [3 x double]* %0 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = fneg <2 x double> %49
%51 = bitcast [3 x double]* %0 to <2 x double>*
store <2 x double> %50, <2 x double>* %51
%52 = bitcast double* %22 to <2 x double>*
%53 = load <2 x double>, <2 x double>* %52
%54 = fneg <2 x double> %53
%55 = bitcast double* %22 to <2 x double>*
store <2 x double> %54, <2 x double>* %55
%56 = bitcast double* %28 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = fneg <2 x double> %57
%59 = bitcast double* %28 to <2 x double>*
store <2 x double> %58, <2 x double>* %59
%60 = bitcast double* %34 to <2 x double>*
%61 = load <2 x double>, <2 x double>* %60
%62 = fneg <2 x double> %61
%63 = bitcast double* %34 to <2 x double>*
store <2 x double> %62, <2 x double>* %63
%64 = load double, double* %40
%65 = fneg double %64
store double %65, double* %40
br label %66
66: ; preds = %47, %12, %45
%67 = phi i32 [ 1, %45 ], [ 0, %12 ], [ 1, %47 ]
ret i32 %67
}