#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 */
size_t strlen(char const *const);
scalar_t__ strncmp(char *, char const *const, size_t const);
int validate(const char *const tag) {
  size_t const tagLength = strlen(tag);
  size_t const verLength = strlen("1.9.3");
  if (tagLength < 2)
    return 0;
  if (tag[0] != 'v')
    return 0;
  if (tagLength <= verLength)
    return 0;
  if (strncmp("1.9.3", tag + 1, verLength))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<validate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
movq   $0x5,-0x20(%rbp)
cmpq   $0x2,-0x18(%rbp)
jae    1158 <validate+0x38>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <validate+0xa1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x76,%eax
je     1174 <validate+0x54>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <validate+0xa1>
cmpq   $0x5,-0x18(%rbp)
ja     118b <validate+0x6b>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <validate+0xa1>
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    0xe66(%rip),%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11ba <validate+0x9a>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <validate+0xa1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate>:
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x2,%rcx
jb     1162 <validate+0x42>
cmpb   $0x76,(%rbx)
jne    1162 <validate+0x42>
cmp    $0x6,%rcx
jb     1162 <validate+0x42>
add    $0x1,%rbx
lea    0xeb6(%rip),%rdi
mov    $0x5,%edx
mov    %rbx,%rsi
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"1.9.3\00"
define i32 @validate(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @strlen(i8* %6)
store i64 %7, i64* %4
store i64 5, i64* %5
%8 = load i64, i64* %4
%9 = icmp ult i64 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %29
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 118
br i1 %16, label %17, label %18
17: ; preds = %11
store i32 0, i32* %2
br label %29
18: ; preds = %11
%19 = load i64, i64* %4
%20 = icmp ule i64 %19, 5
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 0, i32* %2
br label %29
22: ; preds = %18
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = call i64 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %24, i64 5)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 0, i32* %2
br label %29
28: ; preds = %22
store i32 1, i32* %2
br label %29
29: ; preds = %28, %27, %21, %17, %10
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@.str = [6 x i8] c"1.9.3\00"
define i32 @validate(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = icmp ult i64 %2, 2
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = load i8, i8* %0
%6 = icmp ne i8 %5, 118
%7 = icmp ult i64 %2, 6
%8 = select i1 %6, i1 true, i1 %7
br i1 %8, label %14, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = tail call i64 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %10, i64 5)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %9, %4, %1
%15 = phi i32 [ 0, %1 ], [ 0, %4 ], [ %13, %9 ]
ret i32 %15
}