#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__ expf(float);
float logf(scalar_t__);
float my_logaddf(float x, float y) {
  float diff;
  if (x < y) {
    diff = x - y;
    x = y;
  } else {
    diff = y - x;
  }
  if (x < 0.5 * -1.0e10)
    return -1.0e10;
  if (diff < -15.942385065)
    return x;
  return x + logf(1.0 + expf(diff));
}


x86 assembly (clang, -O0):
<my_logaddf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1163 <my_logaddf+0x43>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1172 <my_logaddf+0x52>
movss  -0xc(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe7d(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    119f <my_logaddf+0x7f>
movss  0xe83(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1209 <my_logaddf+0xe9>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe58(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c9 <my_logaddf+0xa9>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1209 <my_logaddf+0xe9>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
call   1040 <expf@plt>
cvtsi2sd %rax,%xmm1
movsd  0xe26(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1030 <logf@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_logaddf>:
push   %rax
movaps %xmm1,%xmm4
maxss  %xmm0,%xmm4
movss  0xed4(%rip),%xmm2
ucomiss %xmm4,%xmm2
jbe    113f <my_logaddf+0x1f>
movss  0xec3(%rip),%xmm4
jmp    119f <my_logaddf+0x7f>
movaps %xmm0,%xmm2
subss  %xmm1,%xmm2
movaps %xmm1,%xmm3
subss  %xmm0,%xmm3
cmpltss %xmm1,%xmm0
andps  %xmm0,%xmm2
andnps %xmm3,%xmm0
orps   %xmm2,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xe9e(%rip),%xmm2
ucomisd %xmm1,%xmm2
ja     119f <my_logaddf+0x7f>
movss  %xmm4,0x4(%rsp)
call   1040 <expf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xe85(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1030 <logf@plt>
movss  0x4(%rsp),%xmm4
addss  %xmm0,%xmm4
movaps %xmm4,%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
define float @my_logaddf(float %0, float %1) {
%3 = fcmp olt float %0, %1
%4 = fsub float %0, %1
%5 = fsub float %1, %0
%6 = select i1 %3, float %1, float %0
%7 = select i1 %3, float %4, float %5
%8 = fcmp olt float %6, -5.000000e+09
br i1 %8, label %19, label %9
9: ; preds = %2
%10 = fpext float %7 to double
%11 = fcmp olt double %10, 0xC02FE2804B94D3E2
br i1 %11, label %19, label %12
12: ; preds = %9
%13 = tail call i64 @expf(float %7)
%14 = sitofp i64 %13 to double
%15 = fadd double %14, 1.000000e+00
%16 = fptosi double %15 to i64
%17 = tail call float @logf(i64 %16)
%18 = fadd float %6, %17
br label %19
19: ; preds = %9, %2, %12
%20 = phi float [ %18, %12 ], [ -1.000000e+10, %2 ], [ %6, %9 ]
ret float %20
}