#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 spg_get_ir_reciprocal_mesh(int **, int *, int *, int *, int, double **,
                               double **, int *, int, int);
void test_spg_get_ir_reciprocal_mesh(void) {
  double lattice[3][3] = {{4, 0, 0}, {0, 4, 0}, {0, 0, 3}};
  double position[][3] = {
      {0, 0, 0},     {0.5, 0.5, 0.5}, {0.3, 0.3, 0},
      {0.7, 0.7, 0}, {0.2, 0.8, 0.5}, {0.8, 0.2, 0.5},
  };
  int types[] = {1, 1, 2, 2, 2, 2};
  int num_atom = 6;
  int m = 40;
  int mesh[] = {m, m, m};
  int is_shift[] = {1, 1, 1};
  int grid_address[m * m * m][3];
  int grid_mapping_table[m * m * m];
  printf(
      "*** Example of spg_get_ir_reciprocal_mesh of Rutile structure ***:\n");
  int num_ir = spg_get_ir_reciprocal_mesh(grid_address, grid_mapping_table,
                                          mesh, is_shift, 1, lattice, position,
                                          types, num_atom, 1e-5);
  printf("Number of irreducible k-points of Rutile with\n");
  printf("40x40x40 Monkhorst-Pack mesh is %d (4200).\n", num_ir);
}


