#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 isdigit(int);
int strlen(char const *);
int CharactersInDouble(const char p[]) {
  int len = strlen(p);
  int bytes = 0;
  int state = 0;
  while (1) {
    int c, digit;
    if (bytes < len) {
      c = (int)p[bytes];
    } else {
      c = 0;
    }
    digit = isdigit(c);
    if (state == 0) {
      if (c == '+' || c == '-')
        state = 1;
      else if (digit)
        state = 2;
      else if (c == '.')
        state = 3;
      else
        return 0;
    } else if (state == 1) {
      if (c == '.')
        state = 4;
      else if (digit)
        state = 2;
      else
        return 0;
    } else if (state == 2) {
      if (c == 'e' || c == 'E')
        state = 5;
      else if (digit)
        state = 2;
      else if (c == '.')
        state = 4;
      else
        break;
    } else if (state == 3) {
      if (digit)
        state = 4;
      else
        return 0;
    } else if (state == 4) {
      if (c == 'e' || c == 'E')
        state = 5;
      else if (digit)
        state = 4;
      else
        break;
    } else if (state == 5) {
      if (c == '+' || c == '-')
        state = 6;
      else if (digit)
        state = 7;
      else
        return 0;
    } else if (state == 6) {
      if (digit)
        state = 7;
      else
        return 0;
    } else if (state == 7) {
      if (digit)
        state = 7;
      else
        break;
    }
    bytes++;
  }
  return bytes;
}


