#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 */
struct utsname {
  int /*<<< orphan*/ release;
  int /*<<< orphan*/ sysname;
};

/* Variables and functions */
int sscanf(int /*<<< orphan*/, char *, int *, int *);
scalar_t__ strcmp(char const *, int /*<<< orphan*/);
int uname(struct utsname *);
int kernel_older_than(const char *sysname, int version, int sub_version) {
  struct utsname un;
  int rc;
  int v = 0;
  int sub_v = 0;
  rc = uname(&un);
  if (rc < 0)
    return -1;
  if (strcmp(sysname, un.sysname) != 0)
    return -1;
  rc = sscanf(un.release, "%d.%d", &v, &sub_v);
  if (rc < 2)
    return -1;
  return (v < version || (v == version && sub_v < sub_version));
}


x86 assembly (clang, -O0):
<kernel_older_than>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <uname@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1172 <kernel_older_than+0x42>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <kernel_older_than+0xd3>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1194 <kernel_older_than+0x64>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <kernel_older_than+0xd3>
mov    -0x20(%rbp),%edi
lea    0xe62(%rip),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
call   1050 <sscanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jge    11c4 <kernel_older_than+0x94>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <kernel_older_than+0xd3>
mov    -0x28(%rbp),%ecx
mov    $0x1,%al
cmp    -0x14(%rbp),%ecx
mov    %al,-0x2d(%rbp)
jl     11f8 <kernel_older_than+0xc8>
mov    -0x28(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x2e(%rbp)
jne    11f2 <kernel_older_than+0xc2>
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
setl   %al
mov    %al,-0x2e(%rbp)
mov    -0x2e(%rbp),%al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_older_than>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rdi
call   1030 <uname@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
js     11b2 <kernel_older_than+0x82>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11b2 <kernel_older_than+0x82>
mov    0x10(%rsp),%edi
lea    0xe7e(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jl     11b2 <kernel_older_than+0x82>
mov    $0x1,%ebp
cmp    %r15d,0xc(%rsp)
jl     11b2 <kernel_older_than+0x82>
sete   %al
cmp    %r14d,0x8(%rsp)
setl   %cl
and    %al,%cl
movzbl %cl,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.utsname = type { i32, i32 }
@.str = [6 x i8] c"%d.%d\00"
define i32 @kernel_older_than(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.utsname
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 0, i32* %10
store i32 0, i32* %11
%12 = call i32 @uname(%struct.utsname* %8)
store i32 %12, i32* %9
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %3
store i32 -1, i32* %4
br label %47
16: ; preds = %3
%17 = load i8*, i8** %5
%18 = getelementptr inbounds %struct.utsname, %struct.utsname* %8, i32 0, i32 1
%19 = load i32, i32* %18
%20 = call i64 @strcmp(i8* %17, i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %16
store i32 -1, i32* %4
br label %47
23: ; preds = %16
%24 = getelementptr inbounds %struct.utsname, %struct.utsname* %8, i32 0, i32 0
%25 = load i32, i32* %24
%26 = call i32 @sscanf(i32 %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %10, i32* %11)
store i32 %26, i32* %9
%27 = load i32, i32* %9
%28 = icmp slt i32 %27, 2
br i1 %28, label %29, label %30
29: ; preds = %23
store i32 -1, i32* %4
br label %47
30: ; preds = %23
%31 = load i32, i32* %10
%32 = load i32, i32* %6
%33 = icmp slt i32 %31, %32
br i1 %33, label %44, label %34
34: ; preds = %30
%35 = load i32, i32* %10
%36 = load i32, i32* %6
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load i32, i32* %11
%40 = load i32, i32* %7
%41 = icmp slt i32 %39, %40
br label %42
42: ; preds = %38, %34
%43 = phi i1 [ false, %34 ], [ %41, %38 ]
br label %44
44: ; preds = %42, %30
%45 = phi i1 [ true, %30 ], [ %43, %42 ]
%46 = zext i1 %45 to i32
store i32 %46, i32* %4
br label %47
47: ; preds = %44, %29, %22, %15
%48 = load i32, i32* %4
ret i32 %48
}

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