#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_entropy_part(double, double, double);
double gsw_entropy_part_zerop(double, double);
double gsw_gibbs_pt0_pt0(double, double);
double gsw_pt0_from_t(double sa, double t, double p) {
  int n0, n2, no_iter;
  double pt0, pt0_old, dentropy, dentropy_dt, sso, cp0;
  double s1, true_entropy_part, pt0m;
  n0 = 0;
  n2 = 2;
  cp0 = 3991.86795711963e0;
  sso = 35.16504e0;
  s1 = sa * 35e0 / sso;
  pt0 = t + p * (8.65483913395442e-6 - s1 * 1.41636299744881e-6 -
                 p * 7.38286467135737e-9 +
                 t * (-8.38241357039698e-6 + s1 * 2.83933368585534e-8 +
                      t * 1.77803965218656e-8 + p * 1.71155619208233e-10));
  dentropy_dt = cp0 / ((273.15e0 + pt0) * (1e0 - 0.05e0 * (1e0 - sa / sso)));
  true_entropy_part = gsw_entropy_part(sa, t, p);
  for (no_iter = 1; no_iter <= 2; no_iter++) {
    pt0_old = pt0;
    dentropy = gsw_entropy_part_zerop(sa, pt0_old) - true_entropy_part;
    pt0 = pt0_old - dentropy / dentropy_dt;
    pt0m = 0.5e0 * (pt0 + pt0_old);
    dentropy_dt = -gsw_gibbs_pt0_pt0(sa, pt0m);
    pt0 = pt0_old - dentropy / dentropy_dt;
  }
  return (pt0);
}


