#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*/ uInCIDR4Format(char const *, unsigned int *, unsigned int *);
int /*<<< orphan*/ uInIpv4Format(char const *, unsigned int *);
unsigned uIpv4InCIDR4(const char *cIPv4, const char *cCIDR4) {
  unsigned uIPv4 = 0;
  unsigned uCIDR4IP = 0;
  unsigned uCIDR4Mask = 0;
  unsigned uCIDR4Masked = 0;
  unsigned uIPv4Masked = 0;
  if (!uInCIDR4Format(cCIDR4, &uCIDR4IP, &uCIDR4Mask))
    return (2);
  if (!uInIpv4Format(cIPv4, &uIPv4))
    return (3);
  uCIDR4Masked = (uCIDR4IP & uCIDR4Mask);
  uIPv4Masked = (uIPv4 & uCIDR4Mask);
  if (uIPv4Masked == uCIDR4Masked)
    return (1);
  else
    return (0);
}


x86 assembly (clang, -O0):
<uIpv4InCIDR4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1040 <uInCIDR4Format@plt>
cmp    $0x0,%eax
jne    1179 <uIpv4InCIDR4+0x59>
movl   $0x2,-0x4(%rbp)
jmp    11cc <uIpv4InCIDR4+0xac>
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1030 <uInIpv4Format@plt>
cmp    $0x0,%eax
jne    119b <uIpv4InCIDR4+0x7b>
movl   $0x3,-0x4(%rbp)
jmp    11cc <uIpv4InCIDR4+0xac>
mov    -0x20(%rbp),%eax
and    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
and    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    11c5 <uIpv4InCIDR4+0xa5>
movl   $0x1,-0x4(%rbp)
jmp    11cc <uIpv4InCIDR4+0xac>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uIpv4InCIDR4>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1040 <uInCIDR4Format@plt>
test   %eax,%eax
je     117d <uIpv4InCIDR4+0x5d>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <uInIpv4Format@plt>
test   %eax,%eax
je     1184 <uIpv4InCIDR4+0x64>
mov    0xc(%rsp),%ecx
xor    0x8(%rsp),%ecx
xor    %eax,%eax
test   %ecx,0x4(%rsp)
sete   %al
jmp    1189 <uIpv4InCIDR4+0x69>
mov    $0x2,%eax
jmp    1189 <uIpv4InCIDR4+0x69>
mov    $0x3,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @uIpv4InCIDR4(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%9 = call i32 @uInCIDR4Format(i8* %1, i32* %4, i32* %5)
%10 = icmp eq i32 %9, 0
br i1 %10, label %22, label %11
11: ; preds = %2
%12 = call i32 @uInIpv4Format(i8* %0, i32* %3)
%13 = icmp eq i32 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %11
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = load i32, i32* %3
%18 = xor i32 %17, %15
%19 = and i32 %18, %16
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %14, %11, %2
%23 = phi i32 [ 2, %2 ], [ 3, %11 ], [ %21, %14 ]
ret i32 %23
}