#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);
int /*<<< orphan*/ quadcube_getface(double, double, int *);
double sin(double);
int sph2LMN(double lon, double lat, int *face, double *L, double *M,
            double *N) {
  double l, m, n;
  quadcube_getface(lon, lat, face);
  l = cos(lat) * cos(lon);
  m = cos(lat) * sin(lon);
  n = sin(lat);
  switch (*face) {
  case 0:
    *M = m;
    *N = -1 * l;
    *L = n;
    break;
  case 1:
    *M = m;
    *N = n;
    *L = l;
    break;
  case 2:
    *M = -1 * l;
    *N = n;
    *L = m;
    break;
  case 3:
    *M = -1 * m;
    *N = n;
    *L = -1 * l;
    break;
  case 4:
    *M = l;
    *N = n;
    *L = -1 * m;
    break;
  case 5:
    *M = m;
    *N = l;
    *L = -1 * n;
    break;
  default:
    *M = m;
    *N = n;
    *L = l;
  }
  return (0);
}


x86 assembly (clang, -O0):
<sph2LMN>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rdi
call   1050 <quadcube_getface@plt>
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %rax,-0x50(%rbp)
sub    $0x5,%rax
ja     1328 <sph2LMN+0x1f8>
mov    -0x50(%rbp),%rax
lea    0xe21(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xdfb(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    134f <sph2LMN+0x21f>
movsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    134f <sph2LMN+0x21f>
movsd  0xda8(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    134f <sph2LMN+0x21f>
movsd  0xd74(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xd52(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    134f <sph2LMN+0x21f>
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xd1e(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    134f <sph2LMN+0x21f>
movsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xcea(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    134f <sph2LMN+0x21f>
movsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sph2LMN>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,(%rsp)
call   1050 <quadcube_getface@plt>
movsd  0x28(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x30(%rsp)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x30(%rsp),%xmm0
movapd %xmm0,(%rsp)
movsd  0x28(%rsp),%xmm0
call   1030 <sin@plt>
mov    (%rbx),%eax
cmp    $0x5,%rax
ja     11e6 <sph2LMN+0xb6>
lea    0xe52(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movaps (%rsp),%xmm1
movsd  %xmm1,(%r12)
movaps 0x10(%rsp),%xmm1
xorps  0xe23(%rip),%xmm1
movlps %xmm1,(%r15)
jmp    126b <sph2LMN+0x13b>
movaps (%rsp),%xmm1
movsd  %xmm1,(%r12)
movsd  %xmm0,(%r15)
movaps 0x10(%rsp),%xmm0
jmp    126b <sph2LMN+0x13b>
movaps 0x10(%rsp),%xmm1
xorps  0xdf8(%rip),%xmm1
movlps %xmm1,(%r12)
movsd  %xmm0,(%r15)
movaps (%rsp),%xmm0
jmp    126b <sph2LMN+0x13b>
movaps 0xde1(%rip),%xmm1
movaps (%rsp),%xmm2
xorps  %xmm1,%xmm2
movlps %xmm2,(%r12)
movsd  %xmm0,(%r15)
movaps 0x10(%rsp),%xmm0
xorps  %xmm1,%xmm0
jmp    126b <sph2LMN+0x13b>
movaps 0x10(%rsp),%xmm1
movsd  %xmm1,(%r12)
movsd  %xmm0,(%r15)
movaps (%rsp),%xmm0
jmp    1264 <sph2LMN+0x134>
movaps (%rsp),%xmm1
movsd  %xmm1,(%r12)
movaps 0x10(%rsp),%xmm1
movsd  %xmm1,(%r15)
xorps  0xd95(%rip),%xmm0
movsd  %xmm0,(%r14)
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @sph2LMN(double %0, double %1, i32* %2, double* %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca i32*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double %0, double* %7
store double %1, double* %8
store i32* %2, i32** %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%16 = load double, double* %7
%17 = load double, double* %8
%18 = load i32*, i32** %9
%19 = call i32 @quadcube_getface(double %16, double %17, i32* %18)
%20 = load double, double* %8
%21 = call double @cos(double %20)
%22 = load double, double* %7
%23 = call double @cos(double %22)
%24 = fmul double %21, %23
store double %24, double* %13
%25 = load double, double* %8
%26 = call double @cos(double %25)
%27 = load double, double* %7
%28 = call double @sin(double %27)
%29 = fmul double %26, %28
store double %29, double* %14
%30 = load double, double* %8
%31 = call double @sin(double %30)
store double %31, double* %15
%32 = load i32*, i32** %9
%33 = load i32, i32* %32
switch i32 %33, label %82 [
i32 0, label %34
i32 1, label %42
i32 2, label %49
i32 3, label %57
i32 4, label %66
i32 5, label %74
]
34: ; preds = %6
%35 = load double, double* %14
%36 = load double*, double** %11
store double %35, double* %36
%37 = load double, double* %13
%38 = fmul double -1.000000e+00, %37
%39 = load double*, double** %12
store double %38, double* %39
%40 = load double, double* %15
%41 = load double*, double** %10
store double %40, double* %41
br label %89
42: ; preds = %6
%43 = load double, double* %14
%44 = load double*, double** %11
store double %43, double* %44
%45 = load double, double* %15
%46 = load double*, double** %12
store double %45, double* %46
%47 = load double, double* %13
%48 = load double*, double** %10
store double %47, double* %48
br label %89
49: ; preds = %6
%50 = load double, double* %13
%51 = fmul double -1.000000e+00, %50
%52 = load double*, double** %11
store double %51, double* %52
%53 = load double, double* %15
%54 = load double*, double** %12
store double %53, double* %54
%55 = load double, double* %14
%56 = load double*, double** %10
store double %55, double* %56
br label %89
57: ; preds = %6
%58 = load double, double* %14
%59 = fmul double -1.000000e+00, %58
%60 = load double*, double** %11
store double %59, double* %60
%61 = load double, double* %15
%62 = load double*, double** %12
store double %61, double* %62
%63 = load double, double* %13
%64 = fmul double -1.000000e+00, %63
%65 = load double*, double** %10
store double %64, double* %65
br label %89
66: ; preds = %6
%67 = load double, double* %13
%68 = load double*, double** %11
store double %67, double* %68
%69 = load double, double* %15
%70 = load double*, double** %12
store double %69, double* %70
%71 = load double, double* %14
%72 = fmul double -1.000000e+00, %71
%73 = load double*, double** %10
store double %72, double* %73
br label %89
74: ; preds = %6
%75 = load double, double* %14
%76 = load double*, double** %11
store double %75, double* %76
%77 = load double, double* %13
%78 = load double*, double** %12
store double %77, double* %78
%79 = load double, double* %15
%80 = fmul double -1.000000e+00, %79
%81 = load double*, double** %10
store double %80, double* %81
br label %89
82: ; preds = %6
%83 = load double, double* %14
%84 = load double*, double** %11
store double %83, double* %84
%85 = load double, double* %15
%86 = load double*, double** %12
store double %85, double* %86
%87 = load double, double* %13
%88 = load double*, double** %10
store double %87, double* %88
br label %89
89: ; preds = %82, %74, %66, %57, %49, %42, %34
ret i32 0
}

LLVM IR (-O2):
define i32 @sph2LMN(double %0, double %1, i32* %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = tail call i32 @quadcube_getface(double %0, double %1, i32* %2)
%8 = tail call double @cos(double %1)
%9 = tail call double @cos(double %0)
%10 = fmul double %8, %9
%11 = tail call double @cos(double %1)
%12 = tail call double @sin(double %0)
%13 = fmul double %11, %12
%14 = tail call double @sin(double %1)
%15 = load i32, i32* %2
switch i32 %15, label %28 [
i32 0, label %16
i32 1, label %18
i32 2, label %19
i32 3, label %21
i32 4, label %24
i32 5, label %26
]
16: ; preds = %6
store double %13, double* %4
%17 = fneg double %10
store double %17, double* %5
br label %29
18: ; preds = %6
store double %13, double* %4
store double %14, double* %5
br label %29
19: ; preds = %6
%20 = fneg double %10
store double %20, double* %4
store double %14, double* %5
br label %29
21: ; preds = %6
%22 = fneg double %13
store double %22, double* %4
store double %14, double* %5
%23 = fneg double %10
br label %29
24: ; preds = %6
store double %10, double* %4
store double %14, double* %5
%25 = fneg double %13
br label %29
26: ; preds = %6
store double %13, double* %4
store double %10, double* %5
%27 = fneg double %14
br label %29
28: ; preds = %6
store double %13, double* %4
store double %14, double* %5
br label %29
29: ; preds = %28, %26, %24, %21, %19, %18, %16
%30 = phi double [ %10, %28 ], [ %27, %26 ], [ %25, %24 ], [ %23, %21 ], [ %13, %19 ], [ %10, %18 ], [ %14, %16 ]
store double %30, double* %3
ret i32 0
}