#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 days(int, int, int, double);
int /*<<< orphan*/ equatorial(double, double *, double *, double *);
double fabs(double);
double gst(double);
int /*<<< orphan*/ moonpos(double, double *, double *, double *);
double rangerad(double);
int /*<<< orphan*/ topo(double, double, double *, double *, double *);
double moontransit(int y, int m, int d, double tz, double glat, double glong,
                   int *notransit) {
  double hm, ht, ht1, lon, lat, rv, dnew, lst;
  int itcount;
  ht1 = 180 * 0.0174532925199433;
  ht = 0;
  itcount = 0;
  *notransit = 0;
  do {
    ht = ht1;
    itcount++;
    dnew = days(y, m, d, ht * 57.2957795130823 / 15) - tz / 24;
    lst = gst(dnew) + glong;
    moonpos(dnew, &lon, &lat, &rv);
    equatorial(dnew, &lon, &lat, &rv);
    topo(lst, glat, &lon, &lat, &rv);
    hm = rangerad(lst - lon);
    ht1 = rangerad(ht - hm);
    if (itcount > 30) {
      *notransit = 1;
      break;
    }
  } while (fabs(ht - ht1) > 0.04 * 0.0174532925199433);
  return (ht1);
}


x86 assembly (clang, -O0):
<moontransit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
movsd  0xe71(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
movsd  0xe47(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  0xe32(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <days@plt>
movsd  -0x18(%rbp),%xmm1
movsd  0xe14(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1080 <gst@plt>
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
lea    -0x50(%rbp),%rdi
lea    -0x58(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1030 <moonpos@plt>
movsd  -0x68(%rbp),%xmm0
lea    -0x50(%rbp),%rdi
lea    -0x58(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1040 <equatorial@plt>
movsd  -0x70(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    -0x50(%rbp),%rdi
lea    -0x58(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1070 <topo@plt>
movsd  -0x70(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
call   1060 <rangerad@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
call   1060 <rangerad@plt>
movsd  %xmm0,-0x48(%rbp)
cmpl   $0x1e,-0x74(%rbp)
jle    129d <moontransit+0x13d>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
jmp    12c9 <moontransit+0x169>
jmp    12a2 <moontransit+0x142>
movsd  -0x40(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movaps 0xd7d(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xd61(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11ad <moontransit+0x4d>
movsd  -0x48(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<moontransit>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
movsd  %xmm2,0x30(%rsp)
movsd  %xmm1,0x28(%rsp)
mov    %edx,0x4(%rsp)
mov    %esi,%r12d
mov    %edi,%r13d
mov    %rcx,0x18(%rsp)
movl   $0x0,(%rcx)
divsd  0xe69(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0xe63(%rip),%xmm1
mov    $0x1f,%r15d
lea    0x38(%rsp),%rbx
lea    0x60(%rsp),%rbp
lea    0x58(%rsp),%r14
nopw   0x0(%rax,%rax,1)
movapd %xmm1,0x40(%rsp)
movapd %xmm1,%xmm0
mulsd  0xe3e(%rip),%xmm0
divsd  0xe3e(%rip),%xmm0
mov    %r13d,%edi
mov    %r12d,%esi
mov    0x4(%rsp),%edx
call   1050 <days@plt>
subsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1080 <gst@plt>
addsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1030 <moonpos@plt>
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1040 <equatorial@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1070 <topo@plt>
movsd  0x10(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
call   1060 <rangerad@plt>
movapd 0x40(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1060 <rangerad@plt>
add    $0xffffffff,%r15d
je     1298 <moontransit+0x138>
movapd 0x40(%rsp),%xmm1
subsd  %xmm0,%xmm1
andpd  0xdac(%rip),%xmm1
ucomisd 0xd94(%rip),%xmm1
movapd %xmm0,%xmm1
ja     11c0 <moontransit+0x60>
jmp    12a3 <moontransit+0x143>
mov    0x18(%rsp),%rax
movl   $0x1,(%rax)
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @moontransit(i32 %0, i32 %1, i32 %2, double %3, double %4, double %5, i32* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i32*
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
store i32* %6, i32** %14
store double 0x400921FB54442D1A, double* %17
store double 0.000000e+00, double* %16
store i32 0, i32* %23
%24 = load i32*, i32** %14
store i32 0, i32* %24
br label %25
25: ; preds = %63, %7
%26 = load double, double* %17
store double %26, double* %16
%27 = load i32, i32* %23
%28 = add nsw i32 %27, 1
store i32 %28, i32* %23
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = load i32, i32* %10
%32 = load double, double* %16
%33 = fmul double %32, 0x404CA5DC1A63C1F5
%34 = fdiv double %33, 1.500000e+01
%35 = call double @days(i32 %29, i32 %30, i32 %31, double %34)
%36 = load double, double* %11
%37 = fdiv double %36, 2.400000e+01
%38 = fsub double %35, %37
store double %38, double* %21
%39 = load double, double* %21
%40 = call double @gst(double %39)
%41 = load double, double* %13
%42 = fadd double %40, %41
store double %42, double* %22
%43 = load double, double* %21
%44 = call i32 @moonpos(double %43, double* %18, double* %19, double* %20)
%45 = load double, double* %21
%46 = call i32 @equatorial(double %45, double* %18, double* %19, double* %20)
%47 = load double, double* %22
%48 = load double, double* %12
%49 = call i32 @topo(double %47, double %48, double* %18, double* %19, double* %20)
%50 = load double, double* %22
%51 = load double, double* %18
%52 = fsub double %50, %51
%53 = call double @rangerad(double %52)
store double %53, double* %15
%54 = load double, double* %16
%55 = load double, double* %15
%56 = fsub double %54, %55
%57 = call double @rangerad(double %56)
store double %57, double* %17
%58 = load i32, i32* %23
%59 = icmp sgt i32 %58, 30
br i1 %59, label %60, label %62
60: ; preds = %25
%61 = load i32*, i32** %14
store i32 1, i32* %61
br label %69
62: ; preds = %25
br label %63
63: ; preds = %62
%64 = load double, double* %16
%65 = load double, double* %17
%66 = fsub double %64, %65
%67 = call double @llvm.fabs.f64(double %66)
%68 = fcmp ogt double %67, 0x3F46E05A695F8192
br i1 %68, label %25, label %69
69: ; preds = %63, %60
%70 = load double, double* %17
ret double %70
}

LLVM IR (-O2):
define double @moontransit(i32 %0, i32 %1, i32 %2, double %3, double %4, double %5, i32* nocapture writeonly %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = bitcast double* %8 to i8*
%12 = bitcast double* %9 to i8*
%13 = bitcast double* %10 to i8*
store i32 0, i32* %6
%14 = fdiv double %3, 2.400000e+01
br label %15
15: ; preds = %34, %7
%16 = phi double [ 0x400921FB54442D1A, %7 ], [ %31, %34 ]
%17 = phi i32 [ 0, %7 ], [ %35, %34 ]
%18 = fmul double %16, 0x404CA5DC1A63C1F5
%19 = fdiv double %18, 1.500000e+01
%20 = call double @days(i32 %0, i32 %1, i32 %2, double %19)
%21 = fsub double %20, %14
%22 = call double @gst(double %21)
%23 = fadd double %22, %5
%24 = call i32 @moonpos(double %21, double* %8, double* %9, double* %10)
%25 = call i32 @equatorial(double %21, double* %8, double* %9, double* %10)
%26 = call i32 @topo(double %23, double %4, double* %8, double* %9, double* %10)
%27 = load double, double* %8
%28 = fsub double %23, %27
%29 = call double @rangerad(double %28)
%30 = fsub double %16, %29
%31 = call double @rangerad(double %30)
%32 = icmp eq i32 %17, 30
br i1 %32, label %33, label %34
33: ; preds = %15
store i32 1, i32* %6
br label %39
34: ; preds = %15
%35 = add nuw nsw i32 %17, 1
%36 = fsub double %16, %31
%37 = call double @llvm.fabs.f64(double %36)
%38 = fcmp ogt double %37, 0x3F46E05A695F8192
br i1 %38, label %15, label %39
39: ; preds = %34, %33
ret double %31
}