#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 */
int atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ zget_broadcast(int, int);
int /*<<< orphan*/ zget_ip_max(int, int);
int /*<<< orphan*/ zget_ip_min(int, int);
int zget_ipint(char *);
char *zget_ipstring(int /*<<< orphan*/, char *);
int /*<<< orphan*/ zget_netmask(int);
int /*<<< orphan*/ zget_network(int, int);
scalar_t__ zip_is_intranet(int);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("USAGE: %s ip [ mask-length ]\n", argv[0]);
    return 1;
  }
  char *ipstr = argv[1];
  int masklen = 32;
  int ipint;
  if (argc > 2) {
    masklen = atoi(argv[2]);
  }
  printf("输入: %s %d\n\n", ipstr, masklen);
  ipint = zget_ipint(ipstr);
  printf("ipint: %u\n", (unsigned int)ipint);
  printf("masklen: %d\n", masklen);
  if (masklen == -1) {
    return 0;
  }
  if ((masklen < 1) || (masklen > 32)) {
    printf("ERR unknown mask-length: %s\n", argv[2]);
    return 1;
  }
  char ipbuf[20];
  printf("网络地址: %s\n", zget_ipstring(zget_network(ipint, masklen), ipbuf));
  printf("子网掩码: %s\n", zget_ipstring(zget_netmask(masklen), ipbuf));
  printf("广播地址: %s\n",
         zget_ipstring(zget_broadcast(ipint, masklen), ipbuf));
  printf("最小地址: %s\n", zget_ipstring(zget_ip_min(ipint, masklen), ipbuf));
  printf("最大地址: %s\n", zget_ipstring(zget_ip_max(ipint, masklen), ipbuf));
  printf("保留地址: %s\n", zip_is_intranet(ipint) ? "yes" : "no");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11e1 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1393 <main+0x1f3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x20,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    120e <main+0x6e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10c0 <zget_ipint@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1267 <main+0xc7>
