#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 __ev_fabs(double);
int /*<<< orphan*/ wgs2gcj(double, double, double *, double *);
void gcj2wgs_exact(double gcjLat, double gcjLng, double *wgsLat,
                   double *wgsLng) {
  double initDelta = 0.01;
  double threshold = 0.000001;
  double dLat, dLng, mLat, mLng, pLat, pLng;
  dLat = dLng = initDelta;
  mLat = gcjLat - dLat;
  mLng = gcjLng - dLng;
  pLat = gcjLat + dLat;
  pLng = gcjLng + dLng;
  int i;
  for (i = 0; i < 30; i++) {
    *wgsLat = (mLat + pLat) / 2;
    *wgsLng = (mLng + pLng) / 2;
    double tmpLat, tmpLng;
    wgs2gcj(*wgsLat, *wgsLng, &tmpLat, &tmpLng);
    dLat = tmpLat - gcjLat;
    dLng = tmpLng - gcjLng;
    if ((__ev_fabs(dLat) < threshold) && (__ev_fabs(dLng) < threshold)) {
      return;
    }
    if (dLat > 0) {
      pLat = *wgsLat;
    } else {
      mLat = *wgsLat;
    }
    if (dLng > 0) {
      pLng = *wgsLng;
    } else {
      mLng = *wgsLng;
    }
  }
}


x86 assembly (clang, -O0):
<gcj2wgs_exact>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  0xec3(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xeae(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x1e,-0x64(%rbp)
jge    12dc <gcj2wgs_exact+0x1bc>
movsd  -0x48(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  0xe4b(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  0xe2d(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
lea    -0x70(%rbp),%rdi
lea    -0x78(%rbp),%rsi
call   1040 <wgs2gcj@plt>
movsd  -0x70(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x78(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <__ev_fabs@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1267 <gcj2wgs_exact+0x147>
movsd  -0x40(%rbp),%xmm0
call   1030 <__ev_fabs@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1267 <gcj2wgs_exact+0x147>
jmp    12dc <gcj2wgs_exact+0x1bc>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    128b <gcj2wgs_exact+0x16b>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1298 <gcj2wgs_exact+0x178>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12bc <gcj2wgs_exact+0x19c>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    12c9 <gcj2wgs_exact+0x1a9>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12ce <gcj2wgs_exact+0x1ae>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11a9 <gcj2wgs_exact+0x89>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gcj2wgs_exact>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  0xec6(%rip),%xmm2
movapd %xmm0,%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,(%rsp)
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0xeaf(%rip),%xmm3
movsd  %xmm0,0x18(%rsp)
movapd %xmm0,%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm1,0x20(%rsp)
addsd  %xmm1,%xmm3
mov    $0x1e,%ebp
lea    0x38(%rsp),%r15
lea    0x30(%rsp),%r12
jmp    11c9 <gcj2wgs_exact+0xa9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorpd  %xmm2,%xmm2
cmpltsd %xmm5,%xmm2
andpd  %xmm2,%xmm1
andnpd 0x40(%rsp),%xmm2
orpd   %xmm1,%xmm2
xorpd  %xmm1,%xmm1
cmpltsd %xmm4,%xmm1
andpd  %xmm1,%xmm0
andnpd %xmm3,%xmm1
orpd   %xmm0,%xmm1
movapd %xmm1,%xmm3
add    $0xffffffff,%ebp
je     129f <gcj2wgs_exact+0x17f>
movsd  (%rsp),%xmm0
movapd %xmm2,0x40(%rsp)
addsd  %xmm2,%xmm0
movsd  0xe30(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm1
movapd %xmm3,0x50(%rsp)
addsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,(%r14)
movsd  (%rbx),%xmm0
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <wgs2gcj@plt>
movsd  0x38(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
subsd  0x20(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x28(%rsp)
call   1030 <__ev_fabs@plt>
movsd  0xdd7(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1260 <gcj2wgs_exact+0x140>
movsd  0x10(%rsp),%xmm0
call   1030 <__ev_fabs@plt>
movsd  0xdbe(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     129f <gcj2wgs_exact+0x17f>
movsd  0x10(%rsp),%xmm4
xorpd  %xmm0,%xmm0
movsd  0x28(%rsp),%xmm5
ucomisd %xmm0,%xmm5
movsd  (%rbx),%xmm1
ja     127f <gcj2wgs_exact+0x15f>
movsd  %xmm1,(%rsp)
ucomisd %xmm0,%xmm4
movsd  (%r14),%xmm0
movapd 0x50(%rsp),%xmm3
ja     1190 <gcj2wgs_exact+0x70>
movsd  %xmm0,0x8(%rsp)
jmp    1190 <gcj2wgs_exact+0x70>
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @gcj2wgs_exact(double %0, double %1, double* nocapture %2, double* nocapture %3) {
%5 = alloca double
%6 = alloca double
%7 = fadd double %0, -1.000000e-02
%8 = fadd double %1, -1.000000e-02
%9 = fadd double %0, 1.000000e-02
%10 = fadd double %1, 1.000000e-02
%11 = bitcast double* %5 to i8*
%12 = bitcast double* %6 to i8*
br label %13
13: ; preds = %4, %34
%14 = phi i32 [ 0, %4 ], [ %43, %34 ]
%15 = phi double [ %10, %4 ], [ %42, %34 ]
%16 = phi double [ %9, %4 ], [ %38, %34 ]
%17 = phi double [ %8, %4 ], [ %41, %34 ]
%18 = phi double [ %7, %4 ], [ %37, %34 ]
%19 = fadd double %18, %16
%20 = fmul double %19, 5.000000e-01
store double %20, double* %2
%21 = fadd double %17, %15
%22 = fmul double %21, 5.000000e-01
store double %22, double* %3
%23 = load double, double* %2
%24 = call i32 @wgs2gcj(double %23, double %22, double* %5, double* %6)
%25 = load double, double* %5
%26 = fsub double %25, %0
%27 = load double, double* %6
%28 = fsub double %27, %1
%29 = call double @__ev_fabs(double %26)
%30 = fcmp olt double %29, 0x3EB0C6F7A0B5ED8D
br i1 %30, label %31, label %34
31: ; preds = %13
%32 = call double @__ev_fabs(double %28)
%33 = fcmp olt double %32, 0x3EB0C6F7A0B5ED8D
br i1 %33, label %45, label %34
34: ; preds = %31, %13
%35 = fcmp ogt double %26, 0.000000e+00
%36 = load double, double* %2
%37 = select i1 %35, double %18, double %36
%38 = select i1 %35, double %36, double %16
%39 = fcmp ogt double %28, 0.000000e+00
%40 = load double, double* %3
%41 = select i1 %39, double %17, double %40
%42 = select i1 %39, double %40, double %15
%43 = add nuw nsw i32 %14, 1
%44 = icmp eq i32 %43, 30
br i1 %44, label %46, label %13
45: ; preds = %31
br label %46
46: ; preds = %34, %45
ret void
}