#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);
int 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("*** 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);
  if (num_ir) {
    printf("Number of irreducible k-points of Rutile with\n");
    printf("40x40x40 Monkhorst-Pack mesh is %d (4200).\n", num_ir);
    return 0;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<test_spg_get_ir_reciprocal_mesh>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x158,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,-0x30(%rbp)
movaps %xmm0,-0x40(%rbp)
movaps %xmm0,-0x50(%rbp)
movaps %xmm0,-0x60(%rbp)
movq   $0x0,-0x20(%rbp)
movabs $0x4010000000000000,%rax
mov    %rax,-0x60(%rbp)
mov    %rax,-0x40(%rbp)
movabs $0x4008000000000000,%rax
mov    %rax,-0x20(%rbp)
lea    0xe82(%rip),%rsi
lea    -0xf0(%rbp),%rdi
mov    $0x90,%edx
call   1040 <memcpy@plt>
mov    0xf0a(%rip),%rax
mov    %rax,-0x100(%rbp)
movaps 0xeec(%rip),%xmm0
movaps %xmm0,-0x110(%rbp)
movl   $0x6,-0x114(%rbp)
movl   $0x28,-0x118(%rbp)
mov    -0x118(%rbp),%eax
mov    %eax,-0x124(%rbp)
mov    -0x118(%rbp),%eax
mov    %eax,-0x120(%rbp)
mov    -0x118(%rbp),%eax
mov    %eax,-0x11c(%rbp)
mov    0xec7(%rip),%eax
mov    %eax,-0x128(%rbp)
mov    0xeb2(%rip),%rax
mov    %rax,-0x130(%rbp)
mov    -0x118(%rbp),%ecx
mov    %ecx,%eax
imul   %eax,%eax
imul   %ecx,%eax
mov    %rsp,%rcx
mov    %rcx,-0x138(%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,-0x160(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x140(%rbp)
mov    -0x118(%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,-0x158(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x148(%rbp)
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x160(%rbp),%rdi
mov    -0x158(%rbp),%rsi
lea    -0x124(%rbp),%rdx
lea    -0x130(%rbp),%rcx
lea    -0x60(%rbp),%r9
lea    -0xf0(%rbp),%r11
lea    -0x110(%rbp),%r10
mov    -0x114(%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,-0x14c(%rbp)
cmpl   $0x0,-0x14c(%rbp)
je     132d <test_spg_get_ir_reciprocal_mesh+0x1fd>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14c(%rbp),%esi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x150(%rbp)
jmp    133e <test_spg_get_ir_reciprocal_mesh+0x20e>
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x150(%rbp)
mov    -0x138(%rbp),%rax
mov    %rax,%rsp
mov    -0xc(%rbp),%eax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_spg_get_ir_reciprocal_mesh>:
push   %rbp
push   %r14
push   %rbx
sub    $0xfa120,%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    0xe71(%rip),%rsi
lea    0x90(%rsp),%rbx
mov    $0x90,%edx
mov    %rbx,%rdi
call   1050 <memcpy@plt>
mov    %rsp,%r14
mov    0xef2(%rip),%rax
mov    %rax,0x30(%rsp)
movabs $0x2800000028,%rax
mov    %rax,0x14(%rsp)
mov    0xee8(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xed5(%rip),%rax
mov    %rax,0x8(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x28,0x1c(%rsp)
lea    0xeed(%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
mov    $0x1,%ebp
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
test   %eax,%eax
je     125a <test_spg_get_ir_reciprocal_mesh+0x11a>
mov    %eax,%ebx
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe65(%rip),%rdi
xor    %ebp,%ebp
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rsp
mov    %ebp,%eax
add    $0xfa120,%rsp
pop    %rbx
pop    %r14
pop    %rbp
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 = [57 x i8] c"*** 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 i32 @test_spg_get_ir_reciprocal_mesh() {
%1 = alloca i32
%2 = alloca [3 x [3 x double]]
%3 = alloca [6 x [3 x double]]
%4 = alloca [6 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca [3 x i32]
%8 = alloca [3 x i32]
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = bitcast [3 x [3 x double]]* %2 to i8*
%15 = bitcast i8* %14 to [3 x [3 x double]]*
%16 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %15, i32 0, i32 0
%17 = getelementptr inbounds [3 x double], [3 x double]* %16, i32 0, i32 0
store double 4.000000e+00, double* %17
%18 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %15, i32 0, i32 1
%19 = getelementptr inbounds [3 x double], [3 x double]* %18, i32 0, i32 1
store double 4.000000e+00, double* %19
%20 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %15, i32 0, i32 2
%21 = getelementptr inbounds [3 x double], [3 x double]* %20, i32 0, i32 2
store double 3.000000e+00, double* %21
%22 = bitcast [6 x [3 x double]]* %3 to i8*
%23 = bitcast [6 x i32]* %4 to i8*
store i32 6, i32* %5
store i32 40, i32* %6
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%25 = load i32, i32* %6
store i32 %25, i32* %24
%26 = getelementptr inbounds i32, i32* %24, i64 1
%27 = load i32, i32* %6
store i32 %27, i32* %26
%28 = getelementptr inbounds i32, i32* %26, i64 1
%29 = load i32, i32* %6
store i32 %29, i32* %28
%30 = bitcast [3 x i32]* %8 to i8*
%31 = load i32, i32* %6
%32 = load i32, i32* %6
%33 = mul nsw i32 %31, %32
%34 = load i32, i32* %6
%35 = mul nsw i32 %33, %34
%36 = zext i32 %35 to i64
%37 = call i8* @llvm.stacksave()
store i8* %37, i8** %9
%38 = alloca [3 x i32], i64 %36
store i64 %36, i64* %10
%39 = load i32, i32* %6
%40 = load i32, i32* %6
%41 = mul nsw i32 %39, %40
%42 = load i32, i32* %6
%43 = mul nsw i32 %41, %42
%44 = zext i32 %43 to i64
%45 = alloca i32, i64 %44
store i64 %44, i64* %11
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%47 = bitcast [3 x i32]* %38 to i32**
%48 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%49 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%50 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 0
%51 = bitcast [3 x double]* %50 to double**
%52 = getelementptr inbounds [6 x [3 x double]], [6 x [3 x double]]* %3, i64 0, i64 0
%53 = bitcast [3 x double]* %52 to double**
%54 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%55 = load i32, i32* %5
%56 = call i32 @spg_get_ir_reciprocal_mesh(i32** %47, i32* %45, i32* %48, i32* %49, i32 1, double** %51, double** %53, i32* %54, i32 %55, i32 0)
store i32 %56, i32* %12
%57 = load i32, i32* %12
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %0
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%61 = load i32, i32* %12
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %61)
store i32 0, i32* %1
store i32 1, i32* %13
br label %64
63: ; preds = %0
store i32 1, i32* %1
store i32 1, i32* %13
br label %64
64: ; preds = %63, %59
%65 = load i8*, i8** %9
%66 = load i32, i32* %1
ret i32 %66
}

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 = [56 x i8] c"*** 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 i32 @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 ([56 x i8], [56 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 = icmp eq i32 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %0
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.3, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %32
32: ; preds = %0, %29
%33 = phi i32 [ 0, %29 ], [ 1, %0 ]
ret i32 %33
}