#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*/ abc2cart(double *, double **);
int acos(double);
int /*<<< orphan*/ addabs();
int /*<<< orphan*/ real2rec();
double sqrt(double);
void cart2abc(double basis[3][3], double *abc, int fix) {
  int i, j, k;
  for (i = 0; i < 3; i++)
    abc[i] = sqrt(basis[i][0] * basis[i][0] + basis[i][1] * basis[i][1] +
                  basis[i][2] * basis[i][2]);
  for (i = 3; i < 6; i++) {
    j = (i + 1) % 3;
    k = (i + 2) % 3;
    abc[i] = acos((basis[j][0] * basis[k][0] + basis[j][1] * basis[k][1] +
                   basis[j][2] * basis[k][2]) /
                  (abc[j] * abc[k])) *
             180 / 3.14159265358979;
  }
  if (fix) {
    abc2cart(abc, basis);
    real2rec();
    addabs();
  }
}


x86 assembly (clang, -O0):
<cart2abc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    121a <cart2abc+0xca>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116a <cart2abc+0x1a>
movl   $0x3,-0x18(%rbp)
cmpl   $0x6,-0x18(%rbp)
jge    1327 <cart2abc+0x1d7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
divsd  %xmm1,%xmm0
call   1030 <acos@plt>
imul   $0xb4,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  0xcf8(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1221 <cart2abc+0xd1>
cmpl   $0x0,-0x14(%rbp)
je     134c <cart2abc+0x1fc>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1070 <abc2cart@plt>
mov    $0x0,%al
call   1050 <real2rec@plt>
mov    $0x0,%al
call   1040 <addabs@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cart2abc>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm1
movsd  0x8(%rdi),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rdi),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jb     118e <cart2abc+0x3e>
sqrtsd %xmm0,%xmm0
jmp    1197 <cart2abc+0x47>
call   1060 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  %xmm0,(%r14)
movsd  0x18(%rbx),%xmm1
movsd  0x20(%rbx),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x28(%rbx),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     11cb <cart2abc+0x7b>
sqrtsd %xmm0,%xmm0
jmp    11d0 <cart2abc+0x80>
call   1060 <sqrt@plt>
movsd  %xmm0,0x8(%r14)
movsd  0x30(%rbx),%xmm1
movsd  0x38(%rbx),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x40(%rbx),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1209 <cart2abc+0xb9>
sqrtsd %xmm0,%xmm0
jmp    120e <cart2abc+0xbe>
call   1060 <sqrt@plt>
movsd  %xmm0,0x10(%r14)
movsd  0x18(%rbx),%xmm2
movsd  0x20(%rbx),%xmm1
mulsd  0x38(%rbx),%xmm1
mulsd  0x30(%rbx),%xmm2
addsd  %xmm1,%xmm2
movsd  0x28(%rbx),%xmm1
mulsd  0x40(%rbx),%xmm1
addsd  %xmm2,%xmm1
mulsd  0x8(%r14),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <acos@plt>
imul   $0xb4,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xd9e(%rip),%xmm0
movsd  %xmm0,0x18(%r14)
movsd  0x38(%rbx),%xmm0
mulsd  0x8(%rbx),%xmm0
movsd  0x30(%rbx),%xmm1
mulsd  (%rbx),%xmm1
addsd  %xmm0,%xmm1
movsd  0x40(%rbx),%xmm0
mulsd  0x10(%rbx),%xmm0
addsd  %xmm1,%xmm0
movsd  0x10(%r14),%xmm1
mulsd  (%r14),%xmm1
divsd  %xmm1,%xmm0
call   1030 <acos@plt>
imul   $0xb4,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xd4a(%rip),%xmm0
movsd  %xmm0,0x20(%r14)
movsd  0x8(%rbx),%xmm0
mulsd  0x20(%rbx),%xmm0
movsd  (%rbx),%xmm1
mulsd  0x18(%rbx),%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rbx),%xmm0
mulsd  0x28(%rbx),%xmm0
addsd  %xmm1,%xmm0
movsd  (%r14),%xmm1
mulsd  0x8(%r14),%xmm1
divsd  %xmm1,%xmm0
call   1030 <acos@plt>
imul   $0xb4,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xcf6(%rip),%xmm0
movsd  %xmm0,0x28(%r14)
test   %ebp,%ebp
je     1331 <cart2abc+0x1e1>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <abc2cart@plt>
xor    %eax,%eax
call   1050 <real2rec@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <addabs@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @cart2abc([3 x double]* %0, double* %1, i32 %2) {
%4 = alloca [3 x double]*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store [3 x double]* %0, [3 x double]** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %10
10: ; preds = %58, %3
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %61
13: ; preds = %10
%14 = load [3 x double]*, [3 x double]** %4
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 %16
%18 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 0
%19 = load double, double* %18
%20 = load [3 x double]*, [3 x double]** %4
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [3 x double], [3 x double]* %20, i64 %22
%24 = getelementptr inbounds [3 x double], [3 x double]* %23, i64 0, i64 0
%25 = load double, double* %24
%26 = load [3 x double]*, [3 x double]** %4
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 %28
%30 = getelementptr inbounds [3 x double], [3 x double]* %29, i64 0, i64 1
%31 = load double, double* %30
%32 = load [3 x double]*, [3 x double]** %4
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [3 x double], [3 x double]* %32, i64 %34
%36 = getelementptr inbounds [3 x double], [3 x double]* %35, i64 0, i64 1
%37 = load double, double* %36
%38 = fmul double %31, %37
%39 = call double @llvm.fmuladd.f64(double %19, double %25, double %38)
%40 = load [3 x double]*, [3 x double]** %4
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [3 x double], [3 x double]* %40, i64 %42
%44 = getelementptr inbounds [3 x double], [3 x double]* %43, i64 0, i64 2
%45 = load double, double* %44
%46 = load [3 x double]*, [3 x double]** %4
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [3 x double], [3 x double]* %46, i64 %48
%50 = getelementptr inbounds [3 x double], [3 x double]* %49, i64 0, i64 2
%51 = load double, double* %50
%52 = call double @llvm.fmuladd.f64(double %45, double %51, double %39)
%53 = call double @sqrt(double %52)
%54 = load double*, double** %5
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %54, i64 %56
store double %53, double* %57
br label %58
58: ; preds = %13
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %10
61: ; preds = %10
store i32 3, i32* %7
br label %62
62: ; preds = %131, %61
%63 = load i32, i32* %7
%64 = icmp slt i32 %63, 6
br i1 %64, label %65, label %134
65: ; preds = %62
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
%68 = srem i32 %67, 3
store i32 %68, i32* %8
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 2
%71 = srem i32 %70, 3
store i32 %71, i32* %9
%72 = load [3 x double]*, [3 x double]** %4
%73 = load i32, i32* %8
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [3 x double], [3 x double]* %72, i64 %74
%76 = getelementptr inbounds [3 x double], [3 x double]* %75, i64 0, i64 0
%77 = load double, double* %76
%78 = load [3 x double]*, [3 x double]** %4
%79 = load i32, i32* %9
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [3 x double], [3 x double]* %78, i64 %80
%82 = getelementptr inbounds [3 x double], [3 x double]* %81, i64 0, i64 0
%83 = load double, double* %82
%84 = load [3 x double]*, [3 x double]** %4
%85 = load i32, i32* %8
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [3 x double], [3 x double]* %84, i64 %86
%88 = getelementptr inbounds [3 x double], [3 x double]* %87, i64 0, i64 1
%89 = load double, double* %88
%90 = load [3 x double]*, [3 x double]** %4
%91 = load i32, i32* %9
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [3 x double], [3 x double]* %90, i64 %92
%94 = getelementptr inbounds [3 x double], [3 x double]* %93, i64 0, i64 1
%95 = load double, double* %94
%96 = fmul double %89, %95
%97 = call double @llvm.fmuladd.f64(double %77, double %83, double %96)
%98 = load [3 x double]*, [3 x double]** %4
%99 = load i32, i32* %8
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds [3 x double], [3 x double]* %98, i64 %100
%102 = getelementptr inbounds [3 x double], [3 x double]* %101, i64 0, i64 2
%103 = load double, double* %102
%104 = load [3 x double]*, [3 x double]** %4
%105 = load i32, i32* %9
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [3 x double], [3 x double]* %104, i64 %106
%108 = getelementptr inbounds [3 x double], [3 x double]* %107, i64 0, i64 2
%109 = load double, double* %108
%110 = call double @llvm.fmuladd.f64(double %103, double %109, double %97)
%111 = load double*, double** %5
%112 = load i32, i32* %8
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %111, i64 %113
%115 = load double, double* %114
%116 = load double*, double** %5
%117 = load i32, i32* %9
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds double, double* %116, i64 %118
%120 = load double, double* %119
%121 = fmul double %115, %120
%122 = fdiv double %110, %121
%123 = call i32 @acos(double %122)
%124 = mul nsw i32 %123, 180
%125 = sitofp i32 %124 to double
%126 = fdiv double %125, 0x400921FB54442D11
%127 = load double*, double** %5
%128 = load i32, i32* %7
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds double, double* %127, i64 %129
store double %126, double* %130
br label %131
131: ; preds = %65
%132 = load i32, i32* %7
%133 = add nsw i32 %132, 1
store i32 %133, i32* %7
br label %62
134: ; preds = %62
%135 = load i32, i32* %6
%136 = icmp ne i32 %135, 0
br i1 %136, label %137, label %144
137: ; preds = %134
%138 = load double*, double** %5
%139 = load [3 x double]*, [3 x double]** %4
%140 = bitcast [3 x double]* %139 to double**
%141 = call i32 @abc2cart(double* %138, double** %140)
%142 = call i32 (...) @real2rec()
%143 = call i32 (...) @addabs()
br label %144
144: ; preds = %137, %134
ret void
}

