#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 */

/* Variables and functions */
scalar_t__ _uname(int, int, int, int, int);
int _usage();
int getopt(int, char **, char *);
int optind;
int main(int argc, char *argv[]) {
  int flagm = 0;
  int flagn = 0;
  int flagr = 0;
  int flags = 0;
  int flagv = 0;
  int o;
  while ((o = getopt(argc, argv, "amnrsv")) != -1)
    switch (o) {
    case 'a':
      flagm = 1;
      flagn = 1;
      flagr = 1;
      flags = 1;
      flagv = 1;
      break;
    case 'm':
      flagm = 1;
      break;
    case 'n':
      flagn = 1;
      break;
    case 'r':
      flagr = 1;
      break;
    case 's':
      flags = 1;
      break;
    case 'v':
      flagv = 1;
      break;
    default:
      return _usage();
    }
  if (optind != argc)
    return _usage();
  return _uname(flagm, flagn, flagr, flags, flagv) == 0 ? 0 : 2;
}


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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xee1(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
je     1229 <main+0xf9>
mov    -0x28(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x15,%eax
ja     1215 <main+0xe5>
mov    -0x30(%rbp),%rax
lea    0xe58(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    1224 <main+0xf4>
movl   $0x1,-0x14(%rbp)
jmp    1224 <main+0xf4>
movl   $0x1,-0x18(%rbp)
jmp    1224 <main+0xf4>
movl   $0x1,-0x1c(%rbp)
jmp    1224 <main+0xf4>
movl   $0x1,-0x20(%rbp)
jmp    1224 <main+0xf4>
movl   $0x1,-0x24(%rbp)
jmp    1224 <main+0xf4>
mov    $0x0,%al
call   1030 <_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1273 <main+0x143>
jmp    1169 <main+0x39>
mov    0x2db8(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
je     124a <main+0x11a>
mov    $0x0,%al
call   1030 <_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1273 <main+0x143>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
call   1040 <_uname@plt>
mov    %rax,%rdx
mov    $0x2,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-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
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0x14(%rsp)
lea    0xefa(%rip),%r14
lea    0xea7(%rip),%r12
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
xor    %r13d,%r13d
xor    %r15d,%r15d
mov    %r15d,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ecx,%r15d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
mov    $0x1,%ecx
cmp    $0x76,%eax
je     1180 <main+0x50>
lea    -0x61(%rax),%ecx
cmp    $0x12,%ecx
ja     11fa <main+0xca>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
movl   $0x1,0x14(%rsp)
movl   $0x1,0x10(%rsp)
movl   $0x1,0xc(%rsp)
mov    $0x1,%r13d
mov    $0x1,%r15d
jmp    116f <main+0x3f>
movl   $0x1,0x10(%rsp)
jmp    116f <main+0x3f>
movl   $0x1,0xc(%rsp)
jmp    116f <main+0x3f>
movl   $0x1,0x14(%rsp)
jmp    116f <main+0x3f>
mov    $0x1,%r13d
jmp    116f <main+0x3f>
cmp    $0xffffffff,%eax
jne    123c <main+0x10c>
mov    0x2de2(%rip),%rax
cmp    %ebp,(%rax)
jne    123c <main+0x10c>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x14(%rsp),%edx
mov    %r13d,%ecx
mov    %r15d,%r8d
call   1040 <_uname@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
add    %ecx,%ecx
mov    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <_usage@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"amnrsv\00"
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
br label %12
12: ; preds = %27, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %11
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %28
17: ; preds = %12
%18 = load i32, i32* %11
switch i32 %18, label %25 [
i32 97, label %19
i32 109, label %20
i32 110, label %21
i32 114, label %22
i32 115, label %23
i32 118, label %24
]
19: ; preds = %17
store i32 1, i32* %6
store i32 1, i32* %7
store i32 1, i32* %8
store i32 1, i32* %9
store i32 1, i32* %10
br label %27
20: ; preds = %17
store i32 1, i32* %6
br label %27
21: ; preds = %17
store i32 1, i32* %7
br label %27
22: ; preds = %17
store i32 1, i32* %8
br label %27
23: ; preds = %17
store i32 1, i32* %9
br label %27
24: ; preds = %17
store i32 1, i32* %10
br label %27
25: ; preds = %17
%26 = call i32 (...) @_usage()
store i32 %26, i32* %3
br label %44
27: ; preds = %24, %23, %22, %21, %20, %19
br label %12
28: ; preds = %12
%29 = load i32, i32* @optind
%30 = load i32, i32* %4
%31 = icmp ne i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 (...) @_usage()
store i32 %33, i32* %3
br label %44
34: ; preds = %28
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = load i32, i32* %9
%39 = load i32, i32* %10
%40 = call i64 @_uname(i32 %35, i32 %36, i32 %37, i32 %38, i32 %39)
%41 = icmp eq i64 %40, 0
%42 = zext i1 %41 to i64
%43 = select i1 %41, i32 0, i32 2
store i32 %43, i32* %3
br label %44
44: ; preds = %34, %32, %25
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [7 x i8] c"amnrsv\00"
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %25, %2
%4 = phi i32 [ 0, %2 ], [ 1, %25 ]
%5 = phi i32 [ 0, %2 ], [ %26, %25 ]
%6 = phi i32 [ 0, %2 ], [ %27, %25 ]
%7 = phi i32 [ 0, %2 ], [ %28, %25 ]
%8 = phi i32 [ 0, %2 ], [ %29, %25 ]
br label %9
9: ; preds = %21, %3
%10 = phi i32 [ %5, %3 ], [ 1, %21 ]
%11 = phi i32 [ %6, %3 ], [ %15, %21 ]
%12 = phi i32 [ %7, %3 ], [ %19, %21 ]
%13 = phi i32 [ %8, %3 ], [ %22, %21 ]
br label %14
14: ; preds = %21, %9
%15 = phi i32 [ %11, %9 ], [ 1, %21 ]
%16 = phi i32 [ %12, %9 ], [ %19, %21 ]
%17 = phi i32 [ %13, %9 ], [ %22, %21 ]
br label %18
18: ; preds = %21, %14
%19 = phi i32 [ %16, %14 ], [ 1, %21 ]
%20 = phi i32 [ %17, %14 ], [ %22, %21 ]
br label %21
21: ; preds = %21, %18
%22 = phi i32 [ %20, %18 ], [ 1, %21 ]
%23 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %23, label %30 [
i32 -1, label %32
i32 97, label %25
i32 109, label %24
i32 110, label %9
i32 114, label %14
i32 115, label %18
i32 118, label %21
]
24: ; preds = %21
br label %25
25: ; preds = %21, %24
%26 = phi i32 [ %10, %24 ], [ 1, %21 ]
%27 = phi i32 [ %15, %24 ], [ 1, %21 ]
%28 = phi i32 [ %19, %24 ], [ 1, %21 ]
%29 = phi i32 [ %22, %24 ], [ 1, %21 ]
br label %3
30: ; preds = %21
%31 = tail call i32 (...) @_usage()
br label %41
32: ; preds = %21
%33 = load i32, i32* @optind
%34 = icmp eq i32 %33, %0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = tail call i32 (...) @_usage()
br label %41
37: ; preds = %32
%38 = tail call i64 @_uname(i32 %4, i32 %10, i32 %15, i32 %19, i32 %22)
%39 = icmp eq i64 %38, 0
%40 = select i1 %39, i32 0, i32 2
br label %41
41: ; preds = %37, %35, %30
%42 = phi i32 [ %31, %30 ], [ %36, %35 ], [ %40, %37 ]
ret i32 %42
}