#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 */
scalar_t__ exp(double);
double log(scalar_t__);
extern double _logsumexp_pair(double a, double b) {
  if ((-(1.0 / 0.0) == a) && (-(1.0 / 0.0) == b))
    return -(1.0 / 0.0);
  if (b > a)
    return b + log(1.0 + exp(a - b));
  return a + log(1.0 + exp(b - a));
}


x86 assembly (clang, -O0):
<_logsumexp_pair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  0xec6(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jne    1176 <_logsumexp_pair+0x56>
jp     1176 <_logsumexp_pair+0x56>
movsd  0xead(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1176 <_logsumexp_pair+0x56>
jp     1176 <_logsumexp_pair+0x56>
movsd  0xe94(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1215 <_logsumexp_pair+0xf5>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11d0 <_logsumexp_pair+0xb0>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1030 <exp@plt>
cvtsi2sd %rax,%xmm1
movsd  0xe5c(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1215 <_logsumexp_pair+0xf5>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1030 <exp@plt>
cvtsi2sd %rax,%xmm1
movsd  0xe12(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_logsumexp_pair>:
push   %rax
movsd  0xed7(%rip),%xmm3
ucomisd %xmm0,%xmm3
jb     113d <_logsumexp_pair+0x1d>
movsd  0xec9(%rip),%xmm2
ucomisd %xmm1,%xmm2
jae    119b <_logsumexp_pair+0x7b>
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
movapd %xmm1,%xmm4
movapd %xmm0,%xmm3
subsd  %xmm1,%xmm3
movapd %xmm0,%xmm1
cmpltsd %xmm4,%xmm1
andpd  %xmm1,%xmm3
andnpd %xmm2,%xmm1
orpd   %xmm3,%xmm1
maxsd  %xmm0,%xmm4
movsd  %xmm4,(%rsp)
movapd %xmm1,%xmm0
call   1030 <exp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xe80(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <log@plt>
movapd %xmm0,%xmm3
addsd  (%rsp),%xmm3
movapd %xmm3,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @_logsumexp_pair(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %4
%7 = fcmp oeq double 0xFFF0000000000000, %6
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load double, double* %5
%10 = fcmp oeq double 0xFFF0000000000000, %9
br i1 %10, label %11, label %12
11: ; preds = %8
store double 0xFFF0000000000000, double* %3
br label %38
12: ; preds = %8, %2
%13 = load double, double* %5
%14 = load double, double* %4
%15 = fcmp ogt double %13, %14
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load double, double* %5
%18 = load double, double* %4
%19 = load double, double* %5
%20 = fsub double %18, %19
%21 = call i64 @exp(double %20)
%22 = sitofp i64 %21 to double
%23 = fadd double 1.000000e+00, %22
%24 = fptosi double %23 to i64
%25 = call double @log(i64 %24)
%26 = fadd double %17, %25
store double %26, double* %3
br label %38
27: ; preds = %12
%28 = load double, double* %4
%29 = load double, double* %5
%30 = load double, double* %4
%31 = fsub double %29, %30
%32 = call i64 @exp(double %31)
%33 = sitofp i64 %32 to double
%34 = fadd double 1.000000e+00, %33
%35 = fptosi double %34 to i64
%36 = call double @log(i64 %35)
%37 = fadd double %28, %36
store double %37, double* %3
br label %38
38: ; preds = %27, %16, %11
%39 = load double, double* %3
ret double %39
}

LLVM IR (-O2):
define double @_logsumexp_pair(double %0, double %1) {
%3 = fcmp oeq double %0, 0xFFF0000000000000
%4 = fcmp oeq double %1, 0xFFF0000000000000
%5 = and i1 %3, %4
br i1 %5, label %18, label %6
6: ; preds = %2
%7 = fcmp ogt double %1, %0
%8 = fsub double %1, %0
%9 = fsub double %0, %1
%10 = select i1 %7, double %9, double %8
%11 = select i1 %7, double %1, double %0
%12 = tail call i64 @exp(double %10)
%13 = sitofp i64 %12 to double
%14 = fadd double %13, 1.000000e+00
%15 = fptosi double %14 to i64
%16 = tail call double @log(i64 %15)
%17 = fadd double %16, %11
br label %18
18: ; preds = %6, %2
%19 = phi double [ 0xFFF0000000000000, %2 ], [ %17, %6 ]
ret double %19
}