#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 M_PI;
double cos(double);
double sin(double);
void AngleVectors(const float angles[3], float *forward, float *right,
                  float *up) {
  double angle;
  double sr, sp, sy, cr, cp, cy;
  angle = angles[1] * (M_PI * 2 / 360);
  sy = sin(angle);
  cy = cos(angle);
  angle = angles[0] * (M_PI * 2 / 360);
  sp = sin(angle);
  cp = cos(angle);
  angle = angles[2] * (M_PI * 2 / 360);
  sr = sin(angle);
  cr = cos(angle);
  if (forward) {
    forward[0] = (float)(cp * cy);
    forward[1] = (float)(cp * sy);
    forward[2] = (float)(-sp);
  }
  if (right) {
    right[0] = (float)(-1 * sr * sp * cy + -1 * cr * -sy);
    right[1] = (float)(-1 * sr * sp * sy + -1 * cr * cy);
    right[2] = (float)(-1 * sr * cp);
  }
  if (up) {
    up[0] = (float)(cr * sp * cy + -sr * -sy);
    up[1] = (float)(cr * sp * sy + -sr * cy);
    up[2] = (float)(cr * cp);
  }
}


x86 assembly (clang, -O0):
<AngleVectors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    0x2ea0(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
mov    $0x168,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
mov    $0x168,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    0x2e09(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
mov    $0x168,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x48(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     127c <AngleVectors+0x15c>
movsd  -0x50(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
cmpq   $0x0,-0x18(%rbp)
je     133c <AngleVectors+0x21c>
movsd  0xd71(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  0xd5a(%rip),%xmm1
mulsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movsd  0xd19(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  0xd02(%rip),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
movsd  0xcdb(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x8(%rax)
cmpq   $0x0,-0x20(%rbp)
je     1402 <AngleVectors+0x2e2>
movsd  -0x48(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  -0x40(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x4(%rax)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AngleVectors>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    0x2eb4(%rip),%r13
movslq 0x0(%r13),%rax
imul   $0xffffffffb60b60b7,%rax,%rbx
shr    $0x20,%rbx
add    %eax,%ebx
mov    %ebx,%eax
shr    $0x1f,%eax
sar    $0x7,%ebx
add    %eax,%ebx
cvtsi2ss %ebx,%xmm0
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
mulss  0x4(%rdi),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,(%rsp)
call   1030 <sin@plt>
movsd  %xmm0,0x38(%rsp)
movsd  (%rsp),%xmm0
call   1040 <cos@plt>
movslq 0x0(%r13),%rax
imul   $0xffffffffb60b60b7,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x7,%ecx
add    %eax,%ecx
cvtsi2ss %ecx,%xmm1
movsd  %xmm0,0x30(%rsp)
mulss  (%rbx),%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1030 <sin@plt>
movsd  %xmm0,0x28(%rsp)
movsd  (%rsp),%xmm0
call   1040 <cos@plt>
movslq 0x0(%r13),%rax
imul   $0xffffffffb60b60b7,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x7,%ecx
add    %eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2ss %ecx,%xmm1
movsd  %xmm0,0x20(%rsp)
mulss  0x8(%rbx),%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
call   1030 <sin@plt>
movaps %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
movsd  0x20(%rsp),%xmm5
movsd  0x28(%rsp),%xmm7
movsd  0x30(%rsp),%xmm6
movsd  0x38(%rsp),%xmm8
test   %r12,%r12
je     1270 <AngleVectors+0x150>
movapd %xmm6,%xmm1
mulsd  %xmm5,%xmm1
cvtsd2ss %xmm1,%xmm1
movss  %xmm1,(%r12)
movapd %xmm8,%xmm1
mulsd  %xmm5,%xmm1
cvtsd2ss %xmm1,%xmm1
cvtsd2ss %xmm7,%xmm2
movss  %xmm1,0x4(%r12)
xorps  0xd97(%rip),%xmm2
movss  %xmm2,0x8(%r12)
test   %r15,%r15
movapd (%rsp),%xmm9
je     12d9 <AngleVectors+0x1b9>
movapd 0xd8d(%rip),%xmm1
xorpd  %xmm9,%xmm1
movaps %xmm7,%xmm2
mulsd  %xmm1,%xmm2
movapd %xmm8,%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm2,%xmm4
mulsd  %xmm6,%xmm4
addsd  %xmm3,%xmm4
xorps  %xmm3,%xmm3
cvtsd2ss %xmm4,%xmm3
movss  %xmm3,(%r15)
movapd %xmm6,%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm8,%xmm2
subsd  %xmm3,%xmm2
cvtsd2ss %xmm2,%xmm2
movss  %xmm2,0x4(%r15)
mulsd  %xmm5,%xmm1
cvtsd2ss %xmm1,%xmm1
movss  %xmm1,0x8(%r15)
test   %r14,%r14
je     1330 <AngleVectors+0x210>
mulsd  %xmm0,%xmm7
movapd %xmm8,%xmm1
mulsd  %xmm9,%xmm1
movapd %xmm7,%xmm2
mulsd  %xmm6,%xmm2
addsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
movss  %xmm1,(%r14)
mulsd  %xmm9,%xmm6
mulsd  %xmm8,%xmm7
subsd  %xmm6,%xmm7
xorps  %xmm1,%xmm1
cvtsd2ss %xmm7,%xmm1
movss  %xmm1,0x4(%r14)
mulsd  %xmm0,%xmm5
xorps  %xmm0,%xmm0
cvtsd2ss %xmm5,%xmm0
movss  %xmm0,0x8(%r14)
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@M_PI = global i32 0
define void @AngleVectors(float* nocapture %0, float* writeonly %1, float* writeonly %2, float* writeonly %3) {
%5 = getelementptr inbounds float, float* %0, i64 1
%6 = load float, float* %5
%7 = load i32, i32* @M_PI
%8 = sdiv i32 %7, 180
%9 = sitofp i32 %8 to float
%10 = fmul float %6, %9
%11 = fpext float %10 to double
%12 = tail call double @sin(double %11)
%13 = tail call double @cos(double %11)
%14 = load float, float* %0
%15 = load i32, i32* @M_PI
%16 = sdiv i32 %15, 180
%17 = sitofp i32 %16 to float
%18 = fmul float %14, %17
%19 = fpext float %18 to double
%20 = tail call double @sin(double %19)
%21 = tail call double @cos(double %19)
%22 = getelementptr inbounds float, float* %0, i64 2
%23 = load float, float* %22
%24 = load i32, i32* @M_PI
%25 = sdiv i32 %24, 180
%26 = sitofp i32 %25 to float
%27 = fmul float %23, %26
%28 = fpext float %27 to double
%29 = tail call double @sin(double %28)
%30 = tail call double @cos(double %28)
%31 = icmp eq float* %1, null
br i1 %31, label %41, label %32
32: ; preds = %4
%33 = fmul double %13, %21
%34 = fptrunc double %33 to float
store float %34, float* %1
%35 = fmul double %12, %21
%36 = fptrunc double %35 to float
%37 = getelementptr inbounds float, float* %1, i64 1
store float %36, float* %37
%38 = fptrunc double %20 to float
%39 = fneg float %38
%40 = getelementptr inbounds float, float* %1, i64 2
store float %39, float* %40
br label %41
41: ; preds = %32, %4
%42 = icmp eq float* %2, null
br i1 %42, label %57, label %43
43: ; preds = %41
%44 = fneg double %29
%45 = fmul double %20, %44
%46 = fneg double %30
%47 = fmul double %12, %30
%48 = tail call double @llvm.fmuladd.f64(double %45, double %13, double %47)
%49 = fptrunc double %48 to float
store float %49, float* %2
%50 = fmul double %13, %46
%51 = tail call double @llvm.fmuladd.f64(double %45, double %12, double %50)
%52 = fptrunc double %51 to float
%53 = getelementptr inbounds float, float* %2, i64 1
store float %52, float* %53
%54 = fmul double %21, %44
%55 = fptrunc double %54 to float
%56 = getelementptr inbounds float, float* %2, i64 2
store float %55, float* %56
br label %57
57: ; preds = %43, %41
%58 = icmp eq float* %3, null
br i1 %58, label %72, label %59
59: ; preds = %57
%60 = fmul double %20, %30
%61 = fneg double %29
%62 = fmul double %12, %29
%63 = tail call double @llvm.fmuladd.f64(double %60, double %13, double %62)
%64 = fptrunc double %63 to float
store float %64, float* %3
%65 = fmul double %13, %61
%66 = tail call double @llvm.fmuladd.f64(double %60, double %12, double %65)
%67 = fptrunc double %66 to float
%68 = getelementptr inbounds float, float* %3, i64 1
store float %67, float* %68
%69 = fmul double %21, %30
%70 = fptrunc double %69 to float
%71 = getelementptr inbounds float, float* %3, i64 2
store float %70, float* %71
br label %72
72: ; preds = %59, %57
ret void
}