#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_gibbs(int, int, int, double, double, double);
double sqrt(double);
double gsw_sound_speed_t_exact(double sa, double t, double p) {
  int n0, n1, n2;
  double g_tt, g_tp;
  n0 = 0;
  n1 = 1;
  n2 = 2;
  g_tt = gsw_gibbs(n0, n2, n0, sa, t, p);
  g_tp = gsw_gibbs(n0, n1, n1, sa, t, p);
  return (gsw_gibbs(n0, n0, n1, sa, t, p) *
          sqrt(g_tt / (g_tp * g_tp - g_tt * gsw_gibbs(n0, n0, n2, sa, t, p))));
}


x86 assembly (clang, -O0):
<gsw_sound_speed_t_exact>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x2,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x1c(%rbp),%edx
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1040 <gsw_gibbs@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x20(%rbp),%edx
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1040 <gsw_gibbs@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1040 <gsw_gibbs@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1040 <gsw_gibbs@plt>
movsd  -0x60(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm3
movaps %xmm0,%xmm4
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm4,%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gsw_sound_speed_t_exact>:
sub    $0x38,%rsp
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
xor    %edi,%edi
mov    $0x2,%esi
xor    %edx,%edx
call   1040 <gsw_gibbs@plt>
movsd  %xmm0,0x28(%rsp)
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x1,%edx
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
call   1040 <gsw_gibbs@plt>
movsd  %xmm0,0x20(%rsp)
xor    %edi,%edi
xor    %esi,%esi
mov    $0x1,%edx
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
call   1040 <gsw_gibbs@plt>
movsd  %xmm0,0x30(%rsp)
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2,%edx
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
call   1040 <gsw_gibbs@plt>
movsd  0x28(%rsp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0x20(%rsp),%xmm2
mulsd  %xmm2,%xmm2
subsd  %xmm0,%xmm2
divsd  %xmm2,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
jb     11e9 <gsw_sound_speed_t_exact+0xc9>
sqrtsd %xmm0,%xmm0
jmp    11ee <gsw_sound_speed_t_exact+0xce>
call   1030 <sqrt@plt>
movsd  0x30(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @gsw_sound_speed_t_exact(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
store i32 0, i32* %7
store i32 1, i32* %8
store i32 2, i32* %9
%12 = load i32, i32* %7
%13 = load i32, i32* %9
%14 = load i32, i32* %7
%15 = load double, double* %4
%16 = load double, double* %5
%17 = load double, double* %6
%18 = call double @gsw_gibbs(i32 %12, i32 %13, i32 %14, double %15, double %16, double %17)
store double %18, double* %10
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = load i32, i32* %8
%22 = load double, double* %4
%23 = load double, double* %5
%24 = load double, double* %6
%25 = call double @gsw_gibbs(i32 %19, i32 %20, i32 %21, double %22, double %23, double %24)
store double %25, double* %11
%26 = load i32, i32* %7
%27 = load i32, i32* %7
%28 = load i32, i32* %8
%29 = load double, double* %4
%30 = load double, double* %5
%31 = load double, double* %6
%32 = call double @gsw_gibbs(i32 %26, i32 %27, i32 %28, double %29, double %30, double %31)
%33 = load double, double* %10
%34 = load double, double* %11
%35 = load double, double* %11
%36 = load double, double* %10
%37 = load i32, i32* %7
%38 = load i32, i32* %7
%39 = load i32, i32* %9
%40 = load double, double* %4
%41 = load double, double* %5
%42 = load double, double* %6
%43 = call double @gsw_gibbs(i32 %37, i32 %38, i32 %39, double %40, double %41, double %42)
%44 = fmul double %36, %43
%45 = fneg double %44
%46 = call double @llvm.fmuladd.f64(double %34, double %35, double %45)
%47 = fdiv double %33, %46
%48 = call double @sqrt(double %47)
%49 = fmul double %32, %48
ret double %49
}

LLVM IR (-O2):
define double @gsw_sound_speed_t_exact(double %0, double %1, double %2) {
%4 = tail call double @gsw_gibbs(i32 0, i32 2, i32 0, double %0, double %1, double %2)
%5 = tail call double @gsw_gibbs(i32 0, i32 1, i32 1, double %0, double %1, double %2)
%6 = tail call double @gsw_gibbs(i32 0, i32 0, i32 1, double %0, double %1, double %2)
%7 = tail call double @gsw_gibbs(i32 0, i32 0, i32 2, double %0, double %1, double %2)
%8 = fneg double %4
%9 = fmul double %7, %8
%10 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %9)
%11 = fdiv double %4, %10
%12 = tail call double @sqrt(double %11)
%13 = fmul double %6, %12
ret double %13
}