#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*/ sprintf(char *, char *, unsigned int, unsigned int,
                           unsigned int, unsigned int, unsigned int);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *, unsigned int *,
                          unsigned int *, unsigned int *, unsigned int *);
char *IPv4CIDR(char *cInput) {
  unsigned a = 0, b = 0, c = 0, d = 0, e = 0;
  sscanf(cInput, "%u.%u.%u.%u/%u", &a, &b, &c, &d, &e);
  if (a > 255)
    a = 0;
  if (b > 255)
    b = 0;
  if (c > 255)
    c = 0;
  if (d > 255)
    d = 0;
  if (e > 32)
    e = 32;
  if (e < 20)
    e = 20;
  sprintf(cInput, "%u.%u.%u.%u/%u", a, b, c, d, e);
  return (cInput);
}


x86 assembly (clang, -O0):
<IPv4CIDR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
lea    -0x18(%rbp),%r9
lea    -0x1c(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <sscanf@plt>
cmpl   $0xff,-0xc(%rbp)
jbe    118b <IPv4CIDR+0x6b>
movl   $0x0,-0xc(%rbp)
cmpl   $0xff,-0x10(%rbp)
jbe    119f <IPv4CIDR+0x7f>
movl   $0x0,-0x10(%rbp)
cmpl   $0xff,-0x14(%rbp)
jbe    11b3 <IPv4CIDR+0x93>
movl   $0x0,-0x14(%rbp)
cmpl   $0xff,-0x18(%rbp)
jbe    11c7 <IPv4CIDR+0xa7>
movl   $0x0,-0x18(%rbp)
cmpl   $0x20,-0x1c(%rbp)
jbe    11d8 <IPv4CIDR+0xb8>
movl   $0x20,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jae    11e9 <IPv4CIDR+0xc9>
movl   $0x14,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    -0x1c(%rbp),%eax
lea    0xdfb(%rip),%rsi
mov    %eax,(%rsp)
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IPv4CIDR>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
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    0xea0(%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
cmp    $0x100,%edx
jb     118f <IPv4CIDR+0x6f>
movl   $0x0,0x1c(%rsp)
xor    %edx,%edx
mov    0x18(%rsp),%ecx
cmp    $0x100,%ecx
jb     11a5 <IPv4CIDR+0x85>
movl   $0x0,0x18(%rsp)
xor    %ecx,%ecx
mov    0x14(%rsp),%r8d
cmp    $0x100,%r8d
jb     11be <IPv4CIDR+0x9e>
movl   $0x0,0x14(%rsp)
xor    %r8d,%r8d
mov    0x10(%rsp),%r9d
cmp    $0x100,%r9d
jb     11d7 <IPv4CIDR+0xb7>
movl   $0x0,0x10(%rsp)
xor    %r9d,%r9d
mov    0xc(%rsp),%eax
cmp    $0x21,%eax
jb     11ef <IPv4CIDR+0xcf>
movl   $0x20,0xc(%rsp)
mov    $0x20,%eax
jmp    1201 <IPv4CIDR+0xe1>
cmp    $0x13,%eax
ja     1201 <IPv4CIDR+0xe1>
movl   $0x14,0xc(%rsp)
mov    $0x14,%eax
mov    %eax,(%rsp)
lea    0xdf5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rax
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [15 x i8] c"%u.%u.%u.%u/%u\00"
define i8* @IPv4CIDR(i8* returned %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* %2
%14 = icmp ugt i32 %13, 255
br i1 %14, label %15, label %16
15: ; preds = %1
store i32 0, i32* %2
br label %16
16: ; preds = %15, %1
%17 = phi i32 [ 0, %15 ], [ %13, %1 ]
%18 = load i32, i32* %3
%19 = icmp ugt i32 %18, 255
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 0, i32* %3
br label %21
21: ; preds = %20, %16
%22 = phi i32 [ 0, %20 ], [ %18, %16 ]
%23 = load i32, i32* %4
%24 = icmp ugt i32 %23, 255
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 0, i32* %4
br label %26
26: ; preds = %25, %21
%27 = phi i32 [ 0, %25 ], [ %23, %21 ]
%28 = load i32, i32* %5
%29 = icmp ugt i32 %28, 255
br i1 %29, label %30, label %31
30: ; preds = %26
store i32 0, i32* %5
br label %31
31: ; preds = %30, %26
%32 = phi i32 [ 0, %30 ], [ %28, %26 ]
%33 = load i32, i32* %6
%34 = icmp ugt i32 %33, 32
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 32, i32* %6
br label %39
36: ; preds = %31
%37 = icmp ult i32 %33, 20
br i1 %37, label %38, label %39
38: ; preds = %36
store i32 20, i32* %6
br label %39
39: ; preds = %35, %38, %36
%40 = phi i32 [ 32, %35 ], [ 20, %38 ], [ %33, %36 ]
%41 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %22, i32 %27, i32 %32, i32 %40)
ret i8* %0
}