#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_conv(scalar_t__);
double log_add(double x, double y) {
  double lmin, lmax;
  if (x == y)
    return x + (0.693147180559945);
  lmin = (x < y) ? x : y;
  lmax = (x < y) ? y : x;
  if (lmax > lmin + 50)
    return lmax;
  else
    return lmax + log_conv(exp(lmin - lmax) + 1.0);
}


x86 assembly (clang, -O0):
<log_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    115f <log_add+0x3f>
jp     115f <log_add+0x3f>
movsd  0xec0(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123d <log_add+0x11d>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1182 <log_add+0x62>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    118c <log_add+0x6c>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b9 <log_add+0x99>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11c3 <log_add+0xa3>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe26(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    11f8 <log_add+0xd8>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123d <log_add+0x11d>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
call   1040 <exp@plt>
cvtsi2sd %rax,%xmm0
movsd  0xdea(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1030 <log_conv@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_add>:
push   %rax
movapd %xmm1,%xmm2
movapd %xmm0,%xmm1
ucomisd %xmm2,%xmm0
jne    113f <log_add+0x1f>
jp     113f <log_add+0x1f>
addsd  0xed7(%rip),%xmm1
movapd %xmm1,%xmm2
jmp    118e <log_add+0x6e>
movapd %xmm1,%xmm0
minsd  %xmm2,%xmm0
maxsd  %xmm1,%xmm2
movsd  0xead(%rip),%xmm1
addsd  %xmm0,%xmm1
ucomisd %xmm1,%xmm2
ja     118e <log_add+0x6e>
subsd  %xmm2,%xmm0
movsd  %xmm2,(%rsp)
call   1040 <exp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xe8d(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1030 <log_conv@plt>
movsd  (%rsp),%xmm2
addsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @log_add(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = load double, double* %5
%10 = fcmp oeq double %8, %9
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load double, double* %4
%13 = fadd double %12, 0x3FE62E42FEFA39EC
store double %13, double* %3
br label %50
14: ; preds = %2
%15 = load double, double* %4
%16 = load double, double* %5
%17 = fcmp olt double %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load double, double* %4
br label %22
20: ; preds = %14
%21 = load double, double* %5
br label %22
22: ; preds = %20, %18
%23 = phi double [ %19, %18 ], [ %21, %20 ]
store double %23, double* %6
%24 = load double, double* %4
%25 = load double, double* %5
%26 = fcmp olt double %24, %25
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = load double, double* %5
br label %31
29: ; preds = %22
%30 = load double, double* %4
br label %31
31: ; preds = %29, %27
%32 = phi double [ %28, %27 ], [ %30, %29 ]
store double %32, double* %7
%33 = load double, double* %7
%34 = load double, double* %6
%35 = fadd double %34, 5.000000e+01
%36 = fcmp ogt double %33, %35
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = load double, double* %7
store double %38, double* %3
br label %50
39: ; preds = %31
%40 = load double, double* %7
%41 = load double, double* %6
%42 = load double, double* %7
%43 = fsub double %41, %42
%44 = call i64 @exp(double %43)
%45 = sitofp i64 %44 to double
%46 = fadd double %45, 1.000000e+00
%47 = fptosi double %46 to i64
%48 = call double @log_conv(i64 %47)
%49 = fadd double %40, %48
store double %49, double* %3
br label %50
50: ; preds = %39, %37, %11
%51 = load double, double* %3
ret double %51
}

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