#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*/ sscanf(char *, char *, double *);
double aaip_numeric_id(char *name, int flag) {
  double num;
  char *cpt;
  for (cpt = name; *cpt != 0; cpt++)
    if (*cpt < '0' || *cpt > '9')
      break;
  if (*cpt != 0)
    return (-1);
  sscanf(name, "%lf", &num);
  return (num);
}


x86 assembly (clang, -O0):
<aaip_numeric_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1172 <aaip_numeric_id+0x62>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     1157 <aaip_numeric_id+0x47>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jle    115c <aaip_numeric_id+0x4c>
jmp    1172 <aaip_numeric_id+0x62>
jmp    1161 <aaip_numeric_id+0x51>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1127 <aaip_numeric_id+0x17>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1194 <aaip_numeric_id+0x84>
movsd  0xe76(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b2 <aaip_numeric_id+0xa2>
mov    -0x10(%rbp),%rdi
lea    0xe69(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <sscanf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aaip_numeric_id>:
push   %rax
mov    %rdi,%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rax),%ecx
lea    -0x3a(%rcx),%edx
add    $0x1,%rax
cmp    $0xf5,%dl
ja     1120 <aaip_numeric_id+0x10>
test   %cl,%cl
je     113d <aaip_numeric_id+0x2d>
movsd  0xec5(%rip),%xmm0
pop    %rax
ret
lea    0xec4(%rip),%rsi
mov    %rsp,%rdx
call   1030 <sscanf@plt>
movsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
define double @aaip_numeric_id(i8* %0, i32 %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca i32
%6 = alloca double
%7 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i8*, i8** %4
store i8* %8, i8** %7
br label %9
9: ; preds = %26, %2
%10 = load i8*, i8** %7
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %9
%15 = load i8*, i8** %7
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp slt i32 %17, 48
br i1 %18, label %24, label %19
19: ; preds = %14
%20 = load i8*, i8** %7
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp sgt i32 %22, 57
br i1 %23, label %24, label %25
24: ; preds = %19, %14
br label %29
25: ; preds = %19
br label %26
26: ; preds = %25
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %7
br label %9
29: ; preds = %24, %9
%30 = load i8*, i8** %7
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %29
store double -1.000000e+00, double* %3
br label %39
35: ; preds = %29
%36 = load i8*, i8** %4
%37 = call i32 @sscanf(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %6)
%38 = load double, double* %6
store double %38, double* %3
br label %39
39: ; preds = %35, %34
%40 = load double, double* %3
ret double %40
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
define double @aaip_numeric_id(i8* nocapture %0, i32 %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
br label %5
5: ; preds = %5, %2
%6 = phi i8* [ %0, %2 ], [ %10, %5 ]
%7 = load i8, i8* %6
%8 = add i8 %7, -58
%9 = icmp ult i8 %8, -10
%10 = getelementptr inbounds i8, i8* %6, i64 1
br i1 %9, label %11, label %5
11: ; preds = %5
%12 = icmp eq i8 %7, 0
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %3)
%15 = load double, double* %3
br label %16
16: ; preds = %11, %13
%17 = phi double [ %15, %13 ], [ -1.000000e+00, %11 ]
ret double %17
}