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

/* Variables and functions */
int /*<<< orphan*/ free(struct utsname *);
int getopt(int, char **, char *);
struct utsname *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ uname(struct utsname *);
int main(int argc, char **argv) {
  struct utsname *buf = malloc(sizeof(struct utsname));
  uname(buf);
  if (argc == 1) {
    printf("%s\n", buf->sysname);
    free(buf);
    return 0;
  }
  extern char *optarg;
  extern int optind;
  if (argc >= 2) {
    int c = 0;
    while ((c = getopt(argc, argv, "asnrvmpio")) != -1) {
      switch (c) {
      case 'a':
        printf("%s %s %s %s %s", buf->sysname, buf->nodename, buf->release,
               buf->version, buf->machine);
        break;
      case 's':
        printf("%s ", buf->sysname);
        break;
      case 'n':
        printf("%s ", buf->nodename);
        break;
      case 'r':
        printf("%s ", buf->release);
        break;
      case 'v':
        printf("%s ", buf->version);
        break;
      case 'm':
        printf("%s ", buf->machine);
        break;
      case 'p':
        printf("unknown ");
        break;
      case 'i':
        printf("unknown");
        break;
      case 'o':
        printf("%s ", buf->sysname);
        break;
      }
    }
    printf("\n");
  }
  free(buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <uname@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11b1 <main+0x61>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    1328 <main+0x1d8>
cmpl   $0x2,-0x8(%rbp)
jl     1318 <main+0x1c8>
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe8c(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     130a <main+0x1ba>
mov    -0x1c(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x15,%eax
ja     1305 <main+0x1b5>
mov    -0x28(%rbp),%rax
lea    0xdff(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rcx
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%r8
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%r9
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1305 <main+0x1b5>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1305 <main+0x1b5>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1305 <main+0x1b5>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1305 <main+0x1b5>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1305 <main+0x1b5>
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rsi
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1305 <main+0x1b5>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1305 <main+0x1b5>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1305 <main+0x1b5>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c2 <main+0x72>
lea    0xd49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
mov    $0x28,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <uname@plt>
cmp    $0x1,%ebp
jne    11a7 <main+0x37>
mov    (%rbx),%rdi
call   1050 <puts@plt>
jmp    1253 <main+0xe3>
jle    1253 <main+0xe3>
lea    0xea4(%rip),%r15
lea    0xe45(%rip),%r13
lea    0xeaf(%rip),%r12
jmp    11d1 <main+0x61>
mov    (%rbx),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1090 <getopt@plt>
lea    -0x61(%rax),%ecx
cmp    $0x15,%ecx
ja     1244 <main+0xd4>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
jmp    *%rax
mov    (%rbx),%rsi
mov    0x8(%rbx),%rdx
mov    0x10(%rbx),%rcx
mov    0x18(%rbx),%r8
mov    0x20(%rbx),%r9
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11d1 <main+0x61>
lea    0xe64(%rip),%rdi
jmp    122f <main+0xbf>
mov    0x20(%rbx),%rsi
jmp    11c7 <main+0x57>
mov    0x8(%rbx),%rsi
jmp    11c7 <main+0x57>
lea    0xe46(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11d1 <main+0x61>
mov    0x10(%rbx),%rsi
jmp    11c7 <main+0x57>
mov    0x18(%rbx),%rsi
jmp    11c7 <main+0x57>
cmp    $0xffffffff,%eax
jne    11d1 <main+0x61>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%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* }
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [10 x i8] c"asnrvmpio\00"
@.str.2 = [15 x i8] c"%s %s %s %s %s\00"
@.str.3 = [4 x i8] c"%s \00"
@.str.4 = [9 x i8] c"unknown \00"
@.str.5 = [8 x i8] c"unknown\00"
@.str.6 = [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 %struct.utsname* @malloc(i32 40)
store %struct.utsname* %8, %struct.utsname** %6
%9 = load %struct.utsname*, %struct.utsname** %6
%10 = call i32 @uname(%struct.utsname* %9)
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load %struct.utsname*, %struct.utsname** %6
%15 = getelementptr inbounds %struct.utsname, %struct.utsname* %14, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load %struct.utsname*, %struct.utsname** %6
%19 = call i32 @free(%struct.utsname* %18)
store i32 0, i32* %3
br label %88
20: ; preds = %2
%21 = load i32, i32* %4
%22 = icmp sge i32 %21, 2
br i1 %22, label %23, label %85
23: ; preds = %20
store i32 0, i32* %7
br label %24
24: ; preds = %82, %23
%25 = load i32, i32* %4
%26 = load i8**, i8*** %5
%27 = call i32 @getopt(i32 %25, i8** %26, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 %27, i32* %7
%28 = icmp ne i32 %27, -1
br i1 %28, label %29, label %83
29: ; preds = %24
%30 = load i32, i32* %7
switch i32 %30, label %82 [
i32 97, label %31
i32 115, label %48
i32 110, label %53
i32 114, label %58
i32 118, label %63
i32 109, label %68
i32 112, label %73
i32 105, label %75
i32 111, label %77
]
31: ; preds = %29
%32 = load %struct.utsname*, %struct.utsname** %6
%33 = getelementptr inbounds %struct.utsname, %struct.utsname* %32, i32 0, i32 0
%34 = load i8*, i8** %33
%35 = load %struct.utsname*, %struct.utsname** %6
%36 = getelementptr inbounds %struct.utsname, %struct.utsname* %35, i32 0, i32 1
%37 = load i8*, i8** %36
%38 = load %struct.utsname*, %struct.utsname** %6
%39 = getelementptr inbounds %struct.utsname, %struct.utsname* %38, i32 0, i32 2
%40 = load i8*, i8** %39
%41 = load %struct.utsname*, %struct.utsname** %6
%42 = getelementptr inbounds %struct.utsname, %struct.utsname* %41, i32 0, i32 3
%43 = load i8*, i8** %42
%44 = load %struct.utsname*, %struct.utsname** %6
%45 = getelementptr inbounds %struct.utsname, %struct.utsname* %44, i32 0, i32 4
%46 = load i8*, i8** %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* %37, i8* %40, i8* %43, i8* %46)
br label %82
48: ; preds = %29
%49 = load %struct.utsname*, %struct.utsname** %6
%50 = getelementptr inbounds %struct.utsname, %struct.utsname* %49, i32 0, i32 0
%51 = load i8*, i8** %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %51)
br label %82
53: ; preds = %29
%54 = load %struct.utsname*, %struct.utsname** %6
%55 = getelementptr inbounds %struct.utsname, %struct.utsname* %54, i32 0, i32 1
%56 = load i8*, i8** %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %56)
br label %82
58: ; preds = %29
%59 = load %struct.utsname*, %struct.utsname** %6
%60 = getelementptr inbounds %struct.utsname, %struct.utsname* %59, i32 0, i32 2
%61 = load i8*, i8** %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %61)
br label %82
63: ; preds = %29
%64 = load %struct.utsname*, %struct.utsname** %6
%65 = getelementptr inbounds %struct.utsname, %struct.utsname* %64, i32 0, i32 3
%66 = load i8*, i8** %65
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %66)
br label %82
68: ; preds = %29
%69 = load %struct.utsname*, %struct.utsname** %6
%70 = getelementptr inbounds %struct.utsname, %struct.utsname* %69, i32 0, i32 4
%71 = load i8*, i8** %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %71)
br label %82
73: ; preds = %29
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %82
75: ; preds = %29
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %82
77: ; preds = %29
%78 = load %struct.utsname*, %struct.utsname** %6
%79 = getelementptr inbounds %struct.utsname, %struct.utsname* %78, i32 0, i32 0
%80 = load i8*, i8** %79
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %80)
br label %82
82: ; preds = %29, %77, %75, %73, %68, %63, %58, %53, %48, %31
br label %24
83: ; preds = %24
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %85
85: ; preds = %83, %20
%86 = load %struct.utsname*, %struct.utsname** %6
%87 = call i32 @free(%struct.utsname* %86)
store i32 0, i32* %3
br label %88
88: ; preds = %85, %13
%89 = load i32, i32* %3
ret i32 %89
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@.str.1 = [10 x i8] c"asnrvmpio\00"
@.str.2 = [15 x i8] c"%s %s %s %s %s\00"
@.str.3 = [4 x i8] c"%s \00"
@.str.4 = [9 x i8] c"unknown \00"
@.str.5 = [8 x i8] c"unknown\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call %struct.utsname* @malloc(i32 40)
%4 = tail call i32 @uname(%struct.utsname* %3)
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 0
%8 = load i8*, i8** %7
%9 = tail call i32 @puts(i8* dereferenceable(1) %8)
br label %52
10: ; preds = %2
%11 = icmp sgt i32 %0, 1
br i1 %11, label %12, label %52
12: ; preds = %10
%13 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 0
%14 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 4
%15 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 3
%16 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 2
%17 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 1
br label %18
18: ; preds = %20, %12
%19 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
switch i32 %19, label %20 [
i32 -1, label %50
i32 97, label %21
i32 115, label %28
i32 110, label %31
i32 114, label %34
i32 118, label %37
i32 109, label %40
i32 112, label %43
i32 105, label %45
i32 111, label %47
]
20: ; preds = %18, %47, %45, %43, %40, %37, %34, %31, %28, %21
br label %18
21: ; preds = %18
%22 = load i8*, i8** %13
%23 = load i8*, i8** %17
%24 = load i8*, i8** %16
%25 = load i8*, i8** %15
%26 = load i8*, i8** %14
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %22, i8* %23, i8* %24, i8* %25, i8* %26)
br label %20
28: ; preds = %18
%29 = load i8*, i8** %13
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %29)
br label %20
31: ; preds = %18
%32 = load i8*, i8** %17
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %32)
br label %20
34: ; preds = %18
%35 = load i8*, i8** %16
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %35)
br label %20
37: ; preds = %18
%38 = load i8*, i8** %15
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %38)
br label %20
40: ; preds = %18
%41 = load i8*, i8** %14
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %41)
br label %20
43: ; preds = %18
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %20
45: ; preds = %18
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %20
47: ; preds = %18
%48 = load i8*, i8** %13
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %48)
br label %20
50: ; preds = %18
%51 = tail call i32 @putchar(i32 10)
br label %52
52: ; preds = %10, %50, %6
%53 = tail call i32 @free(%struct.utsname* %3)
ret i32 0
}