#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 errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int handle_gez(int);
int /*<<< orphan*/ printf(char *, ...);
int uname(struct utsname *);
int uname_test(struct utsname *name) {
  int ret, save_errno;
  int passed;
  printf("uname(): name=0x%p\n", name);
  fflush(NULL);
  passed = handle_gez(ret = uname(name));
  save_errno = errno;
  switch (passed) {
  case -1:
    printf("\t\tret = %d\n", ret);
    printf("\tSucceeded Phase 1\n");
    fflush(NULL);
    break;
  case 0:
    printf("\t\tsysname = %s\n",
           (((name->sysname) == NULL) ? "(null)" : (name->sysname)));
    printf("\t\tnodename = %s\n",
           (((name->nodename) == NULL) ? "(null)" : (name->nodename)));
    printf("\t\trelease = %s\n",
           (((name->release) == NULL) ? "(null)" : (name->release)));
    printf("\t\tversion = %s\n",
           (((name->version) == NULL) ? "(null)" : (name->version)));
    printf("\t\tmachine = %s\n",
           (((name->machine) == NULL) ? "(null)" : (name->machine)));
    printf("\t\tret = %d\n", ret);
    printf("\tSucceeded Phase 1\n");
    fflush(NULL);
    break;
  case -2:
    printf("\tFailed Phase 1: returned undefined value! "
           "ret = %d\n",
           ret);
    fflush(NULL);
    break;
  default:
    printf("Internal syscalltester error: passed = %d\n", passed);
    fflush(NULL);
    break;
  }
  errno = save_errno;
  return ret;
}