x86 assembly (clang, -O0):
<CharactersInDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1166 <CharactersInDouble+0x46>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
jmp    116d <CharactersInDouble+0x4d>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1030 <isdigit@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11e9 <CharactersInDouble+0xc9>
cmpl   $0x2b,-0x20(%rbp)
je     1196 <CharactersInDouble+0x76>
cmpl   $0x2d,-0x20(%rbp)
jne    11a2 <CharactersInDouble+0x82>
movl   $0x1,-0x1c(%rbp)
jmp    11e4 <CharactersInDouble+0xc4>
cmpl   $0x0,-0x24(%rbp)
je     11b8 <CharactersInDouble+0x98>
movl   $0x2,-0x1c(%rbp)
jmp    11df <CharactersInDouble+0xbf>
cmpl   $0x2e,-0x20(%rbp)
jne    11ce <CharactersInDouble+0xae>
movl   $0x3,-0x1c(%rbp)
jmp    11da <CharactersInDouble+0xba>
movl   $0x0,-0x4(%rbp)
jmp    1407 <CharactersInDouble+0x2e7>
jmp    11df <CharactersInDouble+0xbf>
jmp    11e4 <CharactersInDouble+0xc4>
jmp    13f3 <CharactersInDouble+0x2d3>
cmpl   $0x1,-0x1c(%rbp)
jne    1235 <CharactersInDouble+0x115>
cmpl   $0x2e,-0x20(%rbp)
jne    1209 <CharactersInDouble+0xe9>
movl   $0x4,-0x1c(%rbp)
jmp    1230 <CharactersInDouble+0x110>
cmpl   $0x0,-0x24(%rbp)
je     121f <CharactersInDouble+0xff>
movl   $0x2,-0x1c(%rbp)
jmp    122b <CharactersInDouble+0x10b>
movl   $0x0,-0x4(%rbp)
jmp    1407 <CharactersInDouble+0x2e7>
jmp    1230 <CharactersInDouble+0x110>
jmp    13ee <CharactersInDouble+0x2ce>
cmpl   $0x2,-0x1c(%rbp)
jne    129f <CharactersInDouble+0x17f>
cmpl   $0x65,-0x20(%rbp)
je     1253 <CharactersInDouble+0x133>
cmpl   $0x45,-0x20(%rbp)
jne    125f <CharactersInDouble+0x13f>
movl   $0x5,-0x1c(%rbp)
jmp    129a <CharactersInDouble+0x17a>
cmpl   $0x0,-0x24(%rbp)
je     1275 <CharactersInDouble+0x155>
movl   $0x2,-0x1c(%rbp)
jmp    1295 <CharactersInDouble+0x175>
cmpl   $0x2e,-0x20(%rbp)
jne    128b <CharactersInDouble+0x16b>
movl   $0x4,-0x1c(%rbp)
jmp    1290 <CharactersInDouble+0x170>
jmp    1401 <CharactersInDouble+0x2e1>
jmp    1295 <CharactersInDouble+0x175>
jmp    129a <CharactersInDouble+0x17a>
jmp    13e9 <CharactersInDouble+0x2c9>
cmpl   $0x3,-0x1c(%rbp)
jne    12d0 <CharactersInDouble+0x1b0>
cmpl   $0x0,-0x24(%rbp)
je     12bf <CharactersInDouble+0x19f>
movl   $0x4,-0x1c(%rbp)
jmp    12cb <CharactersInDouble+0x1ab>
movl   $0x0,-0x4(%rbp)
jmp    1407 <CharactersInDouble+0x2e7>
jmp    13e4 <CharactersInDouble+0x2c4>
cmpl   $0x4,-0x1c(%rbp)
jne    131f <CharactersInDouble+0x1ff>
cmpl   $0x65,-0x20(%rbp)
je     12ee <CharactersInDouble+0x1ce>
cmpl   $0x45,-0x20(%rbp)
jne    12fa <CharactersInDouble+0x1da>
movl   $0x5,-0x1c(%rbp)
jmp    131a <CharactersInDouble+0x1fa>
cmpl   $0x0,-0x24(%rbp)
je     1310 <CharactersInDouble+0x1f0>
movl   $0x4,-0x1c(%rbp)
jmp    1315 <CharactersInDouble+0x1f5>
jmp    1401 <CharactersInDouble+0x2e1>
jmp    131a <CharactersInDouble+0x1fa>
jmp    13df <CharactersInDouble+0x2bf>
cmpl   $0x5,-0x1c(%rbp)
jne    1375 <CharactersInDouble+0x255>
cmpl   $0x2b,-0x20(%rbp)
je     133d <CharactersInDouble+0x21d>
cmpl   $0x2d,-0x20(%rbp)
jne    1349 <CharactersInDouble+0x229>
movl   $0x6,-0x1c(%rbp)
jmp    1370 <CharactersInDouble+0x250>
cmpl   $0x0,-0x24(%rbp)
je     135f <CharactersInDouble+0x23f>
movl   $0x7,-0x1c(%rbp)
jmp    136b <CharactersInDouble+0x24b>
movl   $0x0,-0x4(%rbp)
jmp    1407 <CharactersInDouble+0x2e7>
jmp    1370 <CharactersInDouble+0x250>
jmp    13da <CharactersInDouble+0x2ba>
cmpl   $0x6,-0x1c(%rbp)
jne    13a6 <CharactersInDouble+0x286>
cmpl   $0x0,-0x24(%rbp)
je     1395 <CharactersInDouble+0x275>
movl   $0x7,-0x1c(%rbp)
jmp    13a1 <CharactersInDouble+0x281>
movl   $0x0,-0x4(%rbp)
jmp    1407 <CharactersInDouble+0x2e7>
jmp    13d5 <CharactersInDouble+0x2b5>
cmpl   $0x7,-0x1c(%rbp)
jne    13d0 <CharactersInDouble+0x2b0>
cmpl   $0x0,-0x24(%rbp)
je     13c6 <CharactersInDouble+0x2a6>
movl   $0x7,-0x1c(%rbp)
jmp    13cb <CharactersInDouble+0x2ab>
jmp    1401 <CharactersInDouble+0x2e1>
jmp    13d0 <CharactersInDouble+0x2b0>
jmp    13d5 <CharactersInDouble+0x2b5>
jmp    13da <CharactersInDouble+0x2ba>
jmp    13df <CharactersInDouble+0x2bf>
jmp    13e4 <CharactersInDouble+0x2c4>
jmp    13e9 <CharactersInDouble+0x2c9>
jmp    13ee <CharactersInDouble+0x2ce>
jmp    13f3 <CharactersInDouble+0x2d3>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <CharactersInDouble+0x26>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CharactersInDouble>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
movslq %eax,%rcx
xor    %eax,%eax
lea    0xed8(%rip),%r8
xor    %esi,%esi
jmp    113e <CharactersInDouble+0x2e>
mov    $0x7,%esi
cmp    $0xa,%edi
jae    121a <CharactersInDouble+0x10a>
add    $0x1,%rax
mov    $0x0,%ebx
cmp    %rcx,%rax
jge    114d <CharactersInDouble+0x3d>
movsbl (%r14,%rax,1),%ebx
cmp    $0x7,%esi
ja     113a <CharactersInDouble+0x2a>
lea    -0x30(%rbx),%edi
mov    %esi,%esi
movslq (%r8,%rsi,4),%rsi
add    %r8,%rsi
jmp    *%rsi
mov    $0x1,%esi
cmp    $0x2b,%ebx
je     113a <CharactersInDouble+0x2a>
cmp    $0x2d,%ebx
je     113a <CharactersInDouble+0x2a>
mov    $0x2,%esi
cmp    $0xa,%edi
jb     113a <CharactersInDouble+0x2a>
mov    $0x3,%esi
cmp    $0x2e,%ebx
je     113a <CharactersInDouble+0x2a>
jmp    121a <CharactersInDouble+0x10a>
xor    %esi,%esi
cmp    $0x2e,%ebx
sete   %sil
lea    0x2(%rsi,%rsi,1),%esi
jne    1131 <CharactersInDouble+0x21>
jmp    113a <CharactersInDouble+0x2a>
mov    %ebx,%esi
and    $0xffffffdf,%esi
xor    %edx,%edx
cmp    $0x45,%esi
sete   %dl
lea    0x2(%rdx,%rdx,2),%esi
je     113a <CharactersInDouble+0x2a>
cmp    $0xa,%edi
jb     113a <CharactersInDouble+0x2a>
mov    $0x4,%esi
cmp    $0x2e,%ebx
je     113a <CharactersInDouble+0x2a>
jmp    121c <CharactersInDouble+0x10c>
mov    $0x4,%esi
jmp    1131 <CharactersInDouble+0x21>
and    $0xffffffdf,%ebx
xor    %esi,%esi
cmp    $0x45,%ebx
sete   %sil
or     $0x4,%esi
cmp    $0x45,%ebx
je     113a <CharactersInDouble+0x2a>
cmp    $0xa,%edi
jb     113a <CharactersInDouble+0x2a>
jmp    121c <CharactersInDouble+0x10c>
mov    $0x6,%esi
cmp    $0x2b,%ebx
je     113a <CharactersInDouble+0x2a>
cmp    $0x2d,%ebx
je     113a <CharactersInDouble+0x2a>
jmp    112c <CharactersInDouble+0x1c>
mov    $0x7,%esi
cmp    $0x9,%edi
jbe    113a <CharactersInDouble+0x2a>
jmp    121c <CharactersInDouble+0x10c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @CharactersInDouble(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
br label %4
4: ; preds = %41, %1
%5 = phi i64 [ %43, %41 ], [ 0, %1 ]
%6 = phi i32 [ %42, %41 ], [ 0, %1 ]
%7 = icmp slt i64 %5, %3
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %0, i64 %5
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
br label %12
12: ; preds = %4, %8
%13 = phi i32 [ %11, %8 ], [ 0, %4 ]
%14 = add nsw i32 %13, -48
%15 = icmp ult i32 %14, 10
switch i32 %6, label %41 [
i32 0, label %16
i32 1, label %20
i32 2, label %24
i32 3, label %31
i32 4, label %32
i32 5, label %37
i32 6, label %39
i32 7, label %40
]
16: ; preds = %12
switch i32 %13, label %17 [
i32 45, label %41
i32 43, label %41
]
17: ; preds = %16
br i1 %15, label %41, label %18
18: ; preds = %17
%19 = icmp eq i32 %13, 46
br i1 %19, label %41, label %50
20: ; preds = %12
%21 = icmp eq i32 %13, 46
%22 = select i1 %21, i1 true, i1 %15
%23 = select i1 %21, i32 4, i32 2
br i1 %22, label %41, label %50
24: ; preds = %12
%25 = and i32 %13, -33
%26 = icmp eq i32 %25, 69
%27 = select i1 %26, i1 true, i1 %15
%28 = select i1 %26, i32 5, i32 2
br i1 %27, label %41, label %29
29: ; preds = %24
%30 = icmp eq i32 %13, 46
br i1 %30, label %41, label %48
31: ; preds = %12
br i1 %15, label %41, label %50
32: ; preds = %12
%33 = and i32 %13, -33
%34 = icmp eq i32 %33, 69
%35 = select i1 %34, i1 true, i1 %15
%36 = select i1 %34, i32 5, i32 4
br i1 %35, label %41, label %44
37: ; preds = %12
switch i32 %13, label %38 [
i32 45, label %41
i32 43, label %41
]
38: ; preds = %37
br i1 %15, label %41, label %50
39: ; preds = %12
br i1 %15, label %41, label %50
40: ; preds = %12
br i1 %15, label %41, label %46
41: ; preds = %16, %16, %17, %18, %29, %31, %37, %37, %38, %39, %12, %40, %20, %24, %32
%42 = phi i32 [ 1, %16 ], [ 1, %16 ], [ 2, %17 ], [ 3, %18 ], [ %23, %20 ], [ %28, %24 ], [ 4, %29 ], [ 4, %31 ], [ %36, %32 ], [ 6, %37 ], [ 6, %37 ], [ 7, %38 ], [ 7, %39 ], [ %6, %12 ], [ 7, %40 ]
%43 = add nuw i64 %5, 1
br label %4
44: ; preds = %32
%45 = trunc i64 %5 to i32
br label %50
46: ; preds = %40
%47 = trunc i64 %5 to i32
br label %50
48: ; preds = %29
%49 = trunc i64 %5 to i32
br label %50
50: ; preds = %18, %31, %38, %39, %20, %48, %46, %44
%51 = phi i32 [ %45, %44 ], [ %47, %46 ], [ %49, %48 ], [ 0, %20 ], [ 0, %39 ], [ 0, %38 ], [ 0, %31 ], [ 0, %18 ]
ret i32 %51
}