#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 exp(double);
float log1p(float);
double LogSumOfTwo(double value1, double value2) {
  double minValue, maxValue;
  minValue = value1, maxValue = value2;
  if (maxValue < minValue) {
    minValue = value2;
    maxValue = value1;
  }
  minValue *= 2.3025850929;
  maxValue *= 2.3025850929;
  double difference = minValue - maxValue;
  if (difference < -30) {
    return maxValue / 2.3025850929;
  } else if (difference < -8) {
    return (maxValue + exp(difference)) / 2.3025850929;
  } else {
    float expv = exp(difference);
    float log1pv = log1p(expv);
    return (maxValue + log1pv) / 2.3025850929;
  }
}


x86 assembly (clang, -O0):
<LogSumOfTwo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    116e <LogSumOfTwo+0x4e>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe92(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe80(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe57(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11cf <LogSumOfTwo+0xaf>
movsd  -0x28(%rbp),%xmm0
movsd  0xe47(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125d <LogSumOfTwo+0x13d>
movsd  0xe39(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1218 <LogSumOfTwo+0xf8>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  0xdfe(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125d <LogSumOfTwo+0x13d>
movsd  -0x30(%rbp),%xmm0
call   1030 <exp@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
call   1040 <log1p@plt>
movss  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movss  -0x38(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  0xdb4(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LogSumOfTwo>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
maxsd  %xmm1,%xmm2
minsd  %xmm0,%xmm1
movsd  0xec8(%rip),%xmm0
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
movsd  0xebc(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     118e <LogSumOfTwo+0x6e>
movsd  %xmm2,0x8(%rsp)
movapd %xmm1,%xmm0
movsd  %xmm1,0x10(%rsp)
call   1030 <exp@plt>
movsd  0xea1(%rip),%xmm1
ucomisd 0x10(%rsp),%xmm1
ja     1184 <LogSumOfTwo+0x64>
cvtsd2ss %xmm0,%xmm0
call   1040 <log1p@plt>
cvtss2sd %xmm0,%xmm0
movsd  0x8(%rsp),%xmm2
addsd  %xmm0,%xmm2
divsd  0xe6a(%rip),%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @LogSumOfTwo(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca float
%10 = alloca float
store double %0, double* %4
store double %1, double* %5
%11 = load double, double* %4
store double %11, double* %6
%12 = load double, double* %5
store double %12, double* %7
%13 = load double, double* %7
%14 = load double, double* %6
%15 = fcmp olt double %13, %14
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load double, double* %5
store double %17, double* %6
%18 = load double, double* %4
store double %18, double* %7
br label %19
19: ; preds = %16, %2
%20 = load double, double* %6
%21 = fmul double %20, 0x40026BB1BBB219D9
store double %21, double* %6
%22 = load double, double* %7
%23 = fmul double %22, 0x40026BB1BBB219D9
store double %23, double* %7
%24 = load double, double* %6
%25 = load double, double* %7
%26 = fsub double %24, %25
store double %26, double* %8
%27 = load double, double* %8
%28 = fcmp olt double %27, -3.000000e+01
br i1 %28, label %29, label %32
29: ; preds = %19
%30 = load double, double* %7
%31 = fdiv double %30, 0x40026BB1BBB219D9
store double %31, double* %3
br label %52
32: ; preds = %19
%33 = load double, double* %8
%34 = fcmp olt double %33, -8.000000e+00
br i1 %34, label %35, label %41
35: ; preds = %32
%36 = load double, double* %7
%37 = load double, double* %8
%38 = call double @exp(double %37)
%39 = fadd double %36, %38
%40 = fdiv double %39, 0x40026BB1BBB219D9
store double %40, double* %3
br label %52
41: ; preds = %32
%42 = load double, double* %8
%43 = call double @exp(double %42)
%44 = fptrunc double %43 to float
store float %44, float* %9
%45 = load float, float* %9
%46 = call float @log1p(float %45)
store float %46, float* %10
%47 = load double, double* %7
%48 = load float, float* %10
%49 = fpext float %48 to double
%50 = fadd double %47, %49
%51 = fdiv double %50, 0x40026BB1BBB219D9
store double %51, double* %3
br label %52
52: ; preds = %41, %35, %29
%53 = load double, double* %3
ret double %53
}

LLVM IR (-O2):
define double @LogSumOfTwo(double %0, double %1) {
%3 = fcmp olt double %1, %0
%4 = select i1 %3, double %0, double %1
%5 = select i1 %3, double %1, double %0
%6 = fmul double %5, 0x40026BB1BBB219D9
%7 = fmul double %4, 0x40026BB1BBB219D9
%8 = fsub double %6, %7
%9 = fcmp olt double %8, -3.000000e+01
br i1 %9, label %20, label %10
10: ; preds = %2
%11 = fcmp olt double %8, -8.000000e+00
%12 = tail call double @exp(double %8)
br i1 %11, label %13, label %15
13: ; preds = %10
%14 = fadd double %7, %12
br label %20
15: ; preds = %10
%16 = fptrunc double %12 to float
%17 = tail call float @log1p(float %16)
%18 = fpext float %17 to double
%19 = fadd double %7, %18
br label %20
20: ; preds = %2, %15, %13
%21 = phi double [ %14, %13 ], [ %19, %15 ], [ %7, %2 ]
%22 = fdiv double %21, 0x40026BB1BBB219D9
ret double %22
}