#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 htonl(int);
bool is_ipv4_private_unicast(uint32_t ip) {
  if ((ip & htonl(0xffff0000)) == htonl(0xc0a80000))
    return true;
  if ((ip & htonl(0xfff00000)) == htonl(0xac100000))
    return true;
  if ((ip & htonl(0xff000000)) == htonl(0x0a000000))
    return true;
  if ((ip & htonl(0xffff0000)) == htonl(0xa9fe0000))
    return true;
  return false;
}


x86 assembly (clang, -O0):
<is_ipv4_private_unicast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0xffff0000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    $0xc0a80000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
jne    1158 <is_ipv4_private_unicast+0x48>
movl   $0x1,-0x4(%rbp)
jmp    1216 <is_ipv4_private_unicast+0x106>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0xfff00000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    $0xac100000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jne    1195 <is_ipv4_private_unicast+0x85>
movl   $0x1,-0x4(%rbp)
jmp    1216 <is_ipv4_private_unicast+0x106>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0xff000000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    $0xa000000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jne    11d2 <is_ipv4_private_unicast+0xc2>
movl   $0x1,-0x4(%rbp)
jmp    1216 <is_ipv4_private_unicast+0x106>
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0xffff0000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    $0xa9fe0000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jne    120f <is_ipv4_private_unicast+0xff>
movl   $0x1,-0x4(%rbp)
jmp    1216 <is_ipv4_private_unicast+0x106>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_ipv4_private_unicast>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
mov    $0xffff0000,%edi
call   1030 <htonl@plt>
mov    %eax,%ebx
and    %r15d,%ebx
mov    $0xc0a80000,%edi
call   1030 <htonl@plt>
mov    $0x1,%r14d
cmp    %eax,%ebx
je     118a <is_ipv4_private_unicast+0x7a>
mov    $0xfff00000,%edi
call   1030 <htonl@plt>
mov    %eax,%ebp
and    %r15d,%ebp
mov    $0xac100000,%edi
call   1030 <htonl@plt>
cmp    %eax,%ebp
je     118a <is_ipv4_private_unicast+0x7a>
mov    $0xff000000,%edi
call   1030 <htonl@plt>
mov    %eax,%ebp
and    %r15d,%ebp
mov    $0xa000000,%edi
call   1030 <htonl@plt>
cmp    %eax,%ebp
je     118a <is_ipv4_private_unicast+0x7a>
mov    $0xa9fe0000,%edi
call   1030 <htonl@plt>
xor    %r14d,%r14d
cmp    %eax,%ebx
sete   %r14b
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_ipv4_private_unicast(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i32 @htonl(i32 -65536)
%6 = and i32 %4, %5
%7 = call i32 @htonl(i32 -1062731776)
%8 = icmp eq i32 %6, %7
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 1, i32* %2
br label %32
10: ; preds = %1
%11 = load i32, i32* %3
%12 = call i32 @htonl(i32 -1048576)
%13 = and i32 %11, %12
%14 = call i32 @htonl(i32 -1408237568)
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %10
store i32 1, i32* %2
br label %32
17: ; preds = %10
%18 = load i32, i32* %3
%19 = call i32 @htonl(i32 -16777216)
%20 = and i32 %18, %19
%21 = call i32 @htonl(i32 167772160)
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %17
store i32 1, i32* %2
br label %32
24: ; preds = %17
%25 = load i32, i32* %3
%26 = call i32 @htonl(i32 -65536)
%27 = and i32 %25, %26
%28 = call i32 @htonl(i32 -1442971648)
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %31
30: ; preds = %24
store i32 1, i32* %2
br label %32
31: ; preds = %24
store i32 0, i32* %2
br label %32
32: ; preds = %31, %30, %23, %16, %9
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
define i32 @is_ipv4_private_unicast(i32 %0) {
%2 = tail call i32 @htonl(i32 -65536)
%3 = and i32 %2, %0
%4 = tail call i32 @htonl(i32 -1062731776)
%5 = icmp eq i32 %3, %4
br i1 %5, label %20, label %6
6: ; preds = %1
%7 = tail call i32 @htonl(i32 -1048576)
%8 = and i32 %7, %0
%9 = tail call i32 @htonl(i32 -1408237568)
%10 = icmp eq i32 %8, %9
br i1 %10, label %20, label %11
11: ; preds = %6
%12 = tail call i32 @htonl(i32 -16777216)
%13 = and i32 %12, %0
%14 = tail call i32 @htonl(i32 167772160)
%15 = icmp eq i32 %13, %14
br i1 %15, label %20, label %16
16: ; preds = %11
%17 = tail call i32 @htonl(i32 -1442971648)
%18 = icmp eq i32 %3, %17
%19 = zext i1 %18 to i32
br label %20
20: ; preds = %16, %11, %6, %1
%21 = phi i32 [ 1, %1 ], [ 1, %6 ], [ 1, %11 ], [ %19, %16 ]
ret i32 %21
}