#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_global_unicast(uint32_t ip) {
  if ((ip & htonl(0x80000000)) == 0) {
    ip &= htonl(0xff000000);
    return (ip != htonl(0x0a000000)) && (ip != htonl(0x7f000000)) &&
           (ip != htonl(0x00000000));
  }
  if ((ip & htonl(0x40000000)) == 0) {
    return ((ip & htonl(0xffff0000)) != htonl(0xa9fe0000)) &&
           ((ip & htonl(0xfff00000)) != htonl(0xac100000));
  }
  if ((ip & htonl(0x20000000)) == 0) {
    return ((ip & htonl(0xffff0000)) != htonl(0xc0a80000)) &&
           ((ip & htonl(0xffffff00)) != htonl(0xc0586200));
  }
  if ((ip & htonl(0x10000000)) == 0)
    return false;
  return ip != htonl(0xffffffff);
}


x86 assembly (clang, -O0):
<is_ipv4_global_unicast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x80000000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
and    %ecx,%eax
cmp    $0x0,%eax
jne    11b9 <is_ipv4_global_unicast+0xa9>
mov    $0xff000000,%edi
call   1030 <htonl@plt>
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0xa000000,%edi
call   1030 <htonl@plt>
mov    -0x14(%rbp),%ecx
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0xd(%rbp)
je     11a9 <is_ipv4_global_unicast+0x99>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x7f000000,%edi
call   1030 <htonl@plt>
mov    -0x18(%rbp),%ecx
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0xd(%rbp)
je     11a9 <is_ipv4_global_unicast+0x99>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
xor    %edi,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1335 <is_ipv4_global_unicast+0x225>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x40000000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
and    %ecx,%eax
cmp    $0x0,%eax
jne    1250 <is_ipv4_global_unicast+0x140>
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    $0xffff0000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    $0xa9fe0000,%edi
call   1030 <htonl@plt>
mov    -0x28(%rbp),%ecx
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x21(%rbp)
je     1240 <is_ipv4_global_unicast+0x130>
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    $0xfff00000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    $0xac100000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1335 <is_ipv4_global_unicast+0x225>
mov    -0x8(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    $0x20000000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
and    %ecx,%eax
cmp    $0x0,%eax
jne    12e7 <is_ipv4_global_unicast+0x1d7>
mov    -0x8(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    $0xffff0000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    $0xc0a80000,%edi
call   1030 <htonl@plt>
mov    -0x40(%rbp),%ecx
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x39(%rbp)
je     12d7 <is_ipv4_global_unicast+0x1c7>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    $0xffffff00,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    $0xc0586200,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
cmp    %ecx,%eax
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1335 <is_ipv4_global_unicast+0x225>
mov    -0x8(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    $0x10000000,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
and    %ecx,%eax
cmp    $0x0,%eax
jne    1313 <is_ipv4_global_unicast+0x203>
movl   $0x0,-0x4(%rbp)
jmp    1335 <is_ipv4_global_unicast+0x225>
mov    -0x8(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    $0xffffffff,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_ipv4_global_unicast>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
mov    $0x80000000,%edi
call   1030 <htonl@plt>
test   %ebx,%eax
je     1168 <is_ipv4_global_unicast+0x58>
mov    $0x40000000,%edi
call   1030 <htonl@plt>
test   %ebx,%eax
je     11a4 <is_ipv4_global_unicast+0x94>
mov    $0x20000000,%edi
call   1030 <htonl@plt>
test   %ebx,%eax
je     11dc <is_ipv4_global_unicast+0xcc>
mov    $0x10000000,%edi
call   1030 <htonl@plt>
test   %ebx,%eax
je     1229 <is_ipv4_global_unicast+0x119>
mov    $0xffffffff,%edi
call   1030 <htonl@plt>
mov    %eax,%r14d
jmp    1219 <is_ipv4_global_unicast+0x109>
mov    $0xff000000,%edi
call   1030 <htonl@plt>
mov    %eax,%r14d
and    %ebx,%r14d
mov    $0xa000000,%edi
call   1030 <htonl@plt>
xor    %ebp,%ebp
cmp    %eax,%r14d
je     1222 <is_ipv4_global_unicast+0x112>
mov    $0x7f000000,%edi
call   1030 <htonl@plt>
cmp    %eax,%r14d
je     1222 <is_ipv4_global_unicast+0x112>
xor    %edi,%edi
jmp    1212 <is_ipv4_global_unicast+0x102>
mov    $0xffff0000,%edi
call   1030 <htonl@plt>
mov    %eax,%r14d
and    %ebx,%r14d
mov    $0xa9fe0000,%edi
call   1030 <htonl@plt>
xor    %ebp,%ebp
cmp    %eax,%r14d
je     1222 <is_ipv4_global_unicast+0x112>
mov    $0xfff00000,%edi
call   1030 <htonl@plt>
mov    %eax,%r14d
and    %ebx,%r14d
mov    $0xac100000,%edi
jmp    1212 <is_ipv4_global_unicast+0x102>
mov    $0xffff0000,%edi
call   1030 <htonl@plt>
mov    %eax,%r14d
and    %ebx,%r14d
mov    $0xc0a80000,%edi
call   1030 <htonl@plt>
xor    %ebp,%ebp
cmp    %eax,%r14d
je     1222 <is_ipv4_global_unicast+0x112>
mov    $0xffffff00,%edi
call   1030 <htonl@plt>
mov    %eax,%r14d
and    %ebx,%r14d
mov    $0xc0586200,%edi
call   1030 <htonl@plt>
mov    %eax,%ebx
xor    %ebp,%ebp
cmp    %ebx,%r14d
setne  %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebp,%ebp
jmp    1222 <is_ipv4_global_unicast+0x112>

LLVM IR (-O0):
define i32 @is_ipv4_global_unicast(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i32 @htonl(i32 -2147483648)
%6 = and i32 %4, %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %26
8: ; preds = %1
%9 = call i32 @htonl(i32 -16777216)
%10 = load i32, i32* %3
%11 = and i32 %10, %9
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = call i32 @htonl(i32 167772160)
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %8
%16 = load i32, i32* %3
%17 = call i32 @htonl(i32 2130706432)
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i32, i32* %3
%21 = call i32 @htonl(i32 0)
%22 = icmp ne i32 %20, %21
br label %23
23: ; preds = %19, %15, %8
%24 = phi i1 [ false, %15 ], [ false, %8 ], [ %22, %19 ]
%25 = zext i1 %24 to i32
store i32 %25, i32* %2
br label %77
26: ; preds = %1
%27 = load i32, i32* %3
%28 = call i32 @htonl(i32 1073741824)
%29 = and i32 %27, %28
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %46
31: ; preds = %26
%32 = load i32, i32* %3
%33 = call i32 @htonl(i32 -65536)
%34 = and i32 %32, %33
%35 = call i32 @htonl(i32 -1442971648)
%36 = icmp ne i32 %34, %35
br i1 %36, label %37, label %43
37: ; preds = %31
%38 = load i32, i32* %3
%39 = call i32 @htonl(i32 -1048576)
%40 = and i32 %38, %39
%41 = call i32 @htonl(i32 -1408237568)
%42 = icmp ne i32 %40, %41
br label %43
43: ; preds = %37, %31
%44 = phi i1 [ false, %31 ], [ %42, %37 ]
%45 = zext i1 %44 to i32
store i32 %45, i32* %2
br label %77
46: ; preds = %26
%47 = load i32, i32* %3
%48 = call i32 @htonl(i32 536870912)
%49 = and i32 %47, %48
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %66
51: ; preds = %46
%52 = load i32, i32* %3
%53 = call i32 @htonl(i32 -65536)
%54 = and i32 %52, %53
%55 = call i32 @htonl(i32 -1062731776)
%56 = icmp ne i32 %54, %55
br i1 %56, label %57, label %63
57: ; preds = %51
%58 = load i32, i32* %3
%59 = call i32 @htonl(i32 -256)
%60 = and i32 %58, %59
%61 = call i32 @htonl(i32 -1067949568)
%62 = icmp ne i32 %60, %61
br label %63
63: ; preds = %57, %51
%64 = phi i1 [ false, %51 ], [ %62, %57 ]
%65 = zext i1 %64 to i32
store i32 %65, i32* %2
br label %77
66: ; preds = %46
%67 = load i32, i32* %3
%68 = call i32 @htonl(i32 268435456)
%69 = and i32 %67, %68
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %72
71: ; preds = %66
store i32 0, i32* %2
br label %77
72: ; preds = %66
%73 = load i32, i32* %3
%74 = call i32 @htonl(i32 -1)
%75 = icmp ne i32 %73, %74
%76 = zext i1 %75 to i32
store i32 %76, i32* %2
br label %77
77: ; preds = %72, %71, %63, %43, %23
%78 = load i32, i32* %2
ret i32 %78
}

LLVM IR (-O2):
define i32 @is_ipv4_global_unicast(i32 %0) {
%2 = tail call i32 @htonl(i32 -2147483648)
%3 = and i32 %2, %0
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %1
%6 = tail call i32 @htonl(i32 -16777216)
%7 = and i32 %6, %0
%8 = tail call i32 @htonl(i32 167772160)
%9 = icmp eq i32 %7, %8
br i1 %9, label %52, label %10
10: ; preds = %5
%11 = tail call i32 @htonl(i32 2130706432)
%12 = icmp eq i32 %7, %11
br i1 %12, label %52, label %13
13: ; preds = %10
%14 = tail call i32 @htonl(i32 0)
br label %47
15: ; preds = %1
%16 = tail call i32 @htonl(i32 1073741824)
%17 = and i32 %16, %0
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = tail call i32 @htonl(i32 -65536)
%21 = and i32 %20, %0
%22 = tail call i32 @htonl(i32 -1442971648)
%23 = icmp eq i32 %21, %22
br i1 %23, label %52, label %24
24: ; preds = %19
%25 = tail call i32 @htonl(i32 -1048576)
%26 = and i32 %25, %0
%27 = tail call i32 @htonl(i32 -1408237568)
br label %47
28: ; preds = %15
%29 = tail call i32 @htonl(i32 536870912)
%30 = and i32 %29, %0
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %41
32: ; preds = %28
%33 = tail call i32 @htonl(i32 -65536)
%34 = and i32 %33, %0
%35 = tail call i32 @htonl(i32 -1062731776)
%36 = icmp eq i32 %34, %35
br i1 %36, label %52, label %37
37: ; preds = %32
%38 = tail call i32 @htonl(i32 -256)
%39 = and i32 %38, %0
%40 = tail call i32 @htonl(i32 -1067949568)
br label %47
41: ; preds = %28
%42 = tail call i32 @htonl(i32 268435456)
%43 = and i32 %42, %0
%44 = icmp eq i32 %43, 0
br i1 %44, label %52, label %45
45: ; preds = %41
%46 = tail call i32 @htonl(i32 -1)
br label %47
47: ; preds = %45, %13, %24, %37
%48 = phi i32 [ %40, %37 ], [ %27, %24 ], [ %14, %13 ], [ %0, %45 ]
%49 = phi i32 [ %39, %37 ], [ %26, %24 ], [ %7, %13 ], [ %46, %45 ]
%50 = icmp ne i32 %49, %48
%51 = zext i1 %50 to i32
br label %52
52: ; preds = %47, %41, %32, %19, %5, %10
%53 = phi i32 [ 0, %10 ], [ 0, %5 ], [ 0, %19 ], [ 0, %32 ], [ 0, %41 ], [ %51, %47 ]
ret i32 %53
}