#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 get_standardized_cell(double **, double **, int *, int const, int,
                          double const, double const);
int standardize_cell(double **, double **, int *, int const, double const,
                     double const);
int standardize_primitive(double **, double **, int *, int const, double const,
                          double const);
int spgat_standardize_cell(double lattice[3][3], double position[][3],
                           int types[], const int num_atom,
                           const int to_primitive, const int no_idealize,
                           const double symprec, const double angle_tolerance) {
  if (to_primitive) {
    if (no_idealize) {
      return get_standardized_cell(lattice, position, types, num_atom, 1,
                                   symprec, angle_tolerance);
    } else {
      return standardize_primitive(lattice, position, types, num_atom, symprec,
                                   angle_tolerance);
    }
  } else {
    if (no_idealize) {
      return get_standardized_cell(lattice, position, types, num_atom, 0,
                                   symprec, angle_tolerance);
    } else {
      return standardize_cell(lattice, position, types, num_atom, symprec,
                              angle_tolerance);
    }
  }
}


x86 assembly (clang, -O0):
<spgat_standardize_cell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movsd  %xmm0,-0x38(%rbp)
movsd  %xmm1,-0x40(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     11bf <spgat_standardize_cell+0x8f>
cmpl   $0x0,-0x2c(%rbp)
je     1199 <spgat_standardize_cell+0x69>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mov    $0x1,%r8d
call   1030 <get_standardized_cell@plt>
mov    %eax,-0x4(%rbp)
jmp    1213 <spgat_standardize_cell+0xe3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
call   1050 <standardize_primitive@plt>
mov    %eax,-0x4(%rbp)
jmp    1213 <spgat_standardize_cell+0xe3>
cmpl   $0x0,-0x2c(%rbp)
je     11f2 <spgat_standardize_cell+0xc2>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
xor    %r8d,%r8d
call   1030 <get_standardized_cell@plt>
mov    %eax,-0x4(%rbp)
jmp    1213 <spgat_standardize_cell+0xe3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
call   1040 <standardize_cell@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spgat_standardize_cell>:
test   %r8d,%r8d
je     1145 <spgat_standardize_cell+0x15>
test   %r9d,%r9d
je     1152 <spgat_standardize_cell+0x22>
mov    $0x1,%r8d
jmp    1030 <get_standardized_cell@plt>
test   %r9d,%r9d
je     1157 <spgat_standardize_cell+0x27>
xor    %r8d,%r8d
jmp    1030 <get_standardized_cell@plt>
jmp    1050 <standardize_primitive@plt>
jmp    1040 <standardize_cell@plt>

LLVM IR (-O0):
define i32 @spgat_standardize_cell([3 x double]* %0, [3 x double]* %1, i32* %2, i32 %3, i32 %4, i32 %5, double %6, double %7) {
%9 = alloca i32
%10 = alloca [3 x double]*
%11 = alloca [3 x double]*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca double
store [3 x double]* %0, [3 x double]** %10
store [3 x double]* %1, [3 x double]** %11
store i32* %2, i32** %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store double %6, double* %16
store double %7, double* %17
%18 = load i32, i32* %14
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %43
20: ; preds = %8
%21 = load i32, i32* %15
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load [3 x double]*, [3 x double]** %10
%25 = bitcast [3 x double]* %24 to double**
%26 = load [3 x double]*, [3 x double]** %11
%27 = bitcast [3 x double]* %26 to double**
%28 = load i32*, i32** %12
%29 = load i32, i32* %13
%30 = load double, double* %16
%31 = load double, double* %17
%32 = call i32 @get_standardized_cell(double** %25, double** %27, i32* %28, i32 %29, i32 1, double %30, double %31)
store i32 %32, i32* %9
br label %66
33: ; preds = %20
%34 = load [3 x double]*, [3 x double]** %10
%35 = bitcast [3 x double]* %34 to double**
%36 = load [3 x double]*, [3 x double]** %11
%37 = bitcast [3 x double]* %36 to double**
%38 = load i32*, i32** %12
%39 = load i32, i32* %13
%40 = load double, double* %16
%41 = load double, double* %17
%42 = call i32 @standardize_primitive(double** %35, double** %37, i32* %38, i32 %39, double %40, double %41)
store i32 %42, i32* %9
br label %66
43: ; preds = %8
%44 = load i32, i32* %15
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %56
46: ; preds = %43
%47 = load [3 x double]*, [3 x double]** %10
%48 = bitcast [3 x double]* %47 to double**
%49 = load [3 x double]*, [3 x double]** %11
%50 = bitcast [3 x double]* %49 to double**
%51 = load i32*, i32** %12
%52 = load i32, i32* %13
%53 = load double, double* %16
%54 = load double, double* %17
%55 = call i32 @get_standardized_cell(double** %48, double** %50, i32* %51, i32 %52, i32 0, double %53, double %54)
store i32 %55, i32* %9
br label %66
56: ; preds = %43
%57 = load [3 x double]*, [3 x double]** %10
%58 = bitcast [3 x double]* %57 to double**
%59 = load [3 x double]*, [3 x double]** %11
%60 = bitcast [3 x double]* %59 to double**
%61 = load i32*, i32** %12
%62 = load i32, i32* %13
%63 = load double, double* %16
%64 = load double, double* %17
%65 = call i32 @standardize_cell(double** %58, double** %60, i32* %61, i32 %62, double %63, double %64)
store i32 %65, i32* %9
br label %66
66: ; preds = %56, %46, %33, %23
%67 = load i32, i32* %9
ret i32 %67
}

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