#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 *);
int 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);
  if (num_ir) {
    printf("*** 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);
    return 0;
  } else {
    return 1;
  }
}


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,-0x110(%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,-0x108(%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,-0x100(%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,-0xf8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xc8(%rbp)
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
mov    -0x100(%rbp),%rdi
mov    -0xf8(%rbp),%rsi
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)
cmpl   $0x0,-0xe4(%rbp)
je     13b7 <test_spg_relocate_BZ_grid_address+0x277>
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x110(%rbp),%rdi
mov    -0x100(%rbp),%rdx
mov    -0x108(%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    0xcfb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xe8(%rbp),%esi
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xec(%rbp)
jmp    13c8 <test_spg_relocate_BZ_grid_address+0x288>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xec(%rbp)
mov    -0xa8(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_spg_relocate_BZ_grid_address>:
push   %rbp
push   %r14
push   %rbx
sub    $0x3b7f70,%rsp
mov    %rsp,%r14
mov    0xeeb(%rip),%rax
mov    %rax,0xb0(%rsp)
movabs $0x2800000028,%rax
mov    %rax,0x14(%rsp)
movaps 0xebd(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe9e(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe7f(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe60(%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),%rbp
lea    0x3e8c8(%rsp),%rdi
lea    0xc8(%rsp),%rsi
lea    0x1c(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    $0x1,%ebx
mov    $0x1,%r8d
mov    $0x1,%r9d
push   %rax
push   $0x1
push   %rbp
call   1050 <spg_get_stabilized_reciprocal_mesh@plt>
add    $0x20,%rsp
test   %eax,%eax
je     1293 <test_spg_relocate_BZ_grid_address+0x153>
lea    0xe47(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa0c0(%rsp),%rdi
lea    0x1c3f70(%rsp),%rsi
lea    0x3e8c0(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x70(%rsp),%r8
lea    0x8(%rsp),%r9
call   1060 <spg_relocate_BZ_grid_address@plt>
mov    %eax,%ebp
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
lea    0xdc0(%rip),%rdi
xor    %ebx,%ebx
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rsp
mov    %ebx,%eax
add    $0x3b7f70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
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 = [57 x i8] c"*** 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 i32 @test_spg_relocate_BZ_grid_address() {
%1 = alloca i32
%2 = alloca [3 x [3 x double]]
%3 = alloca [1 x [3 x [3 x i32]]]
%4 = alloca i32
%5 = alloca [3 x i32]
%6 = alloca [3 x i32]
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca [3 x double]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = bitcast [3 x [3 x double]]* %2 to i8*
%17 = bitcast [1 x [3 x [3 x i32]]]* %3 to i8*
%18 = bitcast i8* %17 to [1 x [3 x [3 x i32]]]*
%19 = getelementptr inbounds [1 x [3 x [3 x i32]]], [1 x [3 x [3 x i32]]]* %18, i32 0, i32 0
%20 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %19, i32 0, i32 0
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %20, i32 0, i32 0
store i32 1, i32* %21
%22 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %19, i32 0, i32 1
%23 = getelementptr inbounds [3 x i32], [3 x i32]* %22, i32 0, i32 1
store i32 1, i32* %23
%24 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %19, i32 0, i32 2
%25 = getelementptr inbounds [3 x i32], [3 x i32]* %24, i32 0, i32 2
store i32 1, i32* %25
store i32 40, i32* %4
%26 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%27 = load i32, i32* %4
store i32 %27, i32* %26
%28 = getelementptr inbounds i32, i32* %26, i64 1
%29 = load i32, i32* %4
store i32 %29, i32* %28
%30 = getelementptr inbounds i32, i32* %28, i64 1
%31 = load i32, i32* %4
store i32 %31, i32* %30
%32 = bitcast [3 x i32]* %6 to i8*
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
%37 = mul nsw i32 %34, %36
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
%40 = mul nsw i32 %37, %39
%41 = zext i32 %40 to i64
%42 = call i8* @llvm.stacksave()
store i8* %42, i8** %7
%43 = alloca [3 x i32], i64 %41
store i64 %41, i64* %8
%44 = load i32, i32* %4
%45 = load i32, i32* %4
%46 = mul nsw i32 %44, %45
%47 = load i32, i32* %4
%48 = mul nsw i32 %46, %47
%49 = mul nsw i32 %48, 8
%50 = zext i32 %49 to i64
%51 = alloca i32, i64 %50
store i64 %50, i64* %9
%52 = load i32, i32* %4
%53 = load i32, i32* %4
%54 = mul nsw i32 %52, %53
%55 = load i32, i32* %4
%56 = mul nsw i32 %54, %55
%57 = zext i32 %56 to i64
%58 = alloca [3 x i32], i64 %57
store i64 %57, i64* %10
%59 = load i32, i32* %4
%60 = load i32, i32* %4
%61 = mul nsw i32 %59, %60
%62 = load i32, i32* %4
%63 = mul nsw i32 %61, %62
%64 = zext i32 %63 to i64
%65 = alloca i32, i64 %64
store i64 %64, i64* %11
%66 = bitcast [3 x double]* %12 to i8*
%67 = bitcast [3 x i32]* %58 to i32**
%68 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%69 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%70 = getelementptr inbounds [1 x [3 x [3 x i32]]], [1 x [3 x [3 x i32]]]* %3, i64 0, i64 0
%71 = bitcast [3 x [3 x i32]]* %70 to i32***
%72 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%73 = bitcast double* %72 to [3 x double]*
%74 = bitcast [3 x double]* %73 to double**
%75 = call i32 @spg_get_stabilized_reciprocal_mesh(i32** %67, i32* %65, i32* %68, i32* %69, i32 1, i32 1, i32*** %71, i32 1, double** %74)
store i32 %75, i32* %13
%76 = load i32, i32* %13
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %90
78: ; preds = %0
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%80 = bitcast [3 x i32]* %43 to i32**
%81 = bitcast [3 x i32]* %58 to i32**
%82 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%83 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 0
%84 = bitcast [3 x double]* %83 to double**
%85 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%86 = call i32 @spg_relocate_BZ_grid_address(i32** %80, i32* %51, i32** %81, i32* %82, double** %84, i32* %85)
store i32 %86, i32* %14
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%88 = load i32, i32* %14
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), i32 %88)
store i32 0, i32* %1
store i32 1, i32* %15
br label %91
90: ; preds = %0
store i32 1, i32* %1
store i32 1, i32* %15
br label %91
91: ; preds = %90, %78
%92 = load i8*, i8** %7
%93 = load i32, i32* %1
ret i32 %93
}

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 = [56 x i8] c"*** 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 i32 @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 = bitcast [3 x double]* %5 to i8*
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%25 = bitcast [1 x [3 x [3 x i32]]]* %2 to i32***
%26 = bitcast [3 x double]* %5 to double**
%27 = call i32 @spg_get_stabilized_reciprocal_mesh(i32** %21, i32* %22, i32* %12, i32* %24, i32 1, i32 1, i32*** %25, i32 1, double** %26)
%28 = icmp eq i32 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %0
%30 = getelementptr inbounds [512000 x i32], [512000 x i32]* %18, i64 0, i64 0
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%32 = bitcast [68921 x [3 x i32]]* %17 to i32**
%33 = bitcast [3 x [3 x double]]* %1 to double**
%34 = call i32 @spg_relocate_BZ_grid_address(i32** %32, i32* %30, i32** %21, i32* %12, double** %33, i32* %24)
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.3, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), i32 %34)
br label %37
37: ; preds = %0, %29
%38 = phi i32 [ 0, %29 ], [ 1, %0 ]
ret i32 %38
}