#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 */
float M_PI;
float atan2(float, float);
int /*<<< orphan*/ rotateX(int, float, float *, float *, float *);
int /*<<< orphan*/ rotateY(int, float, float *, float *, float *);
float sqrt(float);
int projection_sphere_longlat(float x, float y, float dlongitude,
                              float dlatitude, float *longitude,
                              float *latitude) {
  float z, r2;
  int side;
  if (x < 0) {
    x += 1.125;
    side = 0;
  } else {
    x = -(x - 1.125);
    side = 1;
  }
  if (x * x + y * y > 1)
    return 0;
  if (side == 0)
    z = -sqrt(1 - x * x - y * y);
  else
    z = sqrt(1 - x * x - y * y);
  rotateX(1, -dlatitude * 180.0 / M_PI, &x, &y, &z);
  rotateY(1, dlongitude * 180.0 / M_PI, &x, &y, &z);
  r2 = sqrt(z * z + x * x);
  *latitude = atan2(r2, y);
  *latitude = 0.5 * M_PI - (*latitude);
  *longitude = atan2(x, -z);
  return 1;
}


x86 assembly (clang, -O0):
<projection_sphere_longlat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  %xmm3,-0x14(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    119b <projection_sphere_longlat+0x5b>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe7e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x0,-0x34(%rbp)
jmp    11d7 <projection_sphere_longlat+0x97>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe54(%rip),%xmm1
subsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x1,-0x34(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm2
movss  -0xc(%rbp),%xmm1
mulss  -0xc(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  0xe1d(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1210 <projection_sphere_longlat+0xd0>
movl   $0x0,-0x4(%rbp)
jmp    1413 <projection_sphere_longlat+0x2d3>
cmpl   $0x0,-0x34(%rbp)
jne    127c <projection_sphere_longlat+0x13c>
movss  -0x8(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm0,%xmm1
movss  0xddb(%rip),%xmm0
addss  %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1050 <sqrt@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
jmp    12cc <projection_sphere_longlat+0x18c>
movss  -0x8(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm0,%xmm1
movss  0xd79(%rip),%xmm0
addss  %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1050 <sqrt@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd26(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2cf3(%rip),%rax
movss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    $0x1,%edi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
call   1040 <rotateX@plt>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xce4(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2cb1(%rip),%rax
movss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    $0x1,%edi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
call   1060 <rotateY@plt>
movss  -0x2c(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1050 <sqrt@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
mov    0x2c47(%rip),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xc34(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x8(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
call   1030 <atan2@plt>
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<projection_sphere_longlat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movaps %xmm0,%xmm7
movss  0xea7(%rip),%xmm0
addss  %xmm7,%xmm0
xorps  0xeac(%rip),%xmm0
movss  %xmm1,0x10(%rsp)
movss  0xe92(%rip),%xmm4
addss  %xmm7,%xmm4
xorps  %xmm5,%xmm5
movaps %xmm7,%xmm6
cmpltss %xmm5,%xmm6
andps  %xmm6,%xmm4
andnps %xmm0,%xmm6
orps   %xmm4,%xmm6
movss  %xmm6,0xc(%rsp)
mulss  %xmm1,%xmm1
movaps %xmm6,%xmm0
mulss  %xmm6,%xmm0
addss  %xmm1,%xmm0
xor    %ebp,%ebp
ucomiss 0xe60(%rip),%xmm0
ja     1321 <projection_sphere_longlat+0x1e1>
mov    %rsi,%r15
movss  %xmm2,0x14(%rsp)
mulss  %xmm6,%xmm6
movss  0xe45(%rip),%xmm0
subss  %xmm6,%xmm0
subss  %xmm1,%xmm0
ucomiss %xmm5,%xmm0
mov    %rdi,0x18(%rsp)
jb     11db <projection_sphere_longlat+0x9b>
sqrtss %xmm0,%xmm0
jmp    11f4 <projection_sphere_longlat+0xb4>
movaps %xmm3,0x30(%rsp)
movaps %xmm7,0x20(%rsp)
call   1050 <sqrt@plt>
movaps 0x20(%rsp),%xmm7
movaps 0x30(%rsp),%xmm3
movaps 0xe15(%rip),%xmm1
movaps %xmm0,%xmm2
xorps  %xmm1,%xmm2
xorps  %xmm4,%xmm4
cmpltss %xmm4,%xmm7
andps  %xmm7,%xmm2
andnps %xmm0,%xmm7
orps   %xmm2,%xmm7
movss  %xmm7,0x8(%rsp)
xorps  %xmm1,%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
mulsd  0xdf6(%rip),%xmm0
mov    0x2db7(%rip),%r14
movss  (%r14),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    $0x1,%ebp
lea    0xc(%rsp),%rbx
lea    0x10(%rsp),%r12
lea    0x8(%rsp),%r13
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1040 <rotateX@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xda5(%rip),%xmm0
movss  (%r14),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1060 <rotateY@plt>
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
ucomiss 0xd4e(%rip),%xmm0
jb     12c6 <projection_sphere_longlat+0x186>
sqrtss %xmm0,%xmm0
jmp    12cb <projection_sphere_longlat+0x18b>
call   1050 <sqrt@plt>
movss  0x10(%rsp),%xmm1
call   1030 <atan2@plt>
movss  %xmm0,(%r15)
movss  (%r14),%xmm1
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm0,%xmm0
mulsd  0xd38(%rip),%xmm1
subsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%r15)
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
xorps  0xcfd(%rip),%xmm1
call   1030 <atan2@plt>
mov    0x18(%rsp),%rax
movss  %xmm0,(%rax)
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global float 0.000000e+00
define i32 @projection_sphere_longlat(float %0, float %1, float %2, float %3, float* %4, float* %5) {
%7 = alloca i32
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float*
%13 = alloca float*
%14 = alloca float
%15 = alloca float
%16 = alloca i32
store float %0, float* %8
store float %1, float* %9
store float %2, float* %10
store float %3, float* %11
store float* %4, float** %12
store float* %5, float** %13
%17 = load float, float* %8
%18 = fcmp olt float %17, 0.000000e+00
br i1 %18, label %19, label %24
19: ; preds = %6
%20 = load float, float* %8
%21 = fpext float %20 to double
%22 = fadd double %21, 1.125000e+00
%23 = fptrunc double %22 to float
store float %23, float* %8
store i32 0, i32* %16
br label %30
24: ; preds = %6
%25 = load float, float* %8
%26 = fpext float %25 to double
%27 = fsub double %26, 1.125000e+00
%28 = fneg double %27
%29 = fptrunc double %28 to float
store float %29, float* %8
store i32 1, i32* %16
br label %30
30: ; preds = %24, %19
%31 = load float, float* %8
%32 = load float, float* %8
%33 = load float, float* %9
%34 = load float, float* %9
%35 = fmul float %33, %34
%36 = call float @llvm.fmuladd.f32(float %31, float %32, float %35)
%37 = fcmp ogt float %36, 1.000000e+00
br i1 %37, label %38, label %39
38: ; preds = %30
store i32 0, i32* %7
br label %106
39: ; preds = %30
%40 = load i32, i32* %16
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %53
42: ; preds = %39
%43 = load float, float* %8
%44 = load float, float* %8
%45 = fneg float %43
%46 = call float @llvm.fmuladd.f32(float %45, float %44, float 1.000000e+00)
%47 = load float, float* %9
%48 = load float, float* %9
%49 = fneg float %47
%50 = call float @llvm.fmuladd.f32(float %49, float %48, float %46)
%51 = call float @sqrt(float %50)
%52 = fneg float %51
store float %52, float* %14
br label %63
53: ; preds = %39
%54 = load float, float* %8
%55 = load float, float* %8
%56 = fneg float %54
%57 = call float @llvm.fmuladd.f32(float %56, float %55, float 1.000000e+00)
%58 = load float, float* %9
%59 = load float, float* %9
%60 = fneg float %58
%61 = call float @llvm.fmuladd.f32(float %60, float %59, float %57)
%62 = call float @sqrt(float %61)
store float %62, float* %14
br label %63
63: ; preds = %53, %42
%64 = load float, float* %11
%65 = fneg float %64
%66 = fpext float %65 to double
%67 = fmul double %66, 1.800000e+02
%68 = load float, float* @M_PI
%69 = fpext float %68 to double
%70 = fdiv double %67, %69
%71 = fptrunc double %70 to float
%72 = call i32 @rotateX(i32 1, float %71, float* %8, float* %9, float* %14)
%73 = load float, float* %10
%74 = fpext float %73 to double
%75 = fmul double %74, 1.800000e+02
%76 = load float, float* @M_PI
%77 = fpext float %76 to double
%78 = fdiv double %75, %77
%79 = fptrunc double %78 to float
%80 = call i32 @rotateY(i32 1, float %79, float* %8, float* %9, float* %14)
%81 = load float, float* %14
%82 = load float, float* %14
%83 = load float, float* %8
%84 = load float, float* %8
%85 = fmul float %83, %84
%86 = call float @llvm.fmuladd.f32(float %81, float %82, float %85)
%87 = call float @sqrt(float %86)
store float %87, float* %15
%88 = load float, float* %15
%89 = load float, float* %9
%90 = call float @atan2(float %88, float %89)
%91 = load float*, float** %13
store float %90, float* %91
%92 = load float, float* @M_PI
%93 = fpext float %92 to double
%94 = load float*, float** %13
%95 = load float, float* %94
%96 = fpext float %95 to double
%97 = fneg double %96
%98 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %93, double %97)
%99 = fptrunc double %98 to float
%100 = load float*, float** %13
store float %99, float* %100
%101 = load float, float* %8
%102 = load float, float* %14
%103 = fneg float %102
%104 = call float @atan2(float %101, float %103)
%105 = load float*, float** %12
store float %104, float* %105
store i32 1, i32* %7
br label %106
106: ; preds = %63, %38
%107 = load i32, i32* %7
ret i32 %107
}

LLVM IR (-O2):
@M_PI = global float 0.000000e+00
define i32 @projection_sphere_longlat(float %0, float %1, float %2, float %3, float* nocapture writeonly %4, float* nocapture writeonly %5) {
%7 = alloca float
%8 = alloca float
%9 = alloca float
store float %1, float* %8
%10 = bitcast float* %9 to i8*
%11 = fcmp olt float %0, 0.000000e+00
%12 = fadd float %0, -1.125000e+00
%13 = fneg float %12
%14 = fadd float %0, 1.125000e+00
%15 = select i1 %11, float %14, float %13
store float %15, float* %7
%16 = fmul float %1, %1
%17 = tail call float @llvm.fmuladd.f32(float %15, float %15, float %16)
%18 = fcmp ogt float %17, 1.000000e+00
br i1 %18, label %59, label %19
19: ; preds = %6
%20 = fneg float %15
%21 = tail call float @llvm.fmuladd.f32(float %20, float %15, float 1.000000e+00)
%22 = fneg float %1
%23 = tail call float @llvm.fmuladd.f32(float %22, float %1, float %21)
%24 = tail call float @sqrt(float %23)
%25 = fneg float %24
%26 = select i1 %11, float %25, float %24
store float %26, float* %9
%27 = fneg float %3
%28 = fpext float %27 to double
%29 = fmul double %28, 1.800000e+02
%30 = load float, float* @M_PI
%31 = fpext float %30 to double
%32 = fdiv double %29, %31
%33 = fptrunc double %32 to float
%34 = call i32 @rotateX(i32 1, float %33, float* %7, float* %8, float* %9)
%35 = fpext float %2 to double
%36 = fmul double %35, 1.800000e+02
%37 = load float, float* @M_PI
%38 = fpext float %37 to double
%39 = fdiv double %36, %38
%40 = fptrunc double %39 to float
%41 = call i32 @rotateY(i32 1, float %40, float* %7, float* %8, float* %9)
%42 = load float, float* %9
%43 = load float, float* %7
%44 = fmul float %43, %43
%45 = call float @llvm.fmuladd.f32(float %42, float %42, float %44)
%46 = call float @sqrt(float %45)
%47 = load float, float* %8
%48 = call float @atan2(float %46, float %47)
store float %48, float* %5
%49 = load float, float* @M_PI
%50 = fpext float %49 to double
%51 = fpext float %48 to double
%52 = fneg double %51
%53 = call double @llvm.fmuladd.f64(double %50, double 5.000000e-01, double %52)
%54 = fptrunc double %53 to float
store float %54, float* %5
%55 = load float, float* %7
%56 = load float, float* %9
%57 = fneg float %56
%58 = call float @atan2(float %55, float %57)
store float %58, float* %4
br label %59
59: ; preds = %6, %19
%60 = phi i32 [ 1, %19 ], [ 0, %6 ]
ret i32 %60
}