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

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ putchar(char);
scalar_t__ uname(struct utsname *);
int _uname(int m, int n, int r, int s, int v) {
  struct utsname buf;
  int spacing = 0;
  if (uname(&buf) != 0) {
    perror("uname");
    return 1;
  }
  if (s && (spacing = 1))
    printf("%s", buf.sysname);
  if (n)
    printf("%s%s", spacing++ ? " " : "", buf.nodename);
  if (r)
    printf("%s%s", spacing++ ? " " : "", buf.release);
  if (v)
    printf("%s%s", spacing++ ? " " : "", buf.version);
  if (m)
    printf("%s%s", spacing++ ? " " : "", buf.machine);
  if (spacing == 0)
    printf("%s", buf.sysname);
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<_uname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
movl   $0x0,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <uname@plt>
cmp    $0x0,%rax
je     118a <_uname+0x4a>
lea    0xe87(%rip),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d5 <_uname+0x195>
cmpl   $0x0,-0x14(%rbp)
je     11bc <_uname+0x7c>
movl   $0x1,-0x34(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    11aa <_uname+0x6a>
jmp    11bc <_uname+0x7c>
mov    -0x30(%rbp),%rsi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
je     11f7 <_uname+0xb7>
mov    -0x34(%rbp),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
lea    0xe34(%rip),%rsi
lea    0xe2c(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x1c(%rbp),%edx
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
je     1232 <_uname+0xf2>
mov    -0x34(%rbp),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
lea    0xdf9(%rip),%rsi
lea    0xdf1(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x20(%rbp),%edx
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
je     126d <_uname+0x12d>
mov    -0x34(%rbp),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
lea    0xdbe(%rip),%rsi
lea    0xdb6(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x24(%rbp),%edx
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     12a8 <_uname+0x168>
mov    -0x34(%rbp),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
lea    0xd83(%rip),%rsi
lea    0xd7b(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x28(%rbp),%edx
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x34(%rbp)
jne    12c4 <_uname+0x184>
mov    -0x30(%rbp),%rsi
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_uname>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r15d
mov    %ecx,%ebp
mov    %edx,%r12d
mov    %esi,%r13d
mov    %edi,%r14d
mov    %rsp,%rdi
call   1050 <uname@plt>
test   %rax,%rax
jne    1288 <_uname+0x148>
test   %ebp,%ebp
je     1247 <_uname+0x107>
mov    (%rsp),%rsi
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
test   %r13d,%r13d
je     11ba <_uname+0x7a>
add    $0x1,%ebx
test   %ebp,%ebp
lea    0xe6f(%rip),%rax
lea    0xe67(%rip),%rsi
cmove  %rax,%rsi
mov    0x14(%rsp),%edx
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12d,%r12d
je     11ea <_uname+0xaa>
lea    0x1(%rbx),%ebp
test   %ebx,%ebx
lea    0xe41(%rip),%rax
lea    0xe39(%rip),%rsi
cmove  %rax,%rsi
mov    0x10(%rsp),%edx
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%ebx
test   %r15d,%r15d
je     121a <_uname+0xda>
lea    0x1(%rbx),%ebp
test   %ebx,%ebx
lea    0xe11(%rip),%rax
lea    0xe09(%rip),%rsi
cmove  %rax,%rsi
mov    0xc(%rsp),%edx
lea    0xdf5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%ebx
test   %r14d,%r14d
je     1257 <_uname+0x117>
test   %ebx,%ebx
lea    0xde4(%rip),%rax
lea    0xddc(%rip),%rsi
cmove  %rax,%rsi
mov    0x8(%rsp),%edx
lea    0xdc8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    126d <_uname+0x12d>
xor    %ebx,%ebx
test   %r13d,%r13d
jne    1191 <_uname+0x51>
jmp    11ba <_uname+0x7a>
test   %ebx,%ebx
jne    126d <_uname+0x12d>
mov    (%rsp),%rsi
lea    0xda2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd71(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%eax
jmp    1279 <_uname+0x139>

LLVM IR (-O0):
%struct.utsname = type { i8*, i32, i32, i32, i32 }
@.str = [6 x i8] c"uname\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c"%s%s\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [1 x i8] zeroinitializer
define i32 @_uname(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.utsname
%13 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 0, i32* %13
%14 = call i64 @uname(%struct.utsname* %12)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %5
%17 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %6
br label %83
18: ; preds = %5
%19 = load i32, i32* %10
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %18
store i32 1, i32* %13
br i1 true, label %22, label %26
22: ; preds = %21
%23 = getelementptr inbounds %struct.utsname, %struct.utsname* %12, i32 0, i32 0
%24 = load i8*, i8** %23
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %22, %21, %18
%27 = load i32, i32* %8
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %38
29: ; preds = %26
%30 = load i32, i32* %13
%31 = add nsw i32 %30, 1
store i32 %31, i32* %13
%32 = icmp ne i32 %30, 0
%33 = zext i1 %32 to i64
%34 = select i1 %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%35 = getelementptr inbounds %struct.utsname, %struct.utsname* %12, i32 0, i32 4
%36 = load i32, i32* %35
%37 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %34, i32 %36)
br label %38
38: ; preds = %29, %26
%39 = load i32, i32* %9
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %50
41: ; preds = %38
%42 = load i32, i32* %13
%43 = add nsw i32 %42, 1
store i32 %43, i32* %13
%44 = icmp ne i32 %42, 0
%45 = zext i1 %44 to i64
%46 = select i1 %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%47 = getelementptr inbounds %struct.utsname, %struct.utsname* %12, i32 0, i32 3
%48 = load i32, i32* %47
%49 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %46, i32 %48)
br label %50
50: ; preds = %41, %38
%51 = load i32, i32* %11
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %62
53: ; preds = %50
%54 = load i32, i32* %13
%55 = add nsw i32 %54, 1
store i32 %55, i32* %13
%56 = icmp ne i32 %54, 0
%57 = zext i1 %56 to i64
%58 = select i1 %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%59 = getelementptr inbounds %struct.utsname, %struct.utsname* %12, i32 0, i32 2
%60 = load i32, i32* %59
%61 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %58, i32 %60)
br label %62
62: ; preds = %53, %50
%63 = load i32, i32* %7
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %74
65: ; preds = %62
%66 = load i32, i32* %13
%67 = add nsw i32 %66, 1
store i32 %67, i32* %13
%68 = icmp ne i32 %66, 0
%69 = zext i1 %68 to i64
%70 = select i1 %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%71 = getelementptr inbounds %struct.utsname, %struct.utsname* %12, i32 0, i32 1
%72 = load i32, i32* %71
%73 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %70, i32 %72)
br label %74
74: ; preds = %65, %62
%75 = load i32, i32* %13
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %81
77: ; preds = %74
%78 = getelementptr inbounds %struct.utsname, %struct.utsname* %12, i32 0, i32 0
%79 = load i8*, i8** %78
%80 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %79)
br label %81
81: ; preds = %77, %74
%82 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %6
br label %83
83: ; preds = %81, %16
%84 = load i32, i32* %6
ret i32 %84
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i32, i32, i32, i32 }
@.str = [6 x i8] c"uname\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c"%s%s\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [1 x i8] zeroinitializer
define i32 @_uname(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca %struct.utsname
%7 = bitcast %struct.utsname* %6 to i8*
%8 = call i64 @uname(%struct.utsname* %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %63
12: ; preds = %5
%13 = icmp eq i32 %3, 0
br i1 %13, label %18, label %14
14: ; preds = %12
%15 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i64 0, i32 0
%16 = load i8*, i8** %15
%17 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %14, %12
%19 = phi i32 [ 1, %14 ], [ 0, %12 ]
%20 = icmp eq i32 %1, 0
br i1 %20, label %27, label %21
21: ; preds = %18
%22 = add nuw nsw i32 %19, 1
%23 = select i1 %13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%24 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i64 0, i32 4
%25 = load i32, i32* %24
%26 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %23, i32 %25)
br label %27
27: ; preds = %21, %18
%28 = phi i32 [ %22, %21 ], [ %19, %18 ]
%29 = icmp eq i32 %2, 0
br i1 %29, label %37, label %30
30: ; preds = %27
%31 = add nuw nsw i32 %28, 1
%32 = icmp eq i32 %28, 0
%33 = select i1 %32, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%34 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i64 0, i32 3
%35 = load i32, i32* %34
%36 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %33, i32 %35)
br label %37
37: ; preds = %30, %27
%38 = phi i32 [ %31, %30 ], [ %28, %27 ]
%39 = icmp eq i32 %4, 0
br i1 %39, label %47, label %40
40: ; preds = %37
%41 = add nuw nsw i32 %38, 1
%42 = icmp eq i32 %38, 0
%43 = select i1 %42, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%44 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i64 0, i32 2
%45 = load i32, i32* %44
%46 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %43, i32 %45)
br label %47
47: ; preds = %40, %37
%48 = phi i32 [ %41, %40 ], [ %38, %37 ]
%49 = icmp eq i32 %0, 0
%50 = icmp eq i32 %48, 0
br i1 %49, label %56, label %51
51: ; preds = %47
%52 = select i1 %50, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%53 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i64 0, i32 1
%54 = load i32, i32* %53
%55 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %52, i32 %54)
br label %61
56: ; preds = %47
br i1 %50, label %57, label %61
57: ; preds = %56
%58 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i64 0, i32 0
%59 = load i8*, i8** %58
%60 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %51, %57, %56
%62 = tail call i32 @putchar(i8 signext 10)
br label %63
63: ; preds = %61, %10
%64 = phi i32 [ 1, %10 ], [ 0, %61 ]
ret i32 %64
}