#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 M_PI;
double cos(double);
double pow(double, double);
double sin(double);
double sqrt(double);
void hpc2hcc(double ttx, double tty, double dsun_obs, double *x, double *y,
             double *z) {
  double tx, ty;
  double A, B, C;
  double AA, BB, d;
  tx = M_PI / 180.0 / 3600.0 * ttx;
  ty = M_PI / 180.0 / 3600.0 * tty;
  A = 1.0;
  B = -2.0 * dsun_obs * cos(tx) * cos(ty);
  C = pow(dsun_obs, 2.0) - pow(696000000.0, 2.0);
  AA = 4.0 * A * C;
  BB = B * B;
  if (AA > BB) {
    *x = *y = *z = -1000;
  } else {
    d = (-1.0 * B - sqrt(BB - AA)) / 2.0;
    *x = d * cos(ty) * sin(tx);
    *y = d * sin(ty);
    *z = dsun_obs - d * cos(ty) * cos(tx);
  }
  return;
}


x86 assembly (clang, -O0):
<hpc2hcc>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    0x2e7b(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xeb7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xea3(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x2e4e(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe8a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe76(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe58(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe43(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xde8(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  0xdce(%rip),%xmm0
movsd  0xdce(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xda0(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
ucomisd -0x68(%rbp),%xmm0
jbe    12c3 <hpc2hcc+0x183>
mov    -0x30(%rbp),%rax
movsd  0xd9e(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0xd8e(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  0xd7e(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    140f <hpc2hcc+0x2cf>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  -0xc0(%rbp),%xmm1
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
subsd  %xmm1,%xmm0
movsd  0xd06(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xb8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xb0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0x98(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x90(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hpc2hcc>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  %xmm2,0x30(%rsp)
mov    0x2e99(%rip),%rax
movsd  (%rax),%xmm3
divsd  0xea5(%rip),%xmm3
divsd  0xea5(%rip),%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm1,%xmm3
movsd  %xmm3,0x8(%rsp)
movsd  0xe97(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x28(%rsp)
call   1040 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movapd %xmm0,%xmm2
movsd  0x30(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  0xe5d(%rip),%xmm1
mulsd  0xe5d(%rip),%xmm1
mulsd  0x10(%rsp),%xmm2
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
ucomisd %xmm0,%xmm1
jbe    11ef <hpc2hcc+0xbf>
movabs $0xc08f400000000000,%rax
40 8f c0
mov    %rax,(%r14)
mov    %rax,(%r15)
mov    %rax,(%rbx)
jmp    12ab <hpc2hcc+0x17b>
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1203 <hpc2hcc+0xd3>
sqrtsd %xmm0,%xmm0
jmp    1214 <hpc2hcc+0xe4>
movapd %xmm2,0x10(%rsp)
call   1050 <sqrt@plt>
movapd 0x10(%rsp),%xmm2
xorpd  0xe14(%rip),%xmm2
subsd  %xmm0,%xmm2
mulsd  0xe00(%rip),%xmm2
movapd %xmm2,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x38(%rsp)
movsd  0x28(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x38(%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r15)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <cos@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x30(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%r14)
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @hpc2hcc(double %0, double %1, double %2, double* %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%21 = load double, double* @M_PI
%22 = fdiv double %21, 1.800000e+02
%23 = fdiv double %22, 3.600000e+03
%24 = load double, double* %7
%25 = fmul double %23, %24
store double %25, double* %13
%26 = load double, double* @M_PI
%27 = fdiv double %26, 1.800000e+02
%28 = fdiv double %27, 3.600000e+03
%29 = load double, double* %8
%30 = fmul double %28, %29
store double %30, double* %14
store double 1.000000e+00, double* %15
%31 = load double, double* %9
%32 = fmul double -2.000000e+00, %31
%33 = load double, double* %13
%34 = call double @cos(double %33)
%35 = fmul double %32, %34
%36 = load double, double* %14
%37 = call double @cos(double %36)
%38 = fmul double %35, %37
store double %38, double* %16
%39 = load double, double* %9
%40 = call double @pow(double %39, double 2.000000e+00)
%41 = call double @pow(double 6.960000e+08, double 2.000000e+00)
%42 = fsub double %40, %41
store double %42, double* %17
%43 = load double, double* %15
%44 = fmul double 4.000000e+00, %43
%45 = load double, double* %17
%46 = fmul double %44, %45
store double %46, double* %18
%47 = load double, double* %16
%48 = load double, double* %16
%49 = fmul double %47, %48
store double %49, double* %19
%50 = load double, double* %18
%51 = load double, double* %19
%52 = fcmp ogt double %50, %51
br i1 %52, label %53, label %57
53: ; preds = %6
%54 = load double*, double** %12
store double -1.000000e+03, double* %54
%55 = load double*, double** %11
store double -1.000000e+03, double* %55
%56 = load double*, double** %10
store double -1.000000e+03, double* %56
br label %89
57: ; preds = %6
%58 = load double, double* %16
%59 = load double, double* %19
%60 = load double, double* %18
%61 = fsub double %59, %60
%62 = call double @sqrt(double %61)
%63 = fneg double %62
%64 = call double @llvm.fmuladd.f64(double -1.000000e+00, double %58, double %63)
%65 = fdiv double %64, 2.000000e+00
store double %65, double* %20
%66 = load double, double* %20
%67 = load double, double* %14
%68 = call double @cos(double %67)
%69 = fmul double %66, %68
%70 = load double, double* %13
%71 = call double @sin(double %70)
%72 = fmul double %69, %71
%73 = load double*, double** %10
store double %72, double* %73
%74 = load double, double* %20
%75 = load double, double* %14
%76 = call double @sin(double %75)
%77 = fmul double %74, %76
%78 = load double*, double** %11
store double %77, double* %78
%79 = load double, double* %9
%80 = load double, double* %20
%81 = load double, double* %14
%82 = call double @cos(double %81)
%83 = fmul double %80, %82
%84 = load double, double* %13
%85 = call double @cos(double %84)
%86 = fneg double %83
%87 = call double @llvm.fmuladd.f64(double %86, double %85, double %79)
%88 = load double*, double** %12
store double %87, double* %88
br label %89
89: ; preds = %57, %53
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @hpc2hcc(double %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = load double, double* @M_PI
%8 = fdiv double %7, 1.800000e+02
%9 = fdiv double %8, 3.600000e+03
%10 = fmul double %9, %0
%11 = fmul double %9, %1
%12 = fmul double %2, -2.000000e+00
%13 = tail call double @cos(double %10)
%14 = fmul double %12, %13
%15 = tail call double @cos(double %11)
%16 = fmul double %14, %15
%17 = fmul double %2, %2
%18 = fadd double %17, -4.844160e+17
%19 = fmul double %18, 4.000000e+00
%20 = fmul double %16, %16
%21 = fcmp ogt double %19, %20
br i1 %21, label %22, label %23
22: ; preds = %6
store double -1.000000e+03, double* %5
store double -1.000000e+03, double* %4
store double -1.000000e+03, double* %3
br label %40
23: ; preds = %6
%24 = fsub double %20, %19
%25 = tail call double @sqrt(double %24)
%26 = fneg double %25
%27 = tail call double @llvm.fmuladd.f64(double %16, double -1.000000e+00, double %26)
%28 = fmul double %27, 5.000000e-01
%29 = tail call double @cos(double %11)
%30 = fmul double %29, %28
%31 = tail call double @sin(double %10)
%32 = fmul double %31, %30
store double %32, double* %3
%33 = tail call double @sin(double %11)
%34 = fmul double %28, %33
store double %34, double* %4
%35 = tail call double @cos(double %11)
%36 = tail call double @cos(double %10)
%37 = fneg double %28
%38 = fmul double %35, %37
%39 = tail call double @llvm.fmuladd.f64(double %38, double %36, double %2)
store double %39, double* %5
br label %40
40: ; preds = %23, %22
ret void
}