#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*/ printf(char *);
int /*<<< orphan*/ show_cell(double **, double **, int *, int);
int spg_refine_cell(double **, double **, int *, int, double);
int test_spg_refine_cell_BCC(void) {
  double lattice[3][3] = {{0, 2, 2}, {2, 0, 2}, {2, 2, 0}};
  double position[4][3];
  int types[4];
  int num_atom_bravais, num_atom = 1;
  double symprec = 1e-5;
  position[0][0] = 0;
  position[0][1] = 0;
  position[0][2] = 0;
  types[0] = 1;
  printf("*** spg_refine_cell ***:\n");
  num_atom_bravais =
      spg_refine_cell(lattice, position, types, num_atom, symprec);
  if (num_atom_bravais == 0) {
    printf("Refine cell failed.\n");
    return 1;
  } else {
    show_cell(lattice, position, types, num_atom_bravais);
    return 0;
  }
}


x86 assembly (clang, -O0):
<test_spg_refine_cell_BCC>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1050 <memset@plt>
movsd  0xea5(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe98(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe8b(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe7e(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe71(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe64(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0xc8(%rbp)
movsd  0xe45(%rip),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movl   $0x1,-0xc0(%rbp)
lea    0xe1b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
lea    -0xc0(%rbp),%rdx
mov    -0xc8(%rbp),%ecx
movsd  -0xd0(%rbp),%xmm0
ff
call   1030 <spg_refine_cell@plt>
mov    %eax,-0xc4(%rbp)
cmpl   $0x0,-0xc4(%rbp)
jne    124a <test_spg_refine_cell_BCC+0x10a>
lea    0xdf1(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    126e <test_spg_refine_cell_BCC+0x12e>
lea    -0x50(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
lea    -0xc0(%rbp),%rdx
mov    -0xc4(%rbp),%ecx
call   1060 <show_cell@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_spg_refine_cell_BCC>:
push   %rbx
sub    $0xc0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movq   $0x0,0x50(%rsp)
movaps 0xea1(%rip),%xmm1
movups %xmm1,0x18(%rsp)
movabs $0x4000000000000000,%rax
mov    %rax,0x28(%rsp)
movups %xmm1,0x38(%rsp)
mov    %rax,0x48(%rsp)
movaps %xmm0,0x60(%rsp)
movq   $0x0,0x70(%rsp)
movl   $0x1,(%rsp)
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rdi
lea    0x60(%rsp),%rsi
mov    %rsp,%rdx
mov    $0x1,%ebx
movsd  0xe58(%rip),%xmm0
mov    $0x1,%ecx
call   1040 <spg_refine_cell@plt>
test   %eax,%eax
je     11de <test_spg_refine_cell_BCC+0xae>
lea    0x10(%rsp),%rdi
lea    0x60(%rsp),%rsi
mov    %rsp,%rdx
mov    %eax,%ecx
call   1050 <show_cell@plt>
xor    %ebx,%ebx
jmp    11ea <test_spg_refine_cell_BCC+0xba>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0xc0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"*** spg_refine_cell ***:\0A\00"
@.str.1 = [21 x i8] c"Refine cell failed.\0A\00"
define i32 @test_spg_refine_cell_BCC() {
%1 = alloca i32
%2 = alloca [3 x [3 x double]]
%3 = alloca [4 x [3 x double]]
%4 = alloca [4 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = bitcast [3 x [3 x double]]* %2 to i8*
%9 = bitcast i8* %8 to [3 x [3 x double]]*
%10 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i32 0, i32 0
%11 = getelementptr inbounds [3 x double], [3 x double]* %10, i32 0, i32 1
store double 2.000000e+00, double* %11
%12 = getelementptr inbounds [3 x double], [3 x double]* %10, i32 0, i32 2
store double 2.000000e+00, double* %12
%13 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i32 0, i32 1
%14 = getelementptr inbounds [3 x double], [3 x double]* %13, i32 0, i32 0
store double 2.000000e+00, double* %14
%15 = getelementptr inbounds [3 x double], [3 x double]* %13, i32 0, i32 2
store double 2.000000e+00, double* %15
%16 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i32 0, i32 2
%17 = getelementptr inbounds [3 x double], [3 x double]* %16, i32 0, i32 0
store double 2.000000e+00, double* %17
%18 = getelementptr inbounds [3 x double], [3 x double]* %16, i32 0, i32 1
store double 2.000000e+00, double* %18
store i32 1, i32* %6
store double 1.000000e-05, double* %7
%19 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %3, i64 0, i64 0
%20 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 0
store double 0.000000e+00, double* %20
%21 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %3, i64 0, i64 0
%22 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 0, i64 1
store double 0.000000e+00, double* %22
%23 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %3, i64 0, i64 0
%24 = getelementptr inbounds [3 x double], [3 x double]* %23, i64 0, i64 2
store double 0.000000e+00, double* %24
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
store i32 1, i32* %25
%26 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%27 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 0
%28 = bitcast [3 x double]* %27 to double**
%29 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %3, i64 0, i64 0
%30 = bitcast [3 x double]* %29 to double**
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%32 = load i32, i32* %6
%33 = load double, double* %7
%34 = call i32 @spg_refine_cell(double** %28, double** %30, i32* %31, i32 %32, double %33)
store i32 %34, i32* %5
%35 = load i32, i32* %5
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %0
%38 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %47
39: ; preds = %0
%40 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 0
%41 = bitcast [3 x double]* %40 to double**
%42 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %3, i64 0, i64 0
%43 = bitcast [3 x double]* %42 to double**
%44 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%45 = load i32, i32* %5
%46 = call i32 @show_cell(double** %41, double** %43, i32* %44, i32 %45)
store i32 0, i32* %1
br label %47
47: ; preds = %39, %37
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@str = [25 x i8] c"*** spg_refine_cell ***:\00"
@str.2 = [20 x i8] c"Refine cell failed.\00"
define i32 @test_spg_refine_cell_BCC() {
%1 = alloca [3 x [3 x double]]
%2 = alloca [4 x [3 x double]]
%3 = alloca [4 x i32]
%4 = bitcast [3 x [3 x double]]* %1 to i8*
%5 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 0, i64 1
%6 = bitcast double* %5 to <2 x double>*
store <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double>* %6
%7 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 1, i64 0
store double 2.000000e+00, double* %7
%8 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 1, i64 2
%9 = bitcast double* %8 to <2 x double>*
store <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double>* %9
%10 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 2, i64 1
store double 2.000000e+00, double* %10
%11 = bitcast [4 x [3 x double]]* %2 to i8*
%12 = bitcast [4 x i32]* %3 to i8*
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%14 = bitcast [4 x [3 x double]]* %2 to i8*
store i32 1, i32* %13
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%16 = bitcast [3 x [3 x double]]* %1 to double**
%17 = bitcast [4 x [3 x double]]* %2 to double**
%18 = call i32 @spg_refine_cell(double** %16, double** %17, i32* %13, i32 1, double 1.000000e-05)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %0
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.2, i64 0, i64 0))
br label %24
22: ; preds = %0
%23 = call i32 @show_cell(double** %16, double** %17, i32* %13, i32 %18)
br label %24
24: ; preds = %22, %20
%25 = phi i32 [ 1, %20 ], [ 0, %22 ]
ret i32 %25
}