#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int cidr(int, int);
int class(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ format_ip(int, char *);
int /*<<< orphan*/ free(char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ help();
char *malloc(int);
int optind;
int optopt;
scalar_t__ parse_range(char *, int *, int *);
int /*<<< orphan*/ print_range(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int opt;
  char *range = NULL;
  uint32_t ip_from = 0;
  uint32_t ip_to = 0;
  unsigned char args = 0;
  if (argc <= 1) {
    usage();
  } else {
    while ((opt = getopt(argc, argv, "hcna")) != -1) {
      switch (opt) {
      case 'n':
        args |= 0x02;
        break;
      case 'c':
        args |= 0x04;
        break;
      case 'h':
        args |= 0x01;
        break;
      case 'a':
        args |= 0x08;
        break;
      case '?':
        printf("Unknown option -%c\n", optopt);
        usage();
        break;
      }
    }
    for (; optind < argc; optind++) {
      range = argv[optind];
      if (parse_range(range, &ip_from, &ip_to)) {
        if (ip_from > ip_to) {
          ip_from = ip_from ^ ip_to;
          ip_to = ip_from ^ ip_to;
          ip_from = ip_from ^ ip_to;
        }
      } else {
        exit(EXIT_FAILURE);
      }
      break;
    }
    if (args & 0x01) {
      help();
    } else {
      if (args & 0x02) {
        char *str = malloc(16);
        format_ip(ip_from, str);
        printf("CIDR:\t%s/%u\n", str, cidr(ip_from, ip_to));
        free(str);
      }
      if (args & 0x04) {
        printf("Class:\t%c\n", class(ip_from));
      }
      if (args & 0x08) {
        print_range(ip_from, ip_to);
      }
    }
  }
  exit(EXIT_SUCCESS);
}


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)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movb   $0x0,-0x29(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     1206 <main+0x46>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    13fc <main+0x23c>
jmp    120b <main+0x4b>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea7(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     12b2 <main+0xf2>
mov    -0x14(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x2f,%eax
ja     12ad <main+0xed>
mov    -0x40(%rbp),%rax
lea    0xdb6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movzbl -0x29(%rbp),%eax
or     $0x2,%eax
mov    %al,-0x29(%rbp)
jmp    12ad <main+0xed>
movzbl -0x29(%rbp),%eax
or     $0x4,%eax
mov    %al,-0x29(%rbp)
jmp    12ad <main+0xed>
movzbl -0x29(%rbp),%eax
or     $0x1,%eax
mov    %al,-0x29(%rbp)
jmp    12ad <main+0xed>
movzbl -0x29(%rbp),%eax
or     $0x8,%eax
mov    %al,-0x29(%rbp)
jmp    12ad <main+0xed>
mov    0x2d52(%rip),%rax
mov    (%rax),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1090 <usage@plt>
jmp    120b <main+0x4b>
jmp    12b7 <main+0xf7>
mov    0x2d22(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1339 <main+0x179>
mov    -0x10(%rbp),%rax
mov    0x2d0c(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1070 <parse_range@plt>
cmp    $0x0,%rax
je     1326 <main+0x166>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jle    1321 <main+0x161>
mov    -0x24(%rbp),%eax
xor    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
xor    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
xor    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1334 <main+0x174>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
jmp    1339 <main+0x179>
movzbl -0x29(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1355 <main+0x195>
mov    $0x0,%al
call   10c0 <help@plt>
jmp    13f7 <main+0x237>
movzbl -0x29(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     13af <main+0x1ef>
mov    $0x10,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x38(%rbp),%rsi
call   1040 <format_ip@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1050 <cidr@plt>
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movzbl -0x29(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     13d7 <main+0x217>
mov    -0x24(%rbp),%edi
call   10e0 <class@plt>
mov    %eax,%esi
lea    0xd16(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movzbl -0x29(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     13f2 <main+0x232>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   10a0 <print_range@plt>
jmp    13f7 <main+0x237>
jmp    13fc <main+0x23c>
mov    0x2bc5(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x10(%rsp)
movl   $0x0,0x14(%rsp)
cmp    $0x2,%edi
jge    11ef <main+0x2f>
xor    %eax,%eax
call   1090 <usage@plt>
jmp    138a <main+0x1ca>
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xec5(%rip),%r14
lea    0xdfe(%rip),%r13
mov    0x2ddf(%rip),%r12
lea    0xeb5(%rip),%r15
movl   $0x0,0xc(%rsp)
jmp    1225 <main+0x65>
nopw   0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
je     128b <main+0xcb>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10b0 <getopt@plt>
lea    -0x3f(%rax),%ecx
cmp    $0x2f,%ecx
ja     1220 <main+0x60>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
jmp    *%rax
mov    (%r12),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <usage@plt>
jmp    1225 <main+0x65>
mov    0xc(%rsp),%eax
or     $0x8,%al
mov    %eax,0xc(%rsp)
jmp    1225 <main+0x65>
mov    0xc(%rsp),%eax
or     $0x4,%al
mov    %eax,0xc(%rsp)
jmp    1225 <main+0x65>
mov    0xc(%rsp),%eax
or     $0x1,%al
mov    %eax,0xc(%rsp)
jmp    1225 <main+0x65>
mov    0xc(%rsp),%eax
or     $0x2,%al
mov    %eax,0xc(%rsp)
jmp    1225 <main+0x65>
mov    0x2d4e(%rip),%rax
movslq (%rax),%rax
xor    %r14d,%r14d
cmp    %ebp,%eax
mov    0xc(%rsp),%ebp
jge    12e1 <main+0x121>
mov    (%rbx,%rax,8),%rdi
lea    0x10(%rsp),%rsi
lea    0x14(%rsp),%rdx
call   1070 <parse_range@plt>
test   %rax,%rax
jne    12c6 <main+0x106>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    0x10(%rsp),%eax
mov    0x14(%rsp),%r14d
cmp    %r14d,%eax
jle    1376 <main+0x1b6>
mov    %eax,0x14(%rsp)
mov    %r14d,0x10(%rsp)
test   $0x1,%bpl
jne    1383 <main+0x1c3>
test   $0x2,%bpl
jne    1302 <main+0x142>
test   $0x4,%bpl
jne    1348 <main+0x188>
test   $0x8,%bpl
jne    1367 <main+0x1a7>
jmp    138a <main+0x1ca>
mov    $0x10,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %r14d,%edi
mov    %rax,%rsi
call   1040 <format_ip@plt>
mov    0x10(%rsp),%edi
mov    0x14(%rsp),%esi
call   1050 <cidr@plt>
lea    0xdab(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
test   $0x4,%bpl
je     12f7 <main+0x137>
mov    0x10(%rsp),%edi
call   10e0 <class@plt>
lea    0xd8e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
test   $0x8,%bpl
je     138a <main+0x1ca>
mov    0x10(%rsp),%edi
mov    0x14(%rsp),%esi
call   10a0 <print_range@plt>
jmp    138a <main+0x1ca>
mov    %eax,%r14d
test   $0x1,%bpl
je     12eb <main+0x12b>
xor    %eax,%eax
call   10c0 <help@plt>
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"hcna\00"
@.str.1 = [20 x i8] c"Unknown option -%c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [13 x i8] c"CIDR:\09%s/%u\0A\00"
@.str.3 = [11 x i8] c"Class:\09%c\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i32 0, i32* %8
store i32 0, i32* %9
store i8 0, i8* %10
%12 = load i32, i32* %4
%13 = icmp sle i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (...) @usage()
br label %129
16: ; preds = %2
br label %17
17: ; preds = %48, %16
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @getopt(i32 %18, i8** %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %20, i32* %6
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %49
22: ; preds = %17
%23 = load i32, i32* %6
switch i32 %23, label %48 [
i32 110, label %24
i32 99, label %29
i32 104, label %34
i32 97, label %39
i32 63, label %44
]
24: ; preds = %22
%25 = load i8, i8* %10
%26 = zext i8 %25 to i32
%27 = or i32 %26, 2
%28 = trunc i32 %27 to i8
store i8 %28, i8* %10
br label %48
29: ; preds = %22
%30 = load i8, i8* %10
%31 = zext i8 %30 to i32
%32 = or i32 %31, 4
%33 = trunc i32 %32 to i8
store i8 %33, i8* %10
br label %48
34: ; preds = %22
%35 = load i8, i8* %10
%36 = zext i8 %35 to i32
%37 = or i32 %36, 1
%38 = trunc i32 %37 to i8
store i8 %38, i8* %10
br label %48
39: ; preds = %22
%40 = load i8, i8* %10
%41 = zext i8 %40 to i32
%42 = or i32 %41, 8
%43 = trunc i32 %42 to i8
store i8 %43, i8* %10
br label %48
44: ; preds = %22
%45 = load i32, i32* @optopt
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %45)
%47 = call i32 (...) @usage()
br label %48
48: ; preds = %22, %44, %39, %34, %29, %24
br label %17
49: ; preds = %17
br label %50
50: ; preds = %82, %49
%51 = load i32, i32* @optind
%52 = load i32, i32* %4
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %85
54: ; preds = %50
%55 = load i8**, i8*** %5
%56 = load i32, i32* @optind
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
store i8* %59, i8** %7
%60 = load i8*, i8** %7
%61 = call i64 @parse_range(i8* %60, i32* %8, i32* %9)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %78
63: ; preds = %54
%64 = load i32, i32* %8
%65 = load i32, i32* %9
%66 = icmp sgt i32 %64, %65
br i1 %66, label %67, label %77
67: ; preds = %63
%68 = load i32, i32* %8
%69 = load i32, i32* %9
%70 = xor i32 %68, %69
store i32 %70, i32* %8
%71 = load i32, i32* %8
%72 = load i32, i32* %9
%73 = xor i32 %71, %72
store i32 %73, i32* %9
%74 = load i32, i32* %8
%75 = load i32, i32* %9
%76 = xor i32 %74, %75
store i32 %76, i32* %8
br label %77
77: ; preds = %67, %63
br label %81
78: ; preds = %54
%79 = load i32, i32* @EXIT_FAILURE
%80 = call i32 @exit(i32 %79)
unreachable
81: ; preds = %77
br label %85
82: ; No predecessors!
%83 = load i32, i32* @optind
%84 = add nsw i32 %83, 1
store i32 %84, i32* @optind
br label %50
85: ; preds = %81, %50
%86 = load i8, i8* %10
%87 = zext i8 %86 to i32
%88 = and i32 %87, 1
%89 = icmp ne i32 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %85
%91 = call i32 (...) @help()
br label %128
92: ; preds = %85
%93 = load i8, i8* %10
%94 = zext i8 %93 to i32
%95 = and i32 %94, 2
%96 = icmp ne i32 %95, 0
br i1 %96, label %97, label %109
97: ; preds = %92
%98 = call i8* @malloc(i32 16)
store i8* %98, i8** %11
%99 = load i32, i32* %8
%100 = load i8*, i8** %11
%101 = call i32 @format_ip(i32 %99, i8* %100)
%102 = load i8*, i8** %11
%103 = load i32, i32* %8
%104 = load i32, i32* %9
%105 = call i32 @cidr(i32 %103, i32 %104)
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %102, i32 %105)
%107 = load i8*, i8** %11
%108 = call i32 @free(i8* %107)
br label %109
109: ; preds = %97, %92
%110 = load i8, i8* %10
%111 = zext i8 %110 to i32
%112 = and i32 %111, 4
%113 = icmp ne i32 %112, 0
br i1 %113, label %114, label %118
114: ; preds = %109
%115 = load i32, i32* %8
%116 = call i32 @class(i32 %115)
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %116)
br label %118
118: ; preds = %114, %109
%119 = load i8, i8* %10
%120 = zext i8 %119 to i32
%121 = and i32 %120, 8
%122 = icmp ne i32 %121, 0
br i1 %122, label %123, label %127
123: ; preds = %118
%124 = load i32, i32* %8
%125 = load i32, i32* %9
%126 = call i32 @print_range(i32 %124, i32 %125)
br label %127
127: ; preds = %123, %118
br label %128
128: ; preds = %127, %90
br label %129
129: ; preds = %128, %14
%130 = load i32, i32* @EXIT_SUCCESS
%131 = call i32 @exit(i32 %130)
unreachable
}

LLVM IR (-O2):
@.str = [5 x i8] c"hcna\00"
@.str.1 = [20 x i8] c"Unknown option -%c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [13 x i8] c"CIDR:\09%s/%u\0A\00"
@.str.3 = [11 x i8] c"Class:\09%c\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %23
8: ; preds = %2
%9 = tail call i32 (...) @usage()
br label %78
10: ; preds = %12, %23
%11 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %11, label %12 [
i32 -1, label %29
i32 110, label %13
i32 99, label %15
i32 104, label %17
i32 97, label %19
i32 63, label %25
]
12: ; preds = %10, %25
br label %10
13: ; preds = %10
%14 = or i8 %24, 2
br label %21
15: ; preds = %10
%16 = or i8 %24, 4
br label %21
17: ; preds = %10
%18 = or i8 %24, 1
br label %21
19: ; preds = %10
%20 = or i8 %24, 8
br label %21
21: ; preds = %19, %17, %15, %13
%22 = phi i8 [ %14, %13 ], [ %16, %15 ], [ %18, %17 ], [ %20, %19 ]
br label %23
23: ; preds = %2, %21
%24 = phi i8 [ %22, %21 ], [ 0, %2 ]
br label %10
25: ; preds = %10
%26 = load i32, i32* @optopt
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = tail call i32 (...) @usage()
br label %12
29: ; preds = %10
%30 = load i32, i32* @optind
%31 = icmp slt i32 %30, %0
br i1 %31, label %32, label %46
32: ; preds = %29
%33 = sext i32 %30 to i64
%34 = getelementptr inbounds i8*, i8** %1, i64 %33
%35 = load i8*, i8** %34
%36 = call i64 @parse_range(i8* %35, i32* %3, i32* %4)
%37 = icmp eq i64 %36, 0
br i1 %37, label %43, label %38
38: ; preds = %32
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = icmp sgt i32 %39, %40
br i1 %41, label %42, label %46
42: ; preds = %38
store i32 %39, i32* %4
store i32 %40, i32* %3
br label %46
43: ; preds = %32
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %42, %38, %29
%47 = phi i32 [ %40, %42 ], [ %39, %38 ], [ 0, %29 ]
%48 = zext i8 %24 to i32
%49 = and i32 %48, 1
%50 = icmp eq i32 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %46
%52 = call i32 (...) @help()
br label %78
53: ; preds = %46
%54 = and i32 %48, 2
%55 = icmp eq i32 %54, 0
br i1 %55, label %64, label %56
56: ; preds = %53
%57 = call dereferenceable_or_null(16) i8* @malloc(i32 16)
%58 = call i32 @format_ip(i32 %47, i8* %57)
%59 = load i32, i32* %3
%60 = load i32, i32* %4
%61 = call i32 @cidr(i32 %59, i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %57, i32 %61)
%63 = call i32 @free(i8* %57)
br label %64
64: ; preds = %56, %53
%65 = and i32 %48, 4
%66 = icmp eq i32 %65, 0
br i1 %66, label %71, label %67
67: ; preds = %64
%68 = load i32, i32* %3
%69 = call i32 @class(i32 %68)
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %67, %64
%72 = and i32 %48, 8
%73 = icmp eq i32 %72, 0
br i1 %73, label %78, label %74
74: ; preds = %71
%75 = load i32, i32* %3
%76 = load i32, i32* %4
%77 = call i32 @print_range(i32 %75, i32 %76)
br label %78
78: ; preds = %51, %74, %71, %8
%79 = load i32, i32* @EXIT_SUCCESS
%80 = call i32 @exit(i32 %79)
unreachable
}