LLVM IR (-O2):
define void @cart2abc([3 x double]* %0, double* %1, i32 %2) {
%4 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
%5 = load double, double* %4
%6 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 1
%7 = load double, double* %6
%8 = fmul double %7, %7
%9 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %8)
%10 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
%11 = load double, double* %10
%12 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %9)
%13 = tail call double @sqrt(double %12)
store double %13, double* %1
%14 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
%15 = load double, double* %14
%16 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
%17 = load double, double* %16
%18 = fmul double %17, %17
%19 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %18)
%20 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
%21 = load double, double* %20
%22 = tail call double @llvm.fmuladd.f64(double %21, double %21, double %19)
%23 = tail call double @sqrt(double %22)
%24 = getelementptr inbounds double, double* %1, i64 1
store double %23, double* %24
%25 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
%26 = load double, double* %25
%27 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
%28 = load double, double* %27
%29 = fmul double %28, %28
%30 = tail call double @llvm.fmuladd.f64(double %26, double %26, double %29)
%31 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
%32 = load double, double* %31
%33 = tail call double @llvm.fmuladd.f64(double %32, double %32, double %30)
%34 = tail call double @sqrt(double %33)
%35 = getelementptr inbounds double, double* %1, i64 2
store double %34, double* %35
%36 = load double, double* %14
%37 = load double, double* %25
%38 = load double, double* %16
%39 = load double, double* %27
%40 = fmul double %38, %39
%41 = tail call double @llvm.fmuladd.f64(double %36, double %37, double %40)
%42 = load double, double* %20
%43 = load double, double* %31
%44 = tail call double @llvm.fmuladd.f64(double %42, double %43, double %41)
%45 = load double, double* %24
%46 = fmul double %45, %34
%47 = fdiv double %44, %46
%48 = tail call i32 @acos(double %47)
%49 = mul nsw i32 %48, 180
%50 = sitofp i32 %49 to double
%51 = fdiv double %50, 0x400921FB54442D11
%52 = getelementptr inbounds double, double* %1, i64 3
store double %51, double* %52
%53 = load double, double* %25
%54 = load double, double* %4
%55 = load double, double* %27
%56 = load double, double* %6
%57 = fmul double %55, %56
%58 = tail call double @llvm.fmuladd.f64(double %53, double %54, double %57)
%59 = load double, double* %31
%60 = load double, double* %10
%61 = tail call double @llvm.fmuladd.f64(double %59, double %60, double %58)
%62 = load double, double* %35
%63 = load double, double* %1
%64 = fmul double %62, %63
%65 = fdiv double %61, %64
%66 = tail call i32 @acos(double %65)
%67 = mul nsw i32 %66, 180
%68 = sitofp i32 %67 to double
%69 = fdiv double %68, 0x400921FB54442D11
%70 = getelementptr inbounds double, double* %1, i64 4
store double %69, double* %70
%71 = load double, double* %4
%72 = load double, double* %14
%73 = load double, double* %6
%74 = load double, double* %16
%75 = fmul double %73, %74
%76 = tail call double @llvm.fmuladd.f64(double %71, double %72, double %75)
%77 = load double, double* %10
%78 = load double, double* %20
%79 = tail call double @llvm.fmuladd.f64(double %77, double %78, double %76)
%80 = load double, double* %1
%81 = load double, double* %24
%82 = fmul double %80, %81
%83 = fdiv double %79, %82
%84 = tail call i32 @acos(double %83)
%85 = mul nsw i32 %84, 180
%86 = sitofp i32 %85 to double
%87 = fdiv double %86, 0x400921FB54442D11
%88 = getelementptr inbounds double, double* %1, i64 5
store double %87, double* %88
%89 = icmp eq i32 %2, 0
br i1 %89, label %95, label %90
90: ; preds = %3
%91 = bitcast [3 x double]* %0 to double**
%92 = tail call i32 @abc2cart(double* %1, double** %91)
%93 = tail call i32 (...) @real2rec()
%94 = tail call i32 (...) @addabs()
br label %95
95: ; preds = %90, %3
ret void
}