#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 acos(int);
double sqrt(double);
double calc_dip(double geoalt, double atpress, double attemp,
                double lapse_rate) {
  double krefr = (0.0342 + lapse_rate) / (0.154 * 0.0238);
  double d =
      1 - 1.8480 * krefr * atpress / (273.16 + attemp) / (273.16 + attemp);
  return -180.0 / 3.14159265358979323846 * acos(1 / (1 + geoalt / 6378136.6)) *
         sqrt(d);
}


x86 assembly (clang, -O0):
<calc_dip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  0xeec(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xed7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xebe(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xea4(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe93(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe72(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe64(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe50(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xe44(%rip),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <acos@plt>
movaps %xmm0,%xmm1
movsd  0xe24(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_dip>:
push   %rax
addsd  0xed7(%rip),%xmm3
divsd  0xed7(%rip),%xmm3
mulsd  0xed7(%rip),%xmm3
mulsd  %xmm1,%xmm3
addsd  0xed3(%rip),%xmm2
divsd  %xmm2,%xmm3
divsd  %xmm2,%xmm3
movsd  0xecb(%rip),%xmm1
addsd  %xmm1,%xmm3
movsd  %xmm3,(%rsp)
divsd  0xec2(%rip),%xmm0
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <acos@plt>
movsd  (%rsp),%xmm1
movapd %xmm0,%xmm2
mulsd  0xea8(%rip),%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     119b <calc_dip+0x7b>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    11ae <calc_dip+0x8e>
movapd %xmm1,%xmm0
movsd  %xmm2,(%rsp)
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @calc_dip(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%11 = load double, double* %8
%12 = fadd double 3.420000e-02, %11
%13 = fdiv double %12, 0x3F6E067B4443FCB0
store double %13, double* %9
%14 = load double, double* %9
%15 = fmul double 1.848000e+00, %14
%16 = load double, double* %6
%17 = fmul double %15, %16
%18 = load double, double* %7
%19 = fadd double 2.731600e+02, %18
%20 = fdiv double %17, %19
%21 = load double, double* %7
%22 = fadd double 2.731600e+02, %21
%23 = fdiv double %20, %22
%24 = fsub double 1.000000e+00, %23
store double %24, double* %10
%25 = load double, double* %5
%26 = fdiv double %25, 0x415854A626666666
%27 = fadd double 1.000000e+00, %26
%28 = fdiv double 1.000000e+00, %27
%29 = fptosi double %28 to i32
%30 = call double @acos(i32 %29)
%31 = fmul double 0xC04CA5DC1A63C1F8, %30
%32 = load double, double* %10
%33 = call double @sqrt(double %32)
%34 = fmul double %31, %33
ret double %34
}

LLVM IR (-O2):
define double @calc_dip(double %0, double %1, double %2, double %3) {
%5 = fadd double %3, 3.420000e-02
%6 = fdiv double %5, 0x3F6E067B4443FCB0
%7 = fmul double %6, 1.848000e+00
%8 = fmul double %7, %1
%9 = fadd double %2, 2.731600e+02
%10 = fdiv double %8, %9
%11 = fdiv double %10, %9
%12 = fsub double 1.000000e+00, %11
%13 = fdiv double %0, 0x415854A626666666
%14 = fadd double %13, 1.000000e+00
%15 = fdiv double 1.000000e+00, %14
%16 = fptosi double %15 to i32
%17 = tail call double @acos(i32 %16)
%18 = fmul double %17, 0xC04CA5DC1A63C1F8
%19 = tail call double @sqrt(double %12)
%20 = fmul double %18, %19
ret double %20
}