#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 tokyo2jgd(double *pos) {
  double post[2], dpos[2];
  post[0] = pos[0];
  post[1] = pos[1];
  if (dlatdlon(post, dpos))
    return -1;
  pos[0] = post[0] + dpos[0];
  pos[1] = post[1] + dpos[1];
  return 0;
}


x86 assembly (clang, -O0):
<tokyo2jgd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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)
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <dlatdlon@plt>
cmp    $0x0,%rax
je     115a <tokyo2jgd+0x4a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1186 <tokyo2jgd+0x76>
movsd  -0x20(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokyo2jgd>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movupd (%rdi),%xmm0
movapd %xmm0,(%rsp)
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
call   1030 <dlatdlon@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    114c <tokyo2jgd+0x3c>
movapd (%rsp),%xmm0
addpd  0x10(%rsp),%xmm0
movupd %xmm0,(%rbx)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

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