#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_find_primitive(double **, double **, int *, int, double);
int test_spg_find_primitive_BCC(void) {
  double lattice[3][3] = {{4, 0, 0}, {0, 4, 0}, {0, 0, 4}};
  double position[][3] = {{0, 0, 0}, {0.5, 0.5, 0.5}};
  int types[] = {1, 1};
  int num_atom = 2;
  int num_primitive_atom;
  double symprec = 1e-5;
  printf("*** spg_find_primitive (BCC unitcell --> primitive) ***:\n");
  num_primitive_atom =
      spg_find_primitive(lattice, position, types, num_atom, symprec);
  if (num_primitive_atom == 0) {
    printf("Primitive cell was not found.\n");
    return 1;
  } else {
    show_cell(lattice, position, types, num_primitive_atom);
    return 0;
  }
}


x86 assembly (clang, -O0):
<test_spg_find_primitive_BCC>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1050 <memset@plt>
movsd  0xead(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xea0(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe93(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
movsd  0xe6e(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe61(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe54(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    0xe58(%rip),%rax
mov    %rax,-0x88(%rbp)
movl   $0x2,-0x8c(%rbp)
movsd  0xe27(%rip),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x88(%rbp),%rdx
mov    -0x8c(%rbp),%ecx
movsd  -0x98(%rbp),%xmm0
ff
call   1030 <spg_find_primitive@plt>
mov    %eax,-0x90(%rbp)
cmpl   $0x0,-0x90(%rbp)
jne    123a <test_spg_find_primitive_BCC+0xfa>
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    125b <test_spg_find_primitive_BCC+0x11b>
lea    -0x50(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x88(%rbp),%rdx
mov    -0x90(%rbp),%ecx
call   1060 <show_cell@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_spg_find_primitive_BCC>:
sub    $0x88,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x50(%rsp)
movabs $0x4010000000000000,%rax
mov    %rax,0x40(%rsp)
mov    %rax,0x60(%rsp)
mov    %rax,0x80(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps 0xe85(%rip),%xmm0
movups %xmm0,0x28(%rsp)
movabs $0x3fe0000000000000,%rax
mov    %rax,0x38(%rsp)
movabs $0x100000001,%rax
mov    %rax,0x8(%rsp)
lea    0xe73(%rip),%rdi
call   1040 <puts@plt>
lea    0x40(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
movsd  0xe4f(%rip),%xmm0
mov    $0x2,%ecx
call   1030 <spg_find_primitive@plt>
test   %eax,%eax
je     11ef <test_spg_find_primitive_BCC+0xbf>
lea    0x40(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %eax,%ecx
call   1050 <show_cell@plt>
xor    %eax,%eax
add    $0x88,%rsp
ret
lea    0xe5b(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x88,%rsp
ret

LLVM IR (-O0):
@__const.test_spg_find_primitive_BCC.types = [2 x i32] [i32 1, i32 1]
@.str = [58 x i8] c"*** spg_find_primitive (BCC unitcell --> primitive) ***:\0A\00"
@.str.1 = [31 x i8] c"Primitive cell was not found.\0A\00"
define i32 @test_spg_find_primitive_BCC() {
%1 = alloca i32
%2 = alloca [3 x [3 x double]]
%3 = alloca [2 x [3 x double]]
%4 = alloca [2 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 0
store double 4.000000e+00, double* %11
%12 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i32 0, i32 1
%13 = getelementptr inbounds [3 x double], [3 x double]* %12, i32 0, i32 1
store double 4.000000e+00, double* %13
%14 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %9, i32 0, i32 2
%15 = getelementptr inbounds [3 x double], [3 x double]* %14, i32 0, i32 2
store double 4.000000e+00, double* %15
%16 = bitcast [2 x [3 x double]]* %3 to i8*
%17 = bitcast i8* %16 to [2 x [3 x double]]*
%18 = getelementptr inbounds [2 x [3 x double]], [2 x [3 x double]]* %17, i32 0, i32 1
%19 = getelementptr inbounds [3 x double], [3 x double]* %18, i32 0, i32 0
store double 5.000000e-01, double* %19
%20 = getelementptr inbounds [3 x double], [3 x double]* %18, i32 0, i32 1
store double 5.000000e-01, double* %20
%21 = getelementptr inbounds [3 x double], [3 x double]* %18, i32 0, i32 2
store double 5.000000e-01, double* %21
%22 = bitcast [2 x i32]* %4 to i8*
store i32 2, i32* %5
store double 1.000000e-05, double* %7
%23 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%24 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 0
%25 = bitcast [3 x double]* %24 to double**
%26 = getelementptr inbounds [2 x [3 x double]], [2 x [3 x double]]* %3, i64 0, i64 0
%27 = bitcast [3 x double]* %26 to double**
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%29 = load i32, i32* %5
%30 = load double, double* %7
%31 = call i32 @spg_find_primitive(double** %25, double** %27, i32* %28, i32 %29, double %30)
store i32 %31, i32* %6
%32 = load i32, i32* %6
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %0
%35 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %44
36: ; preds = %0
%37 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 0
%38 = bitcast [3 x double]* %37 to double**
%39 = getelementptr inbounds [2 x [3 x double]], [2 x [3 x double]]* %3, i64 0, i64 0
%40 = bitcast [3 x double]* %39 to double**
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%42 = load i32, i32* %6
%43 = call i32 @show_cell(double** %38, double** %40, i32* %41, i32 %42)
store i32 0, i32* %1
br label %44
44: ; preds = %36, %34
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
@str = [57 x i8] c"*** spg_find_primitive (BCC unitcell --> primitive) ***:\00"
@str.2 = [30 x i8] c"Primitive cell was not found.\00"
define i32 @test_spg_find_primitive_BCC() {
%1 = alloca [3 x [3 x double]]
%2 = alloca [2 x [3 x double]]
%3 = alloca i64
%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 0
store double 4.000000e+00, double* %5
%6 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 1, i64 1
store double 4.000000e+00, double* %6
%7 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 2, i64 2
store double 4.000000e+00, double* %7
%8 = bitcast [2 x [3 x double]]* %2 to i8*
%9 = getelementptr inbounds [2 x [3 x double]], [2 x [3 x double]]* %2, i64 0, i64 1, i64 0
%10 = bitcast double* %9 to <2 x double>*
store <2 x double> <double 5.000000e-01, double 5.000000e-01>, <2 x double>* %10
%11 = getelementptr inbounds [2 x [3 x double]], [2 x [3 x double]]* %2, i64 0, i64 1, i64 2
store double 5.000000e-01, double* %11
%12 = bitcast i64* %3 to i8*
store i64 4294967297, i64* %3
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
%14 = bitcast [3 x [3 x double]]* %1 to double**
%15 = bitcast [2 x [3 x double]]* %2 to double**
%16 = bitcast i64* %3 to i32*
%17 = call i32 @spg_find_primitive(double** %14, double** %15, i32* %16, i32 2, double 1.000000e-05)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %0
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.2, i64 0, i64 0))
br label %23
21: ; preds = %0
%22 = call i32 @show_cell(double** %14, double** %15, i32* %16, i32 %17)
br label %23
23: ; preds = %21, %19
%24 = phi i32 [ 1, %19 ], [ 0, %21 ]
ret i32 %24
}