#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 *IPv4Range(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 > 255)
    e = 0;
  if (e < d)
    e = d;
  sprintf(cInput, "%u.%u.%u.%u-%u", a, b, c, d, e);
  return (cInput);
}


x86 assembly (clang, -O0):
<IPv4Range>:
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 <IPv4Range+0x6b>
movl   $0x0,-0xc(%rbp)
cmpl   $0xff,-0x10(%rbp)
jbe    119f <IPv4Range+0x7f>
movl   $0x0,-0x10(%rbp)
cmpl   $0xff,-0x14(%rbp)
jbe    11b3 <IPv4Range+0x93>
movl   $0x0,-0x14(%rbp)
cmpl   $0xff,-0x18(%rbp)
jbe    11c7 <IPv4Range+0xa7>
movl   $0x0,-0x18(%rbp)
cmpl   $0xff,-0x1c(%rbp)
jbe    11db <IPv4Range+0xbb>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    11ed <IPv4Range+0xcd>
mov    -0x18(%rbp),%eax
mov    %eax,-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    0xdf7(%rip),%rsi
mov    %eax,(%rsp)
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IPv4Range>:
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 <IPv4Range+0x6f>
movl   $0x0,0x1c(%rsp)
xor    %edx,%edx
mov    0x18(%rsp),%ecx
cmp    $0x100,%ecx
jb     11a5 <IPv4Range+0x85>
movl   $0x0,0x18(%rsp)
xor    %ecx,%ecx
mov    0x14(%rsp),%r8d
cmp    $0x100,%r8d
jb     11be <IPv4Range+0x9e>
movl   $0x0,0x14(%rsp)
xor    %r8d,%r8d
mov    0x10(%rsp),%r9d
cmp    $0x100,%r9d
jb     11d7 <IPv4Range+0xb7>
movl   $0x0,0x10(%rsp)
xor    %r9d,%r9d
mov    0xc(%rsp),%edi
xor    %esi,%esi
cmp    $0x100,%edi
cmovb  %edi,%esi
cmp    %r9d,%esi
mov    %esi,%eax
cmovb  %r9d,%eax
cmp    $0xff,%edi
ja     11fc <IPv4Range+0xdc>
cmp    %r9d,%esi
jae    1200 <IPv4Range+0xe0>
mov    %eax,0xc(%rsp)
mov    %eax,(%rsp)
lea    0xdf6(%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* @IPv4Range(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, 255
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 0, i32* %7
br label %29
29: ; preds = %28, %25
%30 = load i32, i32* %7
%31 = load i32, i32* %6
%32 = icmp ult i32 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load i32, i32* %6
store i32 %34, i32* %7
br label %35
35: ; preds = %33, %29
%36 = load i8*, i8** %2
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = call i32 @sprintf(i8* %36, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %38, i32 %39, i32 %40, i32 %41)
%43 = load i8*, i8** %2
ret i8* %43
}

LLVM IR (-O2):
@.str = [15 x i8] c"%u.%u.%u.%u-%u\00"
define i8* @IPv4Range(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, 255
%35 = select i1 %34, i32 0, i32 %33
%36 = icmp ult i32 %35, %32
%37 = select i1 %36, i32 %32, i32 %35
%38 = or i1 %34, %36
br i1 %38, label %39, label %40
39: ; preds = %31
store i32 %37, i32* %6
br label %40
40: ; preds = %31, %39
%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 %37)
ret i8* %0
}