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

/* Variables and functions */
scalar_t__ EFAULT;
scalar_t__ errno;
int strlen(char *);
int uname(struct utsname *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  struct utsname un;
  if (uname(&un) == -1) {
    if (errno == EFAULT) {
      write(2, "uname: buffer for uname isn't valid", 35);
    }
  }
  if (argc == 1) {
    write(1, un.sysname, strlen(un.sysname));
    return 0;
  }
  int i = 1;
  do {
    if (*argv[i] == '-') {
      ++argv[i];
      switch (*argv[i]) {
      case 'v':
        write(1, un.version, strlen(un.version));
        break;
      case 'r':
        write(1, un.release, strlen(un.release));
        break;
      case 'n':
        write(1, un.nodename, strlen(un.nodename));
        break;
      case 's':
        write(1, un.sysname, strlen(un.sysname));
        break;
      case 'm':
      case 'p':
        write(1, un.machine, strlen(un.machine));
        break;
      default:
        write(2, "uname: unknown option", 22);
        break;
      }
      write(1, " ", 1);
    }
    ++i;
  } while (i < argc);
  write(1, "\n", 1);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x38(%rbp),%rdi
call   1050 <uname@plt>
cmp    $0xffffffff,%eax
jne    1190 <main+0x60>
mov    0x2e76(%rip),%rax
mov    (%rax),%rax
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%rax
jne    118b <main+0x5b>
mov    $0x2,%edi
lea    0xea7(%rip),%rsi
mov    $0x23,%edx
call   1030 <write@plt>
jmp    1190 <main+0x60>
cmpl   $0x1,-0x8(%rbp)
jne    11c7 <main+0x97>
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
movl   $0x0,-0x4(%rbp)
jmp    1345 <main+0x215>
movl   $0x1,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1316 <main+0x1e6>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
add    $0x1,%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
add    $0xffffff93,%eax
mov    %eax,%ecx
mov    %rcx,-0x50(%rbp)
sub    $0x9,%eax
ja     12ed <main+0x1bd>
mov    -0x50(%rbp),%rax
lea    0xdda(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
jmp    1303 <main+0x1d3>
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
jmp    1303 <main+0x1d3>
mov    -0x20(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x68(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
jmp    1303 <main+0x1d3>
mov    -0x38(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
jmp    1303 <main+0x1d3>
mov    -0x18(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x78(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
jmp    1303 <main+0x1d3>
mov    $0x2,%edi
lea    0xd53(%rip),%rsi
mov    $0x16,%edx
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xd53(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     11ce <main+0x9e>
mov    $0x1,%edx
lea    0xd2d(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0x20(%rsp),%rdi
call   1050 <uname@plt>
cmp    $0xffffffff,%eax
jne    117f <main+0x4f>
mov    0x2e7e(%rip),%rax
mov    (%rax),%rax
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%rax
jne    117f <main+0x4f>
lea    0xeb8(%rip),%rsi
mov    $0x2,%edi
mov    $0x23,%edx
call   1030 <write@plt>
cmp    $0x1,%r14d
jne    11a8 <main+0x78>
mov    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
xor    %ebx,%ebx
jmp    12aa <main+0x17a>
mov    0x40(%rsp),%r15
mov    0x20(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    0x28(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    0x38(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    0x30(%rsp),%rax
mov    %rax,(%rsp)
cmp    $0x3,%r14d
mov    $0x2,%eax
cmovl  %eax,%r14d
mov    $0x1,%ebp
lea    0xe13(%rip),%r12
jmp    122a <main+0xfa>
mov    0x10(%rsp),%r13
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x1,%edi
lea    0xe4b(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
je     128f <main+0x15f>
mov    (%rbx,%rbp,8),%rax
cmpb   $0x2d,(%rax)
jne    1221 <main+0xf1>
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx,%rbp,8)
movsbl 0x1(%rax),%eax
add    $0xffffff93,%eax
cmp    $0x9,%eax
ja     1269 <main+0x139>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %r15,%rsi
jmp    1204 <main+0xd4>
mov    0x8(%rsp),%r13
jmp    11f4 <main+0xc4>
mov    $0x2,%edi
lea    0xdd7(%rip),%rsi
mov    $0x16,%edx
jmp    1206 <main+0xd6>
mov    (%rsp),%r13
jmp    11f4 <main+0xc4>
mov    0x18(%rsp),%r13
jmp    11f4 <main+0xc4>
lea    0xdce(%rip),%rsi
mov    $0x1,%ebx
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %ebx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@errno = global i64 0
@EFAULT = global i64 0
@.str = [36 x i8] c"uname: buffer for uname isn't valid\00"
@.str.1 = [22 x i8] c"uname: unknown option\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.utsname
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @uname(%struct.utsname* %6)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i64, i64* @errno
%12 = load i64, i64* @EFAULT
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @write(i32 2, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 35)
br label %16
16: ; preds = %14, %10
br label %17
17: ; preds = %16, %2
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 0
%22 = load i8*, i8** %21
%23 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 0
%24 = load i8*, i8** %23
%25 = call i32 @strlen(i8* %24)
%26 = call i32 @write(i32 1, i8* %22, i32 %25)
store i32 0, i32* %3
br label %99
27: ; preds = %17
store i32 1, i32* %7
br label %28
28: ; preds = %93, %27
%29 = load i8**, i8*** %5
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 45
br i1 %36, label %37, label %90
37: ; preds = %28
%38 = load i8**, i8*** %5
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %41
%44 = load i8**, i8*** %5
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
switch i32 %50, label %86 [
i32 118, label %51
i32 114, label %58
i32 110, label %65
i32 115, label %72
i32 109, label %79
i32 112, label %79
]
51: ; preds = %37
%52 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 1
%53 = load i8*, i8** %52
%54 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 1
%55 = load i8*, i8** %54
%56 = call i32 @strlen(i8* %55)
%57 = call i32 @write(i32 1, i8* %53, i32 %56)
br label %88
58: ; preds = %37
%59 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 2
%60 = load i8*, i8** %59
%61 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 2
%62 = load i8*, i8** %61
%63 = call i32 @strlen(i8* %62)
%64 = call i32 @write(i32 1, i8* %60, i32 %63)
br label %88
65: ; preds = %37
%66 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 3
%67 = load i8*, i8** %66
%68 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 3
%69 = load i8*, i8** %68
%70 = call i32 @strlen(i8* %69)
%71 = call i32 @write(i32 1, i8* %67, i32 %70)
br label %88
72: ; preds = %37
%73 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 0
%74 = load i8*, i8** %73
%75 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 0
%76 = load i8*, i8** %75
%77 = call i32 @strlen(i8* %76)
%78 = call i32 @write(i32 1, i8* %74, i32 %77)
br label %88
79: ; preds = %37, %37
%80 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 4
%81 = load i8*, i8** %80
%82 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 4
%83 = load i8*, i8** %82
%84 = call i32 @strlen(i8* %83)
%85 = call i32 @write(i32 1, i8* %81, i32 %84)
br label %88
86: ; preds = %37
%87 = call i32 @write(i32 2, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 22)
br label %88
88: ; preds = %86, %79, %72, %65, %58, %51
%89 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %90
90: ; preds = %88, %28
%91 = load i32, i32* %7
%92 = add nsw i32 %91, 1
store i32 %92, i32* %7
br label %93
93: ; preds = %90
%94 = load i32, i32* %7
%95 = load i32, i32* %4
%96 = icmp slt i32 %94, %95
br i1 %96, label %28, label %97
97: ; preds = %93
%98 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
store i32 1, i32* %3
br label %99
99: ; preds = %97, %20
%100 = load i32, i32* %3
ret i32 %100
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@errno = global i64 0
@EFAULT = global i64 0
@.str = [36 x i8] c"uname: buffer for uname isn't valid\00"
@.str.1 = [22 x i8] c"uname: unknown option\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.utsname
%4 = bitcast %struct.utsname* %3 to i8*
%5 = call i32 @uname(%struct.utsname* %3)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = load i64, i64* @errno
%9 = load i64, i64* @EFAULT
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @write(i32 2, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 35)
br label %13
13: ; preds = %7, %11, %2
%14 = icmp eq i32 %0, 1
br i1 %14, label %28, label %15
15: ; preds = %13
%16 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 4
%17 = load i8*, i8** %16
%18 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 0
%19 = load i8*, i8** %18
%20 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 3
%21 = load i8*, i8** %20
%22 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 2
%23 = load i8*, i8** %22
%24 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 1
%25 = load i8*, i8** %24
%26 = call i32 @llvm.smax.i32(i32 %0, i32 2)
%27 = zext i32 %26 to i64
br label %33
28: ; preds = %13
%29 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 0
%30 = load i8*, i8** %29
%31 = tail call i32 @strlen(i8* %30)
%32 = tail call i32 @write(i32 1, i8* %30, i32 %31)
br label %67
33: ; preds = %15, %62
%34 = phi i64 [ 1, %15 ], [ %63, %62 ]
%35 = getelementptr inbounds i8*, i8** %1, i64 %34
%36 = load i8*, i8** %35
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 45
br i1 %38, label %39, label %62
39: ; preds = %33
%40 = getelementptr inbounds i8, i8* %36, i64 1
store i8* %40, i8** %35
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
switch i32 %42, label %58 [
i32 118, label %43
i32 114, label %46
i32 110, label %49
i32 115, label %52
i32 109, label %55
i32 112, label %55
]
43: ; preds = %39
%44 = tail call i32 @strlen(i8* %25)
%45 = tail call i32 @write(i32 1, i8* %25, i32 %44)
br label %60
46: ; preds = %39
%47 = tail call i32 @strlen(i8* %23)
%48 = tail call i32 @write(i32 1, i8* %23, i32 %47)
br label %60
49: ; preds = %39
%50 = tail call i32 @strlen(i8* %21)
%51 = tail call i32 @write(i32 1, i8* %21, i32 %50)
br label %60
52: ; preds = %39
%53 = tail call i32 @strlen(i8* %19)
%54 = tail call i32 @write(i32 1, i8* %19, i32 %53)
br label %60
55: ; preds = %39, %39
%56 = tail call i32 @strlen(i8* %17)
%57 = tail call i32 @write(i32 1, i8* %17, i32 %56)
br label %60
58: ; preds = %39
%59 = tail call i32 @write(i32 2, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 22)
br label %60
60: ; preds = %58, %55, %52, %49, %46, %43
%61 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %62
62: ; preds = %60, %33
%63 = add nuw nsw i64 %34, 1
%64 = icmp eq i64 %63, %27
br i1 %64, label %65, label %33
65: ; preds = %62
%66 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
br label %67
67: ; preds = %65, %28
%68 = phi i32 [ 0, %28 ], [ 1, %65 ]
ret i32 %68
}