#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 svp(double);
double calc_pet(double rad, double ta, double pa, double dayl) {
  double rnet;
  double lhvap;
  double gamma;
  double dt = 0.2;
  double t1, t2;
  double pvs1, pvs2;
  double pet;
  double s;
  rnet = rad * 0.72;
  lhvap = 2.5023e6 - 2430.54 * ta;
  gamma = 1010.0 * pa / (lhvap * 0.62196351);
  t1 = ta + dt;
  t2 = ta - dt;
  pvs1 = svp(t1);
  pvs2 = svp(t2);
  s = (pvs1 - pvs2) / (t1 - t2);
  pet = (1.26 * (s / (s + gamma)) * rnet * dayl) / lhvap;
  return (pet / 10.0);
}


x86 assembly (clang, -O0):
<calc_pet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  0xf04(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xeef(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xec8(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xec4(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xea3(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe8e(%rip),%xmm1
mulsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1030 <svp@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1030 <svp@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
subsd  -0x50(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe04(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  0xdd7(%rip),%xmm1
divsd  %xmm1,%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_pet>:
sub    $0x38,%rsp
mulsd  0xee4(%rip),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0xede(%rip),%xmm4
mulsd  %xmm1,%xmm4
addsd  0xeda(%rip),%xmm4
movsd  %xmm4,0x20(%rsp)
mulsd  0xed4(%rip),%xmm2
movsd  %xmm3,0x28(%rsp)
movsd  0xece(%rip),%xmm0
mulsd  %xmm4,%xmm0
divsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%rsp)
movsd  0xec0(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
addsd  0xeb6(%rip),%xmm1
movsd  %xmm1,(%rsp)
call   1030 <svp@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1030 <svp@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
subsd  (%rsp),%xmm0
divsd  %xmm0,%xmm1
movsd  0x18(%rsp),%xmm0
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm1
mulsd  0xe75(%rip),%xmm1
mulsd  0x30(%rsp),%xmm1
mulsd  0x28(%rsp),%xmm1
divsd  0x20(%rsp),%xmm1
divsd  0xe63(%rip),%xmm1
movapd %xmm1,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @calc_pet(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
%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* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
store double 2.000000e-01, double* %12
%19 = load double, double* %5
%20 = fmul double %19, 0x3FE70A3D70A3D70A
store double %20, double* %9
%21 = load double, double* %6
%22 = call double @llvm.fmuladd.f64(double -2.430540e+03, double %21, double 2.502300e+06)
store double %22, double* %10
%23 = load double, double* %7
%24 = fmul double 1.010000e+03, %23
%25 = load double, double* %10
%26 = fmul double %25, 0x3FE3E72004D82BFC
%27 = fdiv double %24, %26
store double %27, double* %11
%28 = load double, double* %6
%29 = load double, double* %12
%30 = fadd double %28, %29
store double %30, double* %13
%31 = load double, double* %6
%32 = load double, double* %12
%33 = fsub double %31, %32
store double %33, double* %14
%34 = load double, double* %13
%35 = call double @svp(double %34)
store double %35, double* %15
%36 = load double, double* %14
%37 = call double @svp(double %36)
store double %37, double* %16
%38 = load double, double* %15
%39 = load double, double* %16
%40 = fsub double %38, %39
%41 = load double, double* %13
%42 = load double, double* %14
%43 = fsub double %41, %42
%44 = fdiv double %40, %43
store double %44, double* %18
%45 = load double, double* %18
%46 = load double, double* %18
%47 = load double, double* %11
%48 = fadd double %46, %47
%49 = fdiv double %45, %48
%50 = fmul double 1.260000e+00, %49
%51 = load double, double* %9
%52 = fmul double %50, %51
%53 = load double, double* %8
%54 = fmul double %52, %53
%55 = load double, double* %10
%56 = fdiv double %54, %55
store double %56, double* %17
%57 = load double, double* %17
%58 = fdiv double %57, 1.000000e+01
ret double %58
}

LLVM IR (-O2):
define double @calc_pet(double %0, double %1, double %2, double %3) {
%5 = fmul double %0, 0x3FE70A3D70A3D70A
%6 = tail call double @llvm.fmuladd.f64(double %1, double -2.430540e+03, double 2.502300e+06)
%7 = fmul double %2, 1.010000e+03
%8 = fmul double %6, 0x3FE3E72004D82BFC
%9 = fdiv double %7, %8
%10 = fadd double %1, 2.000000e-01
%11 = fadd double %1, -2.000000e-01
%12 = tail call double @svp(double %10)
%13 = tail call double @svp(double %11)
%14 = fsub double %12, %13
%15 = fsub double %10, %11
%16 = fdiv double %14, %15
%17 = fadd double %9, %16
%18 = fdiv double %16, %17
%19 = fmul double %18, 1.260000e+00
%20 = fmul double %5, %19
%21 = fmul double %20, %3
%22 = fdiv double %21, %6
%23 = fdiv double %22, 1.000000e+01
ret double %23
}