#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 */
double atan2(double const, double const);
int fabs(double);
double const sqrt(double const);
void T44_to_rpy(const double T44[4][4], double rpy_xyz[6]) {
  rpy_xyz[3] = T44[0][3];
  rpy_xyz[4] = T44[1][3];
  rpy_xyz[5] = T44[2][3];
  double p =
      atan2(T44[2][0], sqrt(T44[0][0] * T44[0][0] + T44[1][0] * T44[1][0]));
  double r, y;
  if (fabs(p - 3.141592653589793238462643383279502884196 / 2) < 1E-8) {
    r = 0;
    y = atan2(T44[1][2], T44[0][2]);
  } else if (fabs(p + 3.141592653589793238462643383279502884196 / 2) < 1E-8) {
    r = 0;
    y = atan2(-T44[1][2], -T44[0][2]);
  } else {
    y = atan2(T44[1][0], T44[0][0]);
    r = atan2(T44[2][1], T44[2][2]);
  }
  rpy_xyz[0] = r;
  rpy_xyz[1] = p;
  rpy_xyz[2] = y;
}


x86 assembly (clang, -O0):
<T44_to_rpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
movsd  0x38(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x8(%rbp),%rax
movsd  0x58(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x8(%rbp),%rax
movsd  0x40(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x20(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
call   1030 <atan2@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe36(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe19(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    121a <T44_to_rpy+0xea>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    12d5 <T44_to_rpy+0x1a5>
movsd  0xde6(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xdc8(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1299 <T44_to_rpy+0x169>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x30(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    12d0 <T44_to_rpy+0x1a0>
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x48(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x50(%rax),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    12d5 <T44_to_rpy+0x1a5>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<T44_to_rpy>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  0x18(%rdi),%xmm0
movsd  %xmm0,0x18(%rsi)
movsd  0x38(%rdi),%xmm0
movsd  %xmm0,0x20(%rsi)
movsd  0x58(%rdi),%xmm0
movsd  %xmm0,0x28(%rsi)
movsd  0x40(%rdi),%xmm2
movsd  (%rdi),%xmm0
movsd  0x20(%rdi),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1188 <T44_to_rpy+0x58>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    119d <T44_to_rpy+0x6d>
movsd  %xmm2,0x8(%rsp)
call   1050 <sqrt@plt>
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm1
movapd %xmm2,%xmm0
call   1030 <atan2@plt>
movapd %xmm0,%xmm1
movsd  0xe4e(%rip),%xmm0
movsd  %xmm1,0x8(%rsp)
addsd  %xmm1,%xmm0
call   1040 <fabs@plt>
test   %eax,%eax
jle    1207 <T44_to_rpy+0xd7>
movsd  0x8(%rsp),%xmm0
addsd  0xe35(%rip),%xmm0
call   1040 <fabs@plt>
test   %eax,%eax
jle    1213 <T44_to_rpy+0xe3>
movsd  (%rbx),%xmm1
movsd  0x20(%rbx),%xmm0
call   1030 <atan2@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x48(%rbx),%xmm0
movsd  0x50(%rbx),%xmm1
call   1030 <atan2@plt>
movsd  0x10(%rsp),%xmm2
jmp    123a <T44_to_rpy+0x10a>
movsd  0x10(%rbx),%xmm1
movsd  0x30(%rbx),%xmm0
jmp    122d <T44_to_rpy+0xfd>
movsd  0x10(%rbx),%xmm1
movsd  0x30(%rbx),%xmm0
movapd 0xdeb(%rip),%xmm2
xorpd  %xmm2,%xmm0
xorpd  %xmm2,%xmm1
call   1030 <atan2@plt>
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
movsd  %xmm0,(%r14)
movsd  %xmm1,0x8(%r14)
movsd  %xmm2,0x10(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @T44_to_rpy([4 x double]* %0, double* %1) {
%3 = alloca [4 x double]*
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
store [4 x double]* %0, [4 x double]** %3
store double* %1, double** %4
%8 = load [4 x double]*, [4 x double]** %3
%9 = getelementptr inbounds [4 x double], [4 x double]* %8, i64 0
%10 = getelementptr inbounds [4 x double], [4 x double]* %9, i64 0, i64 3
%11 = load double, double* %10
%12 = load double*, double** %4
%13 = getelementptr inbounds double, double* %12, i64 3
store double %11, double* %13
%14 = load [4 x double]*, [4 x double]** %3
%15 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 1
%16 = getelementptr inbounds [4 x double], [4 x double]* %15, i64 0, i64 3
%17 = load double, double* %16
%18 = load double*, double** %4
%19 = getelementptr inbounds double, double* %18, i64 4
store double %17, double* %19
%20 = load [4 x double]*, [4 x double]** %3
%21 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 2
%22 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 3
%23 = load double, double* %22
%24 = load double*, double** %4
%25 = getelementptr inbounds double, double* %24, i64 5
store double %23, double* %25
%26 = load [4 x double]*, [4 x double]** %3
%27 = getelementptr inbounds [4 x double], [4 x double]* %26, i64 2
%28 = getelementptr inbounds [4 x double], [4 x double]* %27, i64 0, i64 0
%29 = load double, double* %28
%30 = load [4 x double]*, [4 x double]** %3
%31 = getelementptr inbounds [4 x double], [4 x double]* %30, i64 0
%32 = getelementptr inbounds [4 x double], [4 x double]* %31, i64 0, i64 0
%33 = load double, double* %32
%34 = load [4 x double]*, [4 x double]** %3
%35 = getelementptr inbounds [4 x double], [4 x double]* %34, i64 0
%36 = getelementptr inbounds [4 x double], [4 x double]* %35, i64 0, i64 0
%37 = load double, double* %36
%38 = load [4 x double]*, [4 x double]** %3
%39 = getelementptr inbounds [4 x double], [4 x double]* %38, i64 1
%40 = getelementptr inbounds [4 x double], [4 x double]* %39, i64 0, i64 0
%41 = load double, double* %40
%42 = load [4 x double]*, [4 x double]** %3
%43 = getelementptr inbounds [4 x double], [4 x double]* %42, i64 1
%44 = getelementptr inbounds [4 x double], [4 x double]* %43, i64 0, i64 0
%45 = load double, double* %44
%46 = fmul double %41, %45
%47 = call double @llvm.fmuladd.f64(double %33, double %37, double %46)
%48 = call double @sqrt(double %47)
%49 = call double @atan2(double %29, double %48)
store double %49, double* %5
%50 = load double, double* %5
%51 = fsub double %50, 0x3FF921FB54442D18
%52 = call i32 @fabs(double %51)
%53 = sitofp i32 %52 to double
%54 = fcmp olt double %53, 1.000000e-08
br i1 %54, label %55, label %65
55: ; preds = %2
store double 0.000000e+00, double* %6
%56 = load [4 x double]*, [4 x double]** %3
%57 = getelementptr inbounds [4 x double], [4 x double]* %56, i64 1
%58 = getelementptr inbounds [4 x double], [4 x double]* %57, i64 0, i64 2
%59 = load double, double* %58
%60 = load [4 x double]*, [4 x double]** %3
%61 = getelementptr inbounds [4 x double], [4 x double]* %60, i64 0
%62 = getelementptr inbounds [4 x double], [4 x double]* %61, i64 0, i64 2
%63 = load double, double* %62
%64 = call double @atan2(double %59, double %63)
store double %64, double* %7
br label %103
65: ; preds = %2
%66 = load double, double* %5
%67 = fadd double %66, 0x3FF921FB54442D18
%68 = call i32 @fabs(double %67)
%69 = sitofp i32 %68 to double
%70 = fcmp olt double %69, 1.000000e-08
br i1 %70, label %71, label %83
71: ; preds = %65
store double 0.000000e+00, double* %6
%72 = load [4 x double]*, [4 x double]** %3
%73 = getelementptr inbounds [4 x double], [4 x double]* %72, i64 1
%74 = getelementptr inbounds [4 x double], [4 x double]* %73, i64 0, i64 2
%75 = load double, double* %74
%76 = fneg double %75
%77 = load [4 x double]*, [4 x double]** %3
%78 = getelementptr inbounds [4 x double], [4 x double]* %77, i64 0
%79 = getelementptr inbounds [4 x double], [4 x double]* %78, i64 0, i64 2
%80 = load double, double* %79
%81 = fneg double %80
%82 = call double @atan2(double %76, double %81)
store double %82, double* %7
br label %102
83: ; preds = %65
%84 = load [4 x double]*, [4 x double]** %3
%85 = getelementptr inbounds [4 x double], [4 x double]* %84, i64 1
%86 = getelementptr inbounds [4 x double], [4 x double]* %85, i64 0, i64 0
%87 = load double, double* %86
%88 = load [4 x double]*, [4 x double]** %3
%89 = getelementptr inbounds [4 x double], [4 x double]* %88, i64 0
%90 = getelementptr inbounds [4 x double], [4 x double]* %89, i64 0, i64 0
%91 = load double, double* %90
%92 = call double @atan2(double %87, double %91)
store double %92, double* %7
%93 = load [4 x double]*, [4 x double]** %3
%94 = getelementptr inbounds [4 x double], [4 x double]* %93, i64 2
%95 = getelementptr inbounds [4 x double], [4 x double]* %94, i64 0, i64 1
%96 = load double, double* %95
%97 = load [4 x double]*, [4 x double]** %3
%98 = getelementptr inbounds [4 x double], [4 x double]* %97, i64 2
%99 = getelementptr inbounds [4 x double], [4 x double]* %98, i64 0, i64 2
%100 = load double, double* %99
%101 = call double @atan2(double %96, double %100)
store double %101, double* %6
br label %102
102: ; preds = %83, %71
br label %103
103: ; preds = %102, %55
%104 = load double, double* %6
%105 = load double*, double** %4
%106 = getelementptr inbounds double, double* %105, i64 0
store double %104, double* %106
%107 = load double, double* %5
%108 = load double*, double** %4
%109 = getelementptr inbounds double, double* %108, i64 1
store double %107, double* %109
%110 = load double, double* %7
%111 = load double*, double** %4
%112 = getelementptr inbounds double, double* %111, i64 2
store double %110, double* %112
ret void
}

LLVM IR (-O2):
define void @T44_to_rpy([4 x double]* nocapture %0, double* nocapture writeonly %1) {
%3 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 3
%4 = load double, double* %3
%5 = getelementptr inbounds double, double* %1, i64 3
store double %4, double* %5
%6 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 3
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %1, i64 4
store double %7, double* %8
%9 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 3
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %1, i64 5
store double %10, double* %11
%12 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 0
%13 = load double, double* %12
%14 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 0
%15 = load double, double* %14
%16 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 0
%17 = load double, double* %16
%18 = fmul double %17, %17
%19 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %18)
%20 = tail call double @sqrt(double %19)
%21 = tail call double @atan2(double %13, double %20)
%22 = fadd double %21, 0xBFF921FB54442D18
%23 = tail call i32 @fabs(double %22)
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %31
25: ; preds = %2
%26 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 2
%27 = load double, double* %26
%28 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 2
%29 = load double, double* %28
%30 = tail call double @atan2(double %27, double %29)
br label %52
31: ; preds = %2
%32 = fadd double %21, 0x3FF921FB54442D18
%33 = tail call i32 @fabs(double %32)
%34 = icmp slt i32 %33, 1
br i1 %34, label %35, label %43
35: ; preds = %31
%36 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 2
%37 = load double, double* %36
%38 = fneg double %37
%39 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 2
%40 = load double, double* %39
%41 = fneg double %40
%42 = tail call double @atan2(double %38, double %41)
br label %52
43: ; preds = %31
%44 = load double, double* %16
%45 = load double, double* %14
%46 = tail call double @atan2(double %44, double %45)
%47 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 1
%48 = load double, double* %47
%49 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 2
%50 = load double, double* %49
%51 = tail call double @atan2(double %48, double %50)
br label %52
52: ; preds = %35, %43, %25
%53 = phi double [ 0.000000e+00, %25 ], [ 0.000000e+00, %35 ], [ %51, %43 ]
%54 = phi double [ %30, %25 ], [ %42, %35 ], [ %46, %43 ]
store double %53, double* %1
%55 = getelementptr inbounds double, double* %1, i64 1
store double %21, double* %55
%56 = getelementptr inbounds double, double* %1, i64 2
store double %54, double* %56
ret void
}