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


x86 assembly (clang, -O0):
<test_TransToRp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <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    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1050 <memset@plt>
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0x80(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
call   1030 <TransToRp@plt>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xf4(%rbp)
cmpl   $0x3,-0xf4(%rbp)
jge    125d <test_TransToRp+0x12d>
movslq -0xf4(%rbp),%rcx
lea    -0xd0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
movslq -0xf4(%rbp),%rcx
lea    -0xd0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm1
movslq -0xf4(%rbp),%rcx
lea    -0xd0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm2
lea    0xdda(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    11e1 <test_TransToRp+0xb1>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0xf0(%rbp),%xmm0
ff
movsd  -0xe8(%rbp),%xmm1
ff
movsd  -0xe0(%rbp),%xmm2
ff
lea    0xd92(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_TransToRp>:
push   %rbx
sub    $0xf0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x70(%rsp)
movabs $0xbff0000000000000,%rcx
mov    %rcx,0xa0(%rsp)
mov    %rax,0xb8(%rsp)
movabs $0x4008000000000000,%rcx
mov    %rcx,0xc8(%rsp)
mov    %rax,0xe8(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x60(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x70(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    %rsp,%rdx
call   1030 <TransToRp@plt>
lea    0xe0f(%rip),%rdi
call   1040 <puts@plt>
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
lea    0xde4(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%al
call   1050 <printf@plt>
movsd  0x38(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
movsd  0x48(%rsp),%xmm2
mov    %rbx,%rdi
mov    $0x3,%al
call   1050 <printf@plt>
movsd  0x50(%rsp),%xmm0
movsd  0x58(%rsp),%xmm1
movsd  0x60(%rsp),%xmm2
mov    %rbx,%rdi
mov    $0x3,%al
call   1050 <printf@plt>
lea    0xdab(%rip),%rdi
call   1040 <puts@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
mov    %rbx,%rdi
mov    $0x3,%al
call   1050 <printf@plt>
add    $0xf0,%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 = [4 x i8] c"p:\0A\00"
define void @test_TransToRp() {
%1 = alloca [4 x [4 x double]]
%2 = alloca [3 x [3 x double]]
%3 = alloca [3 x double]
%4 = alloca i32
%5 = bitcast [4 x [4 x double]]* %1 to i8*
%6 = bitcast i8* %5 to [4 x [4 x double]]*
%7 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %6, i32 0, i32 0
%8 = getelementptr inbounds [4 x double], [4 x double]* %7, i32 0, i32 0
store double 1.000000e+00, double* %8
%9 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %6, i32 0, i32 1
%10 = getelementptr inbounds [4 x double], [4 x double]* %9, i32 0, i32 2
store double -1.000000e+00, double* %10
%11 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %6, i32 0, i32 2
%12 = getelementptr inbounds [4 x double], [4 x double]* %11, i32 0, i32 1
store double 1.000000e+00, double* %12
%13 = getelementptr inbounds [4 x double], [4 x double]* %11, i32 0, i32 3
store double 3.000000e+00, double* %13
%14 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %6, i32 0, i32 3
%15 = getelementptr inbounds [4 x double], [4 x double]* %14, i32 0, i32 3
store double 1.000000e+00, double* %15
%16 = bitcast [3 x [3 x double]]* %2 to i8*
%17 = bitcast [3 x double]* %3 to i8*
%18 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %1, i64 0, i64 0
%19 = bitcast [4 x double]* %18 to double**
%20 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 0
%21 = bitcast [3 x double]* %20 to double**
%22 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%23 = call i32 @TransToRp(double** %19, double** %21, double* %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %25
25: ; preds = %45, %0
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 3
br i1 %27, label %28, label %48
28: ; preds = %25
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 %30
%32 = getelementptr inbounds [3 x double], [3 x double]* %31, i64 0, i64 0
%33 = load double, double* %32
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 %35
%37 = getelementptr inbounds [3 x double], [3 x double]* %36, i64 0, i64 1
%38 = load double, double* %37
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 %40
%42 = getelementptr inbounds [3 x double], [3 x double]* %41, i64 0, i64 2
%43 = load double, double* %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %33, double %38, double %43)
br label %45
45: ; preds = %28
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %25
48: ; preds = %25
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%50 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%51 = load double, double* %50
%52 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%53 = load double, double* %52
%54 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
%55 = load double, double* %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %51, double %53, double %55)
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 = [3 x i8] c"p:\00"
define void @test_TransToRp() {
%1 = alloca [4 x [4 x double]]
%2 = alloca [3 x [3 x double]]
%3 = alloca [3 x double]
%4 = bitcast [4 x [4 x double]]* %1 to i8*
%5 = 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* %5
%6 = 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* %6
%7 = 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* %7
%8 = 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* %8
%9 = 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* %9
%10 = bitcast [3 x [3 x double]]* %2 to i8*
%11 = bitcast [3 x double]* %3 to i8*
%12 = bitcast [4 x [4 x double]]* %1 to double**
%13 = bitcast [3 x [3 x double]]* %2 to double**
%14 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%15 = call i32 @TransToRp(double** %12, double** %13, double* %14)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%17 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 0, i64 0
%18 = load double, double* %17
%19 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 0, i64 1
%20 = load double, double* %19
%21 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 0, i64 2
%22 = load double, double* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %18, double %20, double %22)
%24 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 1, i64 0
%25 = load double, double* %24
%26 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 1, i64 1
%27 = load double, double* %26
%28 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 1, 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 %25, double %27, double %29)
%31 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 2, i64 0
%32 = load double, double* %31
%33 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 2, i64 1
%34 = load double, double* %33
%35 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %2, i64 0, i64 2, i64 2
%36 = load double, double* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %32, double %34, double %36)
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.3, i64 0, i64 0))
%39 = load double, double* %14
%40 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%41 = load double, double* %40
%42 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
%43 = load double, double* %42
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %39, double %41, double %43)
ret void
}