#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 */
char const *bprintf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ uname(struct utsname *);
const char *kernel_release(void) {
  struct utsname udata;
  if (uname(&udata) < 0) {
    fprintf(stderr, "uname: %s\n", strerror(errno));
    return NULL;
  }
  return bprintf("%s", udata.release);
}


x86 assembly (clang, -O0):
<kernel_release>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x10(%rbp),%rdi
call   1030 <uname@plt>
cmp    $0x0,%rax
jge    1194 <kernel_release+0x54>
mov    0x2e7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe7e(%rip),%rsi
call   1050 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11a7 <kernel_release+0x67>
mov    -0x10(%rbp),%esi
lea    0xe6d(%rip),%rdi
call   1040 <bprintf@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_release>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1030 <uname@plt>
test   %rax,%rax
js     1169 <kernel_release+0x29>
mov    0x8(%rsp),%esi
lea    0xeac(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <bprintf@plt>
mov    0x2e70(%rip),%rax
mov    (%rax),%ebx
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe79(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.utsname = type { i32 }
@stderr = global i32 0
@.str = [11 x i8] c"uname: %s\0A\00"
@errno = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i8* @kernel_release() {
%1 = alloca i8*
%2 = alloca %struct.utsname
%3 = call i64 @uname(%struct.utsname* %2)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = call i8* @strerror(i32 %7)
%9 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
store i8* null, i8** %1
br label %14
10: ; preds = %0
%11 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i8* @bprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %12)
store i8* %13, i8** %1
br label %14
14: ; preds = %10, %5
%15 = load i8*, i8** %1
ret i8* %15
}

LLVM IR (-O2):
%struct.utsname = type { i32 }
@stderr = global i32 0
@.str = [11 x i8] c"uname: %s\0A\00"
@errno = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i8* @kernel_release() {
%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 %10
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %14
10: ; preds = %0
%11 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%12 = load i32, i32* %11
%13 = tail call i8* @bprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %10, %5
%15 = phi i8* [ null, %5 ], [ %13, %10 ]
ret i8* %15
}