x86 assembly (clang, -O0):
<gsw_pt0_from_t>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
movsd  0xf03(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xeee(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xed9(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
movsd  0xe8c(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe88(%rip),%xmm3
addsd  %xmm3,%xmm2
movsd  -0x18(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
movsd  0xe50(%rip),%xmm4
mulsd  %xmm4,%xmm3
addsd  %xmm2,%xmm3
movsd  -0x10(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm4
movsd  0xe26(%rip),%xmm5
mulsd  %xmm5,%xmm4
movsd  0xe22(%rip),%xmm5
addsd  %xmm5,%xmm4
movsd  -0x10(%rbp),%xmm5
movsd  0xe01(%rip),%xmm6
mulsd  %xmm6,%xmm5
addsd  %xmm4,%xmm5
movsd  -0x18(%rbp),%xmm4
movsd  0xde4(%rip),%xmm6
mulsd  %xmm6,%xmm4
addsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xdb2(%rip),%xmm1
addsd  -0x30(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm3
divsd  -0x50(%rbp),%xmm3
movsd  0xd93(%rip),%xmm2
subsd  %xmm3,%xmm2
movsd  0xd7f(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xd7b(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1040 <gsw_entropy_part@plt>
movsd  %xmm0,-0x68(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jg     136f <gsw_pt0_from_t+0x23f>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1030 <gsw_entropy_part_zerop@plt>
subsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
divsd  -0x48(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
addsd  -0x38(%rbp),%xmm1
movsd  0xd53(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
call   1050 <gsw_gibbs_pt0_pt0@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
divsd  -0x48(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12be <gsw_pt0_from_t+0x18e>
movsd  -0x30(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gsw_pt0_from_t>:
sub    $0x28,%rsp
movsd  0xec4(%rip),%xmm3
mulsd  %xmm0,%xmm3
movsd  %xmm0,0x10(%rsp)
movsd  0xeba(%rip),%xmm6
divsd  %xmm6,%xmm3
movsd  0xeb6(%rip),%xmm4
mulsd  %xmm3,%xmm4
addsd  0xeb2(%rip),%xmm4
movsd  0xeb2(%rip),%xmm5
mulsd  %xmm2,%xmm5
mulsd  0xeae(%rip),%xmm3
addsd  %xmm4,%xmm5
addsd  0xeaa(%rip),%xmm3
movsd  0xeaa(%rip),%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm3,%xmm4
movsd  0xea2(%rip),%xmm7
mulsd  %xmm2,%xmm7
addsd  %xmm4,%xmm7
mulsd  %xmm1,%xmm7
addsd  %xmm5,%xmm7
mulsd  %xmm2,%xmm7
addsd  %xmm1,%xmm7
movsd  %xmm7,(%rsp)
movsd  0xe85(%rip),%xmm3
addsd  %xmm7,%xmm3
movapd %xmm0,%xmm4
divsd  %xmm6,%xmm4
movsd  0xe79(%rip),%xmm6
movapd %xmm6,%xmm5
subsd  %xmm4,%xmm5
mulsd  0xe71(%rip),%xmm5
addsd  %xmm6,%xmm5
mulsd  %xmm3,%xmm5
movsd  0xe69(%rip),%xmm3
divsd  %xmm5,%xmm3
movsd  %xmm3,0x18(%rsp)
call   1040 <gsw_entropy_part@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1030 <gsw_entropy_part_zerop@plt>
subsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd %xmm0,%xmm1
divsd  0x18(%rsp),%xmm1
movsd  (%rsp),%xmm0
addsd  %xmm0,%xmm1
addsd  %xmm0,%xmm1
mulsd  0xe21(%rip),%xmm1
movsd  0x10(%rsp),%xmm0
call   1050 <gsw_gibbs_pt0_pt0@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  (%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <gsw_entropy_part_zerop@plt>
subsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
divsd  0x18(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm1
addsd  %xmm0,%xmm1
mulsd  0xdc5(%rip),%xmm1
movsd  0x10(%rsp),%xmm0
call   1050 <gsw_gibbs_pt0_pt0@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @gsw_pt0_from_t(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
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
store i32 0, i32* %7
store i32 2, i32* %8
store double 0x40AF2FBC64E02648, double* %15
store double 0x4041952007DD4413, double* %14
%19 = load double, double* %4
%20 = fmul double %19, 3.500000e+01
%21 = load double, double* %14
%22 = fdiv double %20, %21
store double %22, double* %16
%23 = load double, double* %5
%24 = load double, double* %6
%25 = load double, double* %16
%26 = fneg double %25
%27 = call double @llvm.fmuladd.f64(double %26, double 0x3EB7C33B95B88255, double 0x3EE22688087541E7)
%28 = load double, double* %6
%29 = fneg double %28
%30 = call double @llvm.fmuladd.f64(double %29, double 0x3E3FB58BA9535C76, double %27)
%31 = load double, double* %5
%32 = load double, double* %16
%33 = call double @llvm.fmuladd.f64(double %32, double 0x3E5E7CB3752F16F8, double 0xBEE19446261035E0)
%34 = load double, double* %5
%35 = call double @llvm.fmuladd.f64(double %34, double 0x3E5317702C99FB88, double %33)
%36 = load double, double* %6
%37 = call double @llvm.fmuladd.f64(double %36, double 0x3DE78600C409F84E, double %35)
%38 = call double @llvm.fmuladd.f64(double %31, double %37, double %30)
%39 = call double @llvm.fmuladd.f64(double %24, double %38, double %23)
store double %39, double* %10
%40 = load double, double* %15
%41 = load double, double* %10
%42 = fadd double 2.731500e+02, %41
%43 = load double, double* %4
%44 = load double, double* %14
%45 = fdiv double %43, %44
%46 = fsub double 1.000000e+00, %45
%47 = call double @llvm.fmuladd.f64(double -5.000000e-02, double %46, double 1.000000e+00)
%48 = fmul double %42, %47
%49 = fdiv double %40, %48
store double %49, double* %13
%50 = load double, double* %4
%51 = load double, double* %5
%52 = load double, double* %6
%53 = call double @gsw_entropy_part(double %50, double %51, double %52)
store double %53, double* %17
store i32 1, i32* %9
br label %54
54: ; preds = %82, %3
%55 = load i32, i32* %9
%56 = icmp sle i32 %55, 2
br i1 %56, label %57, label %85
57: ; preds = %54
%58 = load double, double* %10
store double %58, double* %11
%59 = load double, double* %4
%60 = load double, double* %11
%61 = call double @gsw_entropy_part_zerop(double %59, double %60)
%62 = load double, double* %17
%63 = fsub double %61, %62
store double %63, double* %12
%64 = load double, double* %11
%65 = load double, double* %12
%66 = load double, double* %13
%67 = fdiv double %65, %66
%68 = fsub double %64, %67
store double %68, double* %10
%69 = load double, double* %10
%70 = load double, double* %11
%71 = fadd double %69, %70
%72 = fmul double 5.000000e-01, %71
store double %72, double* %18
%73 = load double, double* %4
%74 = load double, double* %18
%75 = call double @gsw_gibbs_pt0_pt0(double %73, double %74)
%76 = fneg double %75
store double %76, double* %13
%77 = load double, double* %11
%78 = load double, double* %12
%79 = load double, double* %13
%80 = fdiv double %78, %79
%81 = fsub double %77, %80
store double %81, double* %10
br label %82
82: ; preds = %57
%83 = load i32, i32* %9
%84 = add nsw i32 %83, 1
store i32 %84, i32* %9
br label %54
85: ; preds = %54
%86 = load double, double* %10
ret double %86
}

LLVM IR (-O2):
define double @gsw_pt0_from_t(double %0, double %1, double %2) {
%4 = fmul double %0, 3.500000e+01
%5 = fdiv double %4, 0x4041952007DD4413
%6 = fneg double %5
%7 = tail call double @llvm.fmuladd.f64(double %6, double 0x3EB7C33B95B88255, double 0x3EE22688087541E7)
%8 = fneg double %2
%9 = tail call double @llvm.fmuladd.f64(double %8, double 0x3E3FB58BA9535C76, double %7)
%10 = tail call double @llvm.fmuladd.f64(double %5, double 0x3E5E7CB3752F16F8, double 0xBEE19446261035E0)
%11 = tail call double @llvm.fmuladd.f64(double %1, double 0x3E5317702C99FB88, double %10)
%12 = tail call double @llvm.fmuladd.f64(double %2, double 0x3DE78600C409F84E, double %11)
%13 = tail call double @llvm.fmuladd.f64(double %1, double %12, double %9)
%14 = tail call double @llvm.fmuladd.f64(double %2, double %13, double %1)
%15 = fadd double %14, 2.731500e+02
%16 = fdiv double %0, 0x4041952007DD4413
%17 = fsub double 1.000000e+00, %16
%18 = tail call double @llvm.fmuladd.f64(double %17, double -5.000000e-02, double 1.000000e+00)
%19 = fmul double %18, %15
%20 = fdiv double 0x40AF2FBC64E02648, %19
%21 = tail call double @gsw_entropy_part(double %0, double %1, double %2)
%22 = tail call double @gsw_entropy_part_zerop(double %0, double %14)
%23 = fsub double %22, %21
%24 = fdiv double %23, %20
%25 = fsub double %14, %24
%26 = fadd double %14, %25
%27 = fmul double %26, 5.000000e-01
%28 = tail call double @gsw_gibbs_pt0_pt0(double %0, double %27)
%29 = fdiv double %23, %28
%30 = fadd double %14, %29
%31 = tail call double @gsw_entropy_part_zerop(double %0, double %30)
%32 = fsub double %31, %21
%33 = fdiv double %32, %28
%34 = fadd double %30, %33
%35 = fadd double %30, %34
%36 = fmul double %35, 5.000000e-01
%37 = tail call double @gsw_gibbs_pt0_pt0(double %0, double %36)
%38 = fdiv double %32, %37
%39 = fadd double %30, %38
ret double %39
}