#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 proj3d(double theta, double phi, double x, double y, double z, int in) {
  double ct = cos(.0174532 * theta), st = sin(.0174532 * theta);
  double sp = sin(.0174532 * phi), cp = cos(.0174532 * phi);
  double rm[3][3];
  double vt[3], vnew[3];
  int i, j;
  rm[0][0] = ct;
  rm[0][1] = st;
  rm[0][2] = 0.0;
  rm[1][0] = -cp * st;
  rm[1][1] = cp * ct;
  rm[1][2] = sp;
  rm[2][0] = st * sp;
  rm[2][1] = -sp * ct;
  rm[2][2] = cp;
  vt[0] = x;
  vt[1] = y;
  vt[2] = z;
  for (i = 0; i < 3; i++) {
    vnew[i] = 0.0;
    for (j = 0; j < 3; j++)
      vnew[i] = vnew[i] + rm[i][j] * vt[j];
  }
  return vnew[in];
}


x86 assembly (clang, -O0):
<proj3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
mov    %edi,-0x2c(%rbp)
movsd  0xeb1(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe9a(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  0xe83(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xe6c(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movl   $0x0,-0xe4(%rbp)
cmpl   $0x3,-0xe4(%rbp)
jge    1337 <proj3d+0x217>
movslq -0xe4(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xe0(%rbp,%rax,8)
ff ff
movl   $0x0,-0xe8(%rbp)
cmpl   $0x3,-0xe8(%rbp)
jge    131e <proj3d+0x1fe>
movslq -0xe4(%rbp),%rax
movsd  -0xe0(%rbp,%rax,8),%xmm1
ff ff
movslq -0xe4(%rbp),%rcx
lea    -0xa0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0xe8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0xe8(%rbp),%rax
movsd  -0xc0(%rbp,%rax,8),%xmm2
ff ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0xe4(%rbp),%rax
movsd  %xmm0,-0xe0(%rbp,%rax,8)
ff ff
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    12a4 <proj3d+0x184>
jmp    1323 <proj3d+0x203>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    127a <proj3d+0x15a>
movslq -0x2c(%rbp),%rax
movsd  -0xe0(%rbp,%rax,8),%xmm0
ff ff
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proj3d>:
push   %rbx
sub    $0x90,%rsp
mov    %edi,%ebx
movaps %xmm4,0x60(%rsp)
movaps %xmm3,0x50(%rsp)
movaps %xmm2,0x40(%rsp)
movsd  %xmm1,0x8(%rsp)
mulsd  0xeb9(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1040 <cos@plt>
movapd %xmm0,0x30(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe8a(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <sin@plt>
movapd %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movapd 0xe76(%rip),%xmm3
xorpd  %xmm0,%xmm3
movapd 0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm3
movapd 0x30(%rsp),%xmm6
movapd %xmm6,%xmm4
mulsd  %xmm0,%xmm4
movapd %xmm2,%xmm1
movapd %xmm2,%xmm7
movapd 0x20(%rsp),%xmm5
mulsd  %xmm5,%xmm1
movapd %xmm6,%xmm2
mulsd  %xmm5,%xmm2
movapd %xmm5,%xmm8
unpcklpd %xmm3,%xmm6
movapd %xmm6,%xmm5
movapd 0x40(%rsp),%xmm6
movapd %xmm6,%xmm3
unpcklpd %xmm6,%xmm3
mulpd  %xmm5,%xmm3
xorpd  %xmm5,%xmm5
addpd  %xmm5,%xmm3
unpcklpd %xmm4,%xmm7
movapd 0x50(%rsp),%xmm4
mulsd  %xmm4,%xmm2
unpcklpd %xmm4,%xmm4
mulpd  %xmm7,%xmm4
addpd  %xmm3,%xmm4
movapd %xmm4,%xmm7
movapd 0x60(%rsp),%xmm4
movapd %xmm4,%xmm3
unpcklpd %xmm8,%xmm3
unpcklpd %xmm4,%xmm5
mulpd  %xmm3,%xmm5
addpd  %xmm7,%xmm5
movapd %xmm5,0x70(%rsp)
mulsd  %xmm6,%xmm1
xorpd  %xmm3,%xmm3
addsd  %xmm1,%xmm3
subsd  %xmm2,%xmm3
mulsd  %xmm4,%xmm0
addsd  %xmm3,%xmm0
movsd  %xmm0,0x80(%rsp)
movslq %ebx,%rax
movsd  0x70(%rsp,%rax,8),%xmm0
add    $0x90,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @proj3d(double %0, double %1, double %2, double %3, double %4, i32 %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca [3 x [3 x double]]
%18 = alloca [3 x double]
%19 = alloca [3 x double]
%20 = alloca i32
%21 = alloca i32
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
store i32 %5, i32* %12
%22 = load double, double* %7
%23 = fmul double 1.745320e-02, %22
%24 = call double @cos(double %23)
store double %24, double* %13
%25 = load double, double* %7
%26 = fmul double 1.745320e-02, %25
%27 = call double @sin(double %26)
store double %27, double* %14
%28 = load double, double* %8
%29 = fmul double 1.745320e-02, %28
%30 = call double @sin(double %29)
store double %30, double* %15
%31 = load double, double* %8
%32 = fmul double 1.745320e-02, %31
%33 = call double @cos(double %32)
store double %33, double* %16
%34 = load double, double* %13
%35 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 0
%36 = getelementptr inbounds [3 x double], [3 x double]* %35, i64 0, i64 0
store double %34, double* %36
%37 = load double, double* %14
%38 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 0
%39 = getelementptr inbounds [3 x double], [3 x double]* %38, i64 0, i64 1
store double %37, double* %39
%40 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 0
%41 = getelementptr inbounds [3 x double], [3 x double]* %40, i64 0, i64 2
store double 0.000000e+00, double* %41
%42 = load double, double* %16
%43 = fneg double %42
%44 = load double, double* %14
%45 = fmul double %43, %44
%46 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 1
%47 = getelementptr inbounds [3 x double], [3 x double]* %46, i64 0, i64 0
store double %45, double* %47
%48 = load double, double* %16
%49 = load double, double* %13
%50 = fmul double %48, %49
%51 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 1
%52 = getelementptr inbounds [3 x double], [3 x double]* %51, i64 0, i64 1
store double %50, double* %52
%53 = load double, double* %15
%54 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 1
%55 = getelementptr inbounds [3 x double], [3 x double]* %54, i64 0, i64 2
store double %53, double* %55
%56 = load double, double* %14
%57 = load double, double* %15
%58 = fmul double %56, %57
%59 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 2
%60 = getelementptr inbounds [3 x double], [3 x double]* %59, i64 0, i64 0
store double %58, double* %60
%61 = load double, double* %15
%62 = fneg double %61
%63 = load double, double* %13
%64 = fmul double %62, %63
%65 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 2
%66 = getelementptr inbounds [3 x double], [3 x double]* %65, i64 0, i64 1
store double %64, double* %66
%67 = load double, double* %16
%68 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 2
%69 = getelementptr inbounds [3 x double], [3 x double]* %68, i64 0, i64 2
store double %67, double* %69
%70 = load double, double* %9
%71 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
store double %70, double* %71
%72 = load double, double* %10
%73 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 1
store double %72, double* %73
%74 = load double, double* %11
%75 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 2
store double %74, double* %75
store i32 0, i32* %20
br label %76
76: ; preds = %110, %6
%77 = load i32, i32* %20
%78 = icmp slt i32 %77, 3
br i1 %78, label %79, label %113
79: ; preds = %76
%80 = load i32, i32* %20
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 %81
store double 0.000000e+00, double* %82
store i32 0, i32* %21
br label %83
83: ; preds = %106, %79
%84 = load i32, i32* %21
%85 = icmp slt i32 %84, 3
br i1 %85, label %86, label %109
86: ; preds = %83
%87 = load i32, i32* %20
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 %88
%90 = load double, double* %89
%91 = load i32, i32* %20
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i64 0, i64 %92
%94 = load i32, i32* %21
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [3 x double], [3 x double]* %93, i64 0, i64 %95
%97 = load double, double* %96
%98 = load i32, i32* %21
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 %99
%101 = load double, double* %100
%102 = call double @llvm.fmuladd.f64(double %97, double %101, double %90)
%103 = load i32, i32* %20
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 %104
store double %102, double* %105
br label %106
106: ; preds = %86
%107 = load i32, i32* %21
%108 = add nsw i32 %107, 1
store i32 %108, i32* %21
br label %83
109: ; preds = %83
br label %110
110: ; preds = %109
%111 = load i32, i32* %20
%112 = add nsw i32 %111, 1
store i32 %112, i32* %20
br label %76
113: ; preds = %76
%114 = load i32, i32* %12
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 %115
%117 = load double, double* %116
ret double %117
}

LLVM IR (-O2):
define double @proj3d(double %0, double %1, double %2, double %3, double %4, i32 %5) {
%7 = alloca [3 x double]
%8 = fmul double %0, 1.745320e-02
%9 = tail call double @cos(double %8)
%10 = tail call double @sin(double %8)
%11 = fmul double %1, 1.745320e-02
%12 = tail call double @sin(double %11)
%13 = tail call double @cos(double %11)
%14 = bitcast [3 x double]* %7 to i8*
%15 = fneg double %13
%16 = fmul double %10, %15
%17 = fmul double %9, %13
%18 = fmul double %10, %12
%19 = fneg double %12
%20 = fmul double %9, %19
%21 = insertelement <2 x double> poison, double %9, i64 0
%22 = insertelement <2 x double> %21, double %16, i64 1
%23 = insertelement <2 x double> poison, double %2, i64 0
%24 = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> zeroinitializer
%25 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %22, <2 x double> %24, <2 x double> zeroinitializer)
%26 = insertelement <2 x double> poison, double %10, i64 0
%27 = insertelement <2 x double> %26, double %17, i64 1
%28 = insertelement <2 x double> poison, double %3, i64 0
%29 = shufflevector <2 x double> %28, <2 x double> poison, <2 x i32> zeroinitializer
%30 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %29, <2 x double> %25)
%31 = insertelement <2 x double> poison, double %4, i64 0
%32 = insertelement <2 x double> %31, double %12, i64 1
%33 = insertelement <2 x double> <double 0.000000e+00, double poison>, double %4, i64 1
%34 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %32, <2 x double> %33, <2 x double> %30)
%35 = bitcast [3 x double]* %7 to <2 x double>*
store <2 x double> %34, <2 x double>* %35
%36 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
%37 = tail call double @llvm.fmuladd.f64(double %18, double %2, double 0.000000e+00)
%38 = tail call double @llvm.fmuladd.f64(double %20, double %3, double %37)
%39 = tail call double @llvm.fmuladd.f64(double %13, double %4, double %38)
store double %39, double* %36
%40 = sext i32 %5 to i64
%41 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 %40
%42 = load double, double* %41
ret double %42
}