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

/* Variables and functions */
int _error(char const *, char *, int);
int /*<<< orphan*/ printf(char *, char const *);
scalar_t__ uname(struct utsname *);
int _uname(char const *progname) {
  struct utsname name;
  printf("%s: Testing utsname()\n", progname);
  if (uname(&name))
    return -_error(progname, "utsname", 1);
  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);
  return 0;
}


x86 assembly (clang, -O0):
<_uname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    -0x38(%rbp),%rdi
call   1040 <uname@plt>
cmp    $0x0,%rax
je     1182 <_uname+0x52>
mov    -0x10(%rbp),%rdi
lea    0xead(%rip),%rsi
mov    $0x1,%edx
call   1050 <_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11d9 <_uname+0xa9>
mov    -0x38(%rbp),%rsi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_uname>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
lea    0xec1(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0x8(%rsp),%rdi
call   1040 <uname@plt>
test   %rax,%rax
je     116e <_uname+0x3e>
lea    0xeba(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1050 <_error@plt>
neg    %eax
jmp    11c5 <_uname+0x95>
mov    0x8(%rsp),%rsi
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%rsi
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%rsi
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
mov    0x20(%rsp),%rsi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    0x28(%rsp),%rsi
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@.str = [23 x i8] c"%s: Testing utsname()\0A\00"
@.str.1 = [8 x i8] c"utsname\00"
@.str.2 = [13 x i8] c"sysname: %s\0A\00"
@.str.3 = [14 x i8] c"nodename: %s\0A\00"
@.str.4 = [13 x i8] c"release: %s\0A\00"
@.str.5 = [13 x i8] c"version: %s\0A\00"
@.str.6 = [13 x i8] c"machine: %s\0A\00"
define i32 @_uname(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.utsname
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = call i64 @uname(%struct.utsname* %4)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @_error(i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 1)
%12 = sub nsw i32 0, %11
store i32 %12, i32* %2
br label %29
13: ; preds = %1
%14 = getelementptr inbounds %struct.utsname, %struct.utsname* %4, i32 0, i32 0
%15 = load i8*, i8** %14
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds %struct.utsname, %struct.utsname* %4, i32 0, i32 1
%18 = load i8*, i8** %17
%19 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds %struct.utsname, %struct.utsname* %4, i32 0, i32 2
%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* %4, i32 0, i32 3
%24 = load i8*, i8** %23
%25 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds %struct.utsname, %struct.utsname* %4, i32 0, i32 4
%27 = load i8*, i8** %26
%28 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %27)
store i32 0, i32* %2
br label %29
29: ; preds = %13, %9
%30 = load i32, i32* %2
ret i32 %30
}

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