#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 */
int /*<<< orphan*/ EDOM;
int /*<<< orphan*/ ERANGE;
double HUGE_VAL;
int /*<<< orphan*/ errno;
double log(double);
double log10(double arg) {
  if (arg <= 0) {
    errno = (arg == 0) ? ERANGE : EDOM;
    return -HUGE_VAL;
  }
  return log(arg) * .4342944819032518276511;
}


x86 assembly (clang, -O0):
<log10>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1198 <log10+0x88>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1154 <log10+0x44>
jp     1154 <log10+0x44>
mov    0x2e8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1160 <log10+0x50>
mov    0x2e85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
mov    0x2e5e(%rip),%rax
mov    %ecx,(%rax)
mov    0x2e75(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b3 <log10+0xa3>
movsd  -0x10(%rbp),%xmm0
call   1030 <log@plt>
movsd  0xe56(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log10>:
push   %rax
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    112a <log10+0x1a>
call   1030 <log@plt>
mulsd  0xee8(%rip),%xmm0
pop    %rax
ret
ucomisd %xmm1,%xmm0
mov    0x2eab(%rip),%rax
mov    0x2e9c(%rip),%rcx
cmovne %rax,%rcx
cmovp  %rax,%rcx
mov    (%rcx),%eax
mov    0x2e7b(%rip),%rcx
mov    %eax,(%rcx)
mov    0x2e92(%rip),%rax
movsd  (%rax),%xmm0
xorps  0xe9f(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@ERANGE = global i32 0
@EDOM = global i32 0
@errno = global i32 0
@HUGE_VAL = global double 0.000000e+00
define double @log10(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp ole double %4, 0.000000e+00
br i1 %5, label %6, label %17
6: ; preds = %1
%7 = load double, double* %3
%8 = fcmp oeq double %7, 0.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = load i32, i32* @ERANGE
br label %13
11: ; preds = %6
%12 = load i32, i32* @EDOM
br label %13
13: ; preds = %11, %9
%14 = phi i32 [ %10, %9 ], [ %12, %11 ]
store i32 %14, i32* @errno
%15 = load double, double* @HUGE_VAL
%16 = fneg double %15
store double %16, double* %2
br label %21
17: ; preds = %1
%18 = load double, double* %3
%19 = call double @log(double %18)
%20 = fmul double %19, 0x3FDBCB7B1526E50E
store double %20, double* %2
br label %21
21: ; preds = %17, %13
%22 = load double, double* %2
ret double %22
}

LLVM IR (-O2):
@ERANGE = global i32 0
@EDOM = global i32 0
@errno = global i32 0
@HUGE_VAL = global double 0.000000e+00
define double @log10(double %0) {
%2 = fcmp ugt double %0, 0.000000e+00
br i1 %2, label %10, label %3
3: ; preds = %1
%4 = fcmp oeq double %0, 0.000000e+00
%5 = load i32, i32* @ERANGE
%6 = load i32, i32* @EDOM
%7 = select i1 %4, i32 %5, i32 %6
store i32 %7, i32* @errno
%8 = load double, double* @HUGE_VAL
%9 = fneg double %8
br label %13
10: ; preds = %1
%11 = tail call double @log(double %0)
%12 = fmul double %11, 0x3FDBCB7B1526E50E
br label %13
13: ; preds = %10, %3
%14 = phi double [ %9, %3 ], [ %12, %10 ]
ret double %14
}