#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 */
int /*<<< orphan*/ latlon2rect(int, double, double, double *, double *);
int /*<<< orphan*/ rect2latlon(int, double, double, double *, double *);
int convertCoordsRect(int proj_index_from, int proj_index_to, double x,
                      double y, double *pxnew, double *pynew) {
  double dlat, dlong;
  if (proj_index_from < 0 || proj_index_to < 0)
    return (-1);
  if (proj_index_from == proj_index_to) {
    *pxnew = x;
    *pynew = y;
    return (0);
  }
  rect2latlon(proj_index_from, x, y, &dlat, &dlong);
  latlon2rect(proj_index_to, dlat, dlong, pxnew, pynew);
  return (0);
}


x86 assembly (clang, -O0):
<convertCoordsRect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1154 <convertCoordsRect+0x34>
cmpl   $0x0,-0xc(%rbp)
jge    1160 <convertCoordsRect+0x40>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cd <convertCoordsRect+0xad>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1192 <convertCoordsRect+0x72>
movsd  -0x18(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11cd <convertCoordsRect+0xad>
mov    -0x8(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    -0x38(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1030 <rect2latlon@plt>
mov    -0xc(%rbp),%edi
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1040 <latlon2rect@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertCoordsRect>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%eax
or     %edi,%eax
js     1145 <convertCoordsRect+0x25>
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %esi,%ebp
cmp    %esi,%edi
jne    114c <convertCoordsRect+0x2c>
movsd  %xmm0,(%rbx)
movsd  %xmm1,(%r14)
jmp    1171 <convertCoordsRect+0x51>
mov    $0xffffffff,%eax
jmp    1173 <convertCoordsRect+0x53>
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
call   1030 <rect2latlon@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <latlon2rect@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @convertCoordsRect(i32 %0, i32 %1, double %2, double %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double*
%13 = alloca double*
%14 = alloca double
%15 = alloca double
store i32 %0, i32* %8
store i32 %1, i32* %9
store double %2, double* %10
store double %3, double* %11
store double* %4, double** %12
store double* %5, double** %13
%16 = load i32, i32* %8
%17 = icmp slt i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %6
%19 = load i32, i32* %9
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18, %6
store i32 -1, i32* %7
br label %42
22: ; preds = %18
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load double, double* %10
%28 = load double*, double** %12
store double %27, double* %28
%29 = load double, double* %11
%30 = load double*, double** %13
store double %29, double* %30
store i32 0, i32* %7
br label %42
31: ; preds = %22
%32 = load i32, i32* %8
%33 = load double, double* %10
%34 = load double, double* %11
%35 = call i32 @rect2latlon(i32 %32, double %33, double %34, double* %14, double* %15)
%36 = load i32, i32* %9
%37 = load double, double* %14
%38 = load double, double* %15
%39 = load double*, double** %12
%40 = load double*, double** %13
%41 = call i32 @latlon2rect(i32 %36, double %37, double %38, double* %39, double* %40)
store i32 0, i32* %7
br label %42
42: ; preds = %31, %26, %21
%43 = load i32, i32* %7
ret i32 %43
}

LLVM IR (-O2):
define i32 @convertCoordsRect(i32 %0, i32 %1, double %2, double %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = bitcast double* %7 to i8*
%10 = bitcast double* %8 to i8*
%11 = or i32 %1, %0
%12 = icmp sgt i32 %11, -1
br i1 %12, label %13, label %21
13: ; preds = %6
%14 = icmp eq i32 %0, %1
br i1 %14, label %15, label %16
15: ; preds = %13
store double %2, double* %4
store double %3, double* %5
br label %21
16: ; preds = %13
%17 = call i32 @rect2latlon(i32 %0, double %2, double %3, double* %7, double* %8)
%18 = load double, double* %7
%19 = load double, double* %8
%20 = call i32 @latlon2rect(i32 %1, double %18, double %19, double* %4, double* %5)
br label %21
21: ; preds = %6, %16, %15
%22 = phi i32 [ 0, %15 ], [ 0, %16 ], [ -1, %6 ]
ret i32 %22
}