#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*/ RotInv(double **, double **);
int /*<<< orphan*/ printf(char *, ...);
void test_RotInv() {
  double R[3][3] = {0, 0, 1, 1, 0, 0, 0, 1, 0};
  double InvR[3][3] = {{0}};
  RotInv(R, InvR);
  int i;
  printf("R:\n");
  for (i = 0; i < 3; i++) {
    printf("%lf %lf %lf\n", R[i][0], R[i][1], R[i][2]);
  }
  printf("InvR:\n");
  for (i = 0; i < 3; i++) {
    printf("%lf %lf %lf\n", InvR[i][0], InvR[i][1], InvR[i][2]);
  }
}


x86 assembly (clang, -O0):
<test_RotInv>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1040 <memset@plt>
movsd  0xead(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xea0(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe93(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1040 <memset@plt>
lea    -0x50(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1050 <RotInv@plt>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xa4(%rbp)
cmpl   $0x3,-0xa4(%rbp)
jge    1220 <test_RotInv+0xf0>
movslq -0xa4(%rbp),%rcx
lea    -0x50(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
movslq -0xa4(%rbp),%rcx
lea    -0x50(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm1
movslq -0xa4(%rbp),%rcx
lea    -0x50(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm2
lea    0xe03(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    11ad <test_RotInv+0x7d>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xa4(%rbp)
cmpl   $0x3,-0xa4(%rbp)
jge    12b4 <test_RotInv+0x184>
movslq -0xa4(%rbp),%rcx
lea    -0xa0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
movslq -0xa4(%rbp),%rcx
lea    -0xa0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm1
movslq -0xa4(%rbp),%rcx
lea    -0xa0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm2
lea    0xd6f(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1238 <test_RotInv+0x108>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_RotInv>:
push   %rbx
sub    $0xa0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x40(%rsp)
movaps 0xea7(%rip),%xmm1
movaps %xmm1,0x10(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x38(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movq   $0x0,0x90(%rsp)
mov    %rsp,%rdi
lea    0x50(%rsp),%rsi
call   1050 <RotInv@plt>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
lea    0xe4f(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
mov    %rbx,%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movsd  0x30(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
movsd  0x40(%rsp),%xmm2
mov    %rbx,%rdi
mov    $0x3,%al
call   1040 <printf@plt>
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
movsd  0x50(%rsp),%xmm0
movsd  0x58(%rsp),%xmm1
movsd  0x60(%rsp),%xmm2
mov    %rbx,%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movsd  0x68(%rsp),%xmm0
movsd  0x70(%rsp),%xmm1
movsd  0x78(%rsp),%xmm2
mov    %rbx,%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movsd  0x80(%rsp),%xmm0
movsd  0x88(%rsp),%xmm1
movsd  0x90(%rsp),%xmm2
mov    %rbx,%rdi
mov    $0x3,%al
call   1040 <printf@plt>
add    $0xa0,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str.1 = [13 x i8] c"%lf %lf %lf\0A\00"
@str = [3 x i8] c"R:\00"
@str.3 = [6 x i8] c"InvR:\00"
define void @test_RotInv() {
%1 = alloca [3 x [3 x double]]
%2 = alloca [3 x [3 x double]]
%3 = bitcast [3 x [3 x double]]* %1 to i8*
%4 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 0, i64 2
%5 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 1, i64 0
%6 = bitcast double* %4 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %6
%7 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 2, i64 1
store double 1.000000e+00, double* %7
%8 = bitcast [3 x [3 x double]]* %2 to i8*
%9 = bitcast [3 x [3 x double]]* %1 to double**
%10 = bitcast [3 x [3 x double]]* %2 to double**
%11 = call i32 @RotInv(double** %9, double** %10)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%13 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 0, i64 0
%14 = load double, double* %13
%15 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 0, i64 1
%16 = load double, double* %15
%17 = load double, double* %4
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %14, double %16, double %17)
%19 = load double, double* %5
%20 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 1, i64 1
%21 = load double, double* %20
%22 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 1, i64 2
%23 = load double, double* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %19, double %21, double %23)
%25 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 2, i64 0
%26 = load double, double* %25
%27 = load double, double* %7
%28 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 2, i64 2
%29 = load double, double* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %26, double %27, double %29)
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.3, i64 0, i64 0))
%32 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 0, i64 0
%33 = load double, double* %32
%34 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 0, i64 1
%35 = load double, double* %34
%36 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 0, i64 2
%37 = load double, double* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %33, double %35, double %37)
%39 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 1, i64 0
%40 = load double, double* %39
%41 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 1, i64 1
%42 = load double, double* %41
%43 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 1, i64 2
%44 = load double, double* %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %40, double %42, double %44)
%46 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 2, i64 0
%47 = load double, double* %46
%48 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 2, i64 1
%49 = load double, double* %48
%50 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 2, i64 2
%51 = load double, double* %50
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %47, double %49, double %51)
ret void
}