x86 assembly (clang, -O0):
<test_spg_get_ir_reciprocal_mesh>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x148,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,-0x20(%rbp)
movaps %xmm0,-0x30(%rbp)
movaps %xmm0,-0x40(%rbp)
movaps %xmm0,-0x50(%rbp)
movq   $0x0,-0x10(%rbp)
movabs $0x4010000000000000,%rax
mov    %rax,-0x50(%rbp)
mov    %rax,-0x30(%rbp)
movabs $0x4008000000000000,%rax
mov    %rax,-0x10(%rbp)
lea    0xe82(%rip),%rsi
lea    -0xe0(%rbp),%rdi
mov    $0x90,%edx
call   1040 <memcpy@plt>
mov    0xf0a(%rip),%rax
mov    %rax,-0xf0(%rbp)
movaps 0xeec(%rip),%xmm0
movaps %xmm0,-0x100(%rbp)
movl   $0x6,-0x104(%rbp)
movl   $0x28,-0x108(%rbp)
mov    -0x108(%rbp),%eax
mov    %eax,-0x114(%rbp)
mov    -0x108(%rbp),%eax
mov    %eax,-0x110(%rbp)
mov    -0x108(%rbp),%eax
mov    %eax,-0x10c(%rbp)
mov    0xec7(%rip),%eax
mov    %eax,-0x118(%rbp)
mov    0xeb2(%rip),%rax
mov    %rax,-0x120(%rbp)
mov    -0x108(%rbp),%ecx
mov    %ecx,%eax
imul   %eax,%eax
imul   %ecx,%eax
mov    %rsp,%rcx
mov    %rcx,-0x128(%rbp)
lea    (%rax,%rax,2),%rcx
lea    0xf(,%rcx,4),%rdx
movabs $0x1ffffffff0,%rcx
and    %rcx,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x150(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x130(%rbp)
mov    -0x108(%rbp),%ecx
mov    %ecx,%eax
imul   %eax,%eax
imul   %ecx,%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x148(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x138(%rbp)
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x150(%rbp),%rdi
mov    -0x148(%rbp),%rsi
lea    -0x114(%rbp),%rdx
lea    -0x120(%rbp),%rcx
lea    -0x50(%rbp),%r9
lea    -0xe0(%rbp),%r11
lea    -0x100(%rbp),%r10
mov    -0x104(%rbp),%eax
mov    $0x1,%r8d
xor    %ebx,%ebx
sub    $0x20,%rsp
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
movl   $0x0,0x18(%rsp)
call   1050 <spg_get_ir_reciprocal_mesh@plt>
add    $0x20,%rsp
mov    %eax,-0x13c(%rbp)
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x13c(%rbp),%esi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x128(%rbp),%rax
mov    %rax,%rsp
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_spg_get_ir_reciprocal_mesh>:
push   %r14
push   %rbx
sub    $0xfa128,%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)
movabs $0x4008000000000000,%rax
mov    %rax,0x80(%rsp)
lea    0xe72(%rip),%rsi
lea    0x90(%rsp),%rbx
mov    $0x90,%edx
mov    %rbx,%rdi
call   1050 <memcpy@plt>
mov    %rsp,%r14
mov    0xef3(%rip),%rax
mov    %rax,0x30(%rsp)
movabs $0x2800000028,%rax
mov    %rax,0x14(%rsp)
mov    0xee9(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xed6(%rip),%rax
mov    %rax,0x8(%rsp)
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x28,0x1c(%rsp)
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0x20(%rsp),%rax
lea    0x3e920(%rsp),%rdi
lea    0x120(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x40(%rsp),%r9
mov    $0x1,%r8d
push   $0x0
push   $0x6
push   %rax
push   %rbx
call   1060 <spg_get_ir_reciprocal_mesh@plt>
add    $0x20,%rsp
mov    %eax,%ebx
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rsp
add    $0xfa128,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_spg_get_ir_reciprocal_mesh.position = [6 x [3 x double]] [[3 x double] zeroinitializer, [3 x double] [double 5.000000e-01, double 5.000000e-01, double 5.000000e-01], [3 x double] [double 3.000000e-01, double 3.000000e-01, double 0.000000e+00], [3 x double] [double 0x3FE6666666666666, double 0x3FE6666666666666, double 0.000000e+00], [3 x double] [double 2.000000e-01, double 8.000000e-01, double 5.000000e-01], [3 x double] [double 8.000000e-01, double 2.000000e-01, double 5.000000e-01]]
@__const.test_spg_get_ir_reciprocal_mesh.types = [6 x i32] [i32 1, i32 1, i32 2, i32 2, i32 2, i32 2]
@__const.test_spg_get_ir_reciprocal_mesh.is_shift = [3 x i32] [i32 1, i32 1, i32 1]
@.str = [68 x i8] c"*** Example of spg_get_ir_reciprocal_mesh of Rutile structure ***:\0A\00"
@.str.1 = [47 x i8] c"Number of irreducible k-points of Rutile with\0A\00"
@.str.2 = [44 x i8] c"40x40x40 Monkhorst-Pack mesh is %d (4200).\0A\00"
define void @test_spg_get_ir_reciprocal_mesh() {
%1 = alloca [3 x [3 x double]]
%2 = alloca [6 x [3 x double]]
%3 = alloca [6 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [3 x i32]
%7 = alloca [3 x i32]
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
%12 = bitcast [3 x [3 x double]]* %1 to i8*
%13 = bitcast i8* %12 to [3 x [3 x double]]*
%14 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %13, i32 0, i32 0
%15 = getelementptr inbounds [3 x double], [3 x double]* %14, i32 0, i32 0
store double 4.000000e+00, double* %15
%16 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %13, i32 0, i32 1
%17 = getelementptr inbounds [3 x double], [3 x double]* %16, i32 0, i32 1
store double 4.000000e+00, double* %17
%18 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %13, i32 0, i32 2
%19 = getelementptr inbounds [3 x double], [3 x double]* %18, i32 0, i32 2
store double 3.000000e+00, double* %19
%20 = bitcast [6 x [3 x double]]* %2 to i8*
%21 = bitcast [6 x i32]* %3 to i8*
store i32 6, i32* %4
store i32 40, i32* %5
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%23 = load i32, i32* %5
store i32 %23, i32* %22
%24 = getelementptr inbounds i32, i32* %22, i64 1
%25 = load i32, i32* %5
store i32 %25, i32* %24
%26 = getelementptr inbounds i32, i32* %24, i64 1
%27 = load i32, i32* %5
store i32 %27, i32* %26
%28 = bitcast [3 x i32]* %7 to i8*
%29 = load i32, i32* %5
%30 = load i32, i32* %5
%31 = mul nsw i32 %29, %30
%32 = load i32, i32* %5
%33 = mul nsw i32 %31, %32
%34 = zext i32 %33 to i64
%35 = call i8* @llvm.stacksave()
store i8* %35, i8** %8
%36 = alloca [3 x i32], i64 %34
store i64 %34, i64* %9
%37 = load i32, i32* %5
%38 = load i32, i32* %5
%39 = mul nsw i32 %37, %38
%40 = load i32, i32* %5
%41 = mul nsw i32 %39, %40
%42 = zext i32 %41 to i64
%43 = alloca i32, i64 %42
store i64 %42, i64* %10
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%45 = bitcast [3 x i32]* %36 to i32**
%46 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%47 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%48 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 0
%49 = bitcast [3 x double]* %48 to double**
%50 = getelementptr inbounds [6 x [3 x double]], [6 x [3 x double]]* %2, i64 0, i64 0
%51 = bitcast [3 x double]* %50 to double**
%52 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%53 = load i32, i32* %4
%54 = call i32 @spg_get_ir_reciprocal_mesh(i32** %45, i32* %43, i32* %46, i32* %47, i32 1, double** %49, double** %51, i32* %52, i32 %53, i32 0)
store i32 %54, i32* %11
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%56 = load i32, i32* %11
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %56)
%58 = load i8*, i8** %8
ret void
}

LLVM IR (-O2):
@__const.test_spg_get_ir_reciprocal_mesh.position = [6 x [3 x double]] [[3 x double] zeroinitializer, [3 x double] [double 5.000000e-01, double 5.000000e-01, double 5.000000e-01], [3 x double] [double 3.000000e-01, double 3.000000e-01, double 0.000000e+00], [3 x double] [double 0x3FE6666666666666, double 0x3FE6666666666666, double 0.000000e+00], [3 x double] [double 2.000000e-01, double 8.000000e-01, double 5.000000e-01], [3 x double] [double 8.000000e-01, double 2.000000e-01, double 5.000000e-01]]
@__const.test_spg_get_ir_reciprocal_mesh.types = [6 x i32] [i32 1, i32 1, i32 2, i32 2, i32 2, i32 2]
@__const.test_spg_get_ir_reciprocal_mesh.is_shift = [3 x i32] [i32 1, i32 1, i32 1]
@.str.2 = [44 x i8] c"40x40x40 Monkhorst-Pack mesh is %d (4200).\0A\00"
@str = [67 x i8] c"*** Example of spg_get_ir_reciprocal_mesh of Rutile structure ***:\00"
@str.3 = [46 x i8] c"Number of irreducible k-points of Rutile with\00"
define void @test_spg_get_ir_reciprocal_mesh() {
%1 = alloca [3 x [3 x double]]
%2 = alloca [6 x [3 x double]]
%3 = alloca [6 x i32]
%4 = alloca [3 x i32]
%5 = alloca [3 x i32]
%6 = bitcast [3 x [3 x double]]* %1 to i8*
%7 = 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* %7
%8 = 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* %8
%9 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 2, i64 2
store double 3.000000e+00, double* %9
%10 = bitcast [6 x [3 x double]]* %2 to i8*
%11 = bitcast [6 x i32]* %3 to i8*
%12 = bitcast [3 x i32]* %4 to i8*
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
store i32 40, i32* %13
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 1
store i32 40, i32* %14
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 2
store i32 40, i32* %15
%16 = bitcast [3 x i32]* %5 to i8*
%17 = tail call i8* @llvm.stacksave()
%18 = alloca [96000 x i32*]
%19 = alloca [64000 x i32]
%20 = getelementptr inbounds [96000 x i32*], [96000 x i32*]* %18, i64 0, i64 0
%21 = getelementptr inbounds [64000 x i32], [64000 x i32]* %19, i64 0, i64 0
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str, i64 0, i64 0))
%23 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%24 = bitcast [3 x [3 x double]]* %1 to double**
%25 = bitcast [6 x [3 x double]]* %2 to double**
%26 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%27 = call i32 @spg_get_ir_reciprocal_mesh(i32** %20, i32* %21, i32* %13, i32* %23, i32 1, double** %24, double** %25, i32* %26, i32 6, i32 0)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.3, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %27)
ret void
}