movl   $0x0,-0x4(%rbp)
jmp    1393 <main+0x1f3>
cmpl   $0x1,-0x1c(%rbp)
jl     127b <main+0xdb>
cmpl   $0x20,-0x1c(%rbp)
jle    129d <main+0xfd>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1393 <main+0x1f3>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <zget_network@plt>
mov    %eax,%edi
lea    -0x40(%rbp),%rsi
call   10a0 <zget_ipstring@plt>
mov    %rax,%rsi
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1050 <zget_netmask@plt>
mov    %eax,%edi
lea    -0x40(%rbp),%rsi
call   10a0 <zget_ipstring@plt>
mov    %rax,%rsi
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1090 <zget_broadcast@plt>
mov    %eax,%edi
lea    -0x40(%rbp),%rsi
call   10a0 <zget_ipstring@plt>
mov    %rax,%rsi
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1070 <zget_ip_min@plt>
mov    %eax,%edi
lea    -0x40(%rbp),%rsi
call   10a0 <zget_ipstring@plt>
mov    %rax,%rsi
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1080 <zget_ip_max@plt>
mov    %eax,%edi
lea    -0x40(%rbp),%rsi
call   10a0 <zget_ipstring@plt>
mov    %rax,%rsi
lea    0xd55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
call   1060 <zip_is_intranet@plt>
mov    %rax,%rcx
lea    0xd64(%rip),%rsi
lea    0xd59(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%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,%rbp
cmp    $0x1,%edi
jg     11c3 <main+0x23>
mov    0x0(%rbp),%rsi
lea    0xe3f(%rip),%rdi
jmp    123f <main+0x9f>
mov    0x8(%rbp),%rbx
mov    $0x20,%r13d
cmp    $0x2,%edi
je     11de <main+0x3e>
mov    0x10(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,%r13d
lea    0xe39(%rip),%rdi
xor    %r12d,%r12d
mov    %rbx,%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   10c0 <zget_ipint@plt>
mov    %eax,%r14d
lea    0xe27(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe22(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xffffffff,%r13d
je     133d <main+0x19d>
lea    -0x21(%r13),%eax
cmp    $0xffffffdf,%eax
ja     1251 <main+0xb1>
mov    0x10(%rbp),%rsi
lea    0xe07(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r12d
jmp    133d <main+0x19d>
mov    %r14d,%edi
mov    %r13d,%esi
call   1030 <zget_network@plt>
mov    %rsp,%r15
mov    %eax,%edi
mov    %r15,%rsi
call   10a0 <zget_ipstring@plt>
lea    0xdf3(%rip),%rdi
xor    %r12d,%r12d
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%edi
call   1050 <zget_netmask@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   10a0 <zget_ipstring@plt>
lea    0xddf(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%edi
mov    %r13d,%esi
call   1090 <zget_broadcast@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   10a0 <zget_ipstring@plt>
lea    0xdcb(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%edi
mov    %r13d,%esi
call   1070 <zget_ip_min@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   10a0 <zget_ipstring@plt>
lea    0xdb7(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%edi
mov    %r13d,%esi
call   1080 <zget_ip_max@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   10a0 <zget_ipstring@plt>
lea    0xda3(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%edi
call   1060 <zip_is_intranet@plt>
test   %rax,%rax
lea    0xdaf(%rip),%rax
lea    0xda4(%rip),%rsi
cmove  %rax,%rsi
lea    0xd87(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"USAGE: %s ip [ mask-length ]\0A\00"
@.str.1 = [16 x i8] c"\E8\BE\93\E5\85\A5: %s %d\0A\0A\00"
@.str.2 = [11 x i8] c"ipint: %u\0A\00"
@.str.3 = [13 x i8] c"masklen: %d\0A\00"
@.str.4 = [29 x i8] c"ERR unknown mask-length: %s\0A\00"
@.str.5 = [18 x i8] c"\E7\BD\91\E7\BB\9C\E5\9C\B0\E5\9D\80: %s\0A\00"
@.str.6 = [18 x i8] c"\E5\AD\90\E7\BD\91\E6\8E\A9\E7\A0\81: %s\0A\00"
@.str.7 = [18 x i8] c"\E5\B9\BF\E6\92\AD\E5\9C\B0\E5\9D\80: %s\0A\00"
@.str.8 = [18 x i8] c"\E6\9C\80\E5\B0\8F\E5\9C\B0\E5\9D\80: %s\0A\00"
@.str.9 = [18 x i8] c"\E6\9C\80\E5\A4\A7\E5\9C\B0\E5\9D\80: %s\0A\00"
@.str.10 = [18 x i8] c"\E4\BF\9D\E7\95\99\E5\9C\B0\E5\9D\80: %s\0A\00"
@.str.11 = [4 x i8] c"yes\00"
@.str.12 = [3 x i8] c"no\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %88
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %6
store i32 32, i32* %7
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 2
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %7
br label %28
28: ; preds = %23, %17
%29 = load i8*, i8** %6
%30 = load i32, i32* %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %29, i32 %30)
%32 = load i8*, i8** %6
%33 = call i32 @zget_ipint(i8* %32)
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %41
40: ; preds = %28
store i32 0, i32* %3
br label %88
41: ; preds = %28
%42 = load i32, i32* %7
%43 = icmp slt i32 %42, 1
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load i32, i32* %7
%46 = icmp sgt i32 %45, 32
br i1 %46, label %47, label %52
47: ; preds = %44, %41
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %50)
store i32 1, i32* %3
br label %88
52: ; preds = %44
%53 = load i32, i32* %8
%54 = load i32, i32* %7
%55 = call i32 @zget_network(i32 %53, i32 %54)
%56 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%57 = call i8* @zget_ipstring(i32 %55, i8* %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %57)
%59 = load i32, i32* %7
%60 = call i32 @zget_netmask(i32 %59)
%61 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%62 = call i8* @zget_ipstring(i32 %60, i8* %61)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %62)
%64 = load i32, i32* %8
%65 = load i32, i32* %7
%66 = call i32 @zget_broadcast(i32 %64, i32 %65)
%67 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%68 = call i8* @zget_ipstring(i32 %66, i8* %67)
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %68)
%70 = load i32, i32* %8
%71 = load i32, i32* %7
%72 = call i32 @zget_ip_min(i32 %70, i32 %71)
%73 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%74 = call i8* @zget_ipstring(i32 %72, i8* %73)
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* %74)
%76 = load i32, i32* %8
%77 = load i32, i32* %7
%78 = call i32 @zget_ip_max(i32 %76, i32 %77)
%79 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%80 = call i8* @zget_ipstring(i32 %78, i8* %79)
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %80)
%82 = load i32, i32* %8
%83 = call i64 @zip_is_intranet(i32 %82)
%84 = icmp ne i64 %83, 0
%85 = zext i1 %84 to i64
%86 = select i1 %84, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0)
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %86)
store i32 0, i32* %3
br label %88
88: ; preds = %52, %47, %40, %12
%89 = load i32, i32* %3
ret i32 %89
}

LLVM IR (-O2):
@.str = [30 x i8] c"USAGE: %s ip [ mask-length ]\0A\00"
@.str.1 = [16 x i8] c"\E8\BE\93\E5\85\A5: %s %d\0A\0A\00"
@.str.2 = [11 x i8] c"ipint: %u\0A\00"
@.str.3 = [13 x i8] c"masklen: %d\0A\00"
@.str.4 = [29 x i8] c"ERR unknown mask-length: %s\0A\00"
@.str.5 = [18 x i8] c"\E7\BD\91\E7\BB\9C\E5\9C\B0\E5\9D\80: %s\0A\00"
@.str.6 = [18 x i8] c"\E5\AD\90\E7\BD\91\E6\8E\A9\E7\A0\81: %s\0A\00"
@.str.7 = [18 x i8] c"\E5\B9\BF\E6\92\AD\E5\9C\B0\E5\9D\80: %s\0A\00"
@.str.8 = [18 x i8] c"\E6\9C\80\E5\B0\8F\E5\9C\B0\E5\9D\80: %s\0A\00"
@.str.9 = [18 x i8] c"\E6\9C\80\E5\A4\A7\E5\9C\B0\E5\9D\80: %s\0A\00"
@.str.10 = [18 x i8] c"\E4\BF\9D\E7\95\99\E5\9C\B0\E5\9D\80: %s\0A\00"
@.str.11 = [4 x i8] c"yes\00"
@.str.12 = [3 x i8] c"no\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %51
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = icmp eq i32 %0, 2
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
br label %16
16: ; preds = %12, %8
%17 = phi i32 [ %15, %12 ], [ 32, %8 ]
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 %17)
%19 = tail call i32 @zget_ipint(i8* %10)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%22 = icmp eq i32 %17, -1
br i1 %22, label %51, label %23
23: ; preds = %16
%24 = add i32 %17, -33
%25 = icmp ult i32 %24, -32
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %28)
br label %51
30: ; preds = %23
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%32 = tail call i32 @zget_network(i32 %19, i32 %17)
%33 = call i8* @zget_ipstring(i32 %32, i8* %31)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %33)
%35 = call i32 @zget_netmask(i32 %17)
%36 = call i8* @zget_ipstring(i32 %35, i8* %31)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %36)
%38 = call i32 @zget_broadcast(i32 %19, i32 %17)
%39 = call i8* @zget_ipstring(i32 %38, i8* %31)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %39)
%41 = call i32 @zget_ip_min(i32 %19, i32 %17)
%42 = call i8* @zget_ipstring(i32 %41, i8* %31)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* %42)
%44 = call i32 @zget_ip_max(i32 %19, i32 %17)
%45 = call i8* @zget_ipstring(i32 %44, i8* %31)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %45)
%47 = call i64 @zip_is_intranet(i32 %19)
%48 = icmp eq i64 %47, 0
%49 = select i1 %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %26, %30, %16, %5
%52 = phi i32 [ 1, %5 ], [ 1, %26 ], [ 0, %30 ], [ 0, %16 ]
ret i32 %52
}