#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 log(double);
double pow(double, double);
double sqrt(double);
double F0(double mass, double momentum) {
  if (mass < 1.0e-100)
    return pow(momentum, 2.0) / 2.0;
  double E = sqrt(pow(mass, 2.0) + pow(momentum, 2.0));
  double first_term = momentum * E;
  double second_term = -pow(mass, 2.0) * log(momentum + E);
  double third_term = pow(mass, 2.0) * log(mass);
  if (third_term != third_term)
    third_term = 0;
  return (1.0 / 2.0) * (first_term + second_term + third_term);
}


x86 assembly (clang, -O0):
<F0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  0xeb6(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    117d <F0+0x4d>
movsd  -0x18(%rbp),%xmm0
movsd  0xea6(%rip),%xmm1
call   1040 <pow@plt>
movsd  0xe99(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128e <F0+0x15e>
movsd  -0x10(%rbp),%xmm0
movsd  0xe7e(%rip),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe67(%rip),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe30(%rip),%xmm1
call   1040 <pow@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xde2(%rip),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jne    1266 <F0+0x136>
jp     1266 <F0+0x136>
jmp    126e <F0+0x13e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm1
addsd  -0x30(%rbp),%xmm1
addsd  -0x38(%rbp),%xmm1
movsd  0xd8b(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<F0>:
sub    $0x28,%rsp
movapd %xmm1,%xmm2
movsd  0xed0(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    113f <F0+0x1f>
mulsd  %xmm2,%xmm2
jmp    11cb <F0+0xab>
movsd  %xmm0,0x20(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm1,0x18(%rsp)
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     116f <F0+0x4f>
sqrtsd %xmm0,%xmm0
jmp    117e <F0+0x5e>
movapd %xmm2,(%rsp)
call   1040 <sqrt@plt>
movapd (%rsp),%xmm2
movapd %xmm0,%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,(%rsp)
addsd  %xmm2,%xmm0
call   1030 <log@plt>
mulsd  0x18(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <log@plt>
mulsd  0x18(%rsp),%xmm0
movapd %xmm0,%xmm2
cmpordsd %xmm0,%xmm2
andpd  %xmm0,%xmm2
addsd  (%rsp),%xmm2
mulsd  0xe35(%rip),%xmm2
movapd %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @F0(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %4
store double %1, double* %5
%10 = load double, double* %4
%11 = fcmp olt double %10, 1.000000e-100
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load double, double* %5
%14 = call double @pow(double %13, double 2.000000e+00)
%15 = fdiv double %14, 2.000000e+00
store double %15, double* %3
br label %50
16: ; preds = %2
%17 = load double, double* %4
%18 = call double @pow(double %17, double 2.000000e+00)
%19 = load double, double* %5
%20 = call double @pow(double %19, double 2.000000e+00)
%21 = fadd double %18, %20
%22 = call double @sqrt(double %21)
store double %22, double* %6
%23 = load double, double* %5
%24 = load double, double* %6
%25 = fmul double %23, %24
store double %25, double* %7
%26 = load double, double* %4
%27 = call double @pow(double %26, double 2.000000e+00)
%28 = fneg double %27
%29 = load double, double* %5
%30 = load double, double* %6
%31 = fadd double %29, %30
%32 = call double @log(double %31)
%33 = fmul double %28, %32
store double %33, double* %8
%34 = load double, double* %4
%35 = call double @pow(double %34, double 2.000000e+00)
%36 = load double, double* %4
%37 = call double @log(double %36)
%38 = fmul double %35, %37
store double %38, double* %9
%39 = load double, double* %9
%40 = load double, double* %9
%41 = fcmp une double %39, %40
br i1 %41, label %42, label %43
42: ; preds = %16
store double 0.000000e+00, double* %9
br label %43
43: ; preds = %42, %16
%44 = load double, double* %7
%45 = load double, double* %8
%46 = fadd double %44, %45
%47 = load double, double* %9
%48 = fadd double %46, %47
%49 = fmul double 5.000000e-01, %48
store double %49, double* %3
br label %50
50: ; preds = %43, %12
%51 = load double, double* %3
ret double %51
}

LLVM IR (-O2):
define double @F0(double %0, double %1) {
%3 = fcmp olt double %0, 1.000000e-100
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = fmul double %1, %1
br label %23
6: ; preds = %2
%7 = fmul double %0, %0
%8 = fmul double %1, %1
%9 = fadd double %7, %8
%10 = tail call double @sqrt(double %9)
%11 = fmul double %10, %1
%12 = fneg double %0
%13 = fmul double %12, %0
%14 = fadd double %10, %1
%15 = tail call double @log(double %14)
%16 = fmul double %13, %15
%17 = tail call double @log(double %0)
%18 = fmul double %7, %17
%19 = fcmp ord double %18, 0.000000e+00
%20 = select i1 %19, double %18, double 0.000000e+00
%21 = fadd double %11, %16
%22 = fadd double %21, %20
br label %23
23: ; preds = %6, %4
%24 = phi double [ %5, %4 ], [ %22, %6 ]
%25 = fmul double %24, 5.000000e-01
ret double %25
}