#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);
double log(double);
double addlog(double a, double b) {
  double x, y, z;
  x = ((a) < (b) ? (a) : (b));
  y = ((a) < (b) ? (b) : (a));
  z = x - y;
  if (z < -50.0)
    return y;
  z = 1.0 + exp(z);
  z = log(z) + y;
  return (z);
}


x86 assembly (clang, -O0):
<addlog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1155 <addlog+0x35>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    115f <addlog+0x3f>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    118c <addlog+0x6c>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1196 <addlog+0x76>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe49(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11d1 <addlog+0xb1>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120d <addlog+0xed>
movsd  -0x30(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  0xe22(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <log@plt>
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addlog>:
push   %rax
movapd %xmm1,%xmm2
movapd %xmm0,%xmm1
minsd  %xmm2,%xmm0
maxsd  %xmm1,%xmm2
subsd  %xmm2,%xmm0
movsd  0xec3(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1163 <addlog+0x43>
movsd  %xmm2,(%rsp)
call   1030 <exp@plt>
addsd  0xeb3(%rip),%xmm0
call   1040 <log@plt>
movsd  (%rsp),%xmm2
addsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
define double @addlog(double %0, double %1) {
%3 = fcmp olt double %0, %1
%4 = select i1 %3, double %0, double %1
%5 = select i1 %3, double %1, double %0
%6 = fsub double %4, %5
%7 = fcmp olt double %6, -5.000000e+01
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = tail call double @exp(double %6)
%10 = fadd double %9, 1.000000e+00
%11 = tail call double @log(double %10)
%12 = fadd double %5, %11
br label %13
13: ; preds = %2, %8
%14 = phi double [ %12, %8 ], [ %5, %2 ]
ret double %14
}