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


x86 assembly (clang, -O0):
<test_TransInv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
movsd  0xead(%rip),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xeb0(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe93(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe8e(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe79(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
lea    -0x80(%rbp),%rdi
lea    -0x100(%rbp),%rsi
call   1050 <TransInv@plt>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x104(%rbp)
cmpl   $0x4,-0x104(%rbp)
jge    124a <test_TransInv+0x11a>
movslq -0x104(%rbp),%rcx
lea    -0x100(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
movslq -0x104(%rbp),%rcx
lea    -0x100(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm1
movslq -0x104(%rbp),%rcx
lea    -0x100(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm2
movslq -0x104(%rbp),%rcx
lea    -0x100(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x18(%rax),%xmm3
lea    0xdf0(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    11b4 <test_TransInv+0x84>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_TransInv>:
push   %rbx
sub    $0x100,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x80(%rsp)
movabs $0xbff0000000000000,%rcx
mov    %rcx,0xb0(%rsp)
mov    %rax,0xc8(%rsp)
movabs $0x4008000000000000,%rcx
mov    %rcx,0xd8(%rsp)
mov    %rax,0xf8(%rsp)
lea    0x80(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <TransInv@plt>
lea    0xe39(%rip),%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
lea    0xe05(%rip),%rbx
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x38(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0x40(%rsp),%xmm0
movsd  0x48(%rsp),%xmm1
movsd  0x50(%rsp),%xmm2
movsd  0x58(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0x60(%rsp),%xmm0
movsd  0x68(%rsp),%xmm1
movsd  0x70(%rsp),%xmm2
movsd  0x78(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <printf@plt>
add    $0x100,%rsp
pop    %rbx
ret

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

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