#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 */
int /*<<< orphan*/ del_delaunay_reduce_2D(double **, double **, int,
                                          double const);
int /*<<< orphan*/ mat_cast_matrix_3d_to_3i(int **, double **);
int /*<<< orphan*/ mat_inverse_matrix_d3(double **, double **,
                                         int /*<<< orphan*/);
int /*<<< orphan*/ mat_multiply_matrix_d3(double **, double **, double **);
int change_basis_monocli(int int_transform_mat[3][3], double conv_lattice[3][3],
                         double primitive_lattice[3][3], const double symprec) {
  double smallest_lattice[3][3], inv_lattice[3][3], transform_mat[3][3];
  if (!del_delaunay_reduce_2D(smallest_lattice, conv_lattice, 1, symprec)) {
    return 0;
  }
  mat_inverse_matrix_d3(inv_lattice, primitive_lattice, 0);
  mat_multiply_matrix_d3(transform_mat, inv_lattice, smallest_lattice);
  mat_cast_matrix_3d_to_3i(int_transform_mat, transform_mat);
  return 1;
}


x86 assembly (clang, -O0):
<change_basis_monocli>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x28(%rbp),%xmm0
mov    $0x1,%edx
call   1030 <del_delaunay_reduce_2D@plt>
cmp    $0x0,%eax
jne    1188 <change_basis_monocli+0x48>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <change_basis_monocli+0x88>
lea    -0xc0(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1040 <mat_inverse_matrix_d3@plt>
lea    -0x110(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   1060 <mat_multiply_matrix_d3@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1050 <mat_cast_matrix_3d_to_3i@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change_basis_monocli>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rdx,%r15
mov    %rdi,%r14
mov    %rsp,%rdi
mov    $0x1,%ebx
mov    $0x1,%edx
call   1030 <del_delaunay_reduce_2D@plt>
test   %eax,%eax
je     119f <change_basis_monocli+0x5f>
lea    0xa0(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1040 <mat_inverse_matrix_d3@plt>
lea    0x50(%rsp),%r15
mov    %rsp,%rdx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <mat_multiply_matrix_d3@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <mat_cast_matrix_3d_to_3i@plt>
jmp    11a1 <change_basis_monocli+0x61>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @change_basis_monocli([3 x i32]* %0, [3 x double]* %1, [3 x double]* %2, double %3) {
%5 = alloca i32
%6 = alloca [3 x i32]*
%7 = alloca [3 x double]*
%8 = alloca [3 x double]*
%9 = alloca double
%10 = alloca [3 x [3 x double]]
%11 = alloca [3 x [3 x double]]
%12 = alloca [3 x [3 x double]]
store [3 x i32]* %0, [3 x i32]** %6
store [3 x double]* %1, [3 x double]** %7
store [3 x double]* %2, [3 x double]** %8
store double %3, double* %9
%13 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %10, i64 0, i64 0
%14 = bitcast [3 x double]* %13 to double**
%15 = load [3 x double]*, [3 x double]** %7
%16 = bitcast [3 x double]* %15 to double**
%17 = load double, double* %9
%18 = call i32 @del_delaunay_reduce_2D(double** %14, double** %16, i32 1, double %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %4
store i32 0, i32* %5
br label %39
21: ; preds = %4
%22 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %11, i64 0, i64 0
%23 = bitcast [3 x double]* %22 to double**
%24 = load [3 x double]*, [3 x double]** %8
%25 = bitcast [3 x double]* %24 to double**
%26 = call i32 @mat_inverse_matrix_d3(double** %23, double** %25, i32 0)
%27 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 0
%28 = bitcast [3 x double]* %27 to double**
%29 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %11, i64 0, i64 0
%30 = bitcast [3 x double]* %29 to double**
%31 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %10, i64 0, i64 0
%32 = bitcast [3 x double]* %31 to double**
%33 = call i32 @mat_multiply_matrix_d3(double** %28, double** %30, double** %32)
%34 = load [3 x i32]*, [3 x i32]** %6
%35 = bitcast [3 x i32]* %34 to i32**
%36 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 0
%37 = bitcast [3 x double]* %36 to double**
%38 = call i32 @mat_cast_matrix_3d_to_3i(i32** %35, double** %37)
store i32 1, i32* %5
br label %39
39: ; preds = %21, %20
%40 = load i32, i32* %5
ret i32 %40
}

LLVM IR (-O2):
define i32 @change_basis_monocli([3 x i32]* %0, [3 x double]* %1, [3 x double]* %2, double %3) {
%5 = alloca [3 x [3 x double]]
%6 = alloca [3 x [3 x double]]
%7 = alloca [3 x [3 x double]]
%8 = bitcast [3 x [3 x double]]* %5 to i8*
%9 = bitcast [3 x [3 x double]]* %6 to i8*
%10 = bitcast [3 x [3 x double]]* %7 to i8*
%11 = bitcast [3 x [3 x double]]* %5 to double**
%12 = bitcast [3 x double]* %1 to double**
%13 = call i32 @del_delaunay_reduce_2D(double** %11, double** %12, i32 1, double %3)
%14 = icmp eq i32 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %4
%16 = bitcast [3 x [3 x double]]* %6 to double**
%17 = bitcast [3 x double]* %2 to double**
%18 = call i32 @mat_inverse_matrix_d3(double** %16, double** %17, i32 0)
%19 = bitcast [3 x [3 x double]]* %7 to double**
%20 = call i32 @mat_multiply_matrix_d3(double** %19, double** %16, double** %11)
%21 = bitcast [3 x i32]* %0 to i32**
%22 = call i32 @mat_cast_matrix_3d_to_3i(i32** %21, double** %19)
br label %23
23: ; preds = %4, %15
%24 = phi i32 [ 1, %15 ], [ 0, %4 ]
ret i32 %24
}