#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 atoi(char *);
int /*<<< orphan*/ fatal_version_error();
char *strtok(char *, char const *);
void compare_version(char *version) {
  static const char *v_delims = "V.-\n";
  char *token;
  int version_num;
  token = strtok(version, v_delims);
  if (token != NULL) {
    version_num = atoi(token);
    if (version_num < 1)
      fatal_version_error();
    if (version_num > 1)
      fatal_version_error();
  } else {
    fatal_version_error();
  }
  token = strtok(NULL, v_delims);
  if (token != NULL) {
    version_num = atoi(token);
    if (version_num < 0)
      fatal_version_error();
    if (version_num > 99)
      fatal_version_error();
  } else {
    fatal_version_error();
  }
}


x86 assembly (clang, -O0):
<compare_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2ef1(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118e <compare_version+0x5e>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    1178 <compare_version+0x48>
mov    $0x0,%al
call   1030 <fatal_version_error@plt>
cmpl   $0x1,-0x14(%rbp)
jle    1189 <compare_version+0x59>
mov    $0x0,%al
call   1030 <fatal_version_error@plt>
jmp    1195 <compare_version+0x65>
mov    $0x0,%al
call   1030 <fatal_version_error@plt>
mov    0x2e9c(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1040 <strtok@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11e7 <compare_version+0xb7>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11d1 <compare_version+0xa1>
mov    $0x0,%al
call   1030 <fatal_version_error@plt>
cmpl   $0x63,-0x14(%rbp)
jle    11e2 <compare_version+0xb2>
mov    $0x0,%al
call   1030 <fatal_version_error@plt>
jmp    11ee <compare_version+0xbe>
mov    $0x0,%al
call   1030 <fatal_version_error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_version>:
push   %rax
lea    0xec8(%rip),%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     114f <compare_version+0x1f>
mov    %rax,%rdi
call   1050 <atoi@plt>
cmp    $0x1,%eax
je     1156 <compare_version+0x26>
xor    %eax,%eax
call   1030 <fatal_version_error@plt>
lea    0xea3(%rip),%rsi
xor    %edi,%edi
call   1040 <strtok@plt>
test   %rax,%rax
je     1176 <compare_version+0x46>
mov    %rax,%rdi
call   1050 <atoi@plt>
cmp    $0x64,%eax
jb     117e <compare_version+0x4e>
xor    %eax,%eax
pop    %rcx
jmp    1030 <fatal_version_error@plt>
pop    %rax
ret

LLVM IR (-O0):
@compare_version.v_delims = internal global i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0)
@.str = [5 x i8] c"V.-\0A\00"
define void @compare_version(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = load i8*, i8** @compare_version.v_delims
%7 = call i8* @strtok(i8* %5, i8* %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %23
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 (...) @fatal_version_error()
br label %17
17: ; preds = %15, %10
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 1
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (...) @fatal_version_error()
br label %22
22: ; preds = %20, %17
br label %25
23: ; preds = %1
%24 = call i32 (...) @fatal_version_error()
br label %25
25: ; preds = %23, %22
%26 = load i8*, i8** @compare_version.v_delims
%27 = call i8* @strtok(i8* null, i8* %26)
store i8* %27, i8** %3
%28 = load i8*, i8** %3
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %43
30: ; preds = %25
%31 = load i8*, i8** %3
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %4
%33 = load i32, i32* %4
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = call i32 (...) @fatal_version_error()
br label %37
37: ; preds = %35, %30
%38 = load i32, i32* %4
%39 = icmp sgt i32 %38, 99
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 (...) @fatal_version_error()
br label %42
42: ; preds = %40, %37
br label %45
43: ; preds = %25
%44 = call i32 (...) @fatal_version_error()
br label %45
45: ; preds = %43, %42
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"V.-\0A\00"
define void @compare_version(i8* %0) {
%2 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @atoi(i8* %2)
%6 = icmp eq i32 %5, 1
br i1 %6, label %9, label %7
7: ; preds = %1, %4
%8 = tail call i32 (...) @fatal_version_error()
br label %9
9: ; preds = %4, %7
%10 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 @atoi(i8* %10)
%14 = icmp ugt i32 %13, 99
br i1 %14, label %15, label %17
15: ; preds = %9, %12
%16 = tail call i32 (...) @fatal_version_error()
br label %17
17: ; preds = %12, %15
ret void
}