#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 Ten90CprDlon(double, int, int);
double Ten90CprMod(int, int);
double fabs(double);
scalar_t__ floor(double);
scalar_t__ trunc(double);
int Ten90DecodeCPRRelative(double reference_lat, double reference_lon, int odd,
                           int surface, int cpr_lat, int cpr_lon,
                           double *decoded_lat, double *decoded_lon) {
  double AirDlat;
  double AirDlon;
  double lat;
  double lon;
  double rlon, rlat;
  int j, m;
  if (odd) {
    AirDlat = (surface ? 90.0 : 360.0) / 59.0;
    lat = cpr_lat;
    lon = cpr_lon;
  } else {
    AirDlat = (surface ? 90.0 : 360.0) / 60.0;
    lat = cpr_lat;
    lon = cpr_lon;
  }
  j = (int)(floor(reference_lat / AirDlat) +
            trunc(0.5 +
                  Ten90CprMod((int)reference_lat, (int)AirDlat) / AirDlat -
                  lat / 131072));
  rlat = AirDlat * (j + lat / 131072);
  if (rlat >= 270) {
    rlat -= 360;
  }
  if (fabs(rlat - reference_lat) > (AirDlat / 2)) {
    return -1;
  }
  AirDlon = Ten90CprDlon(rlat, odd, surface);
  m = (int)(floor(reference_lon / AirDlon) +
            trunc(0.5 +
                  Ten90CprMod((int)reference_lon, (int)AirDlon) / AirDlon -
                  lon / 131072));
  rlon = AirDlon * (m + lon / 131072);
  if (rlon > 180) {
    rlon -= 360;
  }
  if (fabs(rlon - reference_lon) > (AirDlon / 2)) {
    return -1;
  }
  *decoded_lat = rlat;
  *decoded_lon = rlon;
  return 0;
}


