#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 */
int log(int);
int pow(double, int);
double psi_h(double t0_dem, double h, double U_0, double roh_air) {
  double most_L, most_x, psi_h;
  if (h != 0.0) {
    most_L = (-1004 * roh_air * pow(U_0, 3) * t0_dem) / (0.41 * 9.81 * h);
  } else {
    most_L = -1000.0;
  }
  if (most_L < 0.0) {
    most_x = pow((1 - 16 * (2 / most_L)), 0.25);
    psi_h = (2 * log((1 + pow(most_x, 2)) / 2));
  } else {
    most_x = 1.0;
    psi_h = -5 * 2 / most_L;
  }
  return (psi_h);
}


x86 assembly (clang, -O0):
<psi_h>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1159 <psi_h+0x39>
jp     1159 <psi_h+0x39>
jmp    11a7 <psi_h+0x87>
movsd  0xeaf(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    $0x3,%edi
call   1040 <pow@plt>
movsd  -0x40(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xe74(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11b4 <psi_h+0x94>
movsd  0xe51(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1229 <psi_h+0x109>
movsd  0xe66(%rip),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  0xe51(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe3d(%rip),%xmm1
addsd  %xmm1,%xmm0
xor    %edi,%edi
call   1040 <pow@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <log@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1248 <psi_h+0x128>
movsd  0xdef(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xdda(%rip),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psi_h>:
sub    $0x18,%rsp
movapd %xmm0,%xmm4
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1134 <psi_h+0x14>
jnp    1199 <psi_h+0x79>
mulsd  0xecc(%rip),%xmm3
movsd  %xmm3,(%rsp)
movaps %xmm2,%xmm0
mov    $0x3,%edi
movsd  %xmm1,0x8(%rsp)
movsd  %xmm4,0x10(%rsp)
call   1040 <pow@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  0xe9c(%rip),%xmm0
mulsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
ja     11a1 <psi_h+0x81>
movsd  0xe88(%rip),%xmm0
divsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
movsd  0xe5f(%rip),%xmm1
movsd  0xe77(%rip),%xmm0
divsd  %xmm1,%xmm0
mulsd  0xe73(%rip),%xmm0
addsd  0xe73(%rip),%xmm0
xor    %edi,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %eax,%ecx
add    $0x1,%ecx
shr    $0x1f,%ecx
lea    (%rax,%rcx,1),%edi
add    $0x1,%edi
sar    %edi
call   1030 <log@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @psi_h(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* %6
%13 = fcmp une double %12, 0.000000e+00
br i1 %13, label %14, label %26
14: ; preds = %4
%15 = load double, double* %8
%16 = fmul double -1.004000e+03, %15
%17 = load double, double* %7
%18 = call i32 @pow(double %17, i32 3)
%19 = sitofp i32 %18 to double
%20 = fmul double %16, %19
%21 = load double, double* %5
%22 = fmul double %20, %21
%23 = load double, double* %6
%24 = fmul double 4.022100e+00, %23
%25 = fdiv double %22, %24
store double %25, double* %9
br label %27
26: ; preds = %4
store double -1.000000e+03, double* %9
br label %27
27: ; preds = %26, %14
%28 = load double, double* %9
%29 = fcmp olt double %28, 0.000000e+00
br i1 %29, label %30, label %43
30: ; preds = %27
%31 = load double, double* %9
%32 = fdiv double 2.000000e+00, %31
%33 = call double @llvm.fmuladd.f64(double -1.600000e+01, double %32, double 1.000000e+00)
%34 = call i32 @pow(double %33, i32 0)
%35 = sitofp i32 %34 to double
store double %35, double* %10
%36 = load double, double* %10
%37 = call i32 @pow(double %36, i32 2)
%38 = add nsw i32 1, %37
%39 = sdiv i32 %38, 2
%40 = call i32 @log(i32 %39)
%41 = mul nsw i32 2, %40
%42 = sitofp i32 %41 to double
store double %42, double* %11
br label %46
43: ; preds = %27
store double 1.000000e+00, double* %10
%44 = load double, double* %9
%45 = fdiv double -1.000000e+01, %44
store double %45, double* %11
br label %46
46: ; preds = %43, %30
%47 = load double, double* %11
ret double %47
}

LLVM IR (-O2):
define double @psi_h(double %0, double %1, double %2, double %3) {
%5 = fcmp une double %1, 0.000000e+00
br i1 %5, label %6, label %15
6: ; preds = %4
%7 = fmul double %3, -1.004000e+03
%8 = tail call i32 @pow(double %2, i32 3)
%9 = sitofp i32 %8 to double
%10 = fmul double %7, %9
%11 = fmul double %10, %0
%12 = fmul double %1, 4.022100e+00
%13 = fdiv double %11, %12
%14 = fcmp olt double %13, 0.000000e+00
br i1 %14, label %15, label %27
15: ; preds = %4, %6
%16 = phi double [ %13, %6 ], [ -1.000000e+03, %4 ]
%17 = fdiv double 2.000000e+00, %16
%18 = tail call double @llvm.fmuladd.f64(double %17, double -1.600000e+01, double 1.000000e+00)
%19 = tail call i32 @pow(double %18, i32 0)
%20 = sitofp i32 %19 to double
%21 = tail call i32 @pow(double %20, i32 2)
%22 = add nsw i32 %21, 1
%23 = sdiv i32 %22, 2
%24 = tail call i32 @log(i32 %23)
%25 = shl nsw i32 %24, 1
%26 = sitofp i32 %25 to double
br label %29
27: ; preds = %6
%28 = fdiv double -1.000000e+01, %13
br label %29
29: ; preds = %27, %15
%30 = phi double [ %26, %15 ], [ %28, %27 ]
ret double %30
}