#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 */
typedef int u_int;
struct utsname {
  char *sysname;
  char *release;
  char *version;
  char *machine;
  char *nodename;
};

/* Variables and functions */
int EOF;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ uname(struct utsname *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  u_int flags;
  int ch;
  struct utsname uts;
  flags = 0;
  while ((ch = getopt(argc, argv, "amnrsv")) != EOF) {
    switch (ch) {
    case 'a':
      flags |= (0x01 | 0x02 | 0x04 | 0x08 | 0x10);
      break;
    case 'm':
      flags |= 0x01;
      break;
    case 'n':
      flags |= 0x02;
      break;
    case 'r':
      flags |= 0x04;
      break;
    case 's':
      flags |= 0x08;
      break;
    case 'v':
      flags |= 0x10;
      break;
    case '?':
    default:
      usage();
    }
  }
  argc -= optind;
  argv += optind;
  if (argc)
    usage();
  if (!flags)
    flags |= 0x08;
  uname(&uts);
  if (flags & 0x08)
    printf("%s ", uts.sysname);
  if (flags & 0x04)
    printf("%s ", uts.release);
  if (flags & 0x10)
    printf("%s ", uts.version);
  if (flags & 0x01)
    printf("%s ", uts.machine);
  if (flags & 0x02)
    printf("%s", uts.nodename);
  putchar('\n');
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf55(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e4e(%rip),%rcx
cmp    (%rcx),%eax
je     1230 <main+0xd0>
mov    -0x18(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x37,%eax
ja     1224 <main+0xc4>
mov    -0x48(%rbp),%rax
lea    0xe3e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x14(%rbp),%eax
or     $0x1f,%eax
mov    %eax,-0x14(%rbp)
jmp    122b <main+0xcb>
mov    -0x14(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    122b <main+0xcb>
mov    -0x14(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    122b <main+0xcb>
mov    -0x14(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x14(%rbp)
jmp    122b <main+0xcb>
mov    -0x14(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x14(%rbp)
jmp    122b <main+0xcb>
mov    -0x14(%rbp),%eax
or     $0x10,%eax
mov    %eax,-0x14(%rbp)
jmp    122b <main+0xcb>
jmp    1224 <main+0xc4>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    117d <main+0x1d>
mov    0x2da9(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2d95(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     126b <main+0x10b>
mov    $0x0,%al
call   1060 <usage@plt>
cmpl   $0x0,-0x14(%rbp)
jne    127e <main+0x11e>
mov    -0x14(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x14(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <uname@plt>
mov    -0x14(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     12a6 <main+0x146>
mov    -0x40(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     12c5 <main+0x165>
mov    -0x38(%rbp),%rsi
lea    0xe27(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     12e4 <main+0x184>
mov    -0x30(%rbp),%rsi
lea    0xe08(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1303 <main+0x1a3>
mov    -0x28(%rbp),%rsi
lea    0xde9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1322 <main+0x1c2>
mov    -0x20(%rbp),%rsi
lea    0xdce(%rip),%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r13
mov    %edi,%r15d
lea    0xedd(%rip),%rdx
call   1070 <getopt@plt>
mov    0x2e61(%rip),%r12
xor    %ebp,%ebp
cmp    (%r12),%eax
jne    11ff <main+0x9f>
mov    0x2e4a(%rip),%rax
cmp    %r15d,(%rax)
je     11a2 <main+0x42>
xor    %eax,%eax
call   1060 <usage@plt>
test   %ebp,%ebp
mov    $0x8,%ebx
cmovne %ebp,%ebx
mov    %rsp,%rdi
call   1050 <uname@plt>
test   $0x8,%bl
jne    1267 <main+0x107>
test   $0x4,%bl
jne    1280 <main+0x120>
test   $0x10,%bl
jne    129a <main+0x13a>
test   $0x1,%bl
jne    12b4 <main+0x154>
test   $0x2,%bl
je     11ee <main+0x8e>
mov    0x20(%rsp),%rsi
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0xe52(%rip),%r14
lea    0xdf3(%rip),%rbx
xor    %ebp,%ebp
jmp    1238 <main+0xd8>
xor    %eax,%eax
call   1060 <usage@plt>
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r14,%rdx
call   1070 <getopt@plt>
cmp    (%r12),%eax
je     118f <main+0x2f>
add    $0xffffff9f,%eax
cmp    $0x15,%eax
ja     1211 <main+0xb1>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
or     $0x1f,%ebp
jmp    1220 <main+0xc0>
or     $0x1,%ebp
jmp    1220 <main+0xc0>
or     $0x2,%ebp
jmp    1220 <main+0xc0>
or     $0x4,%ebp
jmp    1220 <main+0xc0>
or     $0x8,%ebp
jmp    1220 <main+0xc0>
or     $0x10,%ebp
jmp    1220 <main+0xc0>
mov    (%rsp),%rsi
lea    0xded(%rip),%rdi
call   1040 <printf@plt>
test   $0x4,%bl
je     11c6 <main+0x66>
mov    0x8(%rsp),%rsi
lea    0xdd3(%rip),%rdi
call   1040 <printf@plt>
test   $0x10,%bl
je     11cf <main+0x6f>
mov    0x10(%rsp),%rsi
lea    0xdb9(%rip),%rdi
call   1040 <printf@plt>
test   $0x1,%bl
je     11d8 <main+0x78>
mov    0x18(%rsp),%rsi
lea    0xd9f(%rip),%rdi
call   1040 <printf@plt>
test   $0x2,%bl
jne    11dd <main+0x7d>
jmp    11ee <main+0x8e>

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

LLVM IR (-O2):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@.str = [7 x i8] c"amnrsv\00"
@EOF = global i32 0
@optind = global i64 0
@.str.1 = [4 x i8] c"%s \00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.utsname
%4 = bitcast %struct.utsname* %3 to i8*
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %30, label %8
8: ; preds = %2, %25
%9 = phi i32 [ %27, %25 ], [ %5, %2 ]
%10 = phi i32 [ %26, %25 ], [ 0, %2 ]
switch i32 %9, label %23 [
i32 97, label %11
i32 109, label %13
i32 110, label %15
i32 114, label %17
i32 115, label %19
i32 118, label %21
]
11: ; preds = %8
%12 = or i32 %10, 31
br label %25
13: ; preds = %8
%14 = or i32 %10, 1
br label %25
15: ; preds = %8
%16 = or i32 %10, 2
br label %25
17: ; preds = %8
%18 = or i32 %10, 4
br label %25
19: ; preds = %8
%20 = or i32 %10, 8
br label %25
21: ; preds = %8
%22 = or i32 %10, 16
br label %25
23: ; preds = %8
%24 = tail call i32 (...) @usage()
br label %25
25: ; preds = %23, %21, %19, %17, %15, %13, %11
%26 = phi i32 [ %10, %23 ], [ %22, %21 ], [ %20, %19 ], [ %18, %17 ], [ %16, %15 ], [ %14, %13 ], [ %12, %11 ]
%27 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %8
30: ; preds = %25, %2
%31 = phi i32 [ 0, %2 ], [ %26, %25 ]
%32 = load i64, i64* @optind
%33 = trunc i64 %32 to i32
%34 = icmp eq i32 %33, %0
br i1 %34, label %37, label %35
35: ; preds = %30
%36 = tail call i32 (...) @usage()
br label %37
37: ; preds = %35, %30
%38 = icmp eq i32 %31, 0
%39 = select i1 %38, i32 8, i32 %31
%40 = call i32 @uname(%struct.utsname* %3)
%41 = and i32 %39, 8
%42 = icmp eq i32 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %37
%44 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 0
%45 = load i8*, i8** %44
%46 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %43, %37
%48 = and i32 %39, 4
%49 = icmp eq i32 %48, 0
br i1 %49, label %54, label %50
50: ; preds = %47
%51 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 1
%52 = load i8*, i8** %51
%53 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %50, %47
%55 = and i32 %39, 16
%56 = icmp eq i32 %55, 0
br i1 %56, label %61, label %57
57: ; preds = %54
%58 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 2
%59 = load i8*, i8** %58
%60 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %57, %54
%62 = and i32 %39, 1
%63 = icmp eq i32 %62, 0
br i1 %63, label %68, label %64
64: ; preds = %61
%65 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 3
%66 = load i8*, i8** %65
%67 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %66)
br label %68
68: ; preds = %64, %61
%69 = and i32 %39, 2
%70 = icmp eq i32 %69, 0
br i1 %70, label %75, label %71
71: ; preds = %68
%72 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 4
%73 = load i8*, i8** %72
%74 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %73)
br label %75
75: ; preds = %71, %68
%76 = tail call i32 @putchar(i8 signext 10)
%77 = tail call i32 @exit(i32 0)
unreachable
}