x86 assembly (clang, -O0):
<Ten90DecodeCPRRelative>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
mov    %esi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    %ecx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11d2 <Ten90DecodeCPRRelative+0x92>
mov    -0x20(%rbp),%eax
movsd  0xe8a(%rip),%xmm0
movsd  0xe8a(%rip),%xmm1
movsd  %xmm1,-0x80(%rbp)
cmp    $0x0,%eax
movsd  %xmm0,-0x78(%rbp)
jne    11a3 <Ten90DecodeCPRRelative+0x63>
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  0xe68(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    123b <Ten90DecodeCPRRelative+0xfb>
mov    -0x20(%rbp),%eax
movsd  0xe2b(%rip),%xmm0
movsd  0xe2b(%rip),%xmm1
movsd  %xmm1,-0x90(%rbp)
ff
cmp    $0x0,%eax
movsd  %xmm0,-0x88(%rbp)
ff
jne    120e <Ten90DecodeCPRRelative+0xce>
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  0xde2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
call   1060 <floor@plt>
mov    %rax,-0x98(%rbp)
cvttsd2si -0x10(%rbp),%edi
cvttsd2si -0x40(%rbp),%esi
call   1040 <Ten90CprMod@plt>
movaps %xmm0,%xmm1
divsd  -0x40(%rbp),%xmm1
movsd  0xdc0(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  0xda7(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
call   1050 <trunc@plt>
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x6c(%rbp)
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x6c(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movsd  0xd73(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  0xd4d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     12f3 <Ten90DecodeCPRRelative+0x1b3>
movsd  -0x68(%rbp),%xmm0
movsd  0xd26(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xd4c(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  0xd23(%rip),%xmm2
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    132f <Ten90DecodeCPRRelative+0x1ef>
movl   $0xffffffff,-0x4(%rbp)
jmp    1459 <Ten90DecodeCPRRelative+0x319>
movsd  -0x68(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <Ten90CprDlon@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
call   1060 <floor@plt>
mov    %rax,-0xa0(%rbp)
cvttsd2si -0x18(%rbp),%edi
cvttsd2si -0x48(%rbp),%esi
call   1040 <Ten90CprMod@plt>
movaps %xmm0,%xmm1
divsd  -0x48(%rbp),%xmm1
movsd  0xcb7(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  0xc9e(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
call   1050 <trunc@plt>
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm0
cvtsi2sdl -0x70(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movsd  0xc6a(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xc64(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    13fc <Ten90DecodeCPRRelative+0x2bc>
movsd  -0x60(%rbp),%xmm0
movsd  0xc1d(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movaps 0xc43(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xc1a(%rip),%xmm2
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1438 <Ten90DecodeCPRRelative+0x2f8>
movl   $0xffffffff,-0x4(%rbp)
jmp    1459 <Ten90DecodeCPRRelative+0x319>
movsd  -0x68(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Ten90DecodeCPRRelative>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x30(%rsp)
mov    %r8,%r15
mov    %ecx,%r12d
mov    %esi,%r14d
mov    %edi,%ebx
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x20(%rsp)
xor    %eax,%eax
test   %esi,%esi
sete   %al
test   %edi,%edi
lea    0xe86(%rip),%rcx
lea    0xe8f(%rip),%rsi
cmove  %rcx,%rsi
movsd  (%rsi,%rax,8),%xmm1
movsd  %xmm1,0x10(%rsp)
cvtsi2sd %edx,%xmm2
movsd  %xmm2,0x8(%rsp)
divsd  %xmm1,%xmm0
call   1060 <floor@plt>
mov    %rax,%rbp
cvttsd2si 0x20(%rsp),%edi
cvttsd2si 0x10(%rsp),%esi
call   1040 <Ten90CprMod@plt>
divsd  0x10(%rsp),%xmm0
addsd  0xe6b(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0xe65(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
subsd  %xmm1,%xmm0
call   1050 <trunc@plt>
add    %eax,%ebp
xorps  %xmm2,%xmm2
cvtsi2sd %ebp,%xmm2
addsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe3d(%rip),%xmm1
addsd  %xmm2,%xmm1
movsd  0xe39(%rip),%xmm0
cmpnlesd %xmm2,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm1,%xmm0
orpd   %xmm2,%xmm0
movapd %xmm0,%xmm1
subsd  0x20(%rsp),%xmm1
andpd  0xdee(%rip),%xmm1
movapd %xmm3,%xmm2
mulsd  0xdf2(%rip),%xmm2
mov    $0xffffffff,%r13d
ucomisd %xmm2,%xmm1
ja     1341 <Ten90DecodeCPRRelative+0x201>
xorps  %xmm1,%xmm1
cvtsi2sd %r12d,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm0,0x20(%rsp)
mov    %ebx,%edi
mov    %r14d,%esi
call   1030 <Ten90CprDlon@plt>
movapd %xmm0,%xmm1
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
divsd  %xmm1,%xmm0
call   1060 <floor@plt>
mov    %rax,%rbx
cvttsd2si 0x18(%rsp),%edi
cvttsd2si 0x10(%rsp),%esi
call   1040 <Ten90CprMod@plt>
divsd  0x10(%rsp),%xmm0
movsd  0xd89(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0xd7f(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
subsd  %xmm1,%xmm0
call   1050 <trunc@plt>
add    %eax,%ebx
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm3
mulsd  %xmm3,%xmm1
movsd  0xd57(%rip),%xmm2
addsd  %xmm1,%xmm2
movsd  0xd5b(%rip),%xmm0
cmpltsd %xmm1,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm1,%xmm0
orpd   %xmm2,%xmm0
movapd %xmm0,%xmm1
subsd  0x18(%rsp),%xmm1
andpd  0xd08(%rip),%xmm1
movapd %xmm3,%xmm2
mulsd  0xd0c(%rip),%xmm2
ucomisd %xmm2,%xmm1
ja     1341 <Ten90DecodeCPRRelative+0x201>
movapd 0x20(%rsp),%xmm1
movsd  %xmm1,(%r15)
mov    0x30(%rsp),%rax
movsd  %xmm0,(%rax)
xor    %r13d,%r13d
mov    %r13d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @Ten90DecodeCPRRelative(double %0, double %1, i32 %2, i32 %3, i32 %4, i32 %5, double* %6, double* %7) {
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double*
%17 = alloca double*
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca i32
%25 = alloca i32
store double %0, double* %10
store double %1, double* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store double* %6, double** %16
store double* %7, double** %17
%26 = load i32, i32* %12
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %38
28: ; preds = %8
%29 = load i32, i32* %13
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, double 9.000000e+01, double 3.600000e+02
%33 = fdiv double %32, 5.900000e+01
store double %33, double* %18
%34 = load i32, i32* %14
%35 = sitofp i32 %34 to double
store double %35, double* %20
%36 = load i32, i32* %15
%37 = sitofp i32 %36 to double
store double %37, double* %21
br label %48
38: ; preds = %8
%39 = load i32, i32* %13
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, double 9.000000e+01, double 3.600000e+02
%43 = fdiv double %42, 6.000000e+01
store double %43, double* %18
%44 = load i32, i32* %14
%45 = sitofp i32 %44 to double
store double %45, double* %20
%46 = load i32, i32* %15
%47 = sitofp i32 %46 to double
store double %47, double* %21
br label %48
48: ; preds = %38, %28
%49 = load double, double* %10
%50 = load double, double* %18
%51 = fdiv double %49, %50
%52 = call i64 @floor(double %51)
%53 = load double, double* %10
%54 = fptosi double %53 to i32
%55 = load double, double* %18
%56 = fptosi double %55 to i32
%57 = call double @Ten90CprMod(i32 %54, i32 %56)
%58 = load double, double* %18
%59 = fdiv double %57, %58
%60 = fadd double 5.000000e-01, %59
%61 = load double, double* %20
%62 = fdiv double %61, 1.310720e+05
%63 = fsub double %60, %62
%64 = call i64 @trunc(double %63)
%65 = add nsw i64 %52, %64
%66 = trunc i64 %65 to i32
store i32 %66, i32* %24
%67 = load double, double* %18
%68 = load i32, i32* %24
%69 = sitofp i32 %68 to double
%70 = load double, double* %20
%71 = fdiv double %70, 1.310720e+05
%72 = fadd double %69, %71
%73 = fmul double %67, %72
store double %73, double* %23
%74 = load double, double* %23
%75 = fcmp oge double %74, 2.700000e+02
br i1 %75, label %76, label %79
76: ; preds = %48
%77 = load double, double* %23
%78 = fsub double %77, 3.600000e+02
store double %78, double* %23
br label %79
79: ; preds = %76, %48
%80 = load double, double* %23
%81 = load double, double* %10
%82 = fsub double %80, %81
%83 = call double @llvm.fabs.f64(double %82)
%84 = load double, double* %18
%85 = fdiv double %84, 2.000000e+00
%86 = fcmp ogt double %83, %85
br i1 %86, label %87, label %88
87: ; preds = %79
store i32 -1, i32* %9
br label %137
88: ; preds = %79
%89 = load double, double* %23
%90 = load i32, i32* %12
%91 = load i32, i32* %13
%92 = call double @Ten90CprDlon(double %89, i32 %90, i32 %91)
store double %92, double* %19
%93 = load double, double* %11
%94 = load double, double* %19
%95 = fdiv double %93, %94
%96 = call i64 @floor(double %95)
%97 = load double, double* %11
%98 = fptosi double %97 to i32
%99 = load double, double* %19
%100 = fptosi double %99 to i32
%101 = call double @Ten90CprMod(i32 %98, i32 %100)
%102 = load double, double* %19
%103 = fdiv double %101, %102
%104 = fadd double 5.000000e-01, %103
%105 = load double, double* %21
%106 = fdiv double %105, 1.310720e+05
%107 = fsub double %104, %106
%108 = call i64 @trunc(double %107)
%109 = add nsw i64 %96, %108
%110 = trunc i64 %109 to i32
store i32 %110, i32* %25
%111 = load double, double* %19
%112 = load i32, i32* %25
%113 = sitofp i32 %112 to double
%114 = load double, double* %21
%115 = fdiv double %114, 1.310720e+05
%116 = fadd double %113, %115
%117 = fmul double %111, %116
store double %117, double* %22
%118 = load double, double* %22
%119 = fcmp ogt double %118, 1.800000e+02
br i1 %119, label %120, label %123
120: ; preds = %88
%121 = load double, double* %22
%122 = fsub double %121, 3.600000e+02
store double %122, double* %22
br label %123
123: ; preds = %120, %88
%124 = load double, double* %22
%125 = load double, double* %11
%126 = fsub double %124, %125
%127 = call double @llvm.fabs.f64(double %126)
%128 = load double, double* %19
%129 = fdiv double %128, 2.000000e+00
%130 = fcmp ogt double %127, %129
br i1 %130, label %131, label %132
131: ; preds = %123
store i32 -1, i32* %9
br label %137
132: ; preds = %123
%133 = load double, double* %23
%134 = load double*, double** %16
store double %133, double* %134
%135 = load double, double* %22
%136 = load double*, double** %17
store double %135, double* %136
store i32 0, i32* %9
br label %137
137: ; preds = %132, %131, %87
%138 = load i32, i32* %9
ret i32 %138
}

LLVM IR (-O2):
define i32 @Ten90DecodeCPRRelative(double %0, double %1, i32 %2, i32 %3, i32 %4, i32 %5, double* nocapture writeonly %6, double* nocapture writeonly %7) {
%9 = icmp eq i32 %2, 0
%10 = icmp eq i32 %3, 0
%11 = select i1 %10, double 0x40186822B63CBEEA, double 0x3FF86822B63CBEEA
%12 = select i1 %10, double 6.000000e+00, double 1.500000e+00
%13 = select i1 %9, double %12, double %11
%14 = sitofp i32 %4 to double
%15 = fdiv double %0, %13
%16 = tail call i64 @floor(double %15)
%17 = fptosi double %0 to i32
%18 = fptosi double %13 to i32
%19 = tail call double @Ten90CprMod(i32 %17, i32 %18)
%20 = fdiv double %19, %13
%21 = fadd double %20, 5.000000e-01
%22 = fmul double %14, 0x3EE0000000000000
%23 = fsub double %21, %22
%24 = tail call i64 @trunc(double %23)
%25 = add nsw i64 %24, %16
%26 = trunc i64 %25 to i32
%27 = sitofp i32 %26 to double
%28 = fadd double %22, %27
%29 = fmul double %13, %28
%30 = fcmp ult double %29, 2.700000e+02
%31 = fadd double %29, -3.600000e+02
%32 = select i1 %30, double %29, double %31
%33 = fsub double %32, %0
%34 = tail call double @llvm.fabs.f64(double %33)
%35 = fmul double %13, 5.000000e-01
%36 = fcmp ogt double %34, %35
br i1 %36, label %63, label %37
37: ; preds = %8
%38 = sitofp i32 %5 to double
%39 = tail call double @Ten90CprDlon(double %32, i32 %2, i32 %3)
%40 = fdiv double %1, %39
%41 = tail call i64 @floor(double %40)
%42 = fptosi double %1 to i32
%43 = fptosi double %39 to i32
%44 = tail call double @Ten90CprMod(i32 %42, i32 %43)
%45 = fdiv double %44, %39
%46 = fadd double %45, 5.000000e-01
%47 = fmul double %38, 0x3EE0000000000000
%48 = fsub double %46, %47
%49 = tail call i64 @trunc(double %48)
%50 = add nsw i64 %49, %41
%51 = trunc i64 %50 to i32
%52 = sitofp i32 %51 to double
%53 = fadd double %47, %52
%54 = fmul double %39, %53
%55 = fcmp ogt double %54, 1.800000e+02
%56 = fadd double %54, -3.600000e+02
%57 = select i1 %55, double %56, double %54
%58 = fsub double %57, %1
%59 = tail call double @llvm.fabs.f64(double %58)
%60 = fmul double %39, 5.000000e-01
%61 = fcmp ogt double %59, %60
br i1 %61, label %63, label %62
62: ; preds = %37
store double %32, double* %6
store double %57, double* %7
br label %63
63: ; preds = %37, %8, %62
%64 = phi i32 [ 0, %62 ], [ -1, %8 ], [ -1, %37 ]
ret i32 %64
}