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

/* Variables and functions */
int /*<<< orphan*/ memset(struct utsname *, int /*<<< orphan*/, int);
int sscanf(int /*<<< orphan*/, char *, int *, int *, int *);
int uname(struct utsname *);
int kernel_has_blkgetsize64(void) {
  int major = 0, minor = 0, patch = 0, parsed;
  int rc;
  struct utsname u;
  memset(&u, 0, sizeof(u));
  rc = uname(&u);
  if (rc)
    return 0;
  parsed = sscanf(u.release, "%d.%d.%d", &major, &minor, &patch);
  if (parsed < 3)
    return 0;
  if (major > 2)
    return 1;
  if (major == 2 && minor > 5)
    return 1;
  if (major == 2 && minor == 5 && patch >= 4)
    return 1;
  if (major == 2 && minor == 4 && patch >= 18)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<kernel_has_blkgetsize64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    -0x20(%rbp),%rdi
call   1030 <uname@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     117f <kernel_has_blkgetsize64+0x4f>
movl   $0x0,-0x4(%rbp)
jmp    1244 <kernel_has_blkgetsize64+0x114>
mov    -0x20(%rbp),%edi
lea    0xe77(%rip),%rsi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
lea    -0x10(%rbp),%r8
call   1050 <sscanf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11b3 <kernel_has_blkgetsize64+0x83>
movl   $0x0,-0x4(%rbp)
jmp    1244 <kernel_has_blkgetsize64+0x114>
cmpl   $0x2,-0x8(%rbp)
jle    11c9 <kernel_has_blkgetsize64+0x99>
movl   $0x1,-0x4(%rbp)
jmp    1244 <kernel_has_blkgetsize64+0x114>
cmpl   $0x2,-0x8(%rbp)
jne    11e9 <kernel_has_blkgetsize64+0xb9>
cmpl   $0x5,-0xc(%rbp)
jle    11e9 <kernel_has_blkgetsize64+0xb9>
movl   $0x1,-0x4(%rbp)
jmp    1244 <kernel_has_blkgetsize64+0x114>
cmpl   $0x2,-0x8(%rbp)
jne    1213 <kernel_has_blkgetsize64+0xe3>
cmpl   $0x5,-0xc(%rbp)
jne    1213 <kernel_has_blkgetsize64+0xe3>
cmpl   $0x4,-0x10(%rbp)
jl     1213 <kernel_has_blkgetsize64+0xe3>
movl   $0x1,-0x4(%rbp)
jmp    1244 <kernel_has_blkgetsize64+0x114>
cmpl   $0x2,-0x8(%rbp)
jne    123d <kernel_has_blkgetsize64+0x10d>
cmpl   $0x4,-0xc(%rbp)
jne    123d <kernel_has_blkgetsize64+0x10d>
cmpl   $0x12,-0x10(%rbp)
jl     123d <kernel_has_blkgetsize64+0x10d>
movl   $0x1,-0x4(%rbp)
jmp    1244 <kernel_has_blkgetsize64+0x114>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_has_blkgetsize64>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
call   1030 <uname@plt>
test   %eax,%eax
jne    11d6 <kernel_has_blkgetsize64+0xa6>
mov    0x10(%rsp),%edi
lea    0xe85(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
call   1050 <sscanf@plt>
cmp    $0x3,%eax
jl     11d6 <kernel_has_blkgetsize64+0xa6>
mov    0xc(%rsp),%eax
mov    $0x1,%ebp
cmp    $0x2,%eax
jg     11d6 <kernel_has_blkgetsize64+0xa6>
mov    0x8(%rsp),%ecx
jne    11ad <kernel_has_blkgetsize64+0x7d>
cmp    $0x5,%ecx
jg     11d6 <kernel_has_blkgetsize64+0xa6>
mov    0x4(%rsp),%edx
cmp    $0x2,%eax
jne    11c0 <kernel_has_blkgetsize64+0x90>
cmp    $0x5,%ecx
jne    11c0 <kernel_has_blkgetsize64+0x90>
cmp    $0x3,%edx
jg     11d6 <kernel_has_blkgetsize64+0xa6>
xor    $0x2,%eax
xor    $0x4,%ecx
or     %eax,%ecx
sete   %al
cmp    $0x12,%edx
setge  %cl
and    %al,%cl
movzbl %cl,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

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