#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 log10(scalar_t__);
scalar_t__ pow(double, double);
double AddLog10(double a, double b) {
  if (a < b) {
    return AddLog10(b, a);
  } else {
    return a + log10(1.0 + pow(10.0, b - a));
  }
}


x86 assembly (clang, -O0):
<AddLog10>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    116f <AddLog10+0x3f>
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1050 <AddLog10@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11bc <AddLog10+0x8c>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xe7d(%rip),%xmm0
call   1030 <pow@plt>
cvtsi2sd %rax,%xmm1
movsd  0xe63(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <log10@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AddLog10>:
movapd %xmm1,%xmm2
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movapd %xmm2,%xmm1
movapd %xmm0,%xmm2
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
ja     1130 <AddLog10+0x10>
push   %rax
subsd  %xmm2,%xmm1
movsd  0xeb1(%rip),%xmm0
movsd  %xmm2,(%rsp)
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xe9f(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <log10@plt>
addsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @AddLog10(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 = load double, double* %5
%8 = fcmp olt double %6, %7
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load double, double* %5
%11 = load double, double* %4
%12 = call double @AddLog10(double %10, double %11)
store double %12, double* %3
br label %24
13: ; preds = %2
%14 = load double, double* %4
%15 = load double, double* %5
%16 = load double, double* %4
%17 = fsub double %15, %16
%18 = call i64 @pow(double 1.000000e+01, double %17)
%19 = sitofp i64 %18 to double
%20 = fadd double 1.000000e+00, %19
%21 = fptosi double %20 to i64
%22 = call double @log10(i64 %21)
%23 = fadd double %14, %22
store double %23, double* %3
br label %24
24: ; preds = %13, %9
%25 = load double, double* %3
ret double %25
}

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