#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 */
scalar_t__ dlatdlon(double *, double *);
extern int jgd2tokyo(double *pos) {
  double posj[2], dpos[2];
  int i;
  posj[0] = pos[0];
  posj[1] = pos[1];
  for (i = 0; i < 2; i++) {
    if (dlatdlon(pos, dpos))
      return -1;
    pos[0] = posj[0] - dpos[0];
    pos[1] = posj[1] - dpos[1];
  }
  return 0;
}


x86 assembly (clang, -O0):
<jgd2tokyo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x2,-0x34(%rbp)
jge    119e <jgd2tokyo+0x8e>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <dlatdlon@plt>
cmp    $0x0,%rax
je     116b <jgd2tokyo+0x5b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a5 <jgd2tokyo+0x95>
movsd  -0x20(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    113e <jgd2tokyo+0x2e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jgd2tokyo>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
movupd (%rdi),%xmm0
movapd %xmm0,0x10(%rsp)
mov    %rsp,%rsi
call   1030 <dlatdlon@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
jne    1165 <jgd2tokyo+0x55>
movapd 0x10(%rsp),%xmm0
subpd  (%rsp),%xmm0
movupd %xmm0,(%rbx)
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <dlatdlon@plt>
test   %rax,%rax
jne    1165 <jgd2tokyo+0x55>
movapd 0x10(%rsp),%xmm0
subpd  (%rsp),%xmm0
movupd %xmm0,(%rbx)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @jgd2tokyo(double* %0) {
%2 = alloca <2 x double>
%3 = bitcast <2 x double>* %2 to i8*
%4 = bitcast double* %0 to <2 x double>*
%5 = load <2 x double>, <2 x double>* %4
%6 = getelementptr inbounds <2 x double>, <2 x double>* %2, i64 0, i64 0
%7 = call i64 @dlatdlon(double* %0, double* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %1
%10 = load <2 x double>, <2 x double>* %2
%11 = fsub <2 x double> %5, %10
%12 = bitcast double* %0 to <2 x double>*
store <2 x double> %11, <2 x double>* %12
%13 = call i64 @dlatdlon(double* %0, double* %6)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %9
%16 = load <2 x double>, <2 x double>* %2
%17 = fsub <2 x double> %5, %16
%18 = bitcast double* %0 to <2 x double>*
store <2 x double> %17, <2 x double>* %18
br label %19
19: ; preds = %15, %9, %1
%20 = phi i32 [ -1, %1 ], [ -1, %9 ], [ 0, %15 ]
ret i32 %20
}