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

/* Variables and functions */
int uname(struct utsname *);
int System_uname(char **sysname, char **release, char **version, char **machine,
                 int flag) {
  int ret;
  static struct utsname uts;
  static int initialized = 0;
  if (initialized == 0) {
    ret = uname(&uts);
    if (ret != 0)
      initialized = -1;
  }
  if (initialized == -1)
    return (0);
  if (sysname != NULL)
    *sysname = uts.sysname;
  if (release != NULL)
    *release = uts.release;
  if (version != NULL)
    *version = uts.version;
  if (machine != NULL)
    *machine = uts.machine;
  return (1);
}


x86 assembly (clang, -O0):
<System_uname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
cmpl   $0x0,0x2f1d(%rip)
jne    1161 <System_uname+0x51>
lea    0x2ef0(%rip),%rdi
call   1030 <uname@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     115c <System_uname+0x4c>
movl   $0xffffffff,0x2ef4(%rip)
ff ff ff
jmp    1161 <System_uname+0x51>
cmpl   $0xffffffff,0x2ee8(%rip)
jne    117a <System_uname+0x6a>
movl   $0x0,-0x4(%rbp)
jmp    11e5 <System_uname+0xd5>
cmpq   $0x0,-0x10(%rbp)
je     1193 <System_uname+0x83>
mov    0x2ea4(%rip),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     11ac <System_uname+0x9c>
mov    0x2e93(%rip),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x20(%rbp)
je     11c5 <System_uname+0xb5>
mov    0x2e82(%rip),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x28(%rbp)
je     11de <System_uname+0xce>
mov    0x2e71(%rip),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<System_uname>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %ebp,%ebp
cmpb   $0x0,0x2f2f(%rip)
jne    1193 <System_uname+0x83>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0x2efa(%rip),%rdi
call   1030 <uname@plt>
test   %eax,%eax
je     1148 <System_uname+0x38>
movb   $0x1,0x2f0a(%rip)
jmp    1193 <System_uname+0x83>
cmpb   $0x0,0x2f01(%rip)
jne    1193 <System_uname+0x83>
test   %rbx,%rbx
je     1160 <System_uname+0x50>
mov    0x2ed3(%rip),%rax
mov    %rax,(%rbx)
test   %r12,%r12
je     1170 <System_uname+0x60>
mov    0x2ecc(%rip),%rax
mov    %rax,(%r12)
test   %r15,%r15
je     117f <System_uname+0x6f>
mov    0x2ec4(%rip),%rax
mov    %rax,(%r15)
mov    $0x1,%ebp
test   %r14,%r14
je     1193 <System_uname+0x83>
mov    0x2eb8(%rip),%rax
mov    %rax,(%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* }
@System_uname.uts = internal global %struct.utsname zeroinitializer
@System_uname.initialized = internal global i32 0
define i32 @System_uname(i8** %0, i8** %1, i8** %2, i8** %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32
store i8** %0, i8*** %7
store i8** %1, i8*** %8
store i8** %2, i8*** %9
store i8** %3, i8*** %10
store i32 %4, i32* %11
%13 = load i32, i32* @System_uname.initialized
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %5
%16 = call i32 @uname(%struct.utsname* @System_uname.uts)
store i32 %16, i32* %12
%17 = load i32, i32* %12
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 -1, i32* @System_uname.initialized
br label %20
20: ; preds = %19, %15
br label %21
21: ; preds = %20, %5
%22 = load i32, i32* @System_uname.initialized
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 0, i32* %6
br label %50
25: ; preds = %21
%26 = load i8**, i8*** %7
%27 = icmp ne i8** %26, null
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i8*, i8** getelementptr inbounds (%struct.utsname, %struct.utsname* @System_uname.uts, i32 0, i32 0)
%30 = load i8**, i8*** %7
store i8* %29, i8** %30
br label %31
31: ; preds = %28, %25
%32 = load i8**, i8*** %8
%33 = icmp ne i8** %32, null
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i8*, i8** getelementptr inbounds (%struct.utsname, %struct.utsname* @System_uname.uts, i32 0, i32 1)
%36 = load i8**, i8*** %8
store i8* %35, i8** %36
br label %37
37: ; preds = %34, %31
%38 = load i8**, i8*** %9
%39 = icmp ne i8** %38, null
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load i8*, i8** getelementptr inbounds (%struct.utsname, %struct.utsname* @System_uname.uts, i32 0, i32 2)
%42 = load i8**, i8*** %9
store i8* %41, i8** %42
br label %43
43: ; preds = %40, %37
%44 = load i8**, i8*** %10
%45 = icmp ne i8** %44, null
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i8*, i8** getelementptr inbounds (%struct.utsname, %struct.utsname* @System_uname.uts, i32 0, i32 3)
%48 = load i8**, i8*** %10
store i8* %47, i8** %48
br label %49
49: ; preds = %46, %43
store i32 1, i32* %6
br label %50
50: ; preds = %49, %24
%51 = load i32, i32* %6
ret i32 %51
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i8*, i8*, i8* }
@System_uname.uts = internal global %struct.utsname zeroinitializer
@System_uname.initialized = internal unnamed_addr global i1 false
define i32 @System_uname(i8** writeonly %0, i8** writeonly %1, i8** writeonly %2, i8** writeonly %3, i32 %4) {
%6 = load i1, i1* @System_uname.initialized
br i1 %6, label %29, label %7
7: ; preds = %5
%8 = tail call i32 @uname(%struct.utsname* @System_uname.uts)
%9 = icmp eq i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %7
store i1 true, i1* @System_uname.initialized
br label %29
11: ; preds = %7
%12 = load i1, i1* @System_uname.initialized
br i1 %12, label %29, label %13
13: ; preds = %11
%14 = icmp eq i8** %0, null
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = load i8*, i8** getelementptr inbounds (%struct.utsname, %struct.utsname* @System_uname.uts, i64 0, i32 0)
store i8* %16, i8** %0
br label %17
17: ; preds = %15, %13
%18 = icmp eq i8** %1, null
br i1 %18, label %21, label %19
19: ; preds = %17
%20 = load i8*, i8** getelementptr inbounds (%struct.utsname, %struct.utsname* @System_uname.uts, i64 0, i32 1)
store i8* %20, i8** %1
br label %21
21: ; preds = %19, %17
%22 = icmp eq i8** %2, null
br i1 %22, label %25, label %23
23: ; preds = %21
%24 = load i8*, i8** getelementptr inbounds (%struct.utsname, %struct.utsname* @System_uname.uts, i64 0, i32 2)
store i8* %24, i8** %2
br label %25
25: ; preds = %23, %21
%26 = icmp eq i8** %3, null
br i1 %26, label %29, label %27
27: ; preds = %25
%28 = load i8*, i8** getelementptr inbounds (%struct.utsname, %struct.utsname* @System_uname.uts, i64 0, i32 3)
store i8* %28, i8** %3
br label %29
29: ; preds = %5, %10, %25, %27, %11
%30 = phi i32 [ 0, %11 ], [ 1, %27 ], [ 1, %25 ], [ 0, %10 ], [ 0, %5 ]
ret i32 %30
}