#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*/ debug(int, char *, char const *);
int sscanf(char *, char *, int *, int *, int *);
char *strstr(char const *, char *);
int check_version_string(const char *str, int req_major, int req_minor,
                         int req_extra) {
  char *p;
  int major, minor, extra;
  int skip = 6;
  p = strstr(str, "(CVS) ");
  if (!p) {
    p = strstr(str, "(CVSNT)");
    skip = 8;
  }
  if (!p) {
    debug(32, "WARNING: malformed CVS version str: %s", str);
    return 0;
  }
  p += skip;
  if (sscanf(p, "%d.%d.%d", &major, &minor, &extra) != 3) {
    if (sscanf(p, "'%d.%d.%d'", &major, &minor, &extra) != 3) {
      debug(32, "WARNING: malformed CVS version: %s", str);
      return 0;
    }
  }
  return (major > req_major || (major == req_major && minor > req_minor) ||
          (major == req_major && minor == req_minor && extra >= req_extra));
}


x86 assembly (clang, -O0):
<check_version_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x6,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1186 <check_version_string+0x56>
mov    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x28(%rbp)
movl   $0x8,-0x38(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11b2 <check_version_string+0x82>
mov    -0x10(%rbp),%rdx
mov    $0x20,%edi
lea    0xe6e(%rip),%rsi
call   1030 <debug@plt>
movl   $0x0,-0x4(%rbp)
jmp    12a0 <check_version_string+0x170>
mov    -0x38(%rbp),%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe68(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x34(%rbp),%r8
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     1233 <check_version_string+0x103>
mov    -0x28(%rbp),%rdi
lea    0xe4c(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x34(%rbp),%r8
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     122e <check_version_string+0xfe>
mov    -0x10(%rbp),%rdx
mov    $0x20,%edi
lea    0xe2d(%rip),%rsi
call   1030 <debug@plt>
movl   $0x0,-0x4(%rbp)
jmp    12a0 <check_version_string+0x170>
jmp    1233 <check_version_string+0x103>
mov    -0x2c(%rbp),%ecx
mov    $0x1,%al
cmp    -0x14(%rbp),%ecx
mov    %al,-0x39(%rbp)
jg     1295 <check_version_string+0x165>
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1261 <check_version_string+0x131>
mov    -0x30(%rbp),%ecx
mov    $0x1,%al
cmp    -0x18(%rbp),%ecx
mov    %al,-0x39(%rbp)
jg     1295 <check_version_string+0x165>
mov    -0x2c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x3a(%rbp)
jne    128f <check_version_string+0x15f>
mov    -0x30(%rbp),%ecx
xor    %eax,%eax
cmp    -0x18(%rbp),%ecx
mov    %al,-0x3a(%rbp)
jne    128f <check_version_string+0x15f>
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
setge  %al
mov    %al,-0x3a(%rbp)
mov    -0x3a(%rbp),%al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_version_string>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rbp
lea    0xeb1(%rip),%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1160 <check_version_string+0x30>
mov    $0x6,%ebx
jmp    117d <check_version_string+0x4d>
lea    0xea0(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     1200 <check_version_string+0xd0>
mov    $0x8,%ebx
add    %rax,%rbx
lea    0xeaf(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %rbx,%rdi
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     11c6 <check_version_string+0x96>
lea    0xe95(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %rbx,%rdi
call   1040 <sscanf@plt>
cmp    $0x3,%eax
jne    11f7 <check_version_string+0xc7>
mov    0xc(%rsp),%ecx
mov    $0x1,%eax
cmp    %r12d,%ecx
jg     1216 <check_version_string+0xe6>
mov    0x8(%rsp),%edx
jne    11df <check_version_string+0xaf>
cmp    %r15d,%edx
jg     1216 <check_version_string+0xe6>
xor    %eax,%eax
cmp    %r12d,%ecx
jne    1216 <check_version_string+0xe6>
cmp    %r15d,%edx
jne    1216 <check_version_string+0xe6>
xor    %eax,%eax
cmp    %r14d,0x4(%rsp)
setge  %al
jmp    1216 <check_version_string+0xe6>
lea    0xe4c(%rip),%rsi
jmp    1207 <check_version_string+0xd7>
lea    0xe08(%rip),%rsi
mov    $0x20,%edi
mov    %rbp,%rdx
call   1030 <debug@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"(CVS) \00"
@.str.1 = [8 x i8] c"(CVSNT)\00"
@.str.2 = [39 x i8] c"WARNING: malformed CVS version str: %s\00"
@.str.3 = [9 x i8] c"%d.%d.%d\00"
@.str.4 = [11 x i8] c"'%d.%d.%d'\00"
@.str.5 = [35 x i8] c"WARNING: malformed CVS version: %s\00"
define i32 @check_version_string(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 6, i32* %14
%15 = load i8*, i8** %6
%16 = call i8* @strstr(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %10
%17 = load i8*, i8** %10
%18 = icmp ne i8* %17, null
br i1 %18, label %22, label %19
19: ; preds = %4
%20 = load i8*, i8** %6
%21 = call i8* @strstr(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i8* %21, i8** %10
store i32 8, i32* %14
br label %22
22: ; preds = %19, %4
%23 = load i8*, i8** %10
%24 = icmp ne i8* %23, null
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i8*, i8** %6
%27 = call i32 @debug(i32 32, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %26)
store i32 0, i32* %5
br label %73
28: ; preds = %22
%29 = load i32, i32* %14
%30 = load i8*, i8** %10
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %30, i64 %31
store i8* %32, i8** %10
%33 = load i8*, i8** %10
%34 = call i32 @sscanf(i8* %33, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %11, i32* %12, i32* %13)
%35 = icmp ne i32 %34, 3
br i1 %35, label %36, label %44
36: ; preds = %28
%37 = load i8*, i8** %10
%38 = call i32 @sscanf(i8* %37, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32* %11, i32* %12, i32* %13)
%39 = icmp ne i32 %38, 3
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i8*, i8** %6
%42 = call i32 @debug(i32 32, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* %41)
store i32 0, i32* %5
br label %73
43: ; preds = %36
br label %44
44: ; preds = %43, %28
%45 = load i32, i32* %11
%46 = load i32, i32* %7
%47 = icmp sgt i32 %45, %46
br i1 %47, label %70, label %48
48: ; preds = %44
%49 = load i32, i32* %11
%50 = load i32, i32* %7
%51 = icmp eq i32 %49, %50
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = load i32, i32* %12
%54 = load i32, i32* %8
%55 = icmp sgt i32 %53, %54
br i1 %55, label %70, label %56
56: ; preds = %52, %48
%57 = load i32, i32* %11
%58 = load i32, i32* %7
%59 = icmp eq i32 %57, %58
br i1 %59, label %60, label %68
60: ; preds = %56
%61 = load i32, i32* %12
%62 = load i32, i32* %8
%63 = icmp eq i32 %61, %62
br i1 %63, label %64, label %68
64: ; preds = %60
%65 = load i32, i32* %13
%66 = load i32, i32* %9
%67 = icmp sge i32 %65, %66
br label %68
68: ; preds = %64, %60, %56
%69 = phi i1 [ false, %60 ], [ false, %56 ], [ %67, %64 ]
br label %70
70: ; preds = %68, %52, %44
%71 = phi i1 [ true, %52 ], [ true, %44 ], [ %69, %68 ]
%72 = zext i1 %71 to i32
store i32 %72, i32* %5
br label %73
73: ; preds = %70, %40, %25
%74 = load i32, i32* %5
ret i32 %74
}

LLVM IR (-O2):
@.str = [7 x i8] c"(CVS) \00"
@.str.1 = [8 x i8] c"(CVSNT)\00"
@.str.2 = [39 x i8] c"WARNING: malformed CVS version str: %s\00"
@.str.3 = [9 x i8] c"%d.%d.%d\00"
@.str.4 = [11 x i8] c"'%d.%d.%d'\00"
@.str.5 = [35 x i8] c"WARNING: malformed CVS version: %s\00"
define i32 @check_version_string(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = bitcast i32* %7 to i8*
%11 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %18
13: ; preds = %4
%14 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @debug(i32 32, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %44
18: ; preds = %4, %13
%19 = phi i64 [ 8, %13 ], [ 6, %4 ]
%20 = phi i8* [ %14, %13 ], [ %11, %4 ]
%21 = getelementptr inbounds i8, i8* %20, i64 %19
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %5, i32* %6, i32* %7)
%23 = icmp eq i32 %22, 3
br i1 %23, label %29, label %24
24: ; preds = %18
%25 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32* %5, i32* %6, i32* %7)
%26 = icmp eq i32 %25, 3
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = call i32 @debug(i32 32, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* %0)
br label %44
29: ; preds = %24, %18
%30 = load i32, i32* %5
%31 = icmp sgt i32 %30, %1
br i1 %31, label %44, label %32
32: ; preds = %29
%33 = icmp eq i32 %30, %1
%34 = load i32, i32* %6
%35 = icmp sgt i32 %34, %2
%36 = select i1 %33, i1 %35, i1 false
br i1 %36, label %44, label %37
37: ; preds = %32
%38 = icmp eq i32 %34, %2
%39 = select i1 %33, i1 %38, i1 false
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = load i32, i32* %7
%42 = icmp sge i32 %41, %3
%43 = zext i1 %42 to i32
br label %44
44: ; preds = %29, %40, %37, %32, %27, %16
%45 = phi i32 [ 0, %27 ], [ 0, %16 ], [ 1, %29 ], [ 0, %37 ], [ %43, %40 ], [ 1, %32 ]
ret i32 %45
}