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


x86 assembly (clang, -O0):
<test_RpToTrans>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1040 <memset@plt>
movsd  0xead(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xea8(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe93(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xe91(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
lea    -0x50(%rbp),%rdi
lea    -0x70(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
call   1050 <RpToTrans@plt>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xf4(%rbp)
cmpl   $0x4,-0xf4(%rbp)
jge    1268 <test_RpToTrans+0x138>
movslq -0xf4(%rbp),%rcx
lea    -0xf0(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
movslq -0xf4(%rbp),%rcx
lea    -0xf0(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm1
movslq -0xf4(%rbp),%rcx
lea    -0xf0(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm2
movslq -0xf4(%rbp),%rcx
lea    -0xf0(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x18(%rax),%xmm3
lea    0xddf(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    11d2 <test_RpToTrans+0xa2>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_RpToTrans>:
push   %rbx
sub    $0xf0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xb0(%rsp)
movq   $0x0,0xe0(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0xa0(%rsp)
movabs $0xbff0000000000000,%rcx
mov    %rcx,0xc8(%rsp)
mov    %rax,0xd8(%rsp)
mov    0xe76(%rip),%rax
mov    %rax,0x90(%rsp)
movaps 0xe57(%rip),%xmm1
movaps %xmm1,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xa0(%rsp),%rdi
lea    0x80(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <RpToTrans@plt>
lea    0xe32(%rip),%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
lea    0xdfe(%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    $0xf0,%rsp
pop    %rbx
ret

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

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