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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ _log(int /*<<< orphan*/, char *, int *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int *strerror(int /*<<< orphan*/);
scalar_t__ uname(struct utsname *);
void _check_linux_version(void) {
  struct utsname name;
  if (0 > uname(&name)) {
    _log(LOG_ERR, "Failure to get linux version number: %s", strerror(errno));
    exit(EXIT_FAILURE);
  }
  switch (name.release[2]) {
  case '6':
    return;
  default:
    _log(LOG_ERR, "Wrong linux version: %s; must be 2.6; exiting",
         name.release);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<_check_linux_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
call   1040 <uname@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    1199 <_check_linux_version+0x59>
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0xc(%rbp),%edi
mov    %rax,%rdx
lea    0xe7a(%rip),%rsi
call   1030 <_log@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
sub    $0x36,%eax
jne    11b4 <_check_linux_version+0x74>
jmp    11ae <_check_linux_version+0x6e>
add    $0x10,%rsp
pop    %rbp
ret
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe60(%rip),%rsi
call   1030 <_log@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<_check_linux_version>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1040 <uname@plt>
test   %rax,%rax
js     1165 <_check_linux_version+0x25>
mov    0x8(%rsp),%rdx
cmpl   $0x36,0x8(%rdx)
jne    118a <_check_linux_version+0x4a>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e5c(%rip),%rax
mov    (%rax),%ebx
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe7d(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
jmp    119a <_check_linux_version+0x5a>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
call   1030 <_log@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.utsname = type { i32* }
@LOG_ERR = global i32 0
@.str = [40 x i8] c"Failure to get linux version number: %s\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [46 x i8] c"Wrong linux version: %s; must be 2.6; exiting\00"
define void @_check_linux_version() {
%1 = alloca %struct.utsname
%2 = call i64 @uname(%struct.utsname* %1)
%3 = icmp sgt i64 0, %2
br i1 %3, label %4, label %11
4: ; preds = %0
%5 = load i32, i32* @LOG_ERR
%6 = load i32, i32* @errno
%7 = call i32* @strerror(i32 %6)
%8 = call i32 @_log(i32 %5, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32* %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %0
%12 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 0
%13 = load i32*, i32** %12
%14 = getelementptr inbounds i32, i32* %13, i64 2
%15 = load i32, i32* %14
switch i32 %15, label %17 [
i32 54, label %16
]
16: ; preds = %11
ret void
17: ; preds = %11
%18 = load i32, i32* @LOG_ERR
%19 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 0
%20 = load i32*, i32** %19
%21 = call i32 @_log(i32 %18, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
}

LLVM IR (-O2):
%struct.utsname = type { i32* }
@LOG_ERR = global i32 0
@.str = [40 x i8] c"Failure to get linux version number: %s\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [46 x i8] c"Wrong linux version: %s; must be 2.6; exiting\00"
define void @_check_linux_version() {
%1 = alloca %struct.utsname
%2 = bitcast %struct.utsname* %1 to i8*
%3 = call i64 @uname(%struct.utsname* %1)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %0
%6 = load i32, i32* @LOG_ERR
%7 = load i32, i32* @errno
%8 = tail call i32* @strerror(i32 %7)
%9 = tail call i32 @_log(i32 %6, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%14 = load i32*, i32** %13
%15 = getelementptr inbounds i32, i32* %14, i64 2
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 54
br i1 %17, label %18, label %19
18: ; preds = %12
ret void
19: ; preds = %12
%20 = load i32, i32* @LOG_ERR
%21 = tail call i32 @_log(i32 %20, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
}