#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 */
size_t kgd_get_dense_grid_point_double_mesh(int *, int const *);
int /*<<< orphan*/ mat_multiply_matrix_vector_i3(int *, int **, int *);
void kpt_get_dense_grid_points_by_rotations(size_t rot_grid_points[],
                                            const int address_orig[3],
                                            int (*rot_reciprocal)[3][3],
                                            const int num_rot,
                                            const int mesh[3],
                                            const int is_shift[3]) {
  int i;
  int address_double_orig[3], address_double[3];
  for (i = 0; i < 3; i++) {
    address_double_orig[i] = address_orig[i] * 2 + is_shift[i];
  }
  for (i = 0; i < num_rot; i++) {
    mat_multiply_matrix_vector_i3(address_double, rot_reciprocal[i],
                                  address_double_orig);
    rot_grid_points[i] =
        kgd_get_dense_grid_point_double_mesh(address_double, mesh);
  }
}


x86 assembly (clang, -O0):
<kpt_get_dense_grid_points_by_rotations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    117f <kpt_get_dense_grid_points_by_rotations+0x5f>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
shl    $0x1,%ecx
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rdx
add    (%rax,%rdx,4),%ecx
movslq -0x34(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1146 <kpt_get_dense_grid_points_by_rotations+0x26>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d8 <kpt_get_dense_grid_points_by_rotations+0xb8>
lea    -0x4c(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x34(%rbp),%rax
imul   $0x24,%rax,%rax
add    %rax,%rsi
lea    -0x40(%rbp),%rdx
call   1030 <mat_multiply_matrix_vector_i3@plt>
lea    -0x4c(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <kgd_get_dense_grid_point_double_mesh@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1186 <kpt_get_dense_grid_points_by_rotations+0x66>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kpt_get_dense_grid_points_by_rotations>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    (%rsi),%eax
add    %eax,%eax
add    (%r9),%eax
mov    %eax,(%rsp)
mov    0x4(%rsi),%eax
add    %eax,%eax
add    0x4(%r9),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rsi),%eax
add    %eax,%eax
add    0x8(%r9),%eax
mov    %eax,0x8(%rsp)
test   %ecx,%ecx
jle    119a <kpt_get_dense_grid_points_by_rotations+0x7a>
mov    %r8,%r14
mov    %rdx,%rbx
mov    %rdi,%r15
mov    %ecx,%ebp
xor    %r13d,%r13d
lea    0xc(%rsp),%r12
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rsp,%rdx
call   1030 <mat_multiply_matrix_vector_i3@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <kgd_get_dense_grid_point_double_mesh@plt>
mov    %rax,(%r15,%r13,8)
add    $0x1,%r13
add    $0x24,%rbx
cmp    %r13,%rbp
jne    1170 <kpt_get_dense_grid_points_by_rotations+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @kpt_get_dense_grid_points_by_rotations(i64* %0, i32* %1, [3 x [3 x i32]]* %2, i32 %3, i32* %4, i32* %5) {
%7 = alloca i64*
%8 = alloca i32*
%9 = alloca [3 x [3 x i32]]*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca [3 x i32]
%15 = alloca [3 x i32]
store i64* %0, i64** %7
store i32* %1, i32** %8
store [3 x [3 x i32]]* %2, [3 x [3 x i32]]** %9
store i32 %3, i32* %10
store i32* %4, i32** %11
store i32* %5, i32** %12
store i32 0, i32* %13
br label %16
16: ; preds = %35, %6
%17 = load i32, i32* %13
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %38
19: ; preds = %16
%20 = load i32*, i32** %8
%21 = load i32, i32* %13
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* %23
%25 = mul nsw i32 %24, 2
%26 = load i32*, i32** %12
%27 = load i32, i32* %13
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = load i32, i32* %29
%31 = add nsw i32 %25, %30
%32 = load i32, i32* %13
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [3 x i32], [3 x i32]* %14, i64 0, i64 %33
store i32 %31, i32* %34
br label %35
35: ; preds = %19
%36 = load i32, i32* %13
%37 = add nsw i32 %36, 1
store i32 %37, i32* %13
br label %16
38: ; preds = %16
store i32 0, i32* %13
br label %39
39: ; preds = %60, %38
%40 = load i32, i32* %13
%41 = load i32, i32* %10
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %63
43: ; preds = %39
%44 = getelementptr inbounds [3 x i32], [3 x i32]* %15, i64 0, i64 0
%45 = load [3 x [3 x i32]]*, [3 x [3 x i32]]** %9
%46 = load i32, i32* %13
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %45, i64 %47
%49 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %48, i64 0, i64 0
%50 = bitcast [3 x i32]* %49 to i32**
%51 = getelementptr inbounds [3 x i32], [3 x i32]* %14, i64 0, i64 0
%52 = call i32 @mat_multiply_matrix_vector_i3(i32* %44, i32** %50, i32* %51)
%53 = getelementptr inbounds [3 x i32], [3 x i32]* %15, i64 0, i64 0
%54 = load i32*, i32** %11
%55 = call i64 @kgd_get_dense_grid_point_double_mesh(i32* %53, i32* %54)
%56 = load i64*, i64** %7
%57 = load i32, i32* %13
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i64, i64* %56, i64 %58
store i64 %55, i64* %59
br label %60
60: ; preds = %43
%61 = load i32, i32* %13
%62 = add nsw i32 %61, 1
store i32 %62, i32* %13
br label %39
63: ; preds = %39
ret void
}

LLVM IR (-O2):
define void @kpt_get_dense_grid_points_by_rotations(i64* nocapture writeonly %0, i32* nocapture %1, [3 x [3 x i32]]* %2, i32 %3, i32* %4, i32* nocapture %5) {
%7 = alloca [3 x i32]
%8 = alloca [3 x i32]
%9 = bitcast [3 x i32]* %7 to i8*
%10 = bitcast [3 x i32]* %8 to i8*
%11 = load i32, i32* %1
%12 = shl nsw i32 %11, 1
%13 = load i32, i32* %5
%14 = add nsw i32 %12, %13
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
store i32 %14, i32* %15
%16 = getelementptr inbounds i32, i32* %1, i64 1
%17 = load i32, i32* %16
%18 = shl nsw i32 %17, 1
%19 = getelementptr inbounds i32, i32* %5, i64 1
%20 = load i32, i32* %19
%21 = add nsw i32 %18, %20
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 1
store i32 %21, i32* %22
%23 = getelementptr inbounds i32, i32* %1, i64 2
%24 = load i32, i32* %23
%25 = shl nsw i32 %24, 1
%26 = getelementptr inbounds i32, i32* %5, i64 2
%27 = load i32, i32* %26
%28 = add nsw i32 %25, %27
%29 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
store i32 %28, i32* %29
%30 = icmp sgt i32 %3, 0
br i1 %30, label %31, label %43
31: ; preds = %6
%32 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%33 = zext i32 %3 to i64
br label %34
34: ; preds = %31, %34
%35 = phi i64 [ 0, %31 ], [ %41, %34 ]
%36 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 %35, i64 0
%37 = bitcast [3 x i32]* %36 to i32**
%38 = call i32 @mat_multiply_matrix_vector_i3(i32* %32, i32** %37, i32* %15)
%39 = call i64 @kgd_get_dense_grid_point_double_mesh(i32* %32, i32* %4)
%40 = getelementptr inbounds i64, i64* %0, i64 %35
store i64 %39, i64* %40
%41 = add nuw nsw i64 %35, 1
%42 = icmp eq i64 %41, %33
br i1 %42, label %43, label %34
43: ; preds = %34, %6
ret void
}