#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 *nodename;
  char *release;
  char *version;
  char *machine;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ printf(char *, char *);
char *strerror(int /*<<< orphan*/);
int uname(struct utsname *);
void print_uname(void) {
  struct utsname name;
  int rc = uname(&name);
  if (rc < 0) {
    printf("uname: %s\n", strerror(errno));
    return;
  }
  printf("sysname  = \"%s\"\n", name.sysname);
  printf("nodename = \"%s\"\n", name.nodename);
  printf("release  = \"%s\"\n", name.release);
  printf("version  = \"%s\"\n", name.version);
  printf("machine  = \"%s\"\n", name.machine);
}


x86 assembly (clang, -O0):
<print_uname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x28(%rbp),%rdi
call   1040 <uname@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1170 <print_uname+0x40>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %rax,%rsi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
jmp    11c0 <print_uname+0x90>
mov    -0x28(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_uname>:
sub    $0x28,%rsp
mov    %rsp,%rdi
call   1040 <uname@plt>
test   %eax,%eax
js     1198 <print_uname+0x68>
mov    (%rsp),%rsi
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rsi
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%rsi
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%rsi
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
mov    0x20(%rsp),%rsi
lea    0xec0(%rip),%rdi
add    $0x28,%rsp
jmp    1030 <printf@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe53(%rip),%rdi
mov    %rax,%rsi
add    $0x28,%rsp
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@.str = [11 x i8] c"uname: %s\0A\00"
@errno = global i32 0
@.str.1 = [17 x i8] c"sysname = \22%s\22\0A\00"
@.str.2 = [17 x i8] c"nodename = \22%s\22\0A\00"
@.str.3 = [17 x i8] c"release = \22%s\22\0A\00"
@.str.4 = [17 x i8] c"version = \22%s\22\0A\00"
@.str.5 = [17 x i8] c"machine = \22%s\22\0A\00"
define void @print_uname() {
%1 = alloca %struct.utsname
%2 = alloca i32
%3 = call i32 @uname(%struct.utsname* %1)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i32, i32* @errno
%8 = call i8* @strerror(i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %26
10: ; preds = %0
%11 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 0
%12 = load i8*, i8** %11
%13 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 1
%15 = load i8*, i8** %14
%16 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 2
%18 = load i8*, i8** %17
%19 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 3
%21 = load i8*, i8** %20
%22 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 4
%24 = load i8*, i8** %23
%25 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %10, %6
ret void
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@.str = [11 x i8] c"uname: %s\0A\00"
@errno = global i32 0
@.str.1 = [17 x i8] c"sysname = \22%s\22\0A\00"
@.str.2 = [17 x i8] c"nodename = \22%s\22\0A\00"
@.str.3 = [17 x i8] c"release = \22%s\22\0A\00"
@.str.4 = [17 x i8] c"version = \22%s\22\0A\00"
@.str.5 = [17 x i8] c"machine = \22%s\22\0A\00"
define void @print_uname() {
%1 = alloca %struct.utsname
%2 = bitcast %struct.utsname* %1 to i8*
%3 = call i32 @uname(%struct.utsname* %1)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = load i32, i32* @errno
%7 = tail call i8* @strerror(i32 %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %25
9: ; preds = %0
%10 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%11 = load i8*, i8** %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 1
%14 = load i8*, i8** %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 2
%17 = load i8*, i8** %16
%18 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 3
%20 = load i8*, i8** %19
%21 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 4
%23 = load i8*, i8** %22
%24 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %9, %5
ret void
}