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

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, size_t, char *, char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, size_t);
int uname(struct utsname *);
void get_kernel(char *buffer, size_t size) {
  struct utsname name;
  if (uname(&name) != -1)
    snprintf(buffer, size, "%s %s", name.sysname, name.release);
  else
    strncpy(buffer, "unknown Darwin", size);
}


x86 assembly (clang, -O0):
<get_kernel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <uname@plt>
cmp    $0xffffffff,%eax
je     1173 <get_kernel+0x43>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe97(%rip),%rdx
call   1040 <snprintf@plt>
jmp    1187 <get_kernel+0x57>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe84(%rip),%rsi
call   1030 <strncpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_kernel>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
call   1050 <uname@plt>
cmp    $0xffffffff,%eax
je     116f <get_kernel+0x3f>
mov    0x8(%rsp),%rcx
mov    0x10(%rsp),%r8
lea    0xea3(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1040 <snprintf@plt>
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strncpy@plt>

LLVM IR (-O0):
%struct.utsname = type { i8*, i8* }
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [15 x i8] c"unknown Darwin\00"
define void @get_kernel(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca %struct.utsname
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = call i32 @uname(%struct.utsname* %5)
%7 = icmp ne i32 %6, -1
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = load i64, i64* %4
%11 = getelementptr inbounds %struct.utsname, %struct.utsname* %5, i32 0, i32 0
%12 = load i8*, i8** %11
%13 = getelementptr inbounds %struct.utsname, %struct.utsname* %5, i32 0, i32 1
%14 = load i8*, i8** %13
%15 = call i32 @snprintf(i8* %9, i64 %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %14)
br label %20
16: ; preds = %2
%17 = load i8*, i8** %3
%18 = load i64, i64* %4
%19 = call i32 @strncpy(i8* %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %18)
br label %20
20: ; preds = %16, %8
ret void
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i8* }
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [15 x i8] c"unknown Darwin\00"
define void @get_kernel(i8* %0, i64 %1) {
%3 = alloca %struct.utsname
%4 = bitcast %struct.utsname* %3 to i8*
%5 = call i32 @uname(%struct.utsname* %3)
%6 = icmp eq i32 %5, -1
br i1 %6, label %13, label %7
7: ; preds = %2
%8 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 0
%9 = load i8*, i8** %8
%10 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 1
%11 = load i8*, i8** %10
%12 = tail call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %11)
br label %15
13: ; preds = %2
%14 = tail call i32 @strncpy(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %1)
br label %15
15: ; preds = %13, %7
ret void
}