#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*/ sscanf(char *, char *, unsigned int *, unsigned int *,
                          unsigned int *, unsigned int *, unsigned int *);
unsigned uGetNumIPs(char *cCIDR4) {
  unsigned uNumIPs = 0;
  unsigned uA = 0;
  unsigned uB = 0;
  unsigned uC = 0;
  unsigned uD = 0;
  unsigned uE = 0;
  if ((uA > 255) || (uB > 255) || (uC > 255) || (uD > 255))
    return (0);
  sscanf(cCIDR4, "%u.%u.%u.%u/%u", &uA, &uB, &uC, &uD, &uE);
  uNumIPs = (unsigned)2 << (32 - uE - 1);
  if (!uNumIPs)
    uNumIPs = 1;
  else
    uNumIPs = uNumIPs - 2;
  return (uNumIPs);
}


x86 assembly (clang, -O0):
<uGetNumIPs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0xff,-0x18(%rbp)
ja     117a <uGetNumIPs+0x6a>
cmpl   $0xff,-0x1c(%rbp)
ja     117a <uGetNumIPs+0x6a>
cmpl   $0xff,-0x20(%rbp)
ja     117a <uGetNumIPs+0x6a>
cmpl   $0xff,-0x24(%rbp)
jbe    1186 <uGetNumIPs+0x76>
movl   $0x0,-0x4(%rbp)
jmp    11e8 <uGetNumIPs+0xd8>
mov    -0x10(%rbp),%rdi
lea    0xe6f(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
lea    -0x20(%rbp),%r8
lea    -0x24(%rbp),%r9
lea    -0x28(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <sscanf@plt>
mov    $0x20,%ecx
sub    -0x28(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x2,%eax
shl    %cl,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11d9 <uGetNumIPs+0xc9>
movl   $0x1,-0x14(%rbp)
jmp    11e2 <uGetNumIPs+0xd2>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uGetNumIPs>:
sub    $0x28,%rsp
movl   $0x0,0x24(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x14(%rsp)
lea    0x14(%rsp),%rax
mov    %rax,(%rsp)
lea    0xeb4(%rip),%rsi
lea    0x24(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x1c(%rsp),%r8
lea    0x18(%rsp),%r9
call   1030 <sscanf@plt>
mov    $0x1f,%ecx
sub    0x14(%rsp),%ecx
mov    $0x2,%edx
shl    %cl,%edx
add    $0xfffffffe,%edx
cmp    $0x1f,%ecx
mov    $0x1,%eax
cmovb  %edx,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"%u.%u.%u.%u/%u\00"
define i32 @uGetNumIPs(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%10 = load i32, i32* %5
%11 = icmp ugt i32 %10, 255
br i1 %11, label %21, label %12
12: ; preds = %1
%13 = load i32, i32* %6
%14 = icmp ugt i32 %13, 255
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = load i32, i32* %7
%17 = icmp ugt i32 %16, 255
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %8
%20 = icmp ugt i32 %19, 255
br i1 %20, label %21, label %22
21: ; preds = %18, %15, %12, %1
store i32 0, i32* %2
br label %37
22: ; preds = %18
%23 = load i8*, i8** %3
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, i32* %7, i32* %8, i32* %9)
%25 = load i32, i32* %9
%26 = sub i32 32, %25
%27 = sub i32 %26, 1
%28 = shl i32 2, %27
store i32 %28, i32* %4
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %22
store i32 1, i32* %4
br label %35
32: ; preds = %22
%33 = load i32, i32* %4
%34 = sub i32 %33, 2
store i32 %34, i32* %4
br label %35
35: ; preds = %32, %31
%36 = load i32, i32* %4
store i32 %36, i32* %2
br label %37
37: ; preds = %35, %21
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@.str = [15 x i8] c"%u.%u.%u.%u/%u\00"
define i32 @uGetNumIPs(i8* nocapture %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%10 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%11 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%12 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %5, i32* %6)
%13 = load i32, i32* %6
%14 = sub i32 31, %13
%15 = icmp ugt i32 %14, 30
%16 = shl i32 2, %14
%17 = add i32 %16, -2
%18 = select i1 %15, i32 1, i32 %17
ret i32 %18
}