#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*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
int /*<<< orphan*/ gethostname(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int uname(struct utsname *);
int main(void) {
  char str[64] = {};
  struct utsname buf;
  if (uname(&buf) == -1)
    do {
      fprintf(stderr, "[%s][%d]:%s %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/"
              "master/apue/day04/uname.c",
              21, "uname", strerror(errno));
      exit(EXIT_FAILURE);
    } while (0);
  printf("sysname:%s\n", buf.sysname);
  printf("nodename:%s\n", buf.nodename);
  printf("release:%s\n", buf.release);
  printf("version:%s\n", buf.version);
  printf("machine:%s\n", buf.machine);
  gethostname(str, 64);
  printf("hostname:%s\n", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
lea    -0x78(%rbp),%rdi
call   1040 <uname@plt>
cmp    $0xffffffff,%eax
jne    11f6 <main+0x86>
jmp    11a9 <main+0x39>
mov    0x2e30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    %rax,%r9
lea    0xe30(%rip),%rsi
lea    0xe39(%rip),%rdx
mov    $0x15,%ecx
lea    0xec1(%rip),%r8
call   1060 <fprintf@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x78(%rbp),%rsi
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x70(%rbp),%rsi
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x68(%rbp),%rsi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x60(%rbp),%rsi
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x58(%rbp),%rsi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    $0x40,%esi
call   1070 <gethostname@plt>
lea    -0x50(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
lea    0x8(%rsp),%rdi
call   1040 <uname@plt>
cmp    $0xffffffff,%eax
je     1209 <main+0xa9>
mov    0x8(%rsp),%rsi
lea    0xf13(%rip),%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%rsi
lea    0xf0e(%rip),%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%rsi
lea    0xf0a(%rip),%rdi
call   1030 <printf@plt>
mov    0x20(%rsp),%rsi
lea    0xf05(%rip),%rdi
call   1030 <printf@plt>
mov    0x28(%rsp),%rsi
lea    0xf00(%rip),%rdi
call   1030 <printf@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1060 <gethostname@plt>
lea    0xeee(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret
mov    0x2dd0(%rip),%rax
mov    (%rax),%ebx
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xdd9(%rip),%rsi
lea    0xde2(%rip),%rdx
lea    0xe6f(%rip),%r8
mov    %ebx,%edi
mov    $0x15,%ecx
mov    %rax,%r9
call   1050 <fprintf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@stderr = global i32 0
@.str = [16 x i8] c"[%s][%d]:%s %s\0A\00"
@.str.1 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/master/apue/day04/uname.c\00"
@.str.2 = [6 x i8] c"uname\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.3 = [12 x i8] c"sysname:%s\0A\00"
@.str.4 = [13 x i8] c"nodename:%s\0A\00"
@.str.5 = [12 x i8] c"release:%s\0A\00"
@.str.6 = [12 x i8] c"version:%s\0A\00"
@.str.7 = [12 x i8] c"machine:%s\0A\00"
@.str.8 = [13 x i8] c"hostname:%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca %struct.utsname
store i32 0, i32* %1
%4 = bitcast [64 x i8]* %2 to i8*
%5 = call i32 @uname(%struct.utsname* %3)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %16
7: ; preds = %0
br label %8
8: ; preds = %7
%9 = load i32, i32* @stderr
%10 = load i32, i32* @errno
%11 = call i8* @strerror(i32 %10)
%12 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; No predecessors!
br label %16
16: ; preds = %15, %0
%17 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 0
%18 = load i8*, i8** %17
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 1
%21 = load i8*, i8** %20
%22 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 2
%24 = load i8*, i8** %23
%25 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 3
%27 = load i8*, i8** %26
%28 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 4
%30 = load i8*, i8** %29
%31 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%33 = call i32 @gethostname(i8* %32, i32 64)
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%35 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %34)
ret i32 0
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@stderr = global i32 0
@.str = [16 x i8] c"[%s][%d]:%s %s\0A\00"
@.str.1 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drsin/linuxCoreLearn/refs/heads/master/apue/day04/uname.c\00"
@.str.2 = [6 x i8] c"uname\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.3 = [12 x i8] c"sysname:%s\0A\00"
@.str.4 = [13 x i8] c"nodename:%s\0A\00"
@.str.5 = [12 x i8] c"release:%s\0A\00"
@.str.6 = [12 x i8] c"version:%s\0A\00"
@.str.7 = [12 x i8] c"machine:%s\0A\00"
@.str.8 = [13 x i8] c"hostname:%s\0A\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = alloca %struct.utsname
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%4 = bitcast %struct.utsname* %2 to i8*
%5 = call i32 @uname(%struct.utsname* %2)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %14
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = tail call i8* @strerror(i32 %9)
%11 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i64 0, i32 0
%16 = load i8*, i8** %15
%17 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i64 0, i32 1
%19 = load i8*, i8** %18
%20 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i64 0, i32 2
%22 = load i8*, i8** %21
%23 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i64 0, i32 3
%25 = load i8*, i8** %24
%26 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i64 0, i32 4
%28 = load i8*, i8** %27
%29 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %28)
%30 = call i32 @gethostname(i8* %3, i32 64)
%31 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %3)
ret i32 0
}