#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 const *, char *, unsigned int *, unsigned int *,
                          unsigned int *, unsigned int *, unsigned int *);
unsigned uInCIDR4Format(const char *cCIDR4, unsigned *uIPv4,
                        unsigned *uCIDR4Mask) {
  unsigned a = 0, b = 0, c = 0, d = 0, e = 0;
  sscanf(cCIDR4, "%u.%u.%u.%u/%u", &a, &b, &c, &d, &e);
  if (!a || !e)
    return (0);
  if (b > 254)
    return (0);
  if (c > 254)
    return (0);
  if (d > 254)
    return (0);
  if (e > 32 || e < 8)
    return (0);
  *uIPv4 = d + (c << 8) + (b << 16) + (a << 24);
  *uCIDR4Mask = (0xffffffff) << (32 - e);
  return (1);
}


x86 assembly (clang, -O0):
<uInCIDR4Format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeae(%rip),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r8
lea    -0x30(%rbp),%r9
lea    -0x34(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <sscanf@plt>
cmpl   $0x0,-0x24(%rbp)
je     1183 <uInCIDR4Format+0x73>
cmpl   $0x0,-0x34(%rbp)
jne    118f <uInCIDR4Format+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    1239 <uInCIDR4Format+0x129>
cmpl   $0xfe,-0x28(%rbp)
jbe    11a8 <uInCIDR4Format+0x98>
movl   $0x0,-0x4(%rbp)
jmp    1239 <uInCIDR4Format+0x129>
cmpl   $0xfe,-0x2c(%rbp)
jbe    11c1 <uInCIDR4Format+0xb1>
movl   $0x0,-0x4(%rbp)
jmp    1239 <uInCIDR4Format+0x129>
cmpl   $0xfe,-0x30(%rbp)
jbe    11da <uInCIDR4Format+0xca>
movl   $0x0,-0x4(%rbp)
jmp    1239 <uInCIDR4Format+0x129>
cmpl   $0x20,-0x34(%rbp)
ja     11ee <uInCIDR4Format+0xde>
cmpl   $0x8,-0x34(%rbp)
jae    11fa <uInCIDR4Format+0xea>
movl   $0x0,-0x4(%rbp)
jmp    1239 <uInCIDR4Format+0x129>
mov    -0x30(%rbp),%ecx
mov    -0x2c(%rbp),%eax
shl    $0x8,%eax
add    %eax,%ecx
mov    -0x28(%rbp),%eax
shl    $0x10,%eax
add    %eax,%ecx
mov    -0x24(%rbp),%eax
shl    $0x18,%eax
add    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x20,%ecx
sub    -0x34(%rbp),%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uInCIDR4Format>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rax
mov    %rax,(%rsp)
lea    0xea9(%rip),%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0x10(%rsp),%r9
call   1030 <sscanf@plt>
mov    0x1c(%rsp),%edx
xor    %eax,%eax
test   %edx,%edx
je     11d4 <uInCIDR4Format+0xc4>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     11d4 <uInCIDR4Format+0xc4>
mov    0x18(%rsp),%edi
cmp    $0xfe,%edi
ja     11d4 <uInCIDR4Format+0xc4>
mov    0x14(%rsp),%esi
cmp    $0xfe,%esi
ja     11d4 <uInCIDR4Format+0xc4>
mov    0x10(%rsp),%r8d
cmp    $0xfe,%r8d
ja     11d4 <uInCIDR4Format+0xc4>
lea    -0x21(%rcx),%ebx
cmp    $0xffffffe7,%ebx
jb     11d4 <uInCIDR4Format+0xc4>
shl    $0x8,%esi
shl    $0x10,%edi
shl    $0x18,%edx
add    %edi,%edx
add    %esi,%edx
neg    %cl
mov    $0xffffffff,%eax
shl    %cl,%eax
add    %r8d,%edx
mov    %edx,(%r15)
mov    %eax,(%r14)
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"%u.%u.%u.%u/%u\00"
define i32 @uInCIDR4Format(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%13 = load i8*, i8** %5
%14 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32* %8, i32* %9, i32* %10, i32* %11, i32* %12)
%15 = load i32, i32* %8
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %3
%18 = load i32, i32* %12
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %17, %3
store i32 0, i32* %4
br label %56
21: ; preds = %17
%22 = load i32, i32* %9
%23 = icmp ugt i32 %22, 254
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 0, i32* %4
br label %56
25: ; preds = %21
%26 = load i32, i32* %10
%27 = icmp ugt i32 %26, 254
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 0, i32* %4
br label %56
29: ; preds = %25
%30 = load i32, i32* %11
%31 = icmp ugt i32 %30, 254
br i1 %31, label %32, label %33
32: ; preds = %29
store i32 0, i32* %4
br label %56
33: ; preds = %29
%34 = load i32, i32* %12
%35 = icmp ugt i32 %34, 32
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = load i32, i32* %12
%38 = icmp ult i32 %37, 8
br i1 %38, label %39, label %40
39: ; preds = %36, %33
store i32 0, i32* %4
br label %56
40: ; preds = %36
%41 = load i32, i32* %11
%42 = load i32, i32* %10
%43 = shl i32 %42, 8
%44 = add i32 %41, %43
%45 = load i32, i32* %9
%46 = shl i32 %45, 16
%47 = add i32 %44, %46
%48 = load i32, i32* %8
%49 = shl i32 %48, 24
%50 = add i32 %47, %49
%51 = load i32*, i32** %6
store i32 %50, i32* %51
%52 = load i32, i32* %12
%53 = sub i32 32, %52
%54 = shl i32 -1, %53
%55 = load i32*, i32** %7
store i32 %54, i32* %55
store i32 1, i32* %4
br label %56
56: ; preds = %40, %39, %32, %28, %24, %20
%57 = load i32, i32* %4
ret i32 %57
}

LLVM IR (-O2):
@.str = [15 x i8] c"%u.%u.%u.%u/%u\00"
define i32 @uInCIDR4Format(i8* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%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 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%13 = bitcast i32* %8 to i8*
store i32 0, i32* %8
%14 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5, i32* %6, i32* %7, i32* %8)
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
%17 = load i32, i32* %8
%18 = icmp ne i32 %17, 0
%19 = select i1 %16, i1 %18, i1 false
br i1 %19, label %20, label %41
20: ; preds = %3
%21 = load i32, i32* %5
%22 = icmp ugt i32 %21, 254
br i1 %22, label %41, label %23
23: ; preds = %20
%24 = load i32, i32* %6
%25 = icmp ugt i32 %24, 254
br i1 %25, label %41, label %26
26: ; preds = %23
%27 = load i32, i32* %7
%28 = icmp ugt i32 %27, 254
%29 = add i32 %17, -33
%30 = icmp ult i32 %29, -25
%31 = select i1 %28, i1 true, i1 %30
br i1 %31, label %41, label %32
32: ; preds = %26
%33 = shl nuw nsw i32 %24, 8
%34 = shl nuw nsw i32 %21, 16
%35 = shl i32 %15, 24
%36 = add nuw i32 %34, %35
%37 = add nuw i32 %36, %33
%38 = add nuw i32 %37, %27
store i32 %38, i32* %1
%39 = sub nuw nsw i32 32, %17
%40 = shl nsw i32 -1, %39
store i32 %40, i32* %2
br label %41
41: ; preds = %26, %23, %20, %3, %32
%42 = phi i32 [ 1, %32 ], [ 0, %3 ], [ 0, %20 ], [ 0, %23 ], [ 0, %26 ]
ret i32 %42
}