#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_version(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 '.':
        state = 2;
        continue;
      default:
        state = 100 + state;
        continue;
      }
    case 5:
      switch (c) {
      case '0':
      case '1':
        state = 5;
        continue;
      case '.':
        state = 2;
        continue;
      default:
        state = 100 + state;
        continue;
      }
    case 2:
      switch (c) {
      case '0':
        state = 3;
        continue;
      case '1':
        state = 6;
        continue;
      default:
        state = 100 + state;
        continue;
      }
    case 6:
      switch (c) {
      case '0':
      case '1':
        state = 6;
        continue;
      case '\0':
        state = 50;
        continue;
      default:
        state = 100 + state;
        continue;
      }
    case 3:
      switch (c) {
      case '\0':
        state = 50;
        continue;
      default:
        state = 100 + state;
        continue;
      }
    default:
      fprintf(stderr, "is_version(): Illegal state=%d\n", state);
      return 0;
    }
  }
  if (state == 50) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<is_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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_version+0x33>
cmpl   $0x63,-0x1c(%rbp)
setle  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1163 <is_version+0x43>
jmp    1371 <is_version+0x251>
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_version+0x7f>
movsbl -0x15(%rbp),%eax
cmp    $0x30,%eax
je     119f <is_version+0x7f>
movb   $0x31,-0x15(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x6,%rax
ja     134d <is_version+0x22d>
mov    -0x28(%rbp),%rax
lea    0xe45(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl -0x15(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x30,%eax
je     11ea <is_version+0xca>
jmp    11d9 <is_version+0xb9>
mov    -0x2c(%rbp),%eax
sub    $0x31,%eax
je     11f6 <is_version+0xd6>
jmp    1202 <is_version+0xe2>
movl   $0x1,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
movl   $0x5,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
mov    -0x1c(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
mov    -0x15(%rbp),%al
sub    $0x2e,%al
jne    122c <is_version+0x10c>
jmp    1220 <is_version+0x100>
movl   $0x2,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
mov    -0x1c(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
movsbl -0x15(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x2e,%eax
je     126f <is_version+0x14f>
jmp    124f <is_version+0x12f>
mov    -0x30(%rbp),%eax
add    $0xffffffd0,%eax
sub    $0x1,%eax
ja     127b <is_version+0x15b>
jmp    1263 <is_version+0x143>
movl   $0x5,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
movl   $0x2,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
mov    -0x1c(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
movsbl -0x15(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x30,%eax
je     12af <is_version+0x18f>
jmp    129e <is_version+0x17e>
mov    -0x34(%rbp),%eax
sub    $0x31,%eax
je     12bb <is_version+0x19b>
jmp    12c7 <is_version+0x1a7>
movl   $0x3,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
movl   $0x6,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
mov    -0x1c(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
movsbl -0x15(%rbp),%eax
mov    %eax,-0x38(%rbp)
test   %eax,%eax
je     1309 <is_version+0x1e9>
jmp    12e9 <is_version+0x1c9>
mov    -0x38(%rbp),%eax
add    $0xffffffd0,%eax
sub    $0x1,%eax
ja     1315 <is_version+0x1f5>
jmp    12fd <is_version+0x1dd>
movl   $0x6,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
movl   $0x32,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
mov    -0x1c(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
mov    -0x15(%rbp),%al
test   %al,%al
jne    133f <is_version+0x21f>
jmp    1333 <is_version+0x213>
movl   $0x32,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
mov    -0x1c(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <is_version+0x1a>
mov    0x2c8c(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xcbc(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    138e <is_version+0x26e>
cmpl   $0x32,-0x1c(%rbp)
jne    1387 <is_version+0x267>
movl   $0x1,-0x4(%rbp)
jmp    138e <is_version+0x26e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_version>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %r14d,%r14d
lea    0xec8(%rip),%r15
mov    $0x1,%r12d
mov    $0x3,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rbx),%ebp
mov    %ebp,%edi
call   1030 <isdigit@plt>
mov    $0x31,%ecx
test   %rax,%rax
jne    1166 <is_version+0x46>
mov    %ebp,%ecx
cmp    $0x30,%ebp
cmove  %ebp,%ecx
cmp    $0x6,%r14d
ja     123c <is_version+0x11c>
mov    %r14d,%eax
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    $0x5,%r14d
cmp    $0x31,%cl
je     1193 <is_version+0x73>
mov    $0x64,%r14d
cmp    $0x30,%cl
cmove  %r12d,%r14d
jmp    1210 <is_version+0xf0>
mov    $0x2,%r14d
cmp    $0x2e,%cl
je     1210 <is_version+0xf0>
mov    $0x65,%r14d
jmp    1210 <is_version+0xf0>
mov    $0x6,%r14d
cmp    $0x31,%cl
je     11c0 <is_version+0xa0>
mov    $0x66,%r14d
cmp    $0x30,%cl
cmove  %r13d,%r14d
jmp    1210 <is_version+0xf0>
mov    $0x32,%r14d
test   %cl,%cl
je     1210 <is_version+0xf0>
mov    $0x67,%r14d
jmp    1210 <is_version+0xf0>
movsbl %cl,%eax
lea    -0x30(%rax),%ecx
cmp    $0x2,%ecx
jae    1201 <is_version+0xe1>
mov    $0x5,%r14d
jmp    1210 <is_version+0xf0>
movsbl %cl,%eax
mov    $0x6,%r14d
lea    -0x30(%rax),%ecx
cmp    $0x2,%ecx
jb     1210 <is_version+0xf0>
jmp    1258 <is_version+0x138>
mov    $0x2,%r14d
cmp    $0x2e,%eax
jne    126a <is_version+0x14a>
nopl   0x0(%rax)
cmp    $0x32,%r14d
je     1224 <is_version+0x104>
add    $0x1,%rbx
cmp    $0x64,%r14d
jb     1150 <is_version+0x30>
xor    %eax,%eax
cmp    $0x32,%r14d
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
mov    %r14d,%edx
call   1040 <fprintf@plt>
xor    %eax,%eax
jmp    122d <is_version+0x10d>
mov    $0x32,%r14d
test   %eax,%eax
je     1224 <is_version+0x104>
mov    $0x6a,%r14d
jmp    1224 <is_version+0x104>
mov    $0x69,%r14d
jmp    1224 <is_version+0x104>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"is_version(): Illegal state=%d\0A\00"
define i32 @is_version(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 = %75, %74, %68, %67, %66, %60, %59, %58, %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 %82
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 %78 [
i32 0, label %32
i32 1, label %40
i32 5, label %47
i32 2, label %55
i32 6, label %63
i32 3, label %71
]
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 46, label %43
]
43: ; preds = %40
store i32 2, 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 46, label %51
]
50: ; preds = %47, %47
store i32 5, i32* %6
br label %7
51: ; preds = %47
store i32 2, 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 i8, i8* %5
%57 = sext i8 %56 to i32
switch i32 %57, label %60 [
i32 48, label %58
i32 49, label %59
]
58: ; preds = %55
store i32 3, i32* %6
br label %7
59: ; preds = %55
store i32 6, i32* %6
br label %7
60: ; preds = %55
%61 = load i32, i32* %6
%62 = add nsw i32 100, %61
store i32 %62, i32* %6
br label %7
63: ; preds = %30
%64 = load i8, i8* %5
%65 = sext i8 %64 to i32
switch i32 %65, label %68 [
i32 48, label %66
i32 49, label %66
i32 0, label %67
]
66: ; preds = %63, %63
store i32 6, i32* %6
br label %7
67: ; preds = %63
store i32 50, i32* %6
br label %7
68: ; preds = %63
%69 = load i32, i32* %6
%70 = add nsw i32 100, %69
store i32 %70, i32* %6
br label %7
71: ; preds = %30
%72 = load i8, i8* %5
%73 = sext i8 %72 to i32
switch i32 %73, label %75 [
i32 0, label %74
]
74: ; preds = %71
store i32 50, i32* %6
br label %7
75: ; preds = %71
%76 = load i32, i32* %6
%77 = add nsw i32 100, %76
store i32 %77, i32* %6
br label %7
78: ; preds = %30
%79 = load i32, i32* @stderr
%80 = load i32, i32* %6
%81 = call i32 @fprintf(i32 %79, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %80)
store i32 0, i32* %2
br label %87
82: ; preds = %13
%83 = load i32, i32* %6
%84 = icmp eq i32 %83, 50
br i1 %84, label %85, label %86
85: ; preds = %82
store i32 1, i32* %2
br label %87
86: ; preds = %82
store i32 0, i32* %2
br label %87
87: ; preds = %86, %85, %78
%88 = load i32, i32* %2
ret i32 %88
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"is_version(): Illegal state=%d\0A\00"
define i32 @is_version(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 %39 [
i32 0, label %13
i32 1, label %23
i32 5, label %26
i32 2, label %29
i32 6, label %34
i32 3, label %36
]
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 = %34, %34, %29, %13, %28, %26, %23, %36
%19 = phi i32 [ 5, %28 ], [ 2, %26 ], [ %25, %23 ], [ %38, %36 ], [ %17, %13 ], [ %33, %29 ], [ 6, %34 ], [ 6, %34 ]
%20 = icmp ne i32 %19, 50
%21 = icmp ult i32 %19, 100
%22 = and i1 %20, %21
br i1 %22, label %2, label %42
23: ; preds = %2
%24 = icmp eq i8 %12, 46
%25 = select i1 %24, i32 2, i32 101
br label %18
26: ; preds = %2
%27 = sext i8 %12 to i32
switch i32 %27, label %42 [
i32 48, label %28
i32 49, label %28
i32 46, label %18
]
28: ; preds = %26, %26
br label %18
29: ; preds = %2
%30 = icmp eq i8 %12, 49
%31 = select i1 %30, i32 6, i32 102
%32 = icmp eq i8 %12, 48
%33 = select i1 %32, i32 3, i32 %31
br label %18
34: ; preds = %2
%35 = sext i8 %12 to i32
switch i32 %35, label %44 [
i32 48, label %18
i32 49, label %18
i32 0, label %42
]
36: ; preds = %2
%37 = icmp eq i8 %12, 0
%38 = select i1 %37, i32 50, i32 103
br label %18
39: ; preds = %2
%40 = load i32, i32* @stderr
%41 = tail call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %4)
br label %48
42: ; preds = %18, %34, %26
%43 = phi i32 [ %19, %18 ], [ 50, %34 ], [ 105, %26 ]
br label %44
44: ; preds = %34, %42
%45 = phi i32 [ %43, %42 ], [ 106, %34 ]
%46 = icmp eq i32 %45, 50
%47 = zext i1 %46 to i32
br label %48
48: ; preds = %44, %39
%49 = phi i32 [ 0, %39 ], [ %47, %44 ]
ret i32 %49
}