#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 acos(double);
double asin(double);
int /*<<< orphan*/ matNormalize(double *, double *);
double sin(double);
int matCalcPolar(double *v1, double *v2, double *om, double *ph, double *ka) {
  double x, y, z, xx, yy, zz, xy, xz, yz;
  double n1[3], n2[3];
  double q, p, r;
  n1[0] = v1[0];
  n1[1] = v1[1];
  n1[2] = v1[2];
  n2[0] = v2[0];
  n2[1] = v2[1];
  n2[2] = v2[2];
  matNormalize(n1, n1);
  matNormalize(n2, n2);
  x = n1[0];
  y = n1[1];
  z = n1[2];
  xx = x * x;
  xy = x * y;
  xz = x * z;
  yy = y * y;
  yz = y * z;
  zz = z * z;
  q = n2[0];
  p = n2[1];
  r = n2[2];
  (*om) = acos(x);
  (*ph) = acos(y / sin((*om)));
  (*ka) = asin((p - xy + (xy * (q - yy) / (1 - yy))) / z);
  return 0;
}


x86 assembly (clang, -O0):
<matCalcPolar>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
lea    -0x90(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1030 <matNormalize@plt>
lea    -0xb0(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1030 <matNormalize@plt>
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x30(%rbp)
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x38(%rbp)
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
call   1040 <acos@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xd0(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
call   1040 <acos@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0xc0(%rbp),%xmm0
ff
subsd  -0x60(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0xb8(%rbp),%xmm2
ff
subsd  -0x50(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xcf9(%rip),%xmm2
subsd  -0x50(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
call   1060 <asin@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matCalcPolar>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%rbx
movups (%rdi),%xmm0
movaps %xmm0,(%rsp)
movsd  0x10(%rdi),%xmm0
movsd  %xmm0,0x10(%rsp)
movups (%rsi),%xmm0
movaps %xmm0,0x30(%rsp)
movsd  0x10(%rsi),%xmm0
movsd  %xmm0,0x40(%rsp)
mov    %rsp,%rdi
mov    %rdi,%rsi
call   1030 <matNormalize@plt>
lea    0x30(%rsp),%rdi
mov    %rdi,%rsi
call   1030 <matNormalize@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
movsd  %xmm2,0x28(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm2,%xmm2
movsd  0x30(%rsp),%xmm4
movsd  0x38(%rsp),%xmm3
subsd  %xmm1,%xmm3
subsd  %xmm2,%xmm4
mulsd  %xmm1,%xmm4
movsd  0xe34(%rip),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm4
addsd  %xmm3,%xmm4
divsd  0x10(%rsp),%xmm4
movsd  %xmm4,0x20(%rsp)
call   1040 <acos@plt>
movsd  %xmm0,(%rbx)
call   1050 <sin@plt>
movsd  0x28(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1040 <acos@plt>
movsd  %xmm0,(%r15)
movsd  0x20(%rsp),%xmm0
call   1060 <asin@plt>
movsd  %xmm0,(%r14)
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @matCalcPolar(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = alloca [3 x double]
%7 = alloca [3 x double]
%8 = bitcast [3 x double]* %6 to i8*
%9 = bitcast [3 x double]* %7 to i8*
%10 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%11 = bitcast double* %0 to <2 x double>*
%12 = load <2 x double>, <2 x double>* %11
%13 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
%14 = bitcast [3 x double]* %6 to <2 x double>*
store <2 x double> %12, <2 x double>* %14
%15 = getelementptr inbounds double, double* %0, i64 2
%16 = load double, double* %15
%17 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
store double %16, double* %17
%18 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%19 = bitcast double* %1 to <2 x double>*
%20 = load <2 x double>, <2 x double>* %19
%21 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 1
%22 = bitcast [3 x double]* %7 to <2 x double>*
store <2 x double> %20, <2 x double>* %22
%23 = getelementptr inbounds double, double* %1, i64 2
%24 = load double, double* %23
%25 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
store double %24, double* %25
%26 = call i32 @matNormalize(double* %10, double* %10)
%27 = call i32 @matNormalize(double* %18, double* %18)
%28 = load double, double* %10
%29 = load double, double* %13
%30 = load double, double* %17
%31 = fmul double %28, %29
%32 = fmul double %29, %29
%33 = load double, double* %18
%34 = load double, double* %21
%35 = call double @acos(double %28)
store double %35, double* %2
%36 = call double @sin(double %35)
%37 = fdiv double %29, %36
%38 = call double @acos(double %37)
store double %38, double* %3
%39 = fsub double %34, %31
%40 = fsub double %33, %32
%41 = fmul double %31, %40
%42 = fsub double 1.000000e+00, %32
%43 = fdiv double %41, %42
%44 = fadd double %39, %43
%45 = fdiv double %44, %30
%46 = call double @asin(double %45)
store double %46, double* %4
ret i32 0
}