#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 in_addr {
  int s_addr;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int in_network(int, int, int);
scalar_t__ inet_aton(char *, struct in_addr *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  struct in_addr a, a1, n;
  char *ip = "192.168.31.1";
  char *netmask = "255.255.254.0";
  if (argc != 2) {
    fprintf(stderr, "%s <dotted-address>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if (inet_aton(argv[1], &a1) == 0) {
    perror("inet_aton");
    exit(EXIT_FAILURE);
  }
  if (inet_aton(ip, &a) == 0) {
    perror("inet_aton");
    exit(EXIT_FAILURE);
  }
  if (inet_aton(netmask, &n) == 0) {
    perror("inet_aton");
    exit(EXIT_FAILURE);
  }
  printf("%08x %08x %08x\n", a1.s_addr, a.s_addr, n.s_addr);
  printf("%d\n", in_network(a1.s_addr, a.s_addr, n.s_addr));
  exit(EXIT_SUCCESS);
}


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)
lea    0xe83(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe85(%rip),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11c0 <main+0x60>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe6e(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <inet_aton@plt>
cmp    $0x0,%rax
jne    11f5 <main+0x95>
lea    0xe4e(%rip),%rdi
call   1070 <perror@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x30(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <inet_aton@plt>
cmp    $0x0,%rax
jne    1226 <main+0xc6>
lea    0xe1d(%rip),%rdi
call   1070 <perror@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x38(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1060 <inet_aton@plt>
cmp    $0x0,%rax
jne    1257 <main+0xf7>
lea    0xdec(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x20(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1040 <in_network@plt>
mov    %eax,%esi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
cmp    $0x2,%edi
jne    11b4 <main+0x54>
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
call   1060 <inet_aton@plt>
test   %rax,%rax
je     11a6 <main+0x46>
lea    0xe7d(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1060 <inet_aton@plt>
test   %rax,%rax
je     11a6 <main+0x46>
lea    0xe74(%rip),%rdi
mov    %rsp,%rsi
call   1060 <inet_aton@plt>
test   %rax,%rax
jne    11da <main+0x7a>
lea    0xe83(%rip),%rdi
call   1070 <perror@plt>
jmp    11cc <main+0x6c>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe54(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x8(%rsp),%esi
mov    0x10(%rsp),%edx
mov    (%rsp),%ecx
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%edi
mov    0x10(%rsp),%esi
mov    (%rsp),%edx
call   1040 <in_network@plt>
lea    0xe40(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@.str = [13 x i8] c"192.168.31.1\00"
@.str.1 = [14 x i8] c"255.255.254.0\00"
@stderr = global i32 0
@.str.2 = [21 x i8] c"%s <dotted-address>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [10 x i8] c"inet_aton\00"
@.str.4 = [16 x i8] c"%08x %08x %08x\0A\00"
@.str.5 = [4 x i8] c"%d\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 %struct.in_addr
%7 = alloca %struct.in_addr
%8 = alloca %struct.in_addr
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %9
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %10
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %21
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @inet_aton(i8* %24, %struct.in_addr* %7)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %21
%32 = load i8*, i8** %9
%33 = call i64 @inet_aton(i8* %32, %struct.in_addr* %6)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %31
%40 = load i8*, i8** %10
%41 = call i64 @inet_aton(i8* %40, %struct.in_addr* %8)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
%46 = call i32 @exit(i32 %45)
unreachable
47: ; preds = %39
%48 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %7, i32 0, i32 0
%49 = load i32, i32* %48
%50 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
%51 = load i32, i32* %50
%52 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
%53 = load i32, i32* %52
%54 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %49, i32 %51, i32 %53)
%55 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %7, i32 0, i32 0
%56 = load i32, i32* %55
%57 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
%58 = load i32, i32* %57
%59 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
%60 = load i32, i32* %59
%61 = call i32 @in_network(i32 %56, i32 %58, i32 %60)
%62 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %61)
%63 = load i32, i32* @EXIT_SUCCESS
%64 = call i32 @exit(i32 %63)
unreachable
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
@.str = [13 x i8] c"192.168.31.1\00"
@.str.1 = [14 x i8] c"255.255.254.0\00"
@stderr = global i32 0
@.str.2 = [21 x i8] c"%s <dotted-address>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [10 x i8] c"inet_aton\00"
@.str.4 = [16 x i8] c"%08x %08x %08x\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.in_addr
%4 = alloca %struct.in_addr
%5 = alloca %struct.in_addr
%6 = bitcast %struct.in_addr* %3 to i8*
%7 = bitcast %struct.in_addr* %4 to i8*
%8 = bitcast %struct.in_addr* %5 to i8*
%9 = icmp eq i32 %0, 2
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i64 @inet_aton(i8* %18, %struct.in_addr* %4)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %16
%26 = call i64 @inet_aton(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %struct.in_addr* %3)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %25
%33 = call i64 @inet_aton(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), %struct.in_addr* %5)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %32
%40 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %4, i64 0, i32 0
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i64 0, i32 0
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %5, i64 0, i32 0
%45 = load i32, i32* %44
%46 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %41, i32 %43, i32 %45)
%47 = load i32, i32* %40
%48 = load i32, i32* %42
%49 = load i32, i32* %44
%50 = call i32 @in_network(i32 %47, i32 %48, i32 %49)
%51 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %50)
%52 = load i32, i32* @EXIT_SUCCESS
%53 = call i32 @exit(i32 %52)
unreachable
}