#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 /*<<< orphan*/ IP2Int(char *, unsigned long *);
int /*<<< orphan*/ printf(char *, char *, char *);
int checkip(char *ip_str, char *net_str, char *mask_str) {
  unsigned long ip;
  unsigned long net;
  unsigned long mask;
  IP2Int(ip_str, &ip);
  IP2Int(net_str, &net);
  IP2Int(mask_str, &mask);
  if ((ip & mask) == (net & mask)) {
    printf(" %s\tappartente alla rete\t\t%s\n", ip_str, net_str);
    return 1;
  } else {
    printf(" %s\tNON appartente alla rete\t%s\n", ip_str, net_str);
    return 0;
  }
}


x86 assembly (clang, -O0):
<checkip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <IP2Int@plt>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <IP2Int@plt>
mov    -0x20(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <IP2Int@plt>
mov    -0x28(%rbp),%rax
and    -0x38(%rbp),%rax
mov    -0x30(%rbp),%rcx
and    -0x38(%rbp),%rcx
cmp    %rcx,%rax
jne    1194 <checkip+0x74>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11af <checkip+0x8f>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkip>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x10(%rsp),%rsi
call   1030 <IP2Int@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1030 <IP2Int@plt>
mov    %rsp,%rsi
mov    %r15,%rdi
call   1030 <IP2Int@plt>
mov    0x8(%rsp),%rax
xor    0x10(%rsp),%rax
xor    %ebp,%ebp
and    (%rsp),%rax
sete   %bpl
lea    0xe90(%rip),%rax
lea    0xea7(%rip),%rdi
cmove  %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c" %s\09appartente alla rete\09\09%s\0A\00"
@.str.1 = [33 x i8] c" %s\09NON appartente alla rete\09%s\0A\00"
define i32 @checkip(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%11 = load i8*, i8** %5
%12 = call i32 @IP2Int(i8* %11, i64* %8)
%13 = load i8*, i8** %6
%14 = call i32 @IP2Int(i8* %13, i64* %9)
%15 = load i8*, i8** %7
%16 = call i32 @IP2Int(i8* %15, i64* %10)
%17 = load i64, i64* %8
%18 = load i64, i64* %10
%19 = and i64 %17, %18
%20 = load i64, i64* %9
%21 = load i64, i64* %10
%22 = and i64 %20, %21
%23 = icmp eq i64 %19, %22
br i1 %23, label %24, label %28
24: ; preds = %3
%25 = load i8*, i8** %5
%26 = load i8*, i8** %6
%27 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %25, i8* %26)
store i32 1, i32* %4
br label %32
28: ; preds = %3
%29 = load i8*, i8** %5
%30 = load i8*, i8** %6
%31 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %30)
store i32 0, i32* %4
br label %32
32: ; preds = %28, %24
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@.str = [30 x i8] c" %s\09appartente alla rete\09\09%s\0A\00"
@.str.1 = [33 x i8] c" %s\09NON appartente alla rete\09%s\0A\00"
define i32 @checkip(i8* %0, i8* %1, i8* %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = bitcast i64* %4 to i8*
%8 = bitcast i64* %5 to i8*
%9 = bitcast i64* %6 to i8*
%10 = call i32 @IP2Int(i8* %0, i64* %4)
%11 = call i32 @IP2Int(i8* %1, i64* %5)
%12 = call i32 @IP2Int(i8* %2, i64* %6)
%13 = load i64, i64* %4
%14 = load i64, i64* %6
%15 = load i64, i64* %5
%16 = xor i64 %15, %13
%17 = and i64 %16, %14
%18 = icmp eq i64 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0)
%20 = zext i1 %18 to i32
%21 = call i32 @printf(i8* %19, i8* %0, i8* %1)
ret i32 %20
}