#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*/ isdigit(char);
int /*<<< orphan*/ printf(char *, ...);
unsigned int sscanf(char *, char *, unsigned int *);
char *strchr(char const *, char);
int /*<<< orphan*/ uInIpv6Format32(char const *, unsigned int *, unsigned int *,
                                   unsigned int *, unsigned int *,
                                   unsigned int *, unsigned int *,
                                   unsigned int *, unsigned int *);
unsigned uInCIDR6Format32(const char *cCIDR6, unsigned *h1, unsigned *h2,
                          unsigned *h3, unsigned *h4, unsigned *h5,
                          unsigned *h6, unsigned *h7, unsigned *h8,
                          unsigned *uCIDR) {
  char *cp;
  if ((cp = strchr(cCIDR6, '/'))) {
    unsigned uCount = 0;
    uCount = sscanf(cp, "/%u", uCIDR);
    if (!uCount || !isdigit(*(cp + 1))) {
      printf("err /(invalid CIDR mask)\n");
      return (0);
    } else if (*uCIDR > 128) {
      printf("err CIDR mask out of range 0-128\n");
      return (0);
    }
    *cp = 0;
  } else {
    printf("err no /\n");
    return (0);
  }
  if (!uInIpv6Format32(cCIDR6, h1, h2, h3, h4, h5, h6, h7, h8)) {
    printf("err !uInIpv6Format\n");
    return (0);
  }
  *cp = '/';
  printf("uInCIDR6Format32: /%u\n", *uCIDR);
  return (1);
}


