#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*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ printf(char *, int);
int sscanf(char const *, char *, int *, ...);
int /*<<< orphan*/ stderr;
void print_version_dep(const char *ver) {
  int kversion, kpatchlevel, ksublevel, kvernum;
  if (sscanf(ver, "%d.%d.%d", &kversion, &kpatchlevel, &ksublevel) != 3) {
    ksublevel = 0;
    if (sscanf(ver, "%d.%d", &kversion, &kpatchlevel) != 2) {
      kpatchlevel = 0;
      if (sscanf(ver, "%d", &kversion) != 1) {
        fprintf(stderr, "Invalid version string %s\n", ver);
        return;
      }
    }
  }
  kvernum = kversion * 100000 + kpatchlevel * 1000 + ksublevel;
  printf("test $kvernum -ge %d", kvernum);
}


x86 assembly (clang, -O0):
<print_version_dep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x3,%eax
je     11db <print_version_dep+0xab>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8e(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     11d6 <print_version_dep+0xa6>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe97(%rip),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x1,%eax
je     11d1 <print_version_dep+0xa1>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe42(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1200 <print_version_dep+0xd0>
jmp    11d6 <print_version_dep+0xa6>
jmp    11db <print_version_dep+0xab>
imul   $0x186a0,-0xc(%rbp),%eax
imul   $0x3e8,-0x10(%rbp),%ecx
add    %ecx,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe29(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_version_dep>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xec1(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
lea    0xc(%rsp),%r8
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x3,%eax
je     11a5 <print_version_dep+0x75>
movl   $0x0,0xc(%rsp)
lea    0xe9a(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     11a5 <print_version_dep+0x75>
movl   $0x0,0x4(%rsp)
lea    0xea5(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    11cd <print_version_dep+0x9d>
imul   $0x186a0,0x8(%rsp),%eax
imul   $0x3e8,0x4(%rsp),%esi
add    %eax,%esi
add    0xc(%rsp),%esi
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    0xe2c(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
jmp    11c7 <print_version_dep+0x97>

LLVM IR (-O0):
@.str = [9 x i8] c"%d.%d.%d\00"
@.str.1 = [6 x i8] c"%d.%d\00"
@.str.2 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.3 = [27 x i8] c"Invalid version string %s\0A\00"
@.str.4 = [21 x i8] c"test $kvernum -ge %d\00"
define void @print_version_dep(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %24
10: ; preds = %1
store i32 0, i32* %5
%11 = load i8*, i8** %2
%12 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %23
14: ; preds = %10
store i32 0, i32* %4
%15 = load i8*, i8** %2
%16 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%17 = icmp ne i32 %16, 1
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %2
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %20)
br label %34
22: ; preds = %14
br label %23
23: ; preds = %22, %10
br label %24
24: ; preds = %23, %1
%25 = load i32, i32* %3
%26 = mul nsw i32 %25, 100000
%27 = load i32, i32* %4
%28 = mul nsw i32 %27, 1000
%29 = add nsw i32 %26, %28
%30 = load i32, i32* %5
%31 = add nsw i32 %29, %30
store i32 %31, i32* %6
%32 = load i32, i32* %6
%33 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %24, %18
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d.%d.%d\00"
@.str.1 = [6 x i8] c"%d.%d\00"
@.str.2 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.3 = [27 x i8] c"Invalid version string %s\0A\00"
@.str.4 = [21 x i8] c"test $kvernum -ge %d\00"
define void @print_version_dep(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%9 = icmp eq i32 %8, 3
br i1 %9, label %19, label %10
10: ; preds = %1
store i32 0, i32* %4
%11 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%12 = icmp eq i32 %11, 2
br i1 %12, label %19, label %13
13: ; preds = %10
store i32 0, i32* %3
%14 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%15 = icmp eq i32 %14, 1
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %28
19: ; preds = %10, %13, %1
%20 = load i32, i32* %2
%21 = mul nsw i32 %20, 100000
%22 = load i32, i32* %3
%23 = mul nsw i32 %22, 1000
%24 = add nsw i32 %23, %21
%25 = load i32, i32* %4
%26 = add nsw i32 %24, %25
%27 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %19, %16
ret void
}