#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 sscanf(char *, char *, int *, int *, ...);
int is_valid_lastz_version(char *s) {
  int major, minor, subminor;
  char extra;
  if (sscanf(s, "%d.%d%c", &major, &minor, &extra) == 2) {
    if (major < 0)
      return 0;
    if (minor < 0)
      return 0;
    return 1;
  }
  if (sscanf(s, "%d.%d.%d%c", &major, &minor, &subminor, &extra) == 3) {
    if (major < 0)
      return 0;
    if (minor < 0)
      return 0;
    if (subminor < 0)
      return 0;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<is_valid_lastz_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xedc(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x1d(%rbp),%r8
mov    $0x0,%al
call   1030 <sscanf@plt>
cmp    $0x2,%eax
jne    117b <is_valid_lastz_version+0x6b>
cmpl   $0x0,-0x14(%rbp)
jge    1159 <is_valid_lastz_version+0x49>
movl   $0x0,-0x4(%rbp)
jmp    11fb <is_valid_lastz_version+0xeb>
cmpl   $0x0,-0x18(%rbp)
jge    116f <is_valid_lastz_version+0x5f>
movl   $0x0,-0x4(%rbp)
jmp    11fb <is_valid_lastz_version+0xeb>
movl   $0x1,-0x4(%rbp)
jmp    11fb <is_valid_lastz_version+0xeb>
mov    -0x10(%rbp),%rdi
lea    0xe7a(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    -0x1d(%rbp),%r9
mov    $0x0,%al
call   1030 <sscanf@plt>
cmp    $0x3,%eax
jne    11f4 <is_valid_lastz_version+0xe4>
cmpl   $0x0,-0x14(%rbp)
jge    11bc <is_valid_lastz_version+0xac>
movl   $0x0,-0x4(%rbp)
jmp    11fb <is_valid_lastz_version+0xeb>
cmpl   $0x0,-0x18(%rbp)
jge    11d2 <is_valid_lastz_version+0xc2>
movl   $0x0,-0x4(%rbp)
jmp    11fb <is_valid_lastz_version+0xeb>
cmpl   $0x0,-0x1c(%rbp)
jge    11e8 <is_valid_lastz_version+0xd8>
movl   $0x0,-0x4(%rbp)
jmp    11fb <is_valid_lastz_version+0xeb>
movl   $0x1,-0x4(%rbp)
jmp    11fb <is_valid_lastz_version+0xeb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_valid_lastz_version>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
lea    0xee2(%rip),%rsi
xor    %ebx,%ebx
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0xb(%rsp),%r8
xor    %eax,%eax
call   1030 <sscanf@plt>
cmp    $0x2,%eax
jne    114b <is_valid_lastz_version+0x3b>
cmpl   $0x0,0x10(%rsp)
js     118c <is_valid_lastz_version+0x7c>
mov    0xc(%rsp),%ebx
jmp    1187 <is_valid_lastz_version+0x77>
lea    0xeae(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0xb(%rsp),%r9
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <sscanf@plt>
cmp    $0x3,%eax
jne    118c <is_valid_lastz_version+0x7c>
cmpl   $0x0,0x10(%rsp)
js     118c <is_valid_lastz_version+0x7c>
cmpl   $0x0,0xc(%rsp)
js     118c <is_valid_lastz_version+0x7c>
mov    0x14(%rsp),%ebx
not    %ebx
shr    $0x1f,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%d.%d%c\00"
@.str.1 = [11 x i8] c"%d.%d.%d%c\00"
define i32 @is_valid_lastz_version(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 (i8*, i8*, i32*, i32*, ...) @sscanf(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5, i8* %7)
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %20
11: ; preds = %1
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 0, i32* %2
br label %38
15: ; preds = %11
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 0, i32* %2
br label %38
19: ; preds = %15
store i32 1, i32* %2
br label %38
20: ; preds = %1
%21 = load i8*, i8** %3
%22 = call i32 (i8*, i8*, i32*, i32*, ...) @sscanf(i8* %21, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5, i32* %6, i8* %7)
%23 = icmp eq i32 %22, 3
br i1 %23, label %24, label %37
24: ; preds = %20
%25 = load i32, i32* %4
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 0, i32* %2
br label %38
28: ; preds = %24
%29 = load i32, i32* %5
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 0, i32* %2
br label %38
32: ; preds = %28
%33 = load i32, i32* %6
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 0, i32* %2
br label %38
36: ; preds = %32
store i32 1, i32* %2
br label %38
37: ; preds = %20
store i32 0, i32* %2
br label %38
38: ; preds = %37, %36, %35, %31, %27, %19, %18, %14
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@.str = [8 x i8] c"%d.%d%c\00"
@.str.1 = [11 x i8] c"%d.%d.%d%c\00"
define i32 @is_valid_lastz_version(i8* nocapture %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 (i8*, i8*, i32*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i8* %5)
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %18
11: ; preds = %1
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 0
br i1 %13, label %31, label %14
14: ; preds = %11
%15 = load i32, i32* %3
%16 = xor i32 %15, -1
%17 = lshr i32 %16, 31
br label %31
18: ; preds = %1
%19 = call i32 (i8*, i8*, i32*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i8* %5)
%20 = icmp ne i32 %19, 3
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 0
%23 = select i1 %20, i1 true, i1 %22
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 0
%26 = select i1 %23, i1 true, i1 %25
br i1 %26, label %31, label %27
27: ; preds = %18
%28 = load i32, i32* %4
%29 = xor i32 %28, -1
%30 = lshr i32 %29, 31
br label %31
31: ; preds = %18, %27, %14, %11
%32 = phi i32 [ 0, %11 ], [ %17, %14 ], [ %30, %27 ], [ 0, %18 ]
ret i32 %32
}