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


x86 assembly (clang, -O0):
<log10_add_pow10>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1185 <log10_add_pow10+0x65>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xea2(%rip),%xmm0
call   1030 <pow@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1040 <log10@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c3 <log10_add_pow10+0xa3>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  0xe5f(%rip),%xmm0
call   1030 <pow@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1040 <log10@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):
<log10_add_pow10>:
push   %rax
movapd %xmm0,%xmm4
subsd  %xmm1,%xmm4
movapd %xmm1,%xmm3
subsd  %xmm0,%xmm3
movapd %xmm1,%xmm2
cmpltsd %xmm0,%xmm2
andpd  %xmm2,%xmm3
andnpd %xmm4,%xmm2
orpd   %xmm3,%xmm2
maxsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movsd  0xea9(%rip),%xmm0
movapd %xmm2,%xmm1
call   1030 <pow@plt>
lea    0x1(%rax),%rdi
call   1040 <log10@plt>
addsd  (%rsp),%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
define double @log10_add_pow10(double %0, double %1) {
%3 = fcmp ogt double %0, %1
%4 = fsub double %0, %1
%5 = fsub double %1, %0
%6 = select i1 %3, double %5, double %4
%7 = select i1 %3, double %0, double %1
%8 = tail call i64 @pow(double 1.000000e+01, double %6)
%9 = add nsw i64 %8, 1
%10 = tail call double @log10(i64 %9)
%11 = fadd double %10, %7
ret double %11
}