x86 assembly (clang, -O0):
<uInCIDR6Format32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
je     122f <uInCIDR6Format32+0xdf>
movl   $0x0,-0x44(%rbp)
mov    -0x40(%rbp),%rdi
mov    0x28(%rbp),%rdx
lea    0xe4e(%rip),%rsi
call   1060 <sscanf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
je     11da <uInCIDR6Format32+0x8a>
mov    -0x40(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11f4 <uInCIDR6Format32+0xa4>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c5 <uInCIDR6Format32+0x175>
mov    0x28(%rbp),%rax
cmpl   $0x80,(%rax)
jbe    121e <uInCIDR6Format32+0xce>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c5 <uInCIDR6Format32+0x175>
jmp    1223 <uInCIDR6Format32+0xd3>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
jmp    1249 <uInCIDR6Format32+0xf9>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c5 <uInCIDR6Format32+0x175>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    0x10(%rbp),%r11
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1070 <uInIpv6Format32@plt>
cmp    $0x0,%eax
jne    12a3 <uInCIDR6Format32+0x153>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c5 <uInCIDR6Format32+0x175>
mov    -0x40(%rbp),%rax
movb   $0x2f,(%rax)
mov    0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uInCIDR6Format32>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,(%rsp)
mov    %r8,%r15
mov    %rcx,%r13
mov    %rdx,%rbp
mov    %rsi,%r12
mov    %rdi,%r14
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11d4 <uInCIDR6Format32+0x74>
mov    %rax,%rbx
mov    0x58(%rsp),%rdx
lea    0xe64(%rip),%rsi
mov    %rax,%rdi
call   1070 <sscanf@plt>
test   %eax,%eax
je     11cb <uInCIDR6Format32+0x6b>
movsbl 0x1(%rbx),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     11cb <uInCIDR6Format32+0x6b>
mov    0x58(%rsp),%rax
cmpl   $0x81,(%rax)
jb     11f1 <uInCIDR6Format32+0x91>
lea    0xe87(%rip),%rdi
jmp    11db <uInCIDR6Format32+0x7b>
lea    0xe52(%rip),%rdi
jmp    11db <uInCIDR6Format32+0x7b>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x50(%rsp),%rax
mov    0x48(%rsp),%r10
mov    0x40(%rsp),%r11
movb   $0x0,(%rbx)
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %r13,%rcx
mov    %r15,%r8
mov    0x8(%rsp),%r9
push   %rax
push   %r10
push   %r11
call   1080 <uInIpv6Format32@plt>
add    $0x20,%rsp
test   %eax,%eax
je     124c <uInCIDR6Format32+0xec>
movb   $0x2f,(%rbx)
mov    0x58(%rsp),%rax
mov    (%rax),%esi
lea    0xdc6(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%eax
jmp    11e2 <uInCIDR6Format32+0x82>
lea    0xdea(%rip),%rdi
jmp    11db <uInCIDR6Format32+0x7b>

LLVM IR (-O0):
@.str = [4 x i8] c"/%u\00"
@.str.1 = [26 x i8] c"err /(invalid CIDR mask)\0A\00"
@.str.2 = [34 x i8] c"err CIDR mask out of range 0-128\0A\00"
@.str.3 = [10 x i8] c"err no /\0A\00"
@.str.4 = [20 x i8] c"err !uInIpv6Format\0A\00"
@.str.5 = [23 x i8] c"uInCIDR6Format32: /%u\0A\00"
define i32 @uInCIDR6Format32(i8* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9) {
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca i32*
%22 = alloca i8*
%23 = alloca i32
store i8* %0, i8** %12
store i32* %1, i32** %13
store i32* %2, i32** %14
store i32* %3, i32** %15
store i32* %4, i32** %16
store i32* %5, i32** %17
store i32* %6, i32** %18
store i32* %7, i32** %19
store i32* %8, i32** %20
store i32* %9, i32** %21
%24 = load i8*, i8** %12
%25 = call i8* @strchr(i8* %24, i8 signext 47)
store i8* %25, i8** %22
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %50
27: ; preds = %10
store i32 0, i32* %23
%28 = load i8*, i8** %22
%29 = load i32*, i32** %21
%30 = call i32 @sscanf(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %29)
store i32 %30, i32* %23
%31 = load i32, i32* %23
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %27
%34 = load i8*, i8** %22
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i8, i8* %35
%37 = call i32 @isdigit(i8 signext %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %33, %27
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %11
br label %71
41: ; preds = %33
%42 = load i32*, i32** %21
%43 = load i32, i32* %42
%44 = icmp ugt i32 %43, 128
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %11
br label %71
47: ; preds = %41
br label %48
48: ; preds = %47
%49 = load i8*, i8** %22
store i8 0, i8* %49
br label %52
50: ; preds = %10
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %11
br label %71
52: ; preds = %48
%53 = load i8*, i8** %12
%54 = load i32*, i32** %13
%55 = load i32*, i32** %14
%56 = load i32*, i32** %15
%57 = load i32*, i32** %16
%58 = load i32*, i32** %17
%59 = load i32*, i32** %18
%60 = load i32*, i32** %19
%61 = load i32*, i32** %20
%62 = call i32 @uInIpv6Format32(i8* %53, i32* %54, i32* %55, i32* %56, i32* %57, i32* %58, i32* %59, i32* %60, i32* %61)
%63 = icmp ne i32 %62, 0
br i1 %63, label %66, label %64
64: ; preds = %52
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %11
br label %71
66: ; preds = %52
%67 = load i8*, i8** %22
store i8 47, i8* %67
%68 = load i32*, i32** %21
%69 = load i32, i32* %68
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %69)
store i32 1, i32* %11
br label %71
71: ; preds = %66, %64, %50, %45, %39
%72 = load i32, i32* %11
ret i32 %72
}

LLVM IR (-O2):
@.str = [4 x i8] c"/%u\00"
@.str.5 = [23 x i8] c"uInCIDR6Format32: /%u\0A\00"
@str = [9 x i8] c"err no /\00"
@str.6 = [25 x i8] c"err /(invalid CIDR mask)\00"
@str.7 = [19 x i8] c"err !uInIpv6Format\00"
@str.8 = [33 x i8] c"err CIDR mask out of range 0-128\00"
define i32 @uInCIDR6Format32(i8* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9) {
%11 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 47)
%12 = icmp eq i8* %11, null
br i1 %12, label %31, label %13
13: ; preds = %10
%14 = tail call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %9)
%15 = icmp eq i32 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %13
%17 = getelementptr inbounds i8, i8* %11, i64 1
%18 = load i8, i8* %17
%19 = tail call i32 @isdigit(i8 signext %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %16, %13
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
br label %38
23: ; preds = %16
%24 = load i32, i32* %9
%25 = icmp ugt i32 %24, 128
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.8, i64 0, i64 0))
br label %38
28: ; preds = %23
store i8 0, i8* %11
%29 = tail call i32 @uInIpv6Format32(i8* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8)
%30 = icmp eq i32 %29, 0
br i1 %30, label %33, label %35
31: ; preds = %10
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %38
33: ; preds = %28
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
br label %38
35: ; preds = %28
store i8 47, i8* %11
%36 = load i32, i32* %9
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %21, %26, %35, %33, %31
%39 = phi i32 [ 1, %35 ], [ 0, %33 ], [ 0, %31 ], [ 0, %26 ], [ 0, %21 ]
ret i32 %39
}