#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 */
float acos(float);
float atan2(float, float);
float cos(float);
int fabs(float);
float sin(float);
void mattoabg(float *r, float *abg) {
  abg[1] = acos(r[8]);
  abg[2] = atan2(r[6], -r[7]);
  abg[0] = atan2(r[2], r[5]);
  if (fabs(sin(abg[2]) * cos(abg[0]) + cos(abg[2]) * cos(abg[1]) * sin(abg[0]) -
           r[1]) > 1e-6) {
    abg[1] = -acos(r[8]);
    abg[2] = atan2(-r[6], r[7]);
    abg[0] = atan2(-r[2], -r[5]);
  }
}


x86 assembly (clang, -O0):
<mattoabg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  0x20(%rax),%xmm0
call   1040 <acos@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
movss  0x18(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  0x1c(%rax),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  0x14(%rax),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
call   1060 <sin@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
call   1070 <cos@plt>
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
call   1070 <cos@plt>
movss  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
call   1060 <sin@plt>
movss  -0x1c(%rbp),%xmm1
movss  -0x18(%rbp),%xmm2
movaps %xmm0,%xmm3
movss  -0x14(%rbp),%xmm0
mulss  %xmm3,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
subss  0x4(%rax),%xmm0
call   1050 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xda1(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12f3 <mattoabg+0x1a3>
mov    -0x8(%rbp),%rax
movss  0x20(%rax),%xmm0
call   1040 <acos@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
movss  0x18(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x8(%rbp),%rax
movss  0x1c(%rax),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x8(%rbp),%rax
movss  0x14(%rax),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mattoabg>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movss  0x20(%rdi),%xmm0
call   1040 <acos@plt>
movss  %xmm0,0x4(%r14)
movss  0x18(%rbx),%xmm0
movss  0x1c(%rbx),%xmm1
xorps  0xe82(%rip),%xmm1
call   1030 <atan2@plt>
movss  %xmm0,0x8(%r14)
movss  0x8(%rbx),%xmm0
movss  0x14(%rbx),%xmm1
call   1030 <atan2@plt>
movss  %xmm0,(%r14)
movss  0x8(%r14),%xmm0
call   1060 <sin@plt>
movss  %xmm0,0x14(%rsp)
movss  (%r14),%xmm0
call   1070 <cos@plt>
movss  %xmm0,0x10(%rsp)
movss  0x8(%r14),%xmm0
call   1070 <cos@plt>
movss  %xmm0,0xc(%rsp)
movss  0x4(%r14),%xmm0
call   1070 <cos@plt>
mulss  0xc(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  (%r14),%xmm0
call   1060 <sin@plt>
mulss  0xc(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
mulss  0x14(%rsp),%xmm1
addss  %xmm1,%xmm0
subss  0x4(%rbx),%xmm0
call   1050 <fabs@plt>
test   %eax,%eax
jle    1267 <mattoabg+0x117>
movss  0x20(%rbx),%xmm0
call   1040 <acos@plt>
movaps 0xddb(%rip),%xmm1
xorps  %xmm1,%xmm0
movss  %xmm0,0x4(%r14)
movss  0x18(%rbx),%xmm0
xorps  %xmm1,%xmm0
movss  0x1c(%rbx),%xmm1
call   1030 <atan2@plt>
movss  %xmm0,0x8(%r14)
movss  0x8(%rbx),%xmm0
movss  0x14(%rbx),%xmm1
movaps 0xda9(%rip),%xmm2
xorps  %xmm2,%xmm0
xorps  %xmm2,%xmm1
call   1030 <atan2@plt>
movss  %xmm0,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @mattoabg(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
store float* %0, float** %3
store float* %1, float** %4
%5 = load float*, float** %3
%6 = getelementptr inbounds float, float* %5, i64 8
%7 = load float, float* %6
%8 = call float @acos(float %7)
%9 = load float*, float** %4
%10 = getelementptr inbounds float, float* %9, i64 1
store float %8, float* %10
%11 = load float*, float** %3
%12 = getelementptr inbounds float, float* %11, i64 6
%13 = load float, float* %12
%14 = load float*, float** %3
%15 = getelementptr inbounds float, float* %14, i64 7
%16 = load float, float* %15
%17 = fneg float %16
%18 = call float @atan2(float %13, float %17)
%19 = load float*, float** %4
%20 = getelementptr inbounds float, float* %19, i64 2
store float %18, float* %20
%21 = load float*, float** %3
%22 = getelementptr inbounds float, float* %21, i64 2
%23 = load float, float* %22
%24 = load float*, float** %3
%25 = getelementptr inbounds float, float* %24, i64 5
%26 = load float, float* %25
%27 = call float @atan2(float %23, float %26)
%28 = load float*, float** %4
%29 = getelementptr inbounds float, float* %28, i64 0
store float %27, float* %29
%30 = load float*, float** %4
%31 = getelementptr inbounds float, float* %30, i64 2
%32 = load float, float* %31
%33 = call float @sin(float %32)
%34 = load float*, float** %4
%35 = getelementptr inbounds float, float* %34, i64 0
%36 = load float, float* %35
%37 = call float @cos(float %36)
%38 = load float*, float** %4
%39 = getelementptr inbounds float, float* %38, i64 2
%40 = load float, float* %39
%41 = call float @cos(float %40)
%42 = load float*, float** %4
%43 = getelementptr inbounds float, float* %42, i64 1
%44 = load float, float* %43
%45 = call float @cos(float %44)
%46 = fmul float %41, %45
%47 = load float*, float** %4
%48 = getelementptr inbounds float, float* %47, i64 0
%49 = load float, float* %48
%50 = call float @sin(float %49)
%51 = fmul float %46, %50
%52 = call float @llvm.fmuladd.f32(float %33, float %37, float %51)
%53 = load float*, float** %3
%54 = getelementptr inbounds float, float* %53, i64 1
%55 = load float, float* %54
%56 = fsub float %52, %55
%57 = call i32 @fabs(float %56)
%58 = sitofp i32 %57 to double
%59 = fcmp ogt double %58, 0x3EB0C6F7A0B5ED8D
br i1 %59, label %60, label %89
60: ; preds = %2
%61 = load float*, float** %3
%62 = getelementptr inbounds float, float* %61, i64 8
%63 = load float, float* %62
%64 = call float @acos(float %63)
%65 = fneg float %64
%66 = load float*, float** %4
%67 = getelementptr inbounds float, float* %66, i64 1
store float %65, float* %67
%68 = load float*, float** %3
%69 = getelementptr inbounds float, float* %68, i64 6
%70 = load float, float* %69
%71 = fneg float %70
%72 = load float*, float** %3
%73 = getelementptr inbounds float, float* %72, i64 7
%74 = load float, float* %73
%75 = call float @atan2(float %71, float %74)
%76 = load float*, float** %4
%77 = getelementptr inbounds float, float* %76, i64 2
store float %75, float* %77
%78 = load float*, float** %3
%79 = getelementptr inbounds float, float* %78, i64 2
%80 = load float, float* %79
%81 = fneg float %80
%82 = load float*, float** %3
%83 = getelementptr inbounds float, float* %82, i64 5
%84 = load float, float* %83
%85 = fneg float %84
%86 = call float @atan2(float %81, float %85)
%87 = load float*, float** %4
%88 = getelementptr inbounds float, float* %87, i64 0
store float %86, float* %88
br label %89
89: ; preds = %60, %2
ret void
}

LLVM IR (-O2):
define void @mattoabg(float* nocapture %0, float* nocapture %1) {
%3 = getelementptr inbounds float, float* %0, i64 8
%4 = load float, float* %3
%5 = tail call float @acos(float %4)
%6 = getelementptr inbounds float, float* %1, i64 1
store float %5, float* %6
%7 = getelementptr inbounds float, float* %0, i64 6
%8 = load float, float* %7
%9 = getelementptr inbounds float, float* %0, i64 7
%10 = load float, float* %9
%11 = fneg float %10
%12 = tail call float @atan2(float %8, float %11)
%13 = getelementptr inbounds float, float* %1, i64 2
store float %12, float* %13
%14 = getelementptr inbounds float, float* %0, i64 2
%15 = load float, float* %14
%16 = getelementptr inbounds float, float* %0, i64 5
%17 = load float, float* %16
%18 = tail call float @atan2(float %15, float %17)
store float %18, float* %1
%19 = load float, float* %13
%20 = tail call float @sin(float %19)
%21 = load float, float* %1
%22 = tail call float @cos(float %21)
%23 = load float, float* %13
%24 = tail call float @cos(float %23)
%25 = load float, float* %6
%26 = tail call float @cos(float %25)
%27 = fmul float %24, %26
%28 = load float, float* %1
%29 = tail call float @sin(float %28)
%30 = fmul float %27, %29
%31 = tail call float @llvm.fmuladd.f32(float %20, float %22, float %30)
%32 = getelementptr inbounds float, float* %0, i64 1
%33 = load float, float* %32
%34 = fsub float %31, %33
%35 = tail call i32 @fabs(float %34)
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %50
37: ; preds = %2
%38 = load float, float* %3
%39 = tail call float @acos(float %38)
%40 = fneg float %39
store float %40, float* %6
%41 = load float, float* %7
%42 = fneg float %41
%43 = load float, float* %9
%44 = tail call float @atan2(float %42, float %43)
store float %44, float* %13
%45 = load float, float* %14
%46 = fneg float %45
%47 = load float, float* %16
%48 = fneg float %47
%49 = tail call float @atan2(float %46, float %48)
store float %49, float* %1
br label %50
50: ; preds = %37, %2
ret void
}