x86 assembly (clang, -O0):
<uname_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea9(%rip),%rdi
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,%edi
call   1050 <fflush@plt>
mov    -0x8(%rbp),%rdi
call   1040 <uname@plt>
mov    %eax,%edi
mov    %edi,-0xc(%rbp)
call   1060 <handle_gez@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0xfffffffe,%eax
je     134b <uname_test+0x20b>
jmp    11a1 <uname_test+0x61>
mov    -0x18(%rbp),%eax
sub    $0xffffffff,%eax
je     11c2 <uname_test+0x82>
jmp    11b2 <uname_test+0x72>
mov    -0x18(%rbp),%eax
test   %eax,%eax
je     11ef <uname_test+0xaf>
jmp    136a <uname_test+0x22a>
mov    -0xc(%rbp),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <fflush@plt>
jmp    1384 <uname_test+0x244>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    120d <uname_test+0xcd>
lea    0xe40(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1218 <uname_test+0xd8>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    1249 <uname_test+0x109>
lea    0xe04(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1255 <uname_test+0x115>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x10(%rax)
jne    1286 <uname_test+0x146>
lea    0xdc7(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    1292 <uname_test+0x152>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x18(%rax)
jne    12c3 <uname_test+0x183>
lea    0xd8a(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    12cf <uname_test+0x18f>
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x20(%rax)
jne    1300 <uname_test+0x1c0>
lea    0xd4d(%rip),%rax
mov    %rax,-0x48(%rbp)
jmp    130c <uname_test+0x1cc>
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rsi
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xcec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xcea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <fflush@plt>
jmp    1384 <uname_test+0x244>
mov    -0xc(%rbp),%esi
lea    0xd37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <fflush@plt>
jmp    1384 <uname_test+0x244>
mov    -0x14(%rbp),%esi
lea    0xd4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <fflush@plt>
mov    -0x10(%rbp),%ecx
mov    0x2c52(%rip),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uname_test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
lea    0xe9e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <fflush@plt>
mov    %rbx,%rdi
call   1050 <uname@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1070 <handle_gez@plt>
mov    0x2e55(%rip),%r14
mov    (%r14),%r15d
cmp    $0xfffffffe,%eax
je     11ab <uname_test+0x5b>
test   %eax,%eax
je     11c0 <uname_test+0x70>
cmp    $0xffffffff,%eax
je     1243 <uname_test+0xf3>
lea    0xf06(%rip),%rdi
mov    %eax,%esi
jmp    11b4 <uname_test+0x64>
lea    0xec6(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    125f <uname_test+0x10f>
mov    (%rbx),%rsi
test   %rsi,%rsi
lea    0xe63(%rip),%r12
cmove  %r12,%rsi
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%rsi
test   %rsi,%rsi
cmove  %r12,%rsi
lea    0xe46(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%rsi
test   %rsi,%rsi
cmove  %r12,%rsi
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%rsi
test   %rsi,%rsi
cmove  %r12,%rsi
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rbx),%rsi
test   %rsi,%rsi
cmove  %r12,%rsi
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdca(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <fflush@plt>
mov    %r15d,(%r14)
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@.str = [20 x i8] c"uname(): name=0x%p\0A\00"
@errno = global i32 0
@.str.1 = [12 x i8] c"\09\09ret = %d\0A\00"
@.str.2 = [20 x i8] c"\09Succeeded Phase 1\0A\00"
@.str.3 = [16 x i8] c"\09\09sysname = %s\0A\00"
@.str.4 = [7 x i8] c"(null)\00"
@.str.5 = [17 x i8] c"\09\09nodename = %s\0A\00"
@.str.6 = [16 x i8] c"\09\09release = %s\0A\00"
@.str.7 = [16 x i8] c"\09\09version = %s\0A\00"
@.str.8 = [16 x i8] c"\09\09machine = %s\0A\00"
@.str.9 = [53 x i8] c"\09Failed Phase 1: returned undefined value! ret = %d\0A\00"
@.str.10 = [43 x i8] c"Internal syscalltester error: passed = %d\0A\00"
define i32 @uname_test(%struct.utsname* %0) {
%2 = alloca %struct.utsname*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store %struct.utsname* %0, %struct.utsname** %2
%6 = load %struct.utsname*, %struct.utsname** %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), %struct.utsname* %6)
%8 = call i32 @fflush(i32* null)
%9 = load %struct.utsname*, %struct.utsname** %2
%10 = call i32 @uname(%struct.utsname* %9)
store i32 %10, i32* %3
%11 = call i32 @handle_gez(i32 %10)
store i32 %11, i32* %5
%12 = load i32, i32* @errno
store i32 %12, i32* %4
%13 = load i32, i32* %5
switch i32 %13, label %88 [
i32 -1, label %14
i32 0, label %19
i32 -2, label %84
]
14: ; preds = %1
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @fflush(i32* null)
br label %92
19: ; preds = %1
%20 = load %struct.utsname*, %struct.utsname** %2
%21 = getelementptr inbounds %struct.utsname, %struct.utsname* %20, i32 0, i32 0
%22 = load i8*, i8** %21
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %25
24: ; preds = %19
br label %29
25: ; preds = %19
%26 = load %struct.utsname*, %struct.utsname** %2
%27 = getelementptr inbounds %struct.utsname, %struct.utsname* %26, i32 0, i32 0
%28 = load i8*, i8** %27
br label %29
29: ; preds = %25, %24
%30 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %24 ], [ %28, %25 ]
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %30)
%32 = load %struct.utsname*, %struct.utsname** %2
%33 = getelementptr inbounds %struct.utsname, %struct.utsname* %32, i32 0, i32 1
%34 = load i8*, i8** %33
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %37
36: ; preds = %29
br label %41
37: ; preds = %29
%38 = load %struct.utsname*, %struct.utsname** %2
%39 = getelementptr inbounds %struct.utsname, %struct.utsname* %38, i32 0, i32 1
%40 = load i8*, i8** %39
br label %41
41: ; preds = %37, %36
%42 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %36 ], [ %40, %37 ]
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %42)
%44 = load %struct.utsname*, %struct.utsname** %2
%45 = getelementptr inbounds %struct.utsname, %struct.utsname* %44, i32 0, i32 2
%46 = load i8*, i8** %45
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %49
48: ; preds = %41
br label %53
49: ; preds = %41
%50 = load %struct.utsname*, %struct.utsname** %2
%51 = getelementptr inbounds %struct.utsname, %struct.utsname* %50, i32 0, i32 2
%52 = load i8*, i8** %51
br label %53
53: ; preds = %49, %48
%54 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %48 ], [ %52, %49 ]
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %54)
%56 = load %struct.utsname*, %struct.utsname** %2
%57 = getelementptr inbounds %struct.utsname, %struct.utsname* %56, i32 0, i32 3
%58 = load i8*, i8** %57
%59 = icmp eq i8* %58, null
br i1 %59, label %60, label %61
60: ; preds = %53
br label %65
61: ; preds = %53
%62 = load %struct.utsname*, %struct.utsname** %2
%63 = getelementptr inbounds %struct.utsname, %struct.utsname* %62, i32 0, i32 3
%64 = load i8*, i8** %63
br label %65
65: ; preds = %61, %60
%66 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %60 ], [ %64, %61 ]
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %66)
%68 = load %struct.utsname*, %struct.utsname** %2
%69 = getelementptr inbounds %struct.utsname, %struct.utsname* %68, i32 0, i32 4
%70 = load i8*, i8** %69
%71 = icmp eq i8* %70, null
br i1 %71, label %72, label %73
72: ; preds = %65
br label %77
73: ; preds = %65
%74 = load %struct.utsname*, %struct.utsname** %2
%75 = getelementptr inbounds %struct.utsname, %struct.utsname* %74, i32 0, i32 4
%76 = load i8*, i8** %75
br label %77
77: ; preds = %73, %72
%78 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %72 ], [ %76, %73 ]
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %78)
%80 = load i32, i32* %3
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %80)
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%83 = call i32 @fflush(i32* null)
br label %92
84: ; preds = %1
%85 = load i32, i32* %3
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0), i32 %85)
%87 = call i32 @fflush(i32* null)
br label %92
88: ; preds = %1
%89 = load i32, i32* %5
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0), i32 %89)
%91 = call i32 @fflush(i32* null)
br label %92
92: ; preds = %88, %84, %77, %14
%93 = load i32, i32* %4
store i32 %93, i32* @errno
%94 = load i32, i32* %3
ret i32 %94
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@.str = [20 x i8] c"uname(): name=0x%p\0A\00"
@errno = global i32 0
@.str.1 = [12 x i8] c"\09\09ret = %d\0A\00"
@.str.3 = [16 x i8] c"\09\09sysname = %s\0A\00"
@.str.4 = [7 x i8] c"(null)\00"
@.str.5 = [17 x i8] c"\09\09nodename = %s\0A\00"
@.str.6 = [16 x i8] c"\09\09release = %s\0A\00"
@.str.7 = [16 x i8] c"\09\09version = %s\0A\00"
@.str.8 = [16 x i8] c"\09\09machine = %s\0A\00"
@.str.9 = [53 x i8] c"\09Failed Phase 1: returned undefined value! ret = %d\0A\00"
@.str.10 = [43 x i8] c"Internal syscalltester error: passed = %d\0A\00"
@str.11 = [19 x i8] c"\09Succeeded Phase 1\00"
define i32 @uname_test(%struct.utsname* %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), %struct.utsname* %0)
%3 = tail call i32 @fflush(i32* null)
%4 = tail call i32 @uname(%struct.utsname* %0)
%5 = tail call i32 @handle_gez(i32 %4)
%6 = load i32, i32* @errno
switch i32 %5, label %40 [
i32 -1, label %7
i32 0, label %10
i32 -2, label %38
]
7: ; preds = %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.11, i64 0, i64 0))
br label %42
10: ; preds = %1
%11 = getelementptr inbounds %struct.utsname, %struct.utsname* %0, i64 0, i32 0
%12 = load i8*, i8** %11
%13 = icmp eq i8* %12, null
%14 = select i1 %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %12
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds %struct.utsname, %struct.utsname* %0, i64 0, i32 1
%17 = load i8*, i8** %16
%18 = icmp eq i8* %17, null
%19 = select i1 %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %17
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds %struct.utsname, %struct.utsname* %0, i64 0, i32 2
%22 = load i8*, i8** %21
%23 = icmp eq i8* %22, null
%24 = select i1 %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %22
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds %struct.utsname, %struct.utsname* %0, i64 0, i32 3
%27 = load i8*, i8** %26
%28 = icmp eq i8* %27, null
%29 = select i1 %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %27
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds %struct.utsname, %struct.utsname* %0, i64 0, i32 4
%32 = load i8*, i8** %31
%33 = icmp eq i8* %32, null
%34 = select i1 %33, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %32
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i8* %34)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.11, i64 0, i64 0))
br label %42
38: ; preds = %1
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.9, i64 0, i64 0), i32 %4)
br label %42
40: ; preds = %1
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0), i32 %5)
br label %42
42: ; preds = %40, %38, %10, %7
%43 = tail call i32 @fflush(i32* null)
store i32 %6, i32* @errno
ret i32 %4
}