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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strncmp(char *, char const *, int);
int uname(struct utsname *);
void check_kernel_version() {
  struct utsname buffer;
  if (-1 == uname(&buffer)) {
    perror("tleds: check_kernel_version()");
    exit(1);
  }
  if (strncmp("2.0.", (const char *)buffer.release, 4)) {
    fprintf(stderr, "%s was compiled for v2.0 kernel. Check Makefile. %s",
            "tleds", "Program (and child) terminated.\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<check_kernel_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
call   1040 <uname@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1186 <check_kernel_version+0x36>
lea    0xe89(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11d2 <check_kernel_version+0x82>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
lea    0xe9b(%rip),%rdx
lea    0xe9a(%rip),%rcx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_kernel_version>:
push   %rax
mov    %rsp,%rdi
call   1040 <uname@plt>
cmp    $0xffffffff,%eax
je     117a <check_kernel_version+0x2a>
mov    (%rsp),%rsi
lea    0xeb5(%rip),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1190 <check_kernel_version+0x40>
pop    %rax
ret
lea    0xe7f(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
lea    0xeb0(%rip),%rdx
lea    0xeaf(%rip),%rcx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.utsname = type { i64 }
@.str = [30 x i8] c"tleds: check_kernel_version()\00"
@.str.1 = [5 x i8] c"2.0.\00"
@stderr = global i32 0
@.str.2 = [52 x i8] c"%s was compiled for v2.0 kernel. Check Makefile. %s\00"
@.str.3 = [6 x i8] c"tleds\00"
@.str.4 = [33 x i8] c"Program (and child) terminated.\0A\00"
define void @check_kernel_version() {
%1 = alloca %struct.utsname
%2 = call i32 @uname(%struct.utsname* %1)
%3 = icmp eq i32 -1, %2
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 0
%9 = load i64, i64* %8
%10 = inttoptr i64 %9 to i8*
%11 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 4)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %7
ret void
}

LLVM IR (-O2):
%struct.utsname = type { i64 }
@.str = [30 x i8] c"tleds: check_kernel_version()\00"
@.str.1 = [5 x i8] c"2.0.\00"
@stderr = global i32 0
@.str.2 = [52 x i8] c"%s was compiled for v2.0 kernel. Check Makefile. %s\00"
@.str.3 = [6 x i8] c"tleds\00"
@.str.4 = [33 x i8] c"Program (and child) terminated.\0A\00"
define void @check_kernel_version() {
%1 = alloca %struct.utsname
%2 = bitcast %struct.utsname* %1 to i8*
%3 = call i32 @uname(%struct.utsname* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%10 = load i64, i64* %9
%11 = inttoptr i64 %10 to i8*
%12 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %8
ret void
}