#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);
double cos(double);
double sin(double);
double sqrt(double);
void RevOrtho(double R, double lam0, double phi0, int xx, int yy, double *lam,
              double *phi) {
  double rho, c, rhoq, x, y;
  x = xx;
  y = yy;
  rhoq = x * x + y * y;
  rho = sqrt(rhoq);
  if (rho > R) {
    *phi = 999.9;
    *lam = 999.9;
  } else if (rho > R / 100000.0) {
    c = asin(rho / R);
    *phi = asin(cos(c) * sin(phi0) + y * sin(c) * cos(phi0) / rho);
    *lam = lam0 +
           atan2(x * sin(c), rho * cos(phi0) * cos(c) - y * sin(phi0) * sin(c));
  } else {
    *phi = phi0;
    *lam = lam0;
  }
}


x86 assembly (clang, -O0):
<RevOrtho>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
mov    %esi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11f1 <RevOrtho+0xa1>
mov    -0x30(%rbp),%rax
movsd  0xe30(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0xe20(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    13d5 <RevOrtho+0x285>
movsd  -0x38(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xdfd(%rip),%xmm2
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    13b6 <RevOrtho+0x266>
movsd  -0x38(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
call   1050 <asin@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xb8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1060 <cos@plt>
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0xa8(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
divsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <asin@plt>
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x80(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm3
movaps %xmm0,%xmm4
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm4,%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
call   1030 <atan2@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13d0 <RevOrtho+0x280>
movsd  -0x18(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13d5 <RevOrtho+0x285>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RevOrtho>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x30(%rsp)
movapd %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %esi,%xmm1
movsd  %xmm1,0x28(%rsp)
mulsd  %xmm1,%xmm1
movsd  %xmm0,0x20(%rsp)
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     12d7 <RevOrtho+0x187>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
ucomisd %xmm2,%xmm1
ja     12f6 <RevOrtho+0x1a6>
movapd %xmm2,%xmm0
divsd  0xe43(%rip),%xmm0
ucomisd %xmm0,%xmm1
jbe    130d <RevOrtho+0x1bd>
movapd %xmm1,%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1050 <asin@plt>
movsd  %xmm0,0x10(%rsp)
call   1060 <cos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x38(%rsp)
movsd  (%rsp),%xmm0
call   1060 <cos@plt>
mulsd  0x38(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
addsd  %xmm1,%xmm0
call   1050 <asin@plt>
movsd  %xmm0,(%rbx)
movsd  0x10(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
call   1060 <cos@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <sin@plt>
movsd  (%rsp),%xmm1
mulsd  0x28(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x20(%rsp),%xmm0
call   1030 <atan2@plt>
movsd  0x30(%rsp),%xmm1
addsd  %xmm0,%xmm1
jmp    131c <RevOrtho+0x1cc>
movsd  %xmm2,0x8(%rsp)
call   1070 <sqrt@plt>
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm1
ucomisd %xmm2,%xmm1
jbe    11b1 <RevOrtho+0x61>
movabs $0x408f3f3333333333,%rax
3f 8f 40
mov    %rax,(%rbx)
movsd  0xcfd(%rip),%xmm1
jmp    131c <RevOrtho+0x1cc>
movsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x30(%rsp),%xmm1
movsd  %xmm1,(%r14)
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @RevOrtho(double %0, double %1, double %2, i32 %3, i32 %4, double* nocapture writeonly %5, double* nocapture writeonly %6) {
%8 = sitofp i32 %3 to double
%9 = sitofp i32 %4 to double
%10 = fmul double %9, %9
%11 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %10)
%12 = tail call double @sqrt(double %11)
%13 = fcmp ogt double %12, %0
br i1 %13, label %14, label %15
14: ; preds = %7
store double 0x408F3F3333333333, double* %6
br label %44
15: ; preds = %7
%16 = fdiv double %0, 1.000000e+05
%17 = fcmp ogt double %12, %16
br i1 %17, label %18, label %43
18: ; preds = %15
%19 = fdiv double %12, %0
%20 = tail call double @asin(double %19)
%21 = tail call double @cos(double %20)
%22 = tail call double @sin(double %2)
%23 = tail call double @sin(double %20)
%24 = fmul double %23, %9
%25 = tail call double @cos(double %2)
%26 = fmul double %24, %25
%27 = fdiv double %26, %12
%28 = tail call double @llvm.fmuladd.f64(double %21, double %22, double %27)
%29 = tail call double @asin(double %28)
store double %29, double* %6
%30 = tail call double @sin(double %20)
%31 = fmul double %30, %8
%32 = tail call double @cos(double %2)
%33 = fmul double %12, %32
%34 = tail call double @cos(double %20)
%35 = tail call double @sin(double %2)
%36 = tail call double @sin(double %20)
%37 = fneg double %35
%38 = fmul double %9, %37
%39 = fmul double %38, %36
%40 = tail call double @llvm.fmuladd.f64(double %33, double %34, double %39)
%41 = tail call double @atan2(double %31, double %40)
%42 = fadd double %41, %1
br label %44
43: ; preds = %15
store double %2, double* %6
br label %44
44: ; preds = %18, %43, %14
%45 = phi double [ %42, %18 ], [ %1, %43 ], [ 0x408F3F3333333333, %14 ]
store double %45, double* %5
ret void
}