#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 cos(double);
double sin(double);
double *transform(double *x, double *t, double *a, double mag) {
  double ca = cos(a[0] * mag), cb = cos(a[1] * mag), cg = cos(a[2] * mag);
  double sa = sin(a[0] * mag), sb = sin(a[1] * mag), sg = sin(a[2] * mag);
  double tx, ty, tz;
  if (mag < 0) {
    tx = sa;
    sa = sg;
    sg = tx;
    tx = ca;
    ca = cg;
    cg = tx;
  }
  tx = x[0] * (cg * ca - sg * cb * sa) + x[1] * (-cg * sa - sg * cb * ca) +
       x[2] * sg * sb;
  ty = x[0] * (sg * ca + cg * cb * sa) + x[1] * (-sg * sa + cg * cb * ca) +
       x[2] * (-cg * sb);
  tz = x[0] * sb * sa + x[1] * sb * ca + x[2] * cb;
  t[0] = tx;
  t[1] = ty;
  t[2] = tz;
  return (t);
}


x86 assembly (clang, -O0):
<transform>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1211 <transform+0xf1>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x50(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm3,%xmm2
addsd  %xmm0,%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  -0x38(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
movsd  -0x40(%rbp),%xmm5
movsd  -0x50(%rbp),%xmm4
mulsd  -0x30(%rbp),%xmm4
mulsd  -0x28(%rbp),%xmm4
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x50(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
mulsd  %xmm3,%xmm2
addsd  %xmm0,%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  -0x50(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
movsd  -0x40(%rbp),%xmm5
movsd  -0x38(%rbp),%xmm4
mulsd  -0x30(%rbp),%xmm4
mulsd  -0x28(%rbp),%xmm4
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  -0x38(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mulsd  -0x48(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x68(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transform>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
movapd %xmm0,%xmm1
movapd %xmm0,(%rsp)
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
movsd  (%rdx),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <cos@plt>
movapd %xmm0,0x30(%rsp)
movsd  0x8(%rbx),%xmm0
mulsd  (%rsp),%xmm0
call   1040 <cos@plt>
movapd %xmm0,0x50(%rsp)
movsd  0x10(%rbx),%xmm0
mulsd  (%rsp),%xmm0
call   1040 <cos@plt>
movapd %xmm0,0x20(%rsp)
movsd  (%rbx),%xmm0
mulsd  (%rsp),%xmm0
call   1030 <sin@plt>
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rbx),%xmm0
mulsd  (%rsp),%xmm0
call   1030 <sin@plt>
movapd %xmm0,0x40(%rsp)
movsd  0x10(%rbx),%xmm0
mulsd  (%rsp),%xmm0
call   1030 <sin@plt>
movapd (%rsp),%xmm7
xorpd  %xmm2,%xmm2
ucomisd %xmm7,%xmm2
movapd %xmm0,%xmm8
ja     11cb <transform+0xab>
movapd 0x10(%rsp),%xmm8
cmpltsd %xmm2,%xmm7
movapd %xmm7,%xmm2
movapd 0x30(%rsp),%xmm5
andnpd %xmm5,%xmm2
movapd 0x20(%rsp),%xmm1
andpd  %xmm1,%xmm7
orpd   %xmm2,%xmm7
ja     11f8 <transform+0xd8>
unpcklpd %xmm0,%xmm1
movapd %xmm1,%xmm5
jmp    11fe <transform+0xde>
unpcklpd 0x10(%rsp),%xmm5
movsd  (%r15),%xmm2
movsd  0x8(%r15),%xmm9
movapd 0xdee(%rip),%xmm10
xorpd  %xmm5,%xmm10
movsd  0x10(%r15),%xmm11
movapd %xmm5,%xmm0
unpckhpd %xmm5,%xmm0
mulsd  %xmm11,%xmm0
movapd 0x50(%rsp),%xmm12
movapd %xmm12,%xmm6
unpcklpd %xmm12,%xmm6
movapd %xmm10,%xmm3
shufpd $0x1,%xmm5,%xmm3
mulpd  %xmm6,%xmm3
movapd %xmm8,%xmm4
unpcklpd %xmm8,%xmm4
movapd %xmm4,%xmm1
mulpd  %xmm3,%xmm1
movapd %xmm7,%xmm6
unpcklpd %xmm7,%xmm6
movapd %xmm5,%xmm13
mulpd  %xmm6,%xmm13
addpd  %xmm1,%xmm13
mulpd  %xmm3,%xmm6
mulpd  %xmm5,%xmm4
subpd  %xmm4,%xmm6
movapd 0x40(%rsp),%xmm4
movapd %xmm4,%xmm1
mulsd  %xmm4,%xmm10
movapd %xmm4,%xmm3
mulsd  %xmm9,%xmm4
unpcklpd %xmm9,%xmm9
mulpd  %xmm6,%xmm9
mulsd  %xmm2,%xmm1
unpcklpd %xmm2,%xmm2
mulpd  %xmm13,%xmm2
addpd  %xmm9,%xmm2
unpcklpd %xmm11,%xmm0
unpcklpd %xmm10,%xmm3
mulpd  %xmm0,%xmm3
addpd  %xmm2,%xmm3
mulsd  %xmm4,%xmm7
mulsd  %xmm8,%xmm1
addsd  %xmm7,%xmm1
mulsd  %xmm12,%xmm11
addsd  %xmm1,%xmm11
movupd %xmm3,(%r14)
movsd  %xmm11,0x10(%r14)
mov    %r14,%rax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double* @transform(double* %0, double* %1, double* %2, double %3) {
%5 = alloca double*
%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
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store double %3, double* %8
%18 = load double*, double** %7
%19 = getelementptr inbounds double, double* %18, i64 0
%20 = load double, double* %19
%21 = load double, double* %8
%22 = fmul double %20, %21
%23 = call double @cos(double %22)
store double %23, double* %9
%24 = load double*, double** %7
%25 = getelementptr inbounds double, double* %24, i64 1
%26 = load double, double* %25
%27 = load double, double* %8
%28 = fmul double %26, %27
%29 = call double @cos(double %28)
store double %29, double* %10
%30 = load double*, double** %7
%31 = getelementptr inbounds double, double* %30, i64 2
%32 = load double, double* %31
%33 = load double, double* %8
%34 = fmul double %32, %33
%35 = call double @cos(double %34)
store double %35, double* %11
%36 = load double*, double** %7
%37 = getelementptr inbounds double, double* %36, i64 0
%38 = load double, double* %37
%39 = load double, double* %8
%40 = fmul double %38, %39
%41 = call double @sin(double %40)
store double %41, double* %12
%42 = load double*, double** %7
%43 = getelementptr inbounds double, double* %42, i64 1
%44 = load double, double* %43
%45 = load double, double* %8
%46 = fmul double %44, %45
%47 = call double @sin(double %46)
store double %47, double* %13
%48 = load double*, double** %7
%49 = getelementptr inbounds double, double* %48, i64 2
%50 = load double, double* %49
%51 = load double, double* %8
%52 = fmul double %50, %51
%53 = call double @sin(double %52)
store double %53, double* %14
%54 = load double, double* %8
%55 = fcmp olt double %54, 0.000000e+00
br i1 %55, label %56, label %63
56: ; preds = %4
%57 = load double, double* %12
store double %57, double* %15
%58 = load double, double* %14
store double %58, double* %12
%59 = load double, double* %15
store double %59, double* %14
%60 = load double, double* %9
store double %60, double* %15
%61 = load double, double* %11
store double %61, double* %9
%62 = load double, double* %15
store double %62, double* %11
br label %63
63: ; preds = %56, %4
%64 = load double*, double** %5
%65 = getelementptr inbounds double, double* %64, i64 0
%66 = load double, double* %65
%67 = load double, double* %11
%68 = load double, double* %9
%69 = load double, double* %14
%70 = load double, double* %10
%71 = fmul double %69, %70
%72 = load double, double* %12
%73 = fmul double %71, %72
%74 = fneg double %73
%75 = call double @llvm.fmuladd.f64(double %67, double %68, double %74)
%76 = load double*, double** %5
%77 = getelementptr inbounds double, double* %76, i64 1
%78 = load double, double* %77
%79 = load double, double* %11
%80 = fneg double %79
%81 = load double, double* %12
%82 = load double, double* %14
%83 = load double, double* %10
%84 = fmul double %82, %83
%85 = load double, double* %9
%86 = fmul double %84, %85
%87 = fneg double %86
%88 = call double @llvm.fmuladd.f64(double %80, double %81, double %87)
%89 = fmul double %78, %88
%90 = call double @llvm.fmuladd.f64(double %66, double %75, double %89)
%91 = load double*, double** %5
%92 = getelementptr inbounds double, double* %91, i64 2
%93 = load double, double* %92
%94 = load double, double* %14
%95 = fmul double %93, %94
%96 = load double, double* %13
%97 = call double @llvm.fmuladd.f64(double %95, double %96, double %90)
store double %97, double* %15
%98 = load double*, double** %5
%99 = getelementptr inbounds double, double* %98, i64 0
%100 = load double, double* %99
%101 = load double, double* %14
%102 = load double, double* %9
%103 = load double, double* %11
%104 = load double, double* %10
%105 = fmul double %103, %104
%106 = load double, double* %12
%107 = fmul double %105, %106
%108 = call double @llvm.fmuladd.f64(double %101, double %102, double %107)
%109 = load double*, double** %5
%110 = getelementptr inbounds double, double* %109, i64 1
%111 = load double, double* %110
%112 = load double, double* %14
%113 = fneg double %112
%114 = load double, double* %12
%115 = load double, double* %11
%116 = load double, double* %10
%117 = fmul double %115, %116
%118 = load double, double* %9
%119 = fmul double %117, %118
%120 = call double @llvm.fmuladd.f64(double %113, double %114, double %119)
%121 = fmul double %111, %120
%122 = call double @llvm.fmuladd.f64(double %100, double %108, double %121)
%123 = load double*, double** %5
%124 = getelementptr inbounds double, double* %123, i64 2
%125 = load double, double* %124
%126 = load double, double* %11
%127 = fneg double %126
%128 = load double, double* %13
%129 = fmul double %127, %128
%130 = call double @llvm.fmuladd.f64(double %125, double %129, double %122)
store double %130, double* %16
%131 = load double*, double** %5
%132 = getelementptr inbounds double, double* %131, i64 0
%133 = load double, double* %132
%134 = load double, double* %13
%135 = fmul double %133, %134
%136 = load double, double* %12
%137 = load double*, double** %5
%138 = getelementptr inbounds double, double* %137, i64 1
%139 = load double, double* %138
%140 = load double, double* %13
%141 = fmul double %139, %140
%142 = load double, double* %9
%143 = fmul double %141, %142
%144 = call double @llvm.fmuladd.f64(double %135, double %136, double %143)
%145 = load double*, double** %5
%146 = getelementptr inbounds double, double* %145, i64 2
%147 = load double, double* %146
%148 = load double, double* %10
%149 = call double @llvm.fmuladd.f64(double %147, double %148, double %144)
store double %149, double* %17
%150 = load double, double* %15
%151 = load double*, double** %6
%152 = getelementptr inbounds double, double* %151, i64 0
store double %150, double* %152
%153 = load double, double* %16
%154 = load double*, double** %6
%155 = getelementptr inbounds double, double* %154, i64 1
store double %153, double* %155
%156 = load double, double* %17
%157 = load double*, double** %6
%158 = getelementptr inbounds double, double* %157, i64 2
store double %156, double* %158
%159 = load double*, double** %6
ret double* %159
}

LLVM IR (-O2):
define double* @transform(double* nocapture %0, double* returned writeonly %1, double* nocapture %2, double %3) {
%5 = load double, double* %2
%6 = fmul double %5, %3
%7 = tail call double @cos(double %6)
%8 = getelementptr inbounds double, double* %2, i64 1
%9 = load double, double* %8
%10 = fmul double %9, %3
%11 = tail call double @cos(double %10)
%12 = getelementptr inbounds double, double* %2, i64 2
%13 = load double, double* %12
%14 = fmul double %13, %3
%15 = tail call double @cos(double %14)
%16 = load double, double* %2
%17 = fmul double %16, %3
%18 = tail call double @sin(double %17)
%19 = load double, double* %8
%20 = fmul double %19, %3
%21 = tail call double @sin(double %20)
%22 = load double, double* %12
%23 = fmul double %22, %3
%24 = tail call double @sin(double %23)
%25 = fcmp olt double %3, 0.000000e+00
%26 = insertelement <2 x double> poison, double %15, i64 0
%27 = insertelement <2 x double> %26, double %24, i64 1
%28 = insertelement <2 x double> poison, double %7, i64 0
%29 = insertelement <2 x double> %28, double %18, i64 1
%30 = select i1 %25, double %24, double %18
%31 = select i1 %25, double %15, double %7
%32 = select i1 %25, <2 x double> %29, <2 x double> %27
%33 = load double, double* %0
%34 = getelementptr inbounds double, double* %0, i64 1
%35 = load double, double* %34
%36 = fneg <2 x double> %32
%37 = getelementptr inbounds double, double* %0, i64 2
%38 = load double, double* %37
%39 = extractelement <2 x double> %32, i64 1
%40 = fmul double %39, %38
%41 = insertelement <2 x double> poison, double %11, i64 0
%42 = shufflevector <2 x double> %41, <2 x double> poison, <2 x i32> zeroinitializer
%43 = shufflevector <2 x double> %36, <2 x double> %32, <2 x i32> <i32 1, i32 2>
%44 = fmul <2 x double> %42, %43
%45 = insertelement <2 x double> poison, double %30, i64 0
%46 = shufflevector <2 x double> %45, <2 x double> poison, <2 x i32> zeroinitializer
%47 = fmul <2 x double> %46, %44
%48 = insertelement <2 x double> poison, double %31, i64 0
%49 = shufflevector <2 x double> %48, <2 x double> poison, <2 x i32> zeroinitializer
%50 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %32, <2 x double> %49, <2 x double> %47)
%51 = fmul <2 x double> %44, %49
%52 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %36, <2 x double> %46, <2 x double> %51)
%53 = insertelement <2 x double> poison, double %35, i64 0
%54 = shufflevector <2 x double> %53, <2 x double> poison, <2 x i32> zeroinitializer
%55 = fmul <2 x double> %54, %52
%56 = insertelement <2 x double> poison, double %33, i64 0
%57 = shufflevector <2 x double> %56, <2 x double> poison, <2 x i32> zeroinitializer
%58 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %57, <2 x double> %50, <2 x double> %55)
%59 = extractelement <2 x double> %36, i64 0
%60 = fmul double %21, %59
%61 = insertelement <2 x double> poison, double %40, i64 0
%62 = insertelement <2 x double> %61, double %38, i64 1
%63 = insertelement <2 x double> poison, double %21, i64 0
%64 = insertelement <2 x double> %63, double %60, i64 1
%65 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %64, <2 x double> %58)
%66 = fmul double %21, %33
%67 = fmul double %21, %35
%68 = fmul double %31, %67
%69 = tail call double @llvm.fmuladd.f64(double %66, double %30, double %68)
%70 = tail call double @llvm.fmuladd.f64(double %38, double %11, double %69)
%71 = bitcast double* %1 to <2 x double>*
store <2 x double> %65, <2 x double>* %71
%72 = getelementptr inbounds double, double* %1, i64 2
store double %70, double* %72
ret double* %1
}