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


x86 assembly (clang, -O0):
<LMNf2sph>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rax,-0x50(%rbp)
sub    $0x5,%rax
ja     1269 <LMNf2sph+0x149>
mov    -0x50(%rbp),%rax
lea    0xeaa(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0xe91(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1287 <LMNf2sph+0x167>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1287 <LMNf2sph+0x167>
movsd  0xe43(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1287 <LMNf2sph+0x167>
movsd  0xe18(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe06(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1287 <LMNf2sph+0x167>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xddb(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1287 <LMNf2sph+0x167>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xda6(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1287 <LMNf2sph+0x167>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <asin@plt>
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LMNf2sph>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
cmp    $0x5,%edi
ja     1166 <LMNf2sph+0x46>
mov    %edi,%eax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
movaps %xmm0,%xmm3
jmp    *%rax
xorps  0xeb2(%rip),%xmm2
jmp    1181 <LMNf2sph+0x61>
xorps  0xea9(%rip),%xmm1
jmp    1172 <LMNf2sph+0x52>
movaps 0xea0(%rip),%xmm3
xorps  %xmm3,%xmm0
xorps  %xmm3,%xmm1
movaps %xmm0,%xmm3
jmp    1187 <LMNf2sph+0x67>
xorps  0xe8e(%rip),%xmm0
movaps %xmm1,%xmm3
movaps %xmm0,%xmm1
jmp    1187 <LMNf2sph+0x67>
xorps  0xe7f(%rip),%xmm0
movaps %xmm2,%xmm3
movaps %xmm0,%xmm2
movaps %xmm1,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
movaps %xmm2,%xmm0
call   1040 <asin@plt>
movsd  %xmm0,(%rbx)
movaps 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,(%r14)
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @LMNf2sph(double %0, double %1, double %2, i32 %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%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 double %2, double* %9
store i32 %3, i32* %10
store double* %4, double** %11
store double* %5, double** %12
%16 = load i32, i32* %10
switch i32 %16, label %47 [
i32 0, label %17
i32 1, label %22
i32 2, label %26
i32 3, label %31
i32 4, label %37
i32 5, label %42
]
17: ; preds = %6
%18 = load double, double* %9
%19 = fmul double -1.000000e+00, %18
store double %19, double* %13
%20 = load double, double* %8
store double %20, double* %14
%21 = load double, double* %7
store double %21, double* %15
br label %51
22: ; preds = %6
%23 = load double, double* %7
store double %23, double* %13
%24 = load double, double* %8
store double %24, double* %14
%25 = load double, double* %9
store double %25, double* %15
br label %51
26: ; preds = %6
%27 = load double, double* %8
%28 = fmul double -1.000000e+00, %27
store double %28, double* %13
%29 = load double, double* %7
store double %29, double* %14
%30 = load double, double* %9
store double %30, double* %15
br label %51
31: ; preds = %6
%32 = load double, double* %7
%33 = fmul double -1.000000e+00, %32
store double %33, double* %13
%34 = load double, double* %8
%35 = fmul double -1.000000e+00, %34
store double %35, double* %14
%36 = load double, double* %9
store double %36, double* %15
br label %51
37: ; preds = %6
%38 = load double, double* %8
store double %38, double* %13
%39 = load double, double* %7
%40 = fmul double -1.000000e+00, %39
store double %40, double* %14
%41 = load double, double* %9
store double %41, double* %15
br label %51
42: ; preds = %6
%43 = load double, double* %9
store double %43, double* %13
%44 = load double, double* %8
store double %44, double* %14
%45 = load double, double* %7
%46 = fmul double -1.000000e+00, %45
store double %46, double* %15
br label %51
47: ; preds = %6
%48 = load double, double* %7
store double %48, double* %13
%49 = load double, double* %8
store double %49, double* %14
%50 = load double, double* %9
store double %50, double* %15
br label %51
51: ; preds = %47, %42, %37, %31, %26, %22, %17
%52 = load double, double* %15
%53 = call double @asin(double %52)
%54 = load double*, double** %12
store double %53, double* %54
%55 = load double, double* %14
%56 = load double, double* %13
%57 = call double @atan2(double %55, double %56)
%58 = load double*, double** %11
store double %57, double* %58
ret i32 0
}

LLVM IR (-O2):
define i32 @LMNf2sph(double %0, double %1, double %2, i32 %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
switch i32 %3, label %18 [
i32 0, label %7
i32 5, label %16
i32 2, label %9
i32 3, label %11
i32 4, label %14
]
7: ; preds = %6
%8 = fneg double %2
br label %18
9: ; preds = %6
%10 = fneg double %1
br label %18
11: ; preds = %6
%12 = fneg double %0
%13 = fneg double %1
br label %18
14: ; preds = %6
%15 = fneg double %0
br label %18
16: ; preds = %6
%17 = fneg double %0
br label %18
18: ; preds = %6, %16, %14, %11, %9, %7
%19 = phi double [ %2, %16 ], [ %1, %14 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %0, %6 ]
%20 = phi double [ %1, %16 ], [ %15, %14 ], [ %13, %11 ], [ %0, %9 ], [ %1, %7 ], [ %1, %6 ]
%21 = phi double [ %17, %16 ], [ %2, %14 ], [ %2, %11 ], [ %2, %9 ], [ %0, %7 ], [ %2, %6 ]
%22 = tail call double @asin(double %21)
store double %22, double* %5
%23 = tail call double @atan2(double %20, double %19)
store double %23, double* %4
ret i32 0
}