#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 {
  int /*<<< orphan*/ __domainname;
  int /*<<< orphan*/ machine;
  int /*<<< orphan*/ version;
  int /*<<< orphan*/ release;
  int /*<<< orphan*/ nodename;
  int /*<<< orphan*/ sysname;
};

/* Variables and functions */
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int uname(struct utsname *uts) {
  strcpy(uts->sysname, "wasi");
  strcpy(uts->nodename, "(none)");
  strcpy(uts->release, "0.0.0");
  strcpy(uts->version, "0.0.0");
  strcpy(uts->machine, "unknown");
  strcpy(uts->__domainname, "(none)");
  return 0;
}


x86 assembly (clang, -O0):
<uname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%edi
lea    0xed6(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%edi
lea    0xec8(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%edi
lea    0xebc(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xea9(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
lea    0xe9c(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uname>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x14(%rdi),%edi
lea    0xede(%rip),%rsi
call   1030 <strcpy@plt>
mov    0x10(%rbx),%edi
lea    0xed4(%rip),%r14
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    0xc(%rbx),%edi
lea    0xec9(%rip),%r15
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    0x8(%rbx),%edi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    0x4(%rbx),%edi
lea    0xeb2(%rip),%rsi
call   1030 <strcpy@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.utsname = type { i32, i32, i32, i32, i32, i32 }
@.str = [5 x i8] c"wasi\00"
@.str.1 = [7 x i8] c"(none)\00"
@.str.2 = [6 x i8] c"0.0.0\00"
@.str.3 = [8 x i8] c"unknown\00"
define i32 @uname(%struct.utsname* %0) {
%2 = alloca %struct.utsname*
store %struct.utsname* %0, %struct.utsname** %2
%3 = load %struct.utsname*, %struct.utsname** %2
%4 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 5
%5 = load i32, i32* %4
%6 = call i32 @strcpy(i32 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = load %struct.utsname*, %struct.utsname** %2
%8 = getelementptr inbounds %struct.utsname, %struct.utsname* %7, i32 0, i32 4
%9 = load i32, i32* %8
%10 = call i32 @strcpy(i32 %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = load %struct.utsname*, %struct.utsname** %2
%12 = getelementptr inbounds %struct.utsname, %struct.utsname* %11, i32 0, i32 3
%13 = load i32, i32* %12
%14 = call i32 @strcpy(i32 %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%15 = load %struct.utsname*, %struct.utsname** %2
%16 = getelementptr inbounds %struct.utsname, %struct.utsname* %15, i32 0, i32 2
%17 = load i32, i32* %16
%18 = call i32 @strcpy(i32 %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%19 = load %struct.utsname*, %struct.utsname** %2
%20 = getelementptr inbounds %struct.utsname, %struct.utsname* %19, i32 0, i32 1
%21 = load i32, i32* %20
%22 = call i32 @strcpy(i32 %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%23 = load %struct.utsname*, %struct.utsname** %2
%24 = getelementptr inbounds %struct.utsname, %struct.utsname* %23, i32 0, i32 0
%25 = load i32, i32* %24
%26 = call i32 @strcpy(i32 %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.utsname = type { i32, i32, i32, i32, i32, i32 }
@.str = [5 x i8] c"wasi\00"
@.str.1 = [7 x i8] c"(none)\00"
@.str.2 = [6 x i8] c"0.0.0\00"
@.str.3 = [8 x i8] c"unknown\00"
define i32 @uname(%struct.utsname* nocapture %0) {
%2 = getelementptr inbounds %struct.utsname, %struct.utsname* %0, i64 0, i32 5
%3 = load i32, i32* %2
%4 = tail call i32 @strcpy(i32 %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds %struct.utsname, %struct.utsname* %0, i64 0, i32 4
%6 = load i32, i32* %5
%7 = tail call i32 @strcpy(i32 %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds %struct.utsname, %struct.utsname* %0, i64 0, i32 3
%9 = load i32, i32* %8
%10 = tail call i32 @strcpy(i32 %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds %struct.utsname, %struct.utsname* %0, i64 0, i32 2
%12 = load i32, i32* %11
%13 = tail call i32 @strcpy(i32 %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds %struct.utsname, %struct.utsname* %0, i64 0, i32 1
%15 = load i32, i32* %14
%16 = tail call i32 @strcpy(i32 %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%17 = getelementptr inbounds %struct.utsname, %struct.utsname* %0, i64 0, i32 0
%18 = load i32, i32* %17
%19 = tail call i32 @strcpy(i32 %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}