#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*/ fprintf(int /*<<< orphan*/, char *, int);
scalar_t__ isdigit(char);
int /*<<< orphan*/ stderr;
int is_number(char *version) {
  int i = 0;
  char c;
  int state;
  state = 0;
  while (state != 50 && state <= 99) {
    c = version[i++];
    if (isdigit(c) && c != '0') {
      c = '1';
    }
    switch (state) {
    case 0:
      switch (c) {
      case '0':
        state = 1;
        continue;
      case '1':
        state = 5;
        continue;
      default:
        state = 100 + state;
        continue;
      }
    case 1:
      switch (c) {
      case '\0':
        state = 50;
        continue;
      default:
        state = 100 + state;
        continue;
      }
    case 5:
      switch (c) {
      case '0':
      case '1':
        state = 5;
        continue;
      case '\0':
        state = 50;
        continue;
      default:
        state = 100 + state;
        continue;
      }
    default:
      fprintf(stderr, "is_number(): Illegal state=%d\n", state);
      return 0;
    }
  }
  if (state == 50) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<is_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x32,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
je     1153 <is_number+0x33>
cmpl   $0x63,-0x1c(%rbp)
setle  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1163 <is_number+0x43>
jmp    12bc <is_number+0x19c>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     119f <is_number+0x7f>
movsbl -0x15(%rbp),%eax
cmp    $0x30,%eax
je     119f <is_number+0x7f>
movb   $0x31,-0x15(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
test   %eax,%eax
je     11d4 <is_number+0xb4>
jmp    11b2 <is_number+0x92>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
je     1220 <is_number+0x100>
jmp    11c3 <is_number+0xa3>
mov    -0x24(%rbp),%eax
sub    $0x5,%eax
je     124a <is_number+0x12a>
jmp    1298 <is_number+0x178>
movsbl -0x15(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x30,%eax
je     11fa <is_number+0xda>
jmp    11e9 <is_number+0xc9>
mov    -0x28(%rbp),%eax
sub    $0x31,%eax
je     1206 <is_number+0xe6>
jmp    1212 <is_number+0xf2>
movl   $0x1,-0x1c(%rbp)
jmp    113a <is_number+0x1a>
movl   $0x5,-0x1c(%rbp)
jmp    113a <is_number+0x1a>
mov    -0x1c(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <is_number+0x1a>
mov    -0x15(%rbp),%al
test   %al,%al
jne    123c <is_number+0x11c>
jmp    1230 <is_number+0x110>
movl   $0x32,-0x1c(%rbp)
jmp    113a <is_number+0x1a>
mov    -0x1c(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <is_number+0x1a>
movsbl -0x15(%rbp),%eax
mov    %eax,-0x2c(%rbp)
test   %eax,%eax
je     127e <is_number+0x15e>
jmp    125e <is_number+0x13e>
mov    -0x2c(%rbp),%eax
add    $0xffffffd0,%eax
sub    $0x1,%eax
ja     128a <is_number+0x16a>
jmp    1272 <is_number+0x152>
movl   $0x5,-0x1c(%rbp)
jmp    113a <is_number+0x1a>
movl   $0x32,-0x1c(%rbp)
jmp    113a <is_number+0x1a>
mov    -0x1c(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <is_number+0x1a>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xd55(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12d9 <is_number+0x1b9>
cmpl   $0x32,-0x1c(%rbp)
jne    12d2 <is_number+0x1b2>
movl   $0x1,-0x4(%rbp)
jmp    12d9 <is_number+0x1b9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_number>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %r14d,%r14d
mov    $0x1,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%rbx),%ebp
mov    %ebp,%edi
call   1030 <isdigit@plt>
mov    $0x31,%ecx
test   %rax,%rax
jne    1156 <is_number+0x36>
mov    %ebp,%ecx
cmp    $0x30,%ebp
cmove  %ebp,%ecx
cmp    $0x5,%r14d
je     1190 <is_number+0x70>
cmp    $0x1,%r14d
je     11b0 <is_number+0x90>
test   %r14d,%r14d
jne    11d6 <is_number+0xb6>
mov    $0x5,%r14d
cmp    $0x31,%cl
je     117e <is_number+0x5e>
mov    $0x64,%r14d
cmp    $0x30,%cl
cmove  %r15d,%r14d
jmp    11c0 <is_number+0xa0>
nopw   0x0(%rax,%rax,1)
movsbl %cl,%eax
mov    $0x5,%r14d
lea    -0x30(%rax),%ecx
cmp    $0x2,%ecx
jb     11c0 <is_number+0xa0>
jmp    11f2 <is_number+0xd2>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x32,%r14d
test   %cl,%cl
je     11c0 <is_number+0xa0>
mov    $0x65,%r14d
cmp    $0x32,%r14d
je     1202 <is_number+0xe2>
add    $0x1,%rbx
cmp    $0x64,%r14d
jb     1140 <is_number+0x20>
jmp    1202 <is_number+0xe2>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
lea    0xe1a(%rip),%rsi
mov    %r14d,%edx
call   1040 <fprintf@plt>
xor    %eax,%eax
jmp    120b <is_number+0xeb>
mov    $0x32,%r14d
test   %eax,%eax
je     1202 <is_number+0xe2>
mov    $0x69,%r14d
xor    %eax,%eax
cmp    $0x32,%r14d
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"is_number(): Illegal state=%d\0A\00"
define i32 @is_number(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %6
br label %7
7: ; preds = %52, %51, %50, %44, %43, %37, %36, %35, %1
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 50
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* %6
%12 = icmp sle i32 %11, 99
br label %13
13: ; preds = %10, %7
%14 = phi i1 [ false, %7 ], [ %12, %10 ]
br i1 %14, label %15, label %59
15: ; preds = %13
%16 = load i8*, i8** %3
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
%21 = load i8, i8* %20
store i8 %21, i8* %5
%22 = load i8, i8* %5
%23 = call i64 @isdigit(i8 signext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %15
%26 = load i8, i8* %5
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 48
br i1 %28, label %29, label %30
29: ; preds = %25
store i8 49, i8* %5
br label %30
30: ; preds = %29, %25, %15
%31 = load i32, i32* %6
switch i32 %31, label %55 [
i32 0, label %32
i32 1, label %40
i32 5, label %47
]
32: ; preds = %30
%33 = load i8, i8* %5
%34 = sext i8 %33 to i32
switch i32 %34, label %37 [
i32 48, label %35
i32 49, label %36
]
35: ; preds = %32
store i32 1, i32* %6
br label %7
36: ; preds = %32
store i32 5, i32* %6
br label %7
37: ; preds = %32
%38 = load i32, i32* %6
%39 = add nsw i32 100, %38
store i32 %39, i32* %6
br label %7
40: ; preds = %30
%41 = load i8, i8* %5
%42 = sext i8 %41 to i32
switch i32 %42, label %44 [
i32 0, label %43
]
43: ; preds = %40
store i32 50, i32* %6
br label %7
44: ; preds = %40
%45 = load i32, i32* %6
%46 = add nsw i32 100, %45
store i32 %46, i32* %6
br label %7
47: ; preds = %30
%48 = load i8, i8* %5
%49 = sext i8 %48 to i32
switch i32 %49, label %52 [
i32 48, label %50
i32 49, label %50
i32 0, label %51
]
50: ; preds = %47, %47
store i32 5, i32* %6
br label %7
51: ; preds = %47
store i32 50, i32* %6
br label %7
52: ; preds = %47
%53 = load i32, i32* %6
%54 = add nsw i32 100, %53
store i32 %54, i32* %6
br label %7
55: ; preds = %30
%56 = load i32, i32* @stderr
%57 = load i32, i32* %6
%58 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %57)
store i32 0, i32* %2
br label %64
59: ; preds = %13
%60 = load i32, i32* %6
%61 = icmp eq i32 %60, 50
br i1 %61, label %62, label %63
62: ; preds = %59
store i32 1, i32* %2
br label %64
63: ; preds = %59
store i32 0, i32* %2
br label %64
64: ; preds = %63, %62, %55
%65 = load i32, i32* %2
ret i32 %65
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"is_number(): Illegal state=%d\0A\00"
define i32 @is_number(i8* nocapture %0) {
br label %2
2: ; preds = %1, %18
%3 = phi i64 [ 0, %1 ], [ %5, %18 ]
%4 = phi i32 [ 0, %1 ], [ %19, %18 ]
%5 = add nuw i64 %3, 1
%6 = getelementptr inbounds i8, i8* %0, i64 %3
%7 = load i8, i8* %6
%8 = tail call i64 @isdigit(i8 signext %7)
%9 = icmp ne i64 %8, 0
%10 = icmp ne i8 %7, 48
%11 = and i1 %10, %9
%12 = select i1 %11, i8 49, i8 %7
switch i32 %4, label %28 [
i32 0, label %13
i32 1, label %23
i32 5, label %26
]
13: ; preds = %2
%14 = icmp eq i8 %12, 49
%15 = select i1 %14, i32 5, i32 100
%16 = icmp eq i8 %12, 48
%17 = select i1 %16, i32 1, i32 %15
br label %18
18: ; preds = %26, %26, %13, %23
%19 = phi i32 [ %25, %23 ], [ %17, %13 ], [ 5, %26 ], [ 5, %26 ]
%20 = icmp ne i32 %19, 50
%21 = icmp ult i32 %19, 100
%22 = and i1 %20, %21
br i1 %22, label %2, label %31
23: ; preds = %2
%24 = icmp eq i8 %12, 0
%25 = select i1 %24, i32 50, i32 101
br label %18
26: ; preds = %2
%27 = sext i8 %12 to i32
switch i32 %27, label %33 [
i32 48, label %18
i32 49, label %18
i32 0, label %31
]
28: ; preds = %2
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %4)
br label %37
31: ; preds = %18, %26
%32 = phi i32 [ %19, %18 ], [ 50, %26 ]
br label %33
33: ; preds = %26, %31
%34 = phi i32 [ %32, %31 ], [ 105, %26 ]
%35 = icmp eq i32 %34, 50
%36 = zext i1 %35 to i32
br label %37
37: ; preds = %33, %28
%38 = phi i32 [ 0, %28 ], [ %36, %33 ]
ret i32 %38
}