int getFileVersionFromCookieString(const char *cookie) {
  const char *ptr_cookie1, *ptr_cookie2;
  const char *pattern1 = "_FILE_VERSION_";
  const char *pattern2 = "?.?";
  const int len_cookie = strlen(cookie);
  const int len_pattern1 = strlen(pattern1);
  const int len_pattern2 = strlen(pattern2);
  const int len_pattern = len_pattern1 + len_pattern2;
  int version_major, version_minor;
  if (len_cookie <= len_pattern)
    return -1;
  ptr_cookie1 = &cookie[len_cookie - len_pattern];
  ptr_cookie2 = &cookie[len_cookie - len_pattern2];
  if (strncmp(ptr_cookie1, pattern1, len_pattern1) != 0)
    return -1;
  if (ptr_cookie2[0] < '0' || ptr_cookie2[0] > '9' || ptr_cookie2[1] != '.' ||
      ptr_cookie2[2] < '0' || ptr_cookie2[2] > '9')
    return -1;
  version_major = ptr_cookie2[0] - '0';
  version_minor = ptr_cookie2[2] - '0';
  return ((version_major)*1000000 + (version_minor)*10000 + (0) * 100 + (0));
}


x86 assembly (clang, -O0):
<getFileVersionFromCookieString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xecd(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xed1(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x40(%rbp),%eax
jg     1187 <getFileVersionFromCookieString+0x67>
movl   $0xffffffff,-0x4(%rbp)
jmp    1268 <getFileVersionFromCookieString+0x148>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    -0x40(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x38(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     11d5 <getFileVersionFromCookieString+0xb5>
movl   $0xffffffff,-0x4(%rbp)
jmp    1268 <getFileVersionFromCookieString+0x148>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     1228 <getFileVersionFromCookieString+0x108>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jg     1228 <getFileVersionFromCookieString+0x108>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%eax
jne    1228 <getFileVersionFromCookieString+0x108>
mov    -0x20(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x30,%eax
jl     1228 <getFileVersionFromCookieString+0x108>
mov    -0x20(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x39,%eax
jle    1234 <getFileVersionFromCookieString+0x114>
movl   $0xffffffff,-0x4(%rbp)
jmp    1268 <getFileVersionFromCookieString+0x148>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rax
movsbl 0x2(%rax),%eax
sub    $0x30,%eax
mov    %eax,-0x48(%rbp)
imul   $0xf4240,-0x44(%rbp),%eax
imul   $0x2710,-0x48(%rbp),%ecx
add    %ecx,%eax
add    $0x0,%eax
add    $0x0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFileVersionFromCookieString>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %rax,%rbp
mov    $0xffffffff,%r14d
cmp    $0x12,%ebp
jl     11af <getFileVersionFromCookieString+0x8f>
shl    $0x20,%rbp
movabs $0xffffffef00000000,%rdi
ff ff ff
add    %rbp,%rdi
sar    $0x20,%rdi
add    %rbx,%rdi
lea    0xea7(%rip),%rsi
mov    $0xe,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    11af <getFileVersionFromCookieString+0x8f>
movabs $0xfffffffd00000000,%rax
ff ff ff
add    %rax,%rbp
sar    $0x20,%rbp
movsbl (%rbx,%rbp,1),%eax
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     11af <getFileVersionFromCookieString+0x8f>
cmpb   $0x2e,0x1(%rbx,%rbp,1)
jne    11af <getFileVersionFromCookieString+0x8f>
movzbl 0x2(%rbx,%rbp,1),%ecx
lea    -0x3a(%rcx),%edx
cmp    $0xf6,%dl
jb     11af <getFileVersionFromCookieString+0x8f>
imul   $0xf4240,%eax,%eax
imul   $0x2710,%ecx,%ecx
lea    (%rax,%rcx,1),%r14d
add    $0xfd1c4100,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"_FILE_VERSION_\00"
@.str.1 = [4 x i8] c"?.?\00"
define i32 @getFileVersionFromCookieString(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %3
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %7
%14 = load i8*, i8** %3
%15 = call i64 @strlen(i8* %14)
%16 = trunc i64 %15 to i32
store i32 %16, i32* %8
%17 = load i8*, i8** %6
%18 = call i64 @strlen(i8* %17)
%19 = trunc i64 %18 to i32
store i32 %19, i32* %9
%20 = load i8*, i8** %7
%21 = call i64 @strlen(i8* %20)
%22 = trunc i64 %21 to i32
store i32 %22, i32* %10
%23 = load i32, i32* %9
%24 = load i32, i32* %10
%25 = add nsw i32 %23, %24
store i32 %25, i32* %11
%26 = load i32, i32* %8
%27 = load i32, i32* %11
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %1
store i32 -1, i32* %2
br label %99
30: ; preds = %1
%31 = load i8*, i8** %3
%32 = load i32, i32* %8
%33 = load i32, i32* %11
%34 = sub nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %31, i64 %35
store i8* %36, i8** %4
%37 = load i8*, i8** %3
%38 = load i32, i32* %8
%39 = load i32, i32* %10
%40 = sub nsw i32 %38, %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %37, i64 %41
store i8* %42, i8** %5
%43 = load i8*, i8** %4
%44 = load i8*, i8** %6
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = call i32 @strncmp(i8* %43, i8* %44, i64 %46)
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %30
store i32 -1, i32* %2
br label %99
50: ; preds = %30
%51 = load i8*, i8** %5
%52 = getelementptr inbounds i8, i8* %51, i64 0
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp slt i32 %54, 48
br i1 %55, label %80, label %56
56: ; preds = %50
%57 = load i8*, i8** %5
%58 = getelementptr inbounds i8, i8* %57, i64 0
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp sgt i32 %60, 57
br i1 %61, label %80, label %62
62: ; preds = %56
%63 = load i8*, i8** %5
%64 = getelementptr inbounds i8, i8* %63, i64 1
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp ne i32 %66, 46
br i1 %67, label %80, label %68
68: ; preds = %62
%69 = load i8*, i8** %5
%70 = getelementptr inbounds i8, i8* %69, i64 2
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp slt i32 %72, 48
br i1 %73, label %80, label %74
74: ; preds = %68
%75 = load i8*, i8** %5
%76 = getelementptr inbounds i8, i8* %75, i64 2
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = icmp sgt i32 %78, 57
br i1 %79, label %80, label %81
80: ; preds = %74, %68, %62, %56, %50
store i32 -1, i32* %2
br label %99
81: ; preds = %74
%82 = load i8*, i8** %5
%83 = getelementptr inbounds i8, i8* %82, i64 0
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = sub nsw i32 %85, 48
store i32 %86, i32* %12
%87 = load i8*, i8** %5
%88 = getelementptr inbounds i8, i8* %87, i64 2
%89 = load i8, i8* %88
%90 = sext i8 %89 to i32
%91 = sub nsw i32 %90, 48
store i32 %91, i32* %13
%92 = load i32, i32* %12
%93 = mul nsw i32 %92, 1000000
%94 = load i32, i32* %13
%95 = mul nsw i32 %94, 10000
%96 = add nsw i32 %93, %95
%97 = add nsw i32 %96, 0
%98 = add nsw i32 %97, 0
store i32 %98, i32* %2
br label %99
99: ; preds = %81, %80, %49, %29
%100 = load i32, i32* %2
ret i32 %100
}

LLVM IR (-O2):
@.str = [15 x i8] c"_FILE_VERSION_\00"
define i32 @getFileVersionFromCookieString(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = trunc i64 %2 to i32
%4 = icmp slt i32 %3, 18
br i1 %4, label %35, label %5
5: ; preds = %1
%6 = shl i64 %2, 32
%7 = add i64 %6, -73014444032
%8 = ashr exact i64 %7, 32
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = add i64 %6, -12884901888
%11 = ashr exact i64 %10, 32
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = tail call i32 @strncmp(i8* dereferenceable(1) %9, i8* dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64 14)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %35
15: ; preds = %5
%16 = load i8, i8* %12
%17 = sext i8 %16 to i32
%18 = add i8 %16, -58
%19 = icmp ult i8 %18, -10
br i1 %19, label %35, label %20
20: ; preds = %15
%21 = getelementptr inbounds i8, i8* %12, i64 1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 46
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = getelementptr inbounds i8, i8* %12, i64 2
%26 = load i8, i8* %25
%27 = add i8 %26, -58
%28 = icmp ult i8 %27, -10
br i1 %28, label %35, label %29
29: ; preds = %24
%30 = zext i8 %26 to i32
%31 = mul nsw i32 %17, 1000000
%32 = mul nuw nsw i32 %30, 10000
%33 = add nsw i32 %31, -48480000
%34 = add nsw i32 %33, %32
br label %35
35: ; preds = %15, %20, %24, %5, %1, %29
%36 = phi i32 [ %34, %29 ], [ -1, %1 ], [ -1, %5 ], [ -1, %24 ], [ -1, %20 ], [ -1, %15 ]
ret i32 %36
}