#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 gsw_z_from_p(double, double);
double sin(double);
double gsw_grav(double lat, double p) {
  double pi = 3.141592653589793e0;
  double gamma, deg2rad, x, sin2, gs, z;
  gamma = 2.26e-7;
  deg2rad = pi / 180e0;
  x = sin(lat * deg2rad);
  sin2 = x * x;
  gs = 9.780327e0 * (1.0e0 + (5.2792e-3 + (2.32e-5 * sin2)) * sin2);
  z = gsw_z_from_p(p, lat);
  return (gs * (1 - gamma * z));
}


x86 assembly (clang, -O0):
<gsw_grav>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  0xef6(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xee1(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xec7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  0xe7e(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe7a(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe4d(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe49(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1040 <gsw_z_from_p@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xdf2(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gsw_grav>:
sub    $0x18,%rsp
movsd  %xmm1,0x10(%rsp)
movapd %xmm0,%xmm1
movsd  %xmm0,0x8(%rsp)
movsd  0xec4(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
mulsd  %xmm0,%xmm0
movsd  0xeb7(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xeb3(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  0xeaf(%rip),%xmm0
mulsd  0xeaf(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1040 <gsw_z_from_p@plt>
mulsd  0xe99(%rip),%xmm0
addsd  0xe81(%rip),%xmm0
mulsd  (%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @gsw_grav(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %3
store double %1, double* %4
store double 0x400921FB54442D18, double* %5
store double 2.260000e-07, double* %6
%12 = load double, double* %5
%13 = fdiv double %12, 1.800000e+02
store double %13, double* %7
%14 = load double, double* %3
%15 = load double, double* %7
%16 = fmul double %14, %15
%17 = call double @sin(double %16)
store double %17, double* %8
%18 = load double, double* %8
%19 = load double, double* %8
%20 = fmul double %18, %19
store double %20, double* %9
%21 = load double, double* %9
%22 = call double @llvm.fmuladd.f64(double 2.320000e-05, double %21, double 5.279200e-03)
%23 = load double, double* %9
%24 = call double @llvm.fmuladd.f64(double %22, double %23, double 1.000000e+00)
%25 = fmul double 0x40238F8705425F20, %24
store double %25, double* %10
%26 = load double, double* %4
%27 = load double, double* %3
%28 = call double @gsw_z_from_p(double %26, double %27)
store double %28, double* %11
%29 = load double, double* %10
%30 = load double, double* %6
%31 = load double, double* %11
%32 = fneg double %30
%33 = call double @llvm.fmuladd.f64(double %32, double %31, double 1.000000e+00)
%34 = fmul double %29, %33
ret double %34
}

LLVM IR (-O2):
define double @gsw_grav(double %0, double %1) {
%3 = fmul double %0, 0x3F91DF46A2529D39
%4 = tail call double @sin(double %3)
%5 = fmul double %4, %4
%6 = tail call double @llvm.fmuladd.f64(double %5, double 2.320000e-05, double 5.279200e-03)
%7 = tail call double @llvm.fmuladd.f64(double %6, double %5, double 1.000000e+00)
%8 = fmul double %7, 0x40238F8705425F20
%9 = tail call double @gsw_z_from_p(double %1, double %0)
%10 = tail call double @llvm.fmuladd.f64(double %9, double -2.260000e-07, double 1.000000e+00)
%11 = fmul double %10, %8
ret double %11
}