#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 */
char *in_netrange(uint32_t ip, uint32_t ifip, uint32_t ifmask) {
  if ((ip & ifmask) != (ifip & ifmask))
    return (char *)"Error: the IP address is not in the interface range\n";
  else if ((ip & ifmask) == ip)
    return (char *)"Error: the IP address is a network address\n";
  else if ((ip | ~ifmask) == ip)
    return (char *)"Error: the IP address is a network address\n";
  return NULL;
}


x86 assembly (clang, -O0):
<in_netrange>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
and    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
and    -0x14(%rbp),%ecx
cmp    %ecx,%eax
je     1131 <in_netrange+0x31>
lea    0xed8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1186 <in_netrange+0x86>
mov    -0xc(%rbp),%eax
and    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1150 <in_netrange+0x50>
lea    0xeee(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1186 <in_netrange+0x86>
mov    -0xc(%rbp),%eax
mov    -0x14(%rbp),%ecx
xor    $0xffffffff,%ecx
or     %ecx,%eax
cmp    -0xc(%rbp),%eax
jne    1174 <in_netrange+0x74>
lea    0xeca(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1186 <in_netrange+0x86>
jmp    1179 <in_netrange+0x79>
jmp    117e <in_netrange+0x7e>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<in_netrange>:
mov    %edx,%eax
and    %edi,%eax
and    %edx,%esi
cmp    %esi,%eax
jne    1116 <in_netrange+0x16>
cmp    %edi,%eax
jne    111e <in_netrange+0x1e>
lea    0xf20(%rip),%rax
ret
lea    0xee3(%rip),%rax
ret
not    %edx
not    %edi
xor    %eax,%eax
test   %edx,%edi
lea    0xf08(%rip),%rcx
cmove  %rcx,%rax
ret

LLVM IR (-O0):
@.str = [53 x i8] c"Error: the IP address is not in the interface range\0A\00"
@.str.1 = [44 x i8] c"Error: the IP address is a network address\0A\00"
define i8* @in_netrange(i32 %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %5
%9 = load i32, i32* %7
%10 = and i32 %8, %9
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = and i32 %11, %12
%14 = icmp ne i32 %10, %13
br i1 %14, label %15, label %16
15: ; preds = %3
store i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8** %4
br label %34
16: ; preds = %3
%17 = load i32, i32* %5
%18 = load i32, i32* %7
%19 = and i32 %17, %18
%20 = load i32, i32* %5
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %16
store i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %34
23: ; preds = %16
%24 = load i32, i32* %5
%25 = load i32, i32* %7
%26 = xor i32 %25, -1
%27 = or i32 %24, %26
%28 = load i32, i32* %5
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %31
30: ; preds = %23
store i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %34
31: ; preds = %23
br label %32
32: ; preds = %31
br label %33
33: ; preds = %32
store i8* null, i8** %4
br label %34
34: ; preds = %33, %30, %22, %15
%35 = load i8*, i8** %4
ret i8* %35
}

LLVM IR (-O2):
@.str = [53 x i8] c"Error: the IP address is not in the interface range\0A\00"
@.str.1 = [44 x i8] c"Error: the IP address is a network address\0A\00"
define i8* @in_netrange(i32 %0, i32 %1, i32 %2) {
%4 = and i32 %2, %0
%5 = and i32 %2, %1
%6 = icmp eq i32 %4, %5
br i1 %6, label %7, label %14
7: ; preds = %3
%8 = icmp eq i32 %4, %0
br i1 %8, label %14, label %9
9: ; preds = %7
%10 = xor i32 %2, -1
%11 = or i32 %10, %0
%12 = icmp eq i32 %11, %0
%13 = select i1 %12, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* null
br label %14
14: ; preds = %9, %7, %3
%15 = phi i8* [ getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), %7 ], [ %13, %9 ]
ret i8* %15
}