#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 asin(double);
double atan2(double, double);
double cos(double);
double sin(double);
void coord_trans(double *alt, double *az, double h, double dec, double lt) {
  double y, x, cos_h, sin_lt, cos_dec, cos_lt;
  cos_h = cos(h);
  sin_lt = sin(lt);
  cos_dec = cos(dec);
  cos_lt = cos(lt);
  y = -cos_dec * sin(h);
  x = sin(dec) * cos_lt - cos_dec * cos_h * sin_lt;
  *az = atan2(y, x);
  if (*az < 0)
    *az += 2 * 3.1415926535897932;
  *alt = asin(sin(dec) * sin_lt + cos_dec * cos_h * cos_lt);
}


x86 assembly (clang, -O0):
<coord_trans>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x58(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    1255 <coord_trans+0x115>
mov    -0x10(%rbp),%rax
movsd  0xdb3(%rip),%xmm0
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <asin@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<coord_trans>:
push   %r14
push   %rbx
sub    $0x58,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r14
call   1060 <cos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x20(%rsp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movaps 0xe5d(%rip),%xmm0
xorps  0x30(%rsp),%xmm0
movaps %xmm0,0x40(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x40(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x20(%rsp),%xmm0
call   1040 <sin@plt>
movapd %xmm0,%xmm1
movsd  0x18(%rsp),%xmm2
mulsd  0x30(%rsp),%xmm2
movsd  %xmm2,0x18(%rsp)
movsd  0x28(%rsp),%xmm0
mulsd  %xmm2,%xmm0
mulsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
call   1030 <atan2@plt>
movsd  0xe04(%rip),%xmm1
addsd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
movapd %xmm0,%xmm3
cmpltsd %xmm2,%xmm3
andpd  %xmm3,%xmm1
andnpd %xmm0,%xmm3
orpd   %xmm1,%xmm3
movlpd %xmm3,(%rbx)
movsd  0x20(%rsp),%xmm0
call   1040 <sin@plt>
movsd  0x18(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
mulsd  0x28(%rsp),%xmm0
addsd  %xmm1,%xmm0
call   1050 <asin@plt>
movsd  %xmm0,(%r14)
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @coord_trans(double* %0, double* %1, double %2, double %3, double %4) {
%6 = alloca double*
%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
store double* %0, double** %6
store double* %1, double** %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%17 = load double, double* %8
%18 = call double @cos(double %17)
store double %18, double* %13
%19 = load double, double* %10
%20 = call double @sin(double %19)
store double %20, double* %14
%21 = load double, double* %9
%22 = call double @cos(double %21)
store double %22, double* %15
%23 = load double, double* %10
%24 = call double @cos(double %23)
store double %24, double* %16
%25 = load double, double* %15
%26 = fneg double %25
%27 = load double, double* %8
%28 = call double @sin(double %27)
%29 = fmul double %26, %28
store double %29, double* %11
%30 = load double, double* %9
%31 = call double @sin(double %30)
%32 = load double, double* %16
%33 = load double, double* %15
%34 = load double, double* %13
%35 = fmul double %33, %34
%36 = load double, double* %14
%37 = fmul double %35, %36
%38 = fneg double %37
%39 = call double @llvm.fmuladd.f64(double %31, double %32, double %38)
store double %39, double* %12
%40 = load double, double* %11
%41 = load double, double* %12
%42 = call double @atan2(double %40, double %41)
%43 = load double*, double** %7
store double %42, double* %43
%44 = load double*, double** %7
%45 = load double, double* %44
%46 = fcmp olt double %45, 0.000000e+00
br i1 %46, label %47, label %51
47: ; preds = %5
%48 = load double*, double** %7
%49 = load double, double* %48
%50 = fadd double %49, 0x401921FB54442D18
store double %50, double* %48
br label %51
51: ; preds = %47, %5
%52 = load double, double* %9
%53 = call double @sin(double %52)
%54 = load double, double* %14
%55 = load double, double* %15
%56 = load double, double* %13
%57 = fmul double %55, %56
%58 = load double, double* %16
%59 = fmul double %57, %58
%60 = call double @llvm.fmuladd.f64(double %53, double %54, double %59)
%61 = call double @asin(double %60)
%62 = load double*, double** %6
store double %61, double* %62
ret void
}

LLVM IR (-O2):
define void @coord_trans(double* nocapture writeonly %0, double* nocapture writeonly %1, double %2, double %3, double %4) {
%6 = tail call double @cos(double %2)
%7 = tail call double @sin(double %4)
%8 = tail call double @cos(double %3)
%9 = tail call double @cos(double %4)
%10 = fneg double %8
%11 = tail call double @sin(double %2)
%12 = fmul double %11, %10
%13 = tail call double @sin(double %3)
%14 = fmul double %6, %8
%15 = fneg double %14
%16 = fmul double %7, %15
%17 = tail call double @llvm.fmuladd.f64(double %13, double %9, double %16)
%18 = tail call double @atan2(double %12, double %17)
%19 = fcmp olt double %18, 0.000000e+00
%20 = fadd double %18, 0x401921FB54442D18
%21 = select i1 %19, double %20, double %18
store double %21, double* %1
%22 = tail call double @sin(double %3)
%23 = fmul double %14, %9
%24 = tail call double @llvm.fmuladd.f64(double %22, double %7, double %23)
%25 = tail call double @asin(double %24)
store double %25, double* %0
ret void
}