#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;
};

/* Variables and functions */
unsigned int MAKE_VERSION(unsigned int, unsigned int, unsigned int);
unsigned int UINT_MAX;
int sscanf(int /*<<< orphan*/, char *, unsigned int *, unsigned int *,
           unsigned int *);
scalar_t__ uname(struct utsname *);
unsigned int linux_version_code(void) {
  struct utsname my_utsname;
  unsigned int p, q = 0, r = 0;
  if (uname(&my_utsname))
    return UINT_MAX;
  if (sscanf(my_utsname.release, "%u.%u.%u", &p, &q, &r) < 1)
    return UINT_MAX;
  return MAKE_VERSION(p, q, r);
}


x86 assembly (clang, -O0):
<linux_version_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <uname@plt>
cmp    $0x0,%rax
je     116a <linux_version_code+0x3a>
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11b0 <linux_version_code+0x80>
mov    -0x8(%rbp),%edi
lea    0xe8c(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jge    119f <linux_version_code+0x6f>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11b0 <linux_version_code+0x80>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <MAKE_VERSION@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linux_version_code>:
sub    $0x18,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rdi
call   1030 <uname@plt>
test   %rax,%rax
je     1161 <linux_version_code+0x31>
mov    0x2e8e(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
ret
mov    0x10(%rsp),%edi
lea    0xe94(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1040 <sscanf@plt>
test   %eax,%eax
jle    1153 <linux_version_code+0x23>
mov    0x14(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
call   1050 <MAKE_VERSION@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.utsname = type { i32 }
@UINT_MAX = global i32 0
@.str = [9 x i8] c"%u.%u.%u\00"
define i32 @linux_version_code() {
%1 = alloca i32
%2 = alloca %struct.utsname
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i64 @uname(%struct.utsname* %2)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = load i32, i32* @UINT_MAX
store i32 %9, i32* %1
br label %22
10: ; preds = %0
%11 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 @sscanf(i32 %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%14 = icmp slt i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = load i32, i32* @UINT_MAX
store i32 %16, i32* %1
br label %22
17: ; preds = %10
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = call i32 @MAKE_VERSION(i32 %18, i32 %19, i32 %20)
store i32 %21, i32* %1
br label %22
22: ; preds = %17, %15, %8
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
%struct.utsname = type { i32 }
@UINT_MAX = global i32 0
@.str = [9 x i8] c"%u.%u.%u\00"
define i32 @linux_version_code() {
%1 = alloca %struct.utsname
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast %struct.utsname* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = call i64 @uname(%struct.utsname* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = load i32, i32* @UINT_MAX
br label %25
13: ; preds = %0
%14 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 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)
%17 = icmp slt i32 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i32, i32* @UINT_MAX
br label %25
20: ; preds = %13
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = call i32 @MAKE_VERSION(i32 %21, i32 %22, i32 %23)
br label %25
25: ; preds = %20, %18, %11
%26 = phi i32 [ %12, %11 ], [ %19, %18 ], [ %24, %20 ]
ret i32 %26
}