#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 EDOM;
double ERANGE;
scalar_t__ isnan(double);
double log10(double);
int _vtodb(double *a, double offset) {
  int result = 0;
  double l = log10(*a);
  if (l == EDOM || l == ERANGE || isnan(l))
    result = -1;
  else
    *a = l * 20.0 + offset;
  return result;
}


x86 assembly (clang, -O0):
<_vtodb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <log10@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    0x2e92(%rip),%rax
ucomisd (%rax),%xmm0
jne    116b <_vtodb+0x4b>
jp     116b <_vtodb+0x4b>
jmp    11a0 <_vtodb+0x80>
movsd  -0x20(%rbp),%xmm0
mov    0x2e69(%rip),%rax
ucomisd (%rax),%xmm0
jne    118c <_vtodb+0x6c>
jp     118c <_vtodb+0x6c>
jmp    11a0 <_vtodb+0x80>
movsd  -0x20(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     11ac <_vtodb+0x8c>
movl   $0xffffffff,-0x14(%rbp)
jmp    11ce <_vtodb+0xae>
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe42(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_vtodb>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1040 <log10@plt>
mov    0x2ea9(%rip),%rax
ucomisd (%rax),%xmm0
mov    $0xffffffff,%ebp
jne    114c <_vtodb+0x2c>
jnp    1185 <_vtodb+0x65>
mov    0x2e8d(%rip),%rax
ucomisd (%rax),%xmm0
jne    115b <_vtodb+0x3b>
jnp    1185 <_vtodb+0x65>
movsd  %xmm0,0x8(%rsp)
call   1030 <isnan@plt>
test   %rax,%rax
jne    1185 <_vtodb+0x65>
movsd  0x8(%rsp),%xmm0
mulsd  0xe87(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rbx)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@EDOM = global double 0.000000e+00
@ERANGE = global double 0.000000e+00
define i32 @_vtodb(double* %0, double %1) {
%3 = alloca double*
%4 = alloca double
%5 = alloca i32
%6 = alloca double
store double* %0, double** %3
store double %1, double* %4
store i32 0, i32* %5
%7 = load double*, double** %3
%8 = load double, double* %7
%9 = call double @log10(double %8)
store double %9, double* %6
%10 = load double, double* %6
%11 = load double, double* @EDOM
%12 = fcmp oeq double %10, %11
br i1 %12, label %21, label %13
13: ; preds = %2
%14 = load double, double* %6
%15 = load double, double* @ERANGE
%16 = fcmp oeq double %14, %15
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = load double, double* %6
%19 = call i64 @isnan(double %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17, %13, %2
store i32 -1, i32* %5
br label %27
22: ; preds = %17
%23 = load double, double* %6
%24 = load double, double* %4
%25 = call double @llvm.fmuladd.f64(double %23, double 2.000000e+01, double %24)
%26 = load double*, double** %3
store double %25, double* %26
br label %27
27: ; preds = %22, %21
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
@EDOM = global double 0.000000e+00
@ERANGE = global double 0.000000e+00
define i32 @_vtodb(double* nocapture %0, double %1) {
%3 = load double, double* %0
%4 = tail call double @log10(double %3)
%5 = load double, double* @EDOM
%6 = fcmp oeq double %4, %5
%7 = load double, double* @ERANGE
%8 = fcmp oeq double %4, %7
%9 = select i1 %6, i1 true, i1 %8
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = tail call i64 @isnan(double %4)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call double @llvm.fmuladd.f64(double %4, double 2.000000e+01, double %1)
store double %14, double* %0
br label %15
15: ; preds = %2, %10, %13
%16 = phi i32 [ 0, %13 ], [ -1, %10 ], [ -1, %2 ]
ret i32 %16
}