#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ uname(struct utsname *);
int main(void) {
  struct utsname uname_buf;
  if (uname(&uname_buf) < 0) {
    perror("Couldn't get system information");
    exit(EXIT_FAILURE);
  }
  printf("System name: %s\n", uname_buf.sysname);
  printf("Node name: %s\n", uname_buf.nodename);
  printf("Release: %s\n", uname_buf.release);
  printf("Version: %s\n", uname_buf.version);
  printf("Machine: %s\n", uname_buf.machine);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <uname@plt>
cmp    $0x0,%rax
jge    117c <main+0x3c>
lea    0xe97(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x30(%rbp),%rsi
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
mov    %rsp,%rdi
call   1040 <uname@plt>
test   %rax,%rax
js     11ac <main+0x6c>
mov    (%rsp),%rsi
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rsi
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%rsi
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%rsi
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
mov    0x20(%rsp),%rsi
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret
lea    0xe4d(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@.str = [32 x i8] c"Couldn't get system information\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [17 x i8] c"System name: %s\0A\00"
@.str.2 = [15 x i8] c"Node name: %s\0A\00"
@.str.3 = [13 x i8] c"Release: %s\0A\00"
@.str.4 = [13 x i8] c"Version: %s\0A\00"
@.str.5 = [13 x i8] c"Machine: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.utsname
store i32 0, i32* %1
%3 = call i64 @uname(%struct.utsname* %2)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = call i32 @exit(i32 %7)
unreachable
9: ; preds = %0
%10 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i32 0, i32 0
%11 = load i8*, i8** %10
%12 = 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* %2, i32 0, i32 1
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i32 0, i32 2
%17 = load i8*, i8** %16
%18 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i32 0, i32 3
%20 = load i8*, i8** %19
%21 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i32 0, i32 4
%23 = load i8*, i8** %22
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %23)
ret i32 0
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@.str = [32 x i8] c"Couldn't get system information\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [17 x i8] c"System name: %s\0A\00"
@.str.2 = [15 x i8] c"Node name: %s\0A\00"
@.str.3 = [13 x i8] c"Release: %s\0A\00"
@.str.4 = [13 x i8] c"Version: %s\0A\00"
@.str.5 = [13 x i8] c"Machine: %s\0A\00"
define i32 @main() {
%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 %9
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
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 ([15 x i8], [15 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 ([13 x i8], [13 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 ([13 x i8], [13 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 ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %23)
ret i32 0
}