#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 */
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ strncmp(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ uname(struct utsname *);
unsigned int getKernelVersion() {
  unsigned int version = 24;
  struct utsname name;
  uname(&name);
  if (!strncmp(name.release, "2.6.17", 6))
    version = 22;
  else if (!strncmp(name.release, "2.6.23", 6))
    version = 23;
  else
    version = 24;
  printf("ustslave: Kernel Version: %d\n", version);
  return version;
}


x86 assembly (clang, -O0):
<getKernelVersion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x18,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1050 <uname@plt>
mov    -0x8(%rbp),%edi
lea    0xeae(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1171 <getKernelVersion+0x41>
movl   $0x16,-0x4(%rbp)
jmp    11a6 <getKernelVersion+0x76>
mov    -0x8(%rbp),%edi
lea    0xe8c(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    119a <getKernelVersion+0x6a>
movl   $0x17,-0x4(%rbp)
jmp    11a1 <getKernelVersion+0x71>
movl   $0x18,-0x4(%rbp)
jmp    11a6 <getKernelVersion+0x76>
mov    -0x4(%rbp),%esi
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getKernelVersion>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1050 <uname@plt>
mov    0x8(%rsp),%ebx
lea    0xeb6(%rip),%rsi
mov    %ebx,%edi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     117a <getKernelVersion+0x4a>
lea    0xea6(%rip),%rsi
mov    %ebx,%edi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x1,%eax
mov    $0x18,%ebx
sbb    $0x0,%ebx
jmp    117f <getKernelVersion+0x4f>
mov    $0x16,%ebx
lea    0xe88(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.utsname = type { i32 }
@.str = [7 x i8] c"2.6.17\00"
@.str.1 = [7 x i8] c"2.6.23\00"
@.str.2 = [30 x i8] c"ustslave: Kernel Version: %d\0A\00"
define i32 @getKernelVersion() {
%1 = alloca i32
%2 = alloca %struct.utsname
store i32 24, i32* %1
%3 = call i32 @uname(%struct.utsname* %2)
%4 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i32 0, i32 0
%5 = load i32, i32* %4
%6 = call i32 @strncmp(i32 %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %0
store i32 22, i32* %1
br label %17
9: ; preds = %0
%10 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i32 0, i32 0
%11 = load i32, i32* %10
%12 = call i32 @strncmp(i32 %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %9
store i32 23, i32* %1
br label %16
15: ; preds = %9
store i32 24, i32* %1
br label %16
16: ; preds = %15, %14
br label %17
17: ; preds = %16, %8
%18 = load i32, i32* %1
%19 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
%struct.utsname = type { i32 }
@.str = [7 x i8] c"2.6.17\00"
@.str.1 = [7 x i8] c"2.6.23\00"
@.str.2 = [30 x i8] c"ustslave: Kernel Version: %d\0A\00"
define i32 @getKernelVersion() {
%1 = alloca %struct.utsname
%2 = bitcast %struct.utsname* %1 to i8*
%3 = call i32 @uname(%struct.utsname* %1)
%4 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = tail call i32 @strncmp(i32 %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %0
%9 = tail call i32 @strncmp(i32 %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i32 23, i32 24
br label %12
12: ; preds = %8, %0
%13 = phi i32 [ 22, %0 ], [ %11, %8 ]
%14 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %13)
ret i32 %13
}