#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 cosd(double);
double sind(double);
int /*<<< orphan*/ sphs2x(double *, int, int /*<<< orphan*/, int, int,
                          double const *, double const *, double *, double *);
int sphdpa(int nfield, double lng0, double lat0, const double lng[],
           const double lat[], double dist[], double pa[]) {
  int i;
  double eul[5];
  eul[0] = lng0;
  eul[1] = 90.0 - lat0;
  eul[2] = 0.0;
  eul[3] = cosd(eul[1]);
  eul[4] = sind(eul[1]);
  sphs2x(eul, nfield, 0, 1, 1, lng, lat, pa, dist);
  for (i = 0; i < nfield; i++) {
    dist[i] = 90.0 - dist[i];
    pa[i] = -pa[i];
    if (pa[i] < -180.0)
      pa[i] += 360.0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<sphdpa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xe96(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1050 <cosd@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1030 <sind@plt>
movsd  %xmm0,-0x50(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x20(%rbp),%r9
mov    -0x28(%rbp),%r11
mov    -0x38(%rbp),%r10
mov    -0x30(%rbp),%rax
xor    %edx,%edx
mov    $0x1,%r8d
mov    %r8d,%ecx
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <sphs2x@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    127d <sphdpa+0x14d>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  0xe0e(%rip),%xmm0
subsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  0xdc3(%rip),%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jbe    126a <sphdpa+0x13a>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  0xdb0(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    126f <sphdpa+0x13f>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11d6 <sphdpa+0xa6>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sphdpa>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %edi,%ebp
movsd  %xmm0,0x10(%rsp)
movsd  0xea8(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  %xmm0,0x18(%rsp)
movq   $0x0,0x20(%rsp)
call   1050 <cosd@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sind@plt>
movsd  %xmm0,0x30(%rsp)
sub    $0x8,%rsp
lea    0x18(%rsp),%rdi
mov    %ebp,%esi
xor    %edx,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
mov    %r12,%r9
push   %rbx
push   %r14
push   %r15
call   1040 <sphs2x@plt>
movsd  0xe46(%rip),%xmm7
add    $0x20,%rsp
test   %ebp,%ebp
jle    1442 <sphdpa+0x312>
mov    %ebp,%eax
cmp    $0x1,%ebp
je     11e7 <sphdpa+0xb7>
lea    (%r14,%rax,8),%rcx
cmp    %rbx,%rcx
jbe    12fc <sphdpa+0x1cc>
lea    (%rbx,%rax,8),%rcx
cmp    %r14,%rcx
jbe    12fc <sphdpa+0x1cc>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
test   $0x1,%al
je     1242 <sphdpa+0x112>
movapd %xmm7,%xmm0
subsd  (%rbx,%rcx,8),%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
movsd  (%r14,%rcx,8),%xmm0
movapd 0xe21(%rip),%xmm1
xorpd  %xmm0,%xmm1
movsd  0xded(%rip),%xmm2
subsd  %xmm0,%xmm2
movsd  0xde9(%rip),%xmm3
cmpltsd %xmm0,%xmm3
andpd  %xmm3,%xmm2
andnpd %xmm1,%xmm3
orpd   %xmm2,%xmm3
movlpd %xmm3,(%r14,%rcx,8)
or     $0x1,%rcx
add    %rax,%rdx
je     1442 <sphdpa+0x312>
movapd 0xddd(%rip),%xmm0
movsd  0xdad(%rip),%xmm1
movsd  0xdad(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movapd %xmm7,%xmm3
subsd  (%rbx,%rcx,8),%xmm3
movsd  %xmm3,(%rbx,%rcx,8)
movsd  (%r14,%rcx,8),%xmm3
movapd %xmm1,%xmm4
subsd  %xmm3,%xmm4
movapd %xmm2,%xmm5
cmpltsd %xmm3,%xmm5
xorpd  %xmm0,%xmm3
andpd  %xmm5,%xmm4
andnpd %xmm3,%xmm5
orpd   %xmm4,%xmm5
movlpd %xmm5,(%r14,%rcx,8)
movapd %xmm7,%xmm3
subsd  0x8(%rbx,%rcx,8),%xmm3
movsd  %xmm3,0x8(%rbx,%rcx,8)
movsd  0x8(%r14,%rcx,8),%xmm3
movapd %xmm1,%xmm4
subsd  %xmm3,%xmm4
movapd %xmm2,%xmm5
cmpltsd %xmm3,%xmm5
xorpd  %xmm0,%xmm3
andpd  %xmm5,%xmm4
andnpd %xmm3,%xmm5
orpd   %xmm4,%xmm5
movlpd %xmm5,0x8(%r14,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%rax
jne    1270 <sphdpa+0x140>
jmp    1442 <sphdpa+0x312>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
lea    -0x2(%rcx),%rdx
mov    %rdx,%rsi
shr    %rsi
add    $0x1,%rsi
test   %rdx,%rdx
je     1451 <sphdpa+0x321>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %edx,%edx
movapd 0xcf7(%rip),%xmm0
movapd 0xcff(%rip),%xmm1
movapd 0xd07(%rip),%xmm2
movapd 0xd0f(%rip),%xmm3
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movupd (%rbx,%rdx,8),%xmm4
movapd %xmm0,%xmm5
subpd  %xmm4,%xmm5
movupd %xmm5,(%rbx,%rdx,8)
movupd (%r14,%rdx,8),%xmm4
movapd %xmm2,%xmm5
cmpltpd %xmm4,%xmm5
movapd %xmm3,%xmm6
subpd  %xmm4,%xmm6
xorpd  %xmm1,%xmm4
andpd  %xmm5,%xmm6
andnpd %xmm4,%xmm5
orpd   %xmm6,%xmm5
movupd %xmm5,(%r14,%rdx,8)
movupd 0x10(%rbx,%rdx,8),%xmm4
movapd %xmm0,%xmm5
subpd  %xmm4,%xmm5
movupd %xmm5,0x10(%rbx,%rdx,8)
movupd 0x10(%r14,%rdx,8),%xmm4
movapd %xmm2,%xmm5
cmpltpd %xmm4,%xmm5
movapd %xmm3,%xmm6
subpd  %xmm4,%xmm6
xorpd  %xmm1,%xmm4
andpd  %xmm5,%xmm6
andnpd %xmm4,%xmm5
orpd   %xmm6,%xmm5
movupd %xmm5,0x10(%r14,%rdx,8)
add    $0x4,%rdx
add    $0xfffffffffffffffe,%rdi
jne    1350 <sphdpa+0x220>
test   $0x1,%sil
je     1439 <sphdpa+0x309>
movupd (%rbx,%rdx,8),%xmm0
movapd 0xc2d(%rip),%xmm1
subpd  %xmm0,%xmm1
movupd %xmm1,(%rbx,%rdx,8)
movupd (%r14,%rdx,8),%xmm0
movapd 0xc26(%rip),%xmm1
xorpd  %xmm0,%xmm1
movapd 0xc2a(%rip),%xmm2
cmpltpd %xmm0,%xmm2
movapd 0xc2d(%rip),%xmm3
subpd  %xmm0,%xmm3
andpd  %xmm2,%xmm3
andnpd %xmm1,%xmm2
orpd   %xmm3,%xmm2
movupd %xmm2,(%r14,%rdx,8)
cmp    %rax,%rcx
jne    11e9 <sphdpa+0xb9>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edx,%edx
test   $0x1,%sil
jne    13e6 <sphdpa+0x2b6>
jmp    1439 <sphdpa+0x309>

LLVM IR (-O0):
define i32 @sphdpa(i32 %0, double %1, double %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca [5 x double]
store i32 %0, i32* %8
store double %1, double* %9
store double %2, double* %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
store double* %6, double** %14
%17 = load double, double* %9
%18 = getelementptr inbounds [5 x double], [5 x double]* %16, i64 0, i64 0
store double %17, double* %18
%19 = load double, double* %10
%20 = fsub double 9.000000e+01, %19
%21 = getelementptr inbounds [5 x double], [5 x double]* %16, i64 0, i64 1
store double %20, double* %21
%22 = getelementptr inbounds [5 x double], [5 x double]* %16, i64 0, i64 2
store double 0.000000e+00, double* %22
%23 = getelementptr inbounds [5 x double], [5 x double]* %16, i64 0, i64 1
%24 = load double, double* %23
%25 = call double @cosd(double %24)
%26 = getelementptr inbounds [5 x double], [5 x double]* %16, i64 0, i64 3
store double %25, double* %26
%27 = getelementptr inbounds [5 x double], [5 x double]* %16, i64 0, i64 1
%28 = load double, double* %27
%29 = call double @sind(double %28)
%30 = getelementptr inbounds [5 x double], [5 x double]* %16, i64 0, i64 4
store double %29, double* %30
%31 = getelementptr inbounds [5 x double], [5 x double]* %16, i64 0, i64 0
%32 = load i32, i32* %8
%33 = load double*, double** %11
%34 = load double*, double** %12
%35 = load double*, double** %14
%36 = load double*, double** %13
%37 = call i32 @sphs2x(double* %31, i32 %32, i32 0, i32 1, i32 1, double* %33, double* %34, double* %35, double* %36)
store i32 0, i32* %15
br label %38
38: ; preds = %77, %7
%39 = load i32, i32* %15
%40 = load i32, i32* %8
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %80
42: ; preds = %38
%43 = load double*, double** %13
%44 = load i32, i32* %15
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = fsub double 9.000000e+01, %47
%49 = load double*, double** %13
%50 = load i32, i32* %15
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
store double %48, double* %52
%53 = load double*, double** %14
%54 = load i32, i32* %15
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
%58 = fneg double %57
%59 = load double*, double** %14
%60 = load i32, i32* %15
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %59, i64 %61
store double %58, double* %62
%63 = load double*, double** %14
%64 = load i32, i32* %15
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
%67 = load double, double* %66
%68 = fcmp olt double %67, -1.800000e+02
br i1 %68, label %69, label %76
69: ; preds = %42
%70 = load double*, double** %14
%71 = load i32, i32* %15
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double, double* %70, i64 %72
%74 = load double, double* %73
%75 = fadd double %74, 3.600000e+02
store double %75, double* %73
br label %76
76: ; preds = %69, %42
br label %77
77: ; preds = %76
%78 = load i32, i32* %15
%79 = add nsw i32 %78, 1
store i32 %79, i32* %15
br label %38
80: ; preds = %38
ret i32 0
}

LLVM IR (-O2):
define i32 @sphdpa(i32 %0, double %1, double %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca [5 x double]
%9 = bitcast [5 x double]* %8 to i8*
%10 = getelementptr inbounds [5 x double], [5 x double]* %8, i64 0, i64 0
store double %1, double* %10
%11 = fsub double 9.000000e+01, %2
%12 = getelementptr inbounds [5 x double], [5 x double]* %8, i64 0, i64 1
store double %11, double* %12
%13 = getelementptr inbounds [5 x double], [5 x double]* %8, i64 0, i64 2
store double 0.000000e+00, double* %13
%14 = tail call double @cosd(double %11)
%15 = getelementptr inbounds [5 x double], [5 x double]* %8, i64 0, i64 3
store double %14, double* %15
%16 = tail call double @sind(double %11)
%17 = getelementptr inbounds [5 x double], [5 x double]* %8, i64 0, i64 4
store double %16, double* %17
%18 = call i32 @sphs2x(double* %10, i32 %0, i32 0, i32 1, i32 1, double* %3, double* %4, double* %6, double* %5)
%19 = icmp sgt i32 %0, 0
br i1 %19, label %20, label %133
20: ; preds = %7
%21 = zext i32 %0 to i64
%22 = icmp eq i32 %0, 1
br i1 %22, label %90, label %23
23: ; preds = %20
%24 = getelementptr double, double* %5, i64 %21
%25 = getelementptr double, double* %6, i64 %21
%26 = icmp ugt double* %25, %5
%27 = icmp ugt double* %24, %6
%28 = and i1 %26, %27
br i1 %28, label %90, label %29
29: ; preds = %23
%30 = and i64 %21, 4294967294
%31 = add nsw i64 %30, -2
%32 = lshr exact i64 %31, 1
%33 = add nuw i64 %32, 1
%34 = and i64 %33, 1
%35 = icmp eq i64 %31, 0
br i1 %35, label %71, label %36
36: ; preds = %29
%37 = and i64 %33, -2
br label %38
38: ; preds = %38, %36
%39 = phi i64 [ 0, %36 ], [ %68, %38 ]
%40 = phi i64 [ 0, %36 ], [ %69, %38 ]
%41 = getelementptr inbounds double, double* %5, i64 %39
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = fsub <2 x double> <double 9.000000e+01, double 9.000000e+01>, %43
%45 = bitcast double* %41 to <2 x double>*
store <2 x double> %44, <2 x double>* %45
%46 = getelementptr inbounds double, double* %6, i64 %39
%47 = bitcast double* %46 to <2 x double>*
%48 = load <2 x double>, <2 x double>* %47
%49 = fneg <2 x double> %48
%50 = fcmp ogt <2 x double> %48, <double 1.800000e+02, double 1.800000e+02>
%51 = fsub <2 x double> <double 3.600000e+02, double 3.600000e+02>, %48
%52 = select <2 x i1> %50, <2 x double> %51, <2 x double> %49
%53 = bitcast double* %46 to <2 x double>*
store <2 x double> %52, <2 x double>* %53
%54 = or i64 %39, 2
%55 = getelementptr inbounds double, double* %5, i64 %54
%56 = bitcast double* %55 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = fsub <2 x double> <double 9.000000e+01, double 9.000000e+01>, %57
%59 = bitcast double* %55 to <2 x double>*
store <2 x double> %58, <2 x double>* %59
%60 = getelementptr inbounds double, double* %6, i64 %54
%61 = bitcast double* %60 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = fneg <2 x double> %62
%64 = fcmp ogt <2 x double> %62, <double 1.800000e+02, double 1.800000e+02>
%65 = fsub <2 x double> <double 3.600000e+02, double 3.600000e+02>, %62
%66 = select <2 x i1> %64, <2 x double> %65, <2 x double> %63
%67 = bitcast double* %60 to <2 x double>*
store <2 x double> %66, <2 x double>* %67
%68 = add nuw i64 %39, 4
%69 = add nuw i64 %40, 2
%70 = icmp eq i64 %69, %37
br i1 %70, label %71, label %38
71: ; preds = %38, %29
%72 = phi i64 [ 0, %29 ], [ %68, %38 ]
%73 = icmp eq i64 %34, 0
br i1 %73, label %88, label %74
74: ; preds = %71
%75 = getelementptr inbounds double, double* %5, i64 %72
%76 = bitcast double* %75 to <2 x double>*
%77 = load <2 x double>, <2 x double>* %76
%78 = fsub <2 x double> <double 9.000000e+01, double 9.000000e+01>, %77
%79 = bitcast double* %75 to <2 x double>*
store <2 x double> %78, <2 x double>* %79
%80 = getelementptr inbounds double, double* %6, i64 %72
%81 = bitcast double* %80 to <2 x double>*
%82 = load <2 x double>, <2 x double>* %81
%83 = fneg <2 x double> %82
%84 = fcmp ogt <2 x double> %82, <double 1.800000e+02, double 1.800000e+02>
%85 = fsub <2 x double> <double 3.600000e+02, double 3.600000e+02>, %82
%86 = select <2 x i1> %84, <2 x double> %85, <2 x double> %83
%87 = bitcast double* %80 to <2 x double>*
store <2 x double> %86, <2 x double>* %87
br label %88
88: ; preds = %71, %74
%89 = icmp eq i64 %30, %21
br i1 %89, label %133, label %90
90: ; preds = %23, %20, %88
%91 = phi i64 [ 0, %23 ], [ 0, %20 ], [ %30, %88 ]
%92 = xor i64 %91, -1
%93 = and i64 %21, 1
%94 = icmp eq i64 %93, 0
br i1 %94, label %106, label %95
95: ; preds = %90
%96 = getelementptr inbounds double, double* %5, i64 %91
%97 = load double, double* %96
%98 = fsub double 9.000000e+01, %97
store double %98, double* %96
%99 = getelementptr inbounds double, double* %6, i64 %91
%100 = load double, double* %99
%101 = fneg double %100
%102 = fcmp ogt double %100, 1.800000e+02
%103 = fsub double 3.600000e+02, %100
%104 = select i1 %102, double %103, double %101
store double %104, double* %99
%105 = or i64 %91, 1
br label %106
106: ; preds = %95, %90
%107 = phi i64 [ %91, %90 ], [ %105, %95 ]
%108 = sub nsw i64 0, %21
%109 = icmp eq i64 %92, %108
br i1 %109, label %133, label %110
110: ; preds = %106, %110
%111 = phi i64 [ %131, %110 ], [ %107, %106 ]
%112 = getelementptr inbounds double, double* %5, i64 %111
%113 = load double, double* %112
%114 = fsub double 9.000000e+01, %113
store double %114, double* %112
%115 = getelementptr inbounds double, double* %6, i64 %111
%116 = load double, double* %115
%117 = fneg double %116
%118 = fcmp ogt double %116, 1.800000e+02
%119 = fsub double 3.600000e+02, %116
%120 = select i1 %118, double %119, double %117
store double %120, double* %115
%121 = add nuw nsw i64 %111, 1
%122 = getelementptr inbounds double, double* %5, i64 %121
%123 = load double, double* %122
%124 = fsub double 9.000000e+01, %123
store double %124, double* %122
%125 = getelementptr inbounds double, double* %6, i64 %121
%126 = load double, double* %125
%127 = fneg double %126
%128 = fcmp ogt double %126, 1.800000e+02
%129 = fsub double 3.600000e+02, %126
%130 = select i1 %128, double %129, double %127
store double %130, double* %125
%131 = add nuw nsw i64 %111, 2
%132 = icmp eq i64 %131, %21
br i1 %132, label %133, label %110
133: ; preds = %106, %110, %88, %7
ret i32 0
}