#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 const fabs(double);
int /*<<< orphan*/ wgs2gcj(double, double, double *, double *);
void gcj2wgs_exact(double gcjLat, double gcjLng, double *wgsLat,
                   double *wgsLng) {
  const double initDelta = 0.01;
  const double threshold = 0.000001;
  double dLat = initDelta, dLng = initDelta;
  double mLat = gcjLat - dLat, mLng = gcjLng - dLng;
  double 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 ((fabs(dLat) < threshold) && (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  0xebb(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xea1(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe94(%rip),%xmm0
movsd  %xmm0,-0x40(%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    12ed <gcj2wgs_exact+0x1cd>
movsd  -0x48(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  0xe40(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  0xe22(%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 <fabs@plt>
movaps %xmm0,%xmm1
movsd  0xdbe(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1278 <gcj2wgs_exact+0x158>
movsd  -0x40(%rbp),%xmm0
call   1030 <fabs@plt>
movaps %xmm0,%xmm1
movsd  0xd9f(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1278 <gcj2wgs_exact+0x158>
jmp    12ed <gcj2wgs_exact+0x1cd>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    129c <gcj2wgs_exact+0x17c>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    12a9 <gcj2wgs_exact+0x189>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12cd <gcj2wgs_exact+0x1ad>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    12da <gcj2wgs_exact+0x1ba>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12df <gcj2wgs_exact+0x1bf>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11b4 <gcj2wgs_exact+0x94>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gcj2wgs_exact>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  0xed6(%rip),%xmm2
movapd %xmm0,%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,(%rsp)
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0xebf(%rip),%xmm3
movsd  %xmm0,0x10(%rsp)
movapd %xmm0,%xmm4
addsd  %xmm3,%xmm4
movsd  %xmm1,0x18(%rsp)
addsd  %xmm1,%xmm3
mov    $0x1e,%ebp
lea    0x28(%rsp),%r15
lea    0x20(%rsp),%r12
jmp    11bb <gcj2wgs_exact+0xab>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorpd  %xmm4,%xmm4
cmpltsd %xmm1,%xmm4
andpd  %xmm4,%xmm3
andnpd 0x30(%rsp),%xmm4
orpd   %xmm3,%xmm4
xorpd  %xmm1,%xmm1
cmpltsd %xmm0,%xmm1
andpd  %xmm1,%xmm2
andnpd 0x40(%rsp),%xmm1
orpd   %xmm2,%xmm1
movapd %xmm1,%xmm3
add    $0xffffffff,%ebp
je     1273 <gcj2wgs_exact+0x163>
movsd  (%rsp),%xmm0
movapd %xmm4,0x30(%rsp)
addsd  %xmm4,%xmm0
movsd  0xe3e(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm1
movapd %xmm3,0x40(%rsp)
addsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,(%r14)
movsd  (%rbx),%xmm0
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <wgs2gcj@plt>
movsd  0xe0e(%rip),%xmm4
movapd 0xe0e(%rip),%xmm3
movsd  0x28(%rsp),%xmm1
subsd  0x10(%rsp),%xmm1
movsd  0x20(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
movapd %xmm1,%xmm2
andpd  %xmm3,%xmm2
ucomisd %xmm2,%xmm4
jbe    1246 <gcj2wgs_exact+0x136>
movapd %xmm0,%xmm2
andpd  %xmm3,%xmm2
ucomisd %xmm2,%xmm4
ja     1273 <gcj2wgs_exact+0x163>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
movsd  (%rbx),%xmm3
ja     1259 <gcj2wgs_exact+0x149>
movsd  %xmm3,(%rsp)
ucomisd %xmm2,%xmm0
movsd  (%r14),%xmm2
ja     1180 <gcj2wgs_exact+0x70>
movsd  %xmm2,0x8(%rsp)
jmp    1180 <gcj2wgs_exact+0x70>
add    $0x50,%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
store double 1.000000e-02, double* %11
store double 1.000000e-02, double* %12
%20 = load double, double* %5
%21 = load double, double* %11
%22 = fsub double %20, %21
store double %22, double* %13
%23 = load double, double* %6
%24 = load double, double* %12
%25 = fsub double %23, %24
store double %25, double* %14
%26 = load double, double* %5
%27 = load double, double* %11
%28 = fadd double %26, %27
store double %28, double* %15
%29 = load double, double* %6
%30 = load double, double* %12
%31 = fadd double %29, %30
store double %31, double* %16
store i32 0, i32* %17
br label %32
32: ; preds = %84, %4
%33 = load i32, i32* %17
%34 = icmp slt i32 %33, 30
br i1 %34, label %35, label %87
35: ; preds = %32
%36 = load double, double* %13
%37 = load double, double* %15
%38 = fadd double %36, %37
%39 = fdiv double %38, 2.000000e+00
%40 = load double*, double** %7
store double %39, double* %40
%41 = load double, double* %14
%42 = load double, double* %16
%43 = fadd double %41, %42
%44 = fdiv double %43, 2.000000e+00
%45 = load double*, double** %8
store double %44, double* %45
%46 = load double*, double** %7
%47 = load double, double* %46
%48 = load double*, double** %8
%49 = load double, double* %48
%50 = call i32 @wgs2gcj(double %47, double %49, double* %18, double* %19)
%51 = load double, double* %18
%52 = load double, double* %5
%53 = fsub double %51, %52
store double %53, double* %11
%54 = load double, double* %19
%55 = load double, double* %6
%56 = fsub double %54, %55
store double %56, double* %12
%57 = load double, double* %11
%58 = call double @fabs(double %57)
%59 = fcmp olt double %58, 0x3EB0C6F7A0B5ED8D
br i1 %59, label %60, label %65
60: ; preds = %35
%61 = load double, double* %12
%62 = call double @fabs(double %61)
%63 = fcmp olt double %62, 0x3EB0C6F7A0B5ED8D
br i1 %63, label %64, label %65
64: ; preds = %60
br label %87
65: ; preds = %60, %35
%66 = load double, double* %11
%67 = fcmp ogt double %66, 0.000000e+00
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = load double*, double** %7
%70 = load double, double* %69
store double %70, double* %15
br label %74
71: ; preds = %65
%72 = load double*, double** %7
%73 = load double, double* %72
store double %73, double* %13
br label %74
74: ; preds = %71, %68
%75 = load double, double* %12
%76 = fcmp ogt double %75, 0.000000e+00
br i1 %76, label %77, label %80
77: ; preds = %74
%78 = load double*, double** %8
%79 = load double, double* %78
store double %79, double* %16
br label %83
80: ; preds = %74
%81 = load double*, double** %8
%82 = load double, double* %81
store double %82, double* %14
br label %83
83: ; preds = %80, %77
br label %84
84: ; preds = %83
%85 = load i32, i32* %17
%86 = add nsw i32 %85, 1
store i32 %86, i32* %17
br label %32
87: ; preds = %64, %32
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 @llvm.fabs.f64(double %26)
%30 = fcmp olt double %29, 0x3EB0C6F7A0B5ED8D
%31 = call double @llvm.fabs.f64(double %28)
%32 = fcmp olt double %31, 0x3EB0C6F7A0B5ED8D
%33 = select i1 %30, i1 %32, i1 false
br i1 %33, label %45, label %34
34: ; preds = %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 = %13
br label %46
46: ; preds = %34, %45
ret void
}