#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 adiabatic_temperature_gradient(double, double, double);
double potential_temperature(double salinity, double temperature,
                             double pressure, double reference_pressure) {
  double h, xk, q;
  h = reference_pressure - pressure;
  xk = h * adiabatic_temperature_gradient(salinity, temperature, pressure);
  temperature += 0.5 * xk;
  q = xk;
  pressure += 0.5 * h;
  xk = h * adiabatic_temperature_gradient(salinity, temperature, pressure);
  temperature += 0.29289322 * (xk - q);
  q = 0.58578644 * xk + 0.121320344 * q;
  xk = h * adiabatic_temperature_gradient(salinity, temperature, pressure);
  temperature += 1.707106781 * (xk - q);
  q = 3.414213562 * xk - 4.121320344 * q;
  pressure += 0.5 * h;
  xk = h * adiabatic_temperature_gradient(salinity, temperature, pressure);
  return temperature + (xk - 2.0 * q) / 0.6;
}


x86 assembly (clang, -O0):
<potential_temperature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1030 <adiabatic_temperature_gradient@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe8c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe63(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1030 <adiabatic_temperature_gradient@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe40(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe1e(%rip),%xmm1
mulsd  -0x38(%rbp),%xmm1
movsd  0xe09(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1030 <adiabatic_temperature_gradient@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xdae(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xd8c(%rip),%xmm1
mulsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xd60(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xd39(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1030 <adiabatic_temperature_gradient@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
addsd  %xmm2,%xmm2
subsd  %xmm2,%xmm1
movsd  0xcd6(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<potential_temperature>:
sub    $0x38,%rsp
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x30(%rsp)
subsd  %xmm2,%xmm3
movsd  %xmm3,0x20(%rsp)
call   1030 <adiabatic_temperature_gradient@plt>
movsd  0x20(%rsp),%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xeb3(%rip),%xmm3
movapd %xmm0,%xmm1
mulsd  %xmm3,%xmm1
addsd  0x28(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm2,%xmm3
movsd  %xmm3,0x28(%rsp)
movsd  0x18(%rsp),%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,0x18(%rsp)
movsd  0x30(%rsp),%xmm0
call   1030 <adiabatic_temperature_gradient@plt>
mulsd  0x20(%rsp),%xmm0
movapd %xmm0,%xmm2
movsd  0x10(%rsp),%xmm1
subsd  %xmm1,%xmm2
mulsd  0xe66(%rip),%xmm2
mulsd  0xe66(%rip),%xmm1
addsd  0x8(%rsp),%xmm2
movsd  %xmm2,0x10(%rsp)
mulsd  0xe5a(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x30(%rsp),%xmm0
movapd %xmm2,%xmm1
movsd  0x18(%rsp),%xmm2
call   1030 <adiabatic_temperature_gradient@plt>
mulsd  0x20(%rsp),%xmm0
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm2
subsd  %xmm2,%xmm1
mulsd  0xe27(%rip),%xmm1
addsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  0xe1b(%rip),%xmm2
mulsd  0xe1b(%rip),%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm2
addsd  0x28(%rsp),%xmm2
movsd  0x30(%rsp),%xmm0
call   1030 <adiabatic_temperature_gradient@plt>
mulsd  0x20(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
divsd  0xde6(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @potential_temperature(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
%11 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%12 = load double, double* %8
%13 = load double, double* %7
%14 = fsub double %12, %13
store double %14, double* %9
%15 = load double, double* %9
%16 = load double, double* %5
%17 = load double, double* %6
%18 = load double, double* %7
%19 = call double @adiabatic_temperature_gradient(double %16, double %17, double %18)
%20 = fmul double %15, %19
store double %20, double* %10
%21 = load double, double* %10
%22 = load double, double* %6
%23 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %21, double %22)
store double %23, double* %6
%24 = load double, double* %10
store double %24, double* %11
%25 = load double, double* %9
%26 = load double, double* %7
%27 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %25, double %26)
store double %27, double* %7
%28 = load double, double* %9
%29 = load double, double* %5
%30 = load double, double* %6
%31 = load double, double* %7
%32 = call double @adiabatic_temperature_gradient(double %29, double %30, double %31)
%33 = fmul double %28, %32
store double %33, double* %10
%34 = load double, double* %10
%35 = load double, double* %11
%36 = fsub double %34, %35
%37 = load double, double* %6
%38 = call double @llvm.fmuladd.f64(double 0x3FD2BEC33447B043, double %36, double %37)
store double %38, double* %6
%39 = load double, double* %10
%40 = load double, double* %11
%41 = fmul double 0x3FBF0ED99DD1C8C6, %40
%42 = call double @llvm.fmuladd.f64(double 0x3FE2BEC33447B043, double %39, double %41)
store double %42, double* %11
%43 = load double, double* %9
%44 = load double, double* %5
%45 = load double, double* %6
%46 = load double, double* %7
%47 = call double @adiabatic_temperature_gradient(double %44, double %45, double %46)
%48 = fmul double %43, %47
store double %48, double* %10
%49 = load double, double* %10
%50 = load double, double* %11
%51 = fsub double %49, %50
%52 = load double, double* %6
%53 = call double @llvm.fmuladd.f64(double 0x3FFB504F3332CC1F, double %51, double %52)
store double %53, double* %6
%54 = load double, double* %10
%55 = load double, double* %11
%56 = fmul double 0x40107C3B66774723, %55
%57 = fneg double %56
%58 = call double @llvm.fmuladd.f64(double 0x400B504F3332CC1F, double %54, double %57)
store double %58, double* %11
%59 = load double, double* %9
%60 = load double, double* %7
%61 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %59, double %60)
store double %61, double* %7
%62 = load double, double* %9
%63 = load double, double* %5
%64 = load double, double* %6
%65 = load double, double* %7
%66 = call double @adiabatic_temperature_gradient(double %63, double %64, double %65)
%67 = fmul double %62, %66
store double %67, double* %10
%68 = load double, double* %6
%69 = load double, double* %10
%70 = load double, double* %11
%71 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %70, double %69)
%72 = fdiv double %71, 6.000000e-01
%73 = fadd double %68, %72
ret double %73
}

LLVM IR (-O2):
define double @potential_temperature(double %0, double %1, double %2, double %3) {
%5 = fsub double %3, %2
%6 = tail call double @adiabatic_temperature_gradient(double %0, double %1, double %2)
%7 = fmul double %5, %6
%8 = tail call double @llvm.fmuladd.f64(double %7, double 5.000000e-01, double %1)
%9 = tail call double @llvm.fmuladd.f64(double %5, double 5.000000e-01, double %2)
%10 = tail call double @adiabatic_temperature_gradient(double %0, double %8, double %9)
%11 = fmul double %5, %10
%12 = fsub double %11, %7
%13 = tail call double @llvm.fmuladd.f64(double %12, double 0x3FD2BEC33447B043, double %8)
%14 = fmul double %7, 0x3FBF0ED99DD1C8C6
%15 = tail call double @llvm.fmuladd.f64(double %11, double 0x3FE2BEC33447B043, double %14)
%16 = tail call double @adiabatic_temperature_gradient(double %0, double %13, double %9)
%17 = fmul double %5, %16
%18 = fsub double %17, %15
%19 = tail call double @llvm.fmuladd.f64(double %18, double 0x3FFB504F3332CC1F, double %13)
%20 = fmul double %15, 0xC0107C3B66774723
%21 = tail call double @llvm.fmuladd.f64(double %17, double 0x400B504F3332CC1F, double %20)
%22 = tail call double @llvm.fmuladd.f64(double %5, double 5.000000e-01, double %9)
%23 = tail call double @adiabatic_temperature_gradient(double %0, double %19, double %22)
%24 = fmul double %5, %23
%25 = tail call double @llvm.fmuladd.f64(double %21, double -2.000000e+00, double %24)
%26 = fdiv double %25, 6.000000e-01
%27 = fadd double %19, %26
ret double %27
}