#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 */
typedef struct TYPE_6__ TYPE_3__;
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  int member_2;
  int /*<<< orphan*/ member_1;
  int /*<<< orphan*/ member_0;
};
struct TYPE_5__ {
  int member_1;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ member_0;
};
struct TYPE_4__ {
  int member_0;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ member_1;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int spg_get_stabilized_reciprocal_mesh(int **, int *, int *, int *, int, int,
                                       int ***, int, double **);
int spg_relocate_BZ_grid_address(int **, int *, int **, int *, double **,
                                 int *);
void test_spg_relocate_BZ_grid_address(void) {
  double rec_lattice[3][3] = {{-0.17573761, 0.17573761, 0.17573761},
                              {0.17573761, -0.17573761, 0.17573761},
                              {0.17573761, 0.17573761, -0.17573761}};
  int rotations[][3][3] = {{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}};
  int m = 40;
  int mesh[] = {m, m, m};
  int is_shift[] = {0, 0, 0};
  int bz_grid_address[(m + 1) * (m + 1) * (m + 1)][3];
  int bz_map[m * m * m * 8];
  int grid_address[m * m * m][3];
  int grid_mapping_table[m * m * m];
  double q[] = {0, 0, 0};
  int num_ir = spg_get_stabilized_reciprocal_mesh(
      grid_address, grid_mapping_table, mesh, is_shift, 1, 1, rotations, 1,
      (double(*)[3])q);
  printf(
      "*** Example of spg_relocate_BZ_grid_address of NaCl structure ***:\n");
  int num_q = spg_relocate_BZ_grid_address(
      bz_grid_address, bz_map, grid_address, mesh, rec_lattice, is_shift);
  printf("Number of k-points of NaCl Brillouin zone\n");
  printf("with Gamma-centered 40x40x40 Monkhorst-Pack mesh is %d (65861).\n",
         num_q);
}


x86 assembly (clang, -O0):
<test_spg_relocate_BZ_grid_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    0xeee(%rip),%rax
mov    %rax,-0x10(%rbp)
movaps 0xed3(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,-0x30(%rbp)
movaps 0xe9d(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
movaps 0xe82(%rip),%xmm0
movaps %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movaps %xmm0,-0x70(%rbp)
movaps %xmm0,-0x80(%rbp)
movl   $0x0,-0x60(%rbp)
movl   $0x1,-0x80(%rbp)
movl   $0x1,-0x70(%rbp)
movl   $0x1,-0x60(%rbp)
movl   $0x28,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x90(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x88(%rbp)
movl   $0x0,-0x98(%rbp)
movq   $0x0,-0xa0(%rbp)
mov    -0x84(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%eax
imul   %eax,%eax
imul   %ecx,%eax
mov    %rsp,%rcx
mov    %rcx,-0xa8(%rbp)
lea    (%rax,%rax,2),%rcx
lea    0xf(,%rcx,4),%rsi
movabs $0x1ffffffff0,%rcx
and    %rcx,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x100(%rbp)
mov    %rdx,%rsp
mov    %rax,-0xb0(%rbp)
mov    -0x84(%rbp),%edx
mov    %edx,%eax
imul   %eax,%eax
imul   %edx,%eax
shl    $0x3,%eax
mov    %rax,%rsi
shl    $0x2,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0xf0(%rbp)
mov    %rdx,%rsp
mov    %rax,-0xb8(%rbp)
mov    -0x84(%rbp),%edx
mov    %edx,%eax
imul   %eax,%eax
imul   %edx,%eax
lea    (%rax,%rax,2),%rdx
lea    0xf(,%rdx,4),%rdx
and    %rcx,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xf8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xc0(%rbp)
mov    -0x84(%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,-0x108(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xc8(%rbp)
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
mov    -0x108(%rbp),%rsi
mov    -0xf8(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    -0xa0(%rbp),%rcx
lea    -0x80(%rbp),%r10
lea    -0xe0(%rbp),%rax
mov    $0x1,%r9d
sub    $0x20,%rsp
mov    %r9d,%r8d
mov    %r10,(%rsp)
movl   $0x1,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <spg_get_stabilized_reciprocal_mesh@plt>
add    $0x20,%rsp
mov    %eax,-0xe4(%rbp)
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x100(%rbp),%rdi
mov    -0xf8(%rbp),%rdx
mov    -0xf0(%rbp),%rsi
lea    -0x90(%rbp),%rcx
lea    -0x50(%rbp),%r8
lea    -0xa0(%rbp),%r9
call   1050 <spg_relocate_BZ_grid_address@plt>
mov    %eax,-0xe8(%rbp)
lea    0xd13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xe8(%rbp),%esi
lea    0xd2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xa8(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_spg_relocate_BZ_grid_address>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3b7f78,%rsp
mov    %rsp,%r12
mov    0xee8(%rip),%rax
mov    %rax,0xb0(%rsp)
movabs $0x2800000028,%rax
mov    %rax,0x14(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe9b(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe7c(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe5d(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movl   $0x1,0x20(%rsp)
movl   $0x1,0x30(%rsp)
movl   $0x1,0x40(%rsp)
movl   $0x28,0x1c(%rsp)
movl   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
movaps %xmm0,0x50(%rsp)
movq   $0x0,0x60(%rsp)
sub    $0x8,%rsp
lea    0x58(%rsp),%rax
lea    0x28(%rsp),%r10
lea    0x3e8c8(%rsp),%rbx
lea    0xc8(%rsp),%rsi
lea    0x1c(%rsp),%r14
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
mov    $0x1,%r8d
mov    $0x1,%r9d
push   %rax
push   $0x1
push   %r10
call   1050 <spg_get_stabilized_reciprocal_mesh@plt>
add    $0x20,%rsp
lea    0xe43(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa0c0(%rsp),%rdi
lea    0x1c3f70(%rsp),%rsi
lea    0x70(%rsp),%r8
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %r15,%r9
call   1060 <spg_relocate_BZ_grid_address@plt>
mov    %eax,%ebx
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
lea    0xdc5(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rsp
add    $0x3b7f78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.test_spg_relocate_BZ_grid_address.rec_lattice = [3 x [3 x double]] [[3 x double] [double 0xBFC67E91EBD0482C, double 0x3FC67E91EBD0482C, double 0x3FC67E91EBD0482C], [3 x double] [double 0x3FC67E91EBD0482C, double 0xBFC67E91EBD0482C, double 0x3FC67E91EBD0482C], [3 x double] [double 0x3FC67E91EBD0482C, double 0x3FC67E91EBD0482C, double 0xBFC67E91EBD0482C]]
@.str = [68 x i8] c"*** Example of spg_relocate_BZ_grid_address of NaCl structure ***:\0A\00"
@.str.1 = [43 x i8] c"Number of k-points of NaCl Brillouin zone\0A\00"
@.str.2 = [65 x i8] c"with Gamma-centered 40x40x40 Monkhorst-Pack mesh is %d (65861).\0A\00"
define void @test_spg_relocate_BZ_grid_address() {
%1 = alloca [3 x [3 x double]]
%2 = alloca [1 x [3 x [3 x i32]]]
%3 = alloca i32
%4 = alloca [3 x i32]
%5 = alloca [3 x i32]
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca [3 x double]
%12 = alloca i32
%13 = alloca i32
%14 = bitcast [3 x [3 x double]]* %1 to i8*
%15 = bitcast [1 x [3 x [3 x i32]]]* %2 to i8*
%16 = bitcast i8* %15 to [1 x [3 x [3 x i32]]]*
%17 = getelementptr inbounds [1 x [3 x [3 x i32]]], [1 x [3 x [3 x i32]]]* %16, i32 0, i32 0
%18 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %17, i32 0, i32 0
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %18, i32 0, i32 0
store i32 1, i32* %19
%20 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %17, i32 0, i32 1
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %20, i32 0, i32 1
store i32 1, i32* %21
%22 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %17, i32 0, i32 2
%23 = getelementptr inbounds [3 x i32], [3 x i32]* %22, i32 0, i32 2
store i32 1, i32* %23
store i32 40, i32* %3
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%25 = load i32, i32* %3
store i32 %25, i32* %24
%26 = getelementptr inbounds i32, i32* %24, i64 1
%27 = load i32, i32* %3
store i32 %27, i32* %26
%28 = getelementptr inbounds i32, i32* %26, i64 1
%29 = load i32, i32* %3
store i32 %29, i32* %28
%30 = bitcast [3 x i32]* %5 to i8*
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
%35 = mul nsw i32 %32, %34
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
%38 = mul nsw i32 %35, %37
%39 = zext i32 %38 to i64
%40 = call i8* @llvm.stacksave()
store i8* %40, i8** %6
%41 = alloca [3 x i32], i64 %39
store i64 %39, i64* %7
%42 = load i32, i32* %3
%43 = load i32, i32* %3
%44 = mul nsw i32 %42, %43
%45 = load i32, i32* %3
%46 = mul nsw i32 %44, %45
%47 = mul nsw i32 %46, 8
%48 = zext i32 %47 to i64
%49 = alloca i32, i64 %48
store i64 %48, i64* %8
%50 = load i32, i32* %3
%51 = load i32, i32* %3
%52 = mul nsw i32 %50, %51
%53 = load i32, i32* %3
%54 = mul nsw i32 %52, %53
%55 = zext i32 %54 to i64
%56 = alloca [3 x i32], i64 %55
store i64 %55, i64* %9
%57 = load i32, i32* %3
%58 = load i32, i32* %3
%59 = mul nsw i32 %57, %58
%60 = load i32, i32* %3
%61 = mul nsw i32 %59, %60
%62 = zext i32 %61 to i64
%63 = alloca i32, i64 %62
store i64 %62, i64* %10
%64 = bitcast [3 x double]* %11 to i8*
%65 = bitcast [3 x i32]* %56 to i32**
%66 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%67 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%68 = getelementptr inbounds [1 x [3 x [3 x i32]]], [1 x [3 x [3 x i32]]]* %2, i64 0, i64 0
%69 = bitcast [3 x [3 x i32]]* %68 to i32***
%70 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%71 = bitcast double* %70 to [3 x double]*
%72 = bitcast [3 x double]* %71 to double**
%73 = call i32 @spg_get_stabilized_reciprocal_mesh(i32** %65, i32* %63, i32* %66, i32* %67, i32 1, i32 1, i32*** %69, i32 1, double** %72)
store i32 %73, i32* %12
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%75 = bitcast [3 x i32]* %41 to i32**
%76 = bitcast [3 x i32]* %56 to i32**
%77 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%78 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 0
%79 = bitcast [3 x double]* %78 to double**
%80 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%81 = call i32 @spg_relocate_BZ_grid_address(i32** %75, i32* %49, i32** %76, i32* %77, double** %79, i32* %80)
store i32 %81, i32* %13
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%83 = load i32, i32* %13
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), i32 %83)
%85 = load i8*, i8** %6
ret void
}

LLVM IR (-O2):
@__const.test_spg_relocate_BZ_grid_address.rec_lattice = [3 x [3 x double]] [[3 x double] [double 0xBFC67E91EBD0482C, double 0x3FC67E91EBD0482C, double 0x3FC67E91EBD0482C], [3 x double] [double 0x3FC67E91EBD0482C, double 0xBFC67E91EBD0482C, double 0x3FC67E91EBD0482C], [3 x double] [double 0x3FC67E91EBD0482C, double 0x3FC67E91EBD0482C, double 0xBFC67E91EBD0482C]]
@.str.2 = [65 x i8] c"with Gamma-centered 40x40x40 Monkhorst-Pack mesh is %d (65861).\0A\00"
@str = [67 x i8] c"*** Example of spg_relocate_BZ_grid_address of NaCl structure ***:\00"
@str.3 = [42 x i8] c"Number of k-points of NaCl Brillouin zone\00"
define void @test_spg_relocate_BZ_grid_address() {
%1 = alloca [3 x [3 x double]]
%2 = alloca [1 x [3 x [3 x i32]]]
%3 = alloca [3 x i32]
%4 = alloca [3 x i32]
%5 = alloca [3 x double]
%6 = bitcast [3 x [3 x double]]* %1 to i8*
%7 = bitcast [1 x [3 x [3 x i32]]]* %2 to i8*
%8 = getelementptr inbounds [1 x [3 x [3 x i32]]], [1 x [3 x [3 x i32]]]* %2, i64 0, i64 0, i64 0, i64 0
store i32 1, i32* %8
%9 = getelementptr inbounds [1 x [3 x [3 x i32]]], [1 x [3 x [3 x i32]]]* %2, i64 0, i64 0, i64 1, i64 1
store i32 1, i32* %9
%10 = getelementptr inbounds [1 x [3 x [3 x i32]]], [1 x [3 x [3 x i32]]]* %2, i64 0, i64 0, i64 2, i64 2
store i32 1, i32* %10
%11 = bitcast [3 x i32]* %3 to i8*
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
store i32 40, i32* %12
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
store i32 40, i32* %13
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
store i32 40, i32* %14
%15 = bitcast [3 x i32]* %4 to i8*
%16 = tail call i8* @llvm.stacksave()
%17 = alloca [68921 x [3 x i32]]
%18 = alloca [512000 x i32]
%19 = alloca [96000 x i32*]
%20 = alloca [64000 x i32]
%21 = getelementptr inbounds [96000 x i32*], [96000 x i32*]* %19, i64 0, i64 0
%22 = getelementptr inbounds [64000 x i32], [64000 x i32]* %20, i64 0, i64 0
%23 = getelementptr inbounds [512000 x i32], [512000 x i32]* %18, i64 0, i64 0
%24 = bitcast [3 x double]* %5 to i8*
%25 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%26 = bitcast [1 x [3 x [3 x i32]]]* %2 to i32***
%27 = bitcast [3 x double]* %5 to double**
%28 = call i32 @spg_get_stabilized_reciprocal_mesh(i32** %21, i32* %22, i32* %12, i32* %25, i32 1, i32 1, i32*** %26, i32 1, double** %27)
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str, i64 0, i64 0))
%30 = bitcast [68921 x [3 x i32]]* %17 to i32**
%31 = bitcast [3 x [3 x double]]* %1 to double**
%32 = call i32 @spg_relocate_BZ_grid_address(i32** %30, i32* %23, i32** %21, i32* %12, double** %31, i32* %25)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.3, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), i32 %32)
ret void
}