#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*/ bitch(char *, char *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ isspace(char);
char *skip_white_space(char *);
double strtod(char *, char **);
int extract_double(char **input, char *what, double *val, int skip_m) {
  char *s = *input;
  char *end = NULL;
  char *stop;
  char c;
  int saw_m = 0;
  while (isdigit(*s) || *s == '+' || *s == '-' || *s == '.')
    s++;
  if (*s && !isspace(*s) && *s != ';' && *s != ')') {
    if (skip_m && (*s == 'm' || *s == 'M')) {
      saw_m = 1;
    } else {
      bitch("%s is not valid", what);
      return -1;
    }
  }
  if (!*s)
    end = s;
  c = *s;
  *s = '\0';
  *val = strtod(*input, &stop);
  if (*stop != '\0') {
    *s = c;
    bitch("%s is not valid", what);
    return -1;
  }
  *s = c;
  if (saw_m) {
    s++;
    if (*s && !isspace(*s) && *s != ';' && *s != ')') {
      bitch("%s is not valid", what);
      return -1;
    }
  }
  if (end) {
    *input = end;
  } else {
    *input = skip_white_space(s);
    if (!*input)
      return -1;
  }
  return 1;
}


x86 assembly (clang, -O0):
<extract_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x49(%rbp)
jne    11d9 <extract_double+0x89>
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2b,%ecx
mov    %al,-0x49(%rbp)
je     11d9 <extract_double+0x89>
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2d,%ecx
mov    %al,-0x49(%rbp)
je     11d9 <extract_double+0x89>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
sete   %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    11e9 <extract_double+0x99>
jmp    11fa <extract_double+0xaa>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1181 <extract_double+0x31>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1296 <extract_double+0x146>
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isspace@plt>
cmp    $0x0,%eax
jne    1296 <extract_double+0x146>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
je     1296 <extract_double+0x146>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x29,%eax
je     1296 <extract_double+0x146>
cmpl   $0x0,-0x24(%rbp)
je     1275 <extract_double+0x125>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6d,%eax
je     1269 <extract_double+0x119>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4d,%eax
jne    1275 <extract_double+0x125>
movl   $0x1,-0x48(%rbp)
jmp    1291 <extract_double+0x141>
mov    -0x18(%rbp),%rsi
lea    0xd80(%rip),%rdi
call   1050 <bitch@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13e1 <extract_double+0x291>
jmp    1296 <extract_double+0x146>
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
jne    12ab <extract_double+0x15b>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x41(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <strtod@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1308 <extract_double+0x1b8>
mov    -0x41(%rbp),%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rsi
lea    0xd09(%rip),%rdi
call   1050 <bitch@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13e1 <extract_double+0x291>
mov    -0x41(%rbp),%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
cmpl   $0x0,-0x48(%rbp)
je     138d <extract_double+0x23d>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1388 <extract_double+0x238>
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isspace@plt>
cmp    $0x0,%eax
jne    1388 <extract_double+0x238>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
je     1388 <extract_double+0x238>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x29,%eax
je     1388 <extract_double+0x238>
mov    -0x18(%rbp),%rsi
lea    0xc89(%rip),%rdi
call   1050 <bitch@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13e1 <extract_double+0x291>
jmp    138d <extract_double+0x23d>
cmpq   $0x0,-0x38(%rbp)
je     13a8 <extract_double+0x258>
mov    -0x38(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    13da <extract_double+0x28a>
mov    -0x30(%rbp),%rdi
call   1070 <skip_white_space@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    13d5 <extract_double+0x285>
movl   $0xffffffff,-0x4(%rbp)
jmp    13e1 <extract_double+0x291>
jmp    13da <extract_double+0x28a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_double>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r13d
mov    %rdx,%r12
mov    %rsi,0x8(%rsp)
mov    %rdi,%r14
mov    (%rdi),%rbx
jmp    1184 <extract_double+0x34>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1180 <extract_double+0x30>
movzbl (%rbx),%ebp
lea    -0x2d(%rbp),%eax
cmp    $0x2,%al
jb     1180 <extract_double+0x30>
cmp    $0x2b,%bpl
je     1180 <extract_double+0x30>
test   %bpl,%bpl
jne    11ab <extract_double+0x5b>
mov    $0x1,%r15b
jmp    11be <extract_double+0x6e>
movsbl %bpl,%edi
call   1060 <isspace@plt>
mov    (%rbx),%bpl
mov    $0x1,%r15b
test   %eax,%eax
je     1236 <extract_double+0xe6>
xor    %r13d,%r13d
test   %bpl,%bpl
cmove  %rbx,%r13
movb   $0x0,(%rbx)
mov    (%r14),%rdi
lea    0x10(%rsp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,(%r12)
mov    0x10(%rsp),%rax
cmpb   $0x0,(%rax)
mov    %bpl,(%rbx)
je     1203 <extract_double+0xb3>
lea    0xe0e(%rip),%rdi
mov    0x8(%rsp),%rsi
call   1050 <bitch@plt>
mov    $0xffffffff,%eax
jmp    1263 <extract_double+0x113>
test   %r15b,%r15b
jne    121f <extract_double+0xcf>
mov    0x1(%rbx),%al
add    $0x1,%rbx
test   %al,%al
je     121f <extract_double+0xcf>
movsbl %al,%edi
call   1060 <isspace@plt>
test   %eax,%eax
je     1272 <extract_double+0x122>
test   %bpl,%bpl
je     125b <extract_double+0x10b>
mov    %rbx,%rdi
call   1070 <skip_white_space@plt>
mov    %rax,(%r14)
test   %rax,%rax
jne    125e <extract_double+0x10e>
jmp    11fc <extract_double+0xac>
cmp    $0x29,%bpl
je     11be <extract_double+0x6e>
cmp    $0x3b,%bpl
je     11be <extract_double+0x6e>
test   %r13d,%r13d
je     11eb <extract_double+0x9b>
mov    %ebp,%eax
or     $0x20,%al
cmp    $0x6d,%al
jne    11eb <extract_double+0x9b>
xor    %r15d,%r15d
jmp    11be <extract_double+0x6e>
mov    %r13,(%r14)
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%al
cmp    $0x29,%al
je     121f <extract_double+0xcf>
cmp    $0x3b,%al
je     121f <extract_double+0xcf>
jmp    11eb <extract_double+0x9b>

LLVM IR (-O0):
@.str = [16 x i8] c"%s is not valid\00"
define i32 @extract_double(i8** %0, i8* %1, double* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8
%14 = alloca i32
store i8** %0, i8*** %6
store i8* %1, i8** %7
store double* %2, double** %8
store i32 %3, i32* %9
%15 = load i8**, i8*** %6
%16 = load i8*, i8** %15
store i8* %16, i8** %10
store i8* null, i8** %11
store i32 0, i32* %14
br label %17
17: ; preds = %39, %4
%18 = load i8*, i8** %10
%19 = load i8, i8* %18
%20 = call i64 @isdigit(i8 signext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %37, label %22
22: ; preds = %17
%23 = load i8*, i8** %10
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 43
br i1 %26, label %37, label %27
27: ; preds = %22
%28 = load i8*, i8** %10
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 45
br i1 %31, label %37, label %32
32: ; preds = %27
%33 = load i8*, i8** %10
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 46
br label %37
37: ; preds = %32, %27, %22, %17
%38 = phi i1 [ true, %27 ], [ true, %22 ], [ true, %17 ], [ %36, %32 ]
br i1 %38, label %39, label %42
39: ; preds = %37
%40 = load i8*, i8** %10
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %10
br label %17
42: ; preds = %37
%43 = load i8*, i8** %10
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %80
47: ; preds = %42
%48 = load i8*, i8** %10
%49 = load i8, i8* %48
%50 = call i32 @isspace(i8 signext %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %80, label %52
52: ; preds = %47
%53 = load i8*, i8** %10
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %55, 59
br i1 %56, label %57, label %80
57: ; preds = %52
%58 = load i8*, i8** %10
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp ne i32 %60, 41
br i1 %61, label %62, label %80
62: ; preds = %57
%63 = load i32, i32* %9
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %76
65: ; preds = %62
%66 = load i8*, i8** %10
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 109
br i1 %69, label %75, label %70
70: ; preds = %65
%71 = load i8*, i8** %10
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 77
br i1 %74, label %75, label %76
75: ; preds = %70, %65
store i32 1, i32* %14
br label %79
76: ; preds = %70, %62
%77 = load i8*, i8** %7
%78 = call i32 @bitch(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %77)
store i32 -1, i32* %5
br label %150
79: ; preds = %75
br label %80
80: ; preds = %79, %57, %52, %47, %42
%81 = load i8*, i8** %10
%82 = load i8, i8* %81
%83 = icmp ne i8 %82, 0
br i1 %83, label %86, label %84
84: ; preds = %80
%85 = load i8*, i8** %10
store i8* %85, i8** %11
br label %86
86: ; preds = %84, %80
%87 = load i8*, i8** %10
%88 = load i8, i8* %87
store i8 %88, i8* %13
%89 = load i8*, i8** %10
store i8 0, i8* %89
%90 = load i8**, i8*** %6
%91 = load i8*, i8** %90
%92 = call double @strtod(i8* %91, i8** %12)
%93 = load double*, double** %8
store double %92, double* %93
%94 = load i8*, i8** %12
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %103
98: ; preds = %86
%99 = load i8, i8* %13
%100 = load i8*, i8** %10
store i8 %99, i8* %100
%101 = load i8*, i8** %7
%102 = call i32 @bitch(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %101)
store i32 -1, i32* %5
br label %150
103: ; preds = %86
%104 = load i8, i8* %13
%105 = load i8*, i8** %10
store i8 %104, i8* %105
%106 = load i32, i32* %14
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %134
108: ; preds = %103
%109 = load i8*, i8** %10
%110 = getelementptr inbounds i8, i8* %109, i32 1
store i8* %110, i8** %10
%111 = load i8*, i8** %10
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp ne i32 %113, 0
br i1 %114, label %115, label %133
115: ; preds = %108
%116 = load i8*, i8** %10
%117 = load i8, i8* %116
%118 = call i32 @isspace(i8 signext %117)
%119 = icmp ne i32 %118, 0
br i1 %119, label %133, label %120
120: ; preds = %115
%121 = load i8*, i8** %10
%122 = load i8, i8* %121
%123 = sext i8 %122 to i32
%124 = icmp ne i32 %123, 59
br i1 %124, label %125, label %133
125: ; preds = %120
%126 = load i8*, i8** %10
%127 = load i8, i8* %126
%128 = sext i8 %127 to i32
%129 = icmp ne i32 %128, 41
br i1 %129, label %130, label %133
130: ; preds = %125
%131 = load i8*, i8** %7
%132 = call i32 @bitch(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %131)
store i32 -1, i32* %5
br label %150
133: ; preds = %125, %120, %115, %108
br label %134
134: ; preds = %133, %103
%135 = load i8*, i8** %11
%136 = icmp ne i8* %135, null
br i1 %136, label %137, label %140
137: ; preds = %134
%138 = load i8*, i8** %11
%139 = load i8**, i8*** %6
store i8* %138, i8** %139
br label %149
140: ; preds = %134
%141 = load i8*, i8** %10
%142 = call i8* @skip_white_space(i8* %141)
%143 = load i8**, i8*** %6
store i8* %142, i8** %143
%144 = load i8**, i8*** %6
%145 = load i8*, i8** %144
%146 = icmp ne i8* %145, null
br i1 %146, label %148, label %147
147: ; preds = %140
store i32 -1, i32* %5
br label %150
148: ; preds = %140
br label %149
149: ; preds = %148, %137
store i32 1, i32* %5
br label %150
150: ; preds = %149, %147, %130, %98, %76
%151 = load i32, i32* %5
ret i32 %151
}

LLVM IR (-O2):
@.str = [16 x i8] c"%s is not valid\00"
define i32 @extract_double(i8** nocapture %0, i8* %1, double* nocapture writeonly %2, i32 %3) {
%5 = alloca i8*
%6 = load i8*, i8** %0
%7 = bitcast i8** %5 to i8*
br label %8
8: ; preds = %15, %4
%9 = phi i8* [ %6, %4 ], [ %16, %15 ]
%10 = load i8, i8* %9
%11 = tail call i64 @isdigit(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = load i8, i8* %9
switch i8 %14, label %17 [
i8 43, label %15
i8 45, label %15
i8 46, label %15
i8 0, label %27
]
15: ; preds = %13, %13, %13, %8
%16 = getelementptr inbounds i8, i8* %9, i64 1
br label %8
17: ; preds = %13
%18 = tail call i32 @isspace(i8 signext %14)
%19 = icmp eq i32 %18, 0
%20 = load i8, i8* %9
br i1 %19, label %21, label %27
21: ; preds = %17
switch i8 %20, label %22 [
i8 59, label %27
i8 41, label %27
]
22: ; preds = %21
%23 = icmp eq i32 %3, 0
br i1 %23, label %25, label %24
24: ; preds = %22
switch i8 %20, label %25 [
i8 109, label %27
i8 77, label %27
]
25: ; preds = %24, %22
%26 = tail call i32 @bitch(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %58
27: ; preds = %13, %17, %24, %24, %21, %21
%28 = phi i8 [ %20, %21 ], [ %20, %21 ], [ %20, %24 ], [ %20, %24 ], [ %20, %17 ], [ %14, %13 ]
%29 = phi i1 [ true, %21 ], [ true, %21 ], [ false, %24 ], [ false, %24 ], [ true, %17 ], [ true, %13 ]
%30 = icmp eq i8 %28, 0
%31 = select i1 %30, i8* %9, i8* null
store i8 0, i8* %9
%32 = load i8*, i8** %0
%33 = call double @strtod(i8* %32, i8** %5)
store double %33, double* %2
%34 = load i8*, i8** %5
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
store i8 %28, i8* %9
br i1 %36, label %39, label %37
37: ; preds = %27
%38 = tail call i32 @bitch(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %58
39: ; preds = %27
br i1 %29, label %51, label %40
40: ; preds = %39
%41 = getelementptr inbounds i8, i8* %9, i64 1
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 0
br i1 %43, label %51, label %44
44: ; preds = %40
%45 = tail call i32 @isspace(i8 signext %42)
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = load i8, i8* %41
switch i8 %48, label %49 [
i8 59, label %51
i8 41, label %51
]
49: ; preds = %47
%50 = tail call i32 @bitch(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %58
51: ; preds = %47, %47, %40, %44, %39
%52 = phi i8* [ %41, %44 ], [ %41, %47 ], [ %41, %40 ], [ %9, %39 ], [ %41, %47 ]
br i1 %30, label %53, label %54
53: ; preds = %51
store i8* %31, i8** %0
br label %57
54: ; preds = %51
%55 = tail call i8* @skip_white_space(i8* %52)
store i8* %55, i8** %0
%56 = icmp eq i8* %55, null
br i1 %56, label %58, label %57
57: ; preds = %54, %53
br label %58
58: ; preds = %54, %57, %49, %37, %25
%59 = phi i32 [ -1, %37 ], [ 1, %57 ], [ -1, %49 ], [ -1, %25 ], [ -1, %54 ]
ret i32 %59
}