#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 */
scalar_t__ ERANGE;
double INFINITY;
scalar_t__ errno;
int /*<<< orphan*/ isfinite(double);
double strtod(char const *, char **);
double parse_bpm(const char *s) {
  char *endptr;
  double bpm;
  if (s[0] == '\0')
    return 0.0;
  errno = 0;
  bpm = strtod(s, &endptr);
  if (errno == ERANGE || *endptr != '\0' || !isfinite(bpm) || bpm <= 0.0)
    return INFINITY;
  return bpm;
}


x86 assembly (clang, -O0):
<parse_bpm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1149 <parse_bpm+0x29>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d3 <parse_bpm+0xb3>
mov    0x2e80(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
mov    0x2e60(%rip),%rax
mov    (%rax),%rax
mov    0x2e66(%rip),%rcx
cmp    (%rcx),%rax
je     11b4 <parse_bpm+0x94>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11b4 <parse_bpm+0x94>
movsd  -0x20(%rbp),%xmm0
call   1040 <isfinite@plt>
cmp    $0x0,%eax
je     11b4 <parse_bpm+0x94>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11c9 <parse_bpm+0xa9>
mov    0x2e2d(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d3 <parse_bpm+0xb3>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_bpm>:
push   %rbx
sub    $0x10,%rsp
cmpb   $0x0,(%rdi)
je     1168 <parse_bpm+0x48>
mov    0x2e9f(%rip),%rbx
movq   $0x0,(%rbx)
lea    0x8(%rsp),%rsi
call   1030 <strtod@plt>
mov    (%rbx),%rax
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%rax
je     115b <parse_bpm+0x3b>
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     1172 <parse_bpm+0x52>
mov    0x2e86(%rip),%rax
movsd  (%rax),%xmm0
jmp    116c <parse_bpm+0x4c>
xorpd  %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbx
ret
movsd  %xmm0,(%rsp)
call   1040 <isfinite@plt>
movsd  (%rsp),%xmm0
test   %eax,%eax
je     115b <parse_bpm+0x3b>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jb     116c <parse_bpm+0x4c>
jmp    115b <parse_bpm+0x3b>

LLVM IR (-O0):
@errno = global i64 0
@ERANGE = global i64 0
@INFINITY = global double 0.000000e+00
define double @parse_bpm(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca double
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %1
store double 0.000000e+00, double* %2
br label %34
12: ; preds = %1
store i64 0, i64* @errno
%13 = load i8*, i8** %3
%14 = call double @strtod(i8* %13, i8** %4)
store double %14, double* %5
%15 = load i64, i64* @errno
%16 = load i64, i64* @ERANGE
%17 = icmp eq i64 %15, %16
br i1 %17, label %30, label %18
18: ; preds = %12
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %30, label %23
23: ; preds = %18
%24 = load double, double* %5
%25 = call i32 @isfinite(double %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load double, double* %5
%29 = fcmp ole double %28, 0.000000e+00
br i1 %29, label %30, label %32
30: ; preds = %27, %23, %18, %12
%31 = load double, double* @INFINITY
store double %31, double* %2
br label %34
32: ; preds = %27
%33 = load double, double* %5
store double %33, double* %2
br label %34
34: ; preds = %32, %30, %11
%35 = load double, double* %2
ret double %35
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
@INFINITY = global double 0.000000e+00
define double @parse_bpm(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %22, label %6
6: ; preds = %1
store i64 0, i64* @errno
%7 = call double @strtod(i8* %0, i8** %2)
%8 = load i64, i64* @errno
%9 = load i64, i64* @ERANGE
%10 = icmp eq i64 %8, %9
br i1 %10, label %20, label %11
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = tail call i32 @isfinite(double %7)
%17 = icmp eq i32 %16, 0
%18 = fcmp ole double %7, 0.000000e+00
%19 = select i1 %17, i1 true, i1 %18
br i1 %19, label %20, label %22
20: ; preds = %15, %11, %6
%21 = load double, double* @INFINITY
br label %22
22: ; preds = %15, %1, %20
%23 = phi double [ %21, %20 ], [ 0.000000e+00, %1 ], [ %7, %15 ]
ret double %23
}