#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 */
scalar_t__ isdigit(int);
scalar_t__ isxdigit(int);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
scalar_t__ strlen(char const *);
scalar_t__ tolower(char const);
int librfc2874_formatcheck(const char *string, char *infostring) {
  unsigned int length, index = 0;
  unsigned int nibblecounter = 0, digitcounter = 0;
  infostring[0] = '\0';
  length = (unsigned int)strlen(string);
  if (length < 5) {
    snprintf(infostring, 1024 - 1,
             "Error in given bitstring label, has less than 5 chars!");
    return (1);
  };
  if (string[index] != '\\') {
    snprintf(infostring, 1024 - 1, "Char '%c' not expected on position %u",
             string[index], index + 1);
    return (1);
  };
  index++;
  if (string[index] != '[') {
    snprintf(infostring, 1024 - 1, "Char '%c' not expected on position %u",
             string[index], index + 1);
    return (1);
  };
  index++;
  if ((char)tolower(string[index]) != 'x') {
    snprintf(infostring, 1024 - 1, "Char '%c' not expected on position %u",
             string[index], index + 1);
    return (1);
  };
  index++;
  while (isxdigit((int)string[index])) {
    nibblecounter++;
    if (nibblecounter > 32) {
      snprintf(infostring, 1024 - 1, "More than 32 nibbles on position %u",
               index + 1);
      return (1);
    };
    index++;
    if (index > length) {
      break;
    };
  };
  if (index >= length) {
    snprintf(infostring, 1024 - 1,
             "Unexpected end of string (missing '/' or ']')");
    return (1);
  };
  if (string[index] == ']') {
    return (0);
  };
  if (string[index] != '/') {
    snprintf(infostring, 1024 - 1, "Char '%c' not expected on position %u",
             string[index], index + 1);
    return (1);
  };
  index++;
  if (index >= length) {
    snprintf(infostring, 1024 - 1,
             "Unexpected end of string (missing prefix length)");
    return (1);
  };
  while (isdigit((int)string[index])) {
    digitcounter++;
    if (digitcounter > 3) {
      snprintf(infostring, 1024 - 1, "More than 3 digits on position %u",
               index + 1);
      return (1);
    };
    index++;
    if (index > length) {
      break;
    };
  };
  if (index >= length) {
    snprintf(infostring, 1024 - 1, "Unexpected end of string (missing ']')");
    return (1);
  };
  if (string[index] == ']') {
    return (0);
  };
  snprintf(infostring, 1024 - 1, "Char '%c' not expected on position %u",
           string[index], index + 1);
  return (1);
}


x86 assembly (clang, -O0):
<librfc2874_formatcheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jae    11b5 <librfc2874_formatcheck+0x65>
mov    -0x18(%rbp),%rdi
mov    $0x3ff,%esi
lea    0xe5e(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f6 <librfc2874_formatcheck+0x3a6>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
je     11ff <librfc2874_formatcheck+0xaf>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%ecx
mov    -0x20(%rbp),%r8d
add    $0x1,%r8d
mov    $0x3ff,%esi
lea    0xe4b(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f6 <librfc2874_formatcheck+0x3a6>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5b,%eax
je     1252 <librfc2874_formatcheck+0x102>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%ecx
mov    -0x20(%rbp),%r8d
add    $0x1,%r8d
mov    $0x3ff,%esi
lea    0xdf8(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f6 <librfc2874_formatcheck+0x3a6>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1060 <tolower@plt>
movsbl %al,%eax
cmp    $0x78,%eax
je     12ad <librfc2874_formatcheck+0x15d>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%ecx
mov    -0x20(%rbp),%r8d
add    $0x1,%r8d
mov    $0x3ff,%esi
lea    0xd9d(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f6 <librfc2874_formatcheck+0x3a6>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1070 <isxdigit@plt>
cmp    $0x0,%rax
je     132b <librfc2874_formatcheck+0x1db>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x20,-0x24(%rbp)
jbe    130c <librfc2874_formatcheck+0x1bc>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
mov    $0x3ff,%esi
lea    0xd64(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f6 <librfc2874_formatcheck+0x3a6>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jbe    1326 <librfc2874_formatcheck+0x1d6>
jmp    132b <librfc2874_formatcheck+0x1db>
jmp    12b6 <librfc2874_formatcheck+0x166>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jb     135a <librfc2874_formatcheck+0x20a>
mov    -0x18(%rbp),%rdi
mov    $0x3ff,%esi
lea    0xd3a(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f6 <librfc2874_formatcheck+0x3a6>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5d,%eax
jne    137a <librfc2874_formatcheck+0x22a>
movl   $0x0,-0x4(%rbp)
jmp    14f6 <librfc2874_formatcheck+0x3a6>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     13c4 <librfc2874_formatcheck+0x274>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%ecx
mov    -0x20(%rbp),%r8d
add    $0x1,%r8d
mov    $0x3ff,%esi
lea    0xc86(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f6 <librfc2874_formatcheck+0x3a6>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jb     13fc <librfc2874_formatcheck+0x2ac>
mov    -0x18(%rbp),%rdi
mov    $0x3ff,%esi
lea    0xcc6(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f6 <librfc2874_formatcheck+0x3a6>
jmp    1401 <librfc2874_formatcheck+0x2b1>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1476 <librfc2874_formatcheck+0x326>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jbe    1457 <librfc2874_formatcheck+0x307>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
mov    $0x3ff,%esi
lea    0xc9c(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f6 <librfc2874_formatcheck+0x3a6>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jbe    1471 <librfc2874_formatcheck+0x321>
jmp    1476 <librfc2874_formatcheck+0x326>
jmp    1401 <librfc2874_formatcheck+0x2b1>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jb     14a5 <librfc2874_formatcheck+0x355>
mov    -0x18(%rbp),%rdi
mov    $0x3ff,%esi
lea    0xc70(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f6 <librfc2874_formatcheck+0x3a6>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5d,%eax
jne    14c5 <librfc2874_formatcheck+0x375>
movl   $0x0,-0x4(%rbp)
jmp    14f6 <librfc2874_formatcheck+0x3a6>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%ecx
mov    -0x20(%rbp),%r8d
add    $0x1,%r8d
mov    $0x3ff,%esi
lea    0xb4f(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<librfc2874_formatcheck>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movb   $0x0,(%rsi)
call   1040 <strlen@plt>
mov    %rax,%r15
cmp    $0x4,%r15d
ja     118d <librfc2874_formatcheck+0x3d>
lea    0xe87(%rip),%rdx
mov    %r14,%rdi
mov    $0x3ff,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
jmp    1278 <librfc2874_formatcheck+0x128>
movsbl (%rbx),%ecx
cmp    $0x5c,%ecx
jne    121e <librfc2874_formatcheck+0xce>
movsbl 0x1(%rbx),%ecx
cmp    $0x5b,%ecx
jne    1241 <librfc2874_formatcheck+0xf1>
movsbl 0x2(%rbx),%edi
call   1060 <tolower@plt>
cmp    $0x78,%al
jne    1258 <librfc2874_formatcheck+0x108>
mov    %r15d,%r13d
mov    $0x3,%ebp
nop
movsbl (%rbx,%rbp,1),%edi
call   1070 <isxdigit@plt>
test   %rax,%rax
je     128e <librfc2874_formatcheck+0x13e>
cmp    $0x23,%rbp
je     12a6 <librfc2874_formatcheck+0x156>
lea    0x1(%rbp),%rax
cmp    %r13,%rbp
mov    %rax,%rbp
jb     11c0 <librfc2874_formatcheck+0x70>
cmp    %r15d,%eax
jae    129a <librfc2874_formatcheck+0x14a>
mov    %eax,%r12d
movsbl (%rbx,%r12,1),%ecx
xor    %ebp,%ebp
cmp    $0x2f,%ecx
je     12c3 <librfc2874_formatcheck+0x173>
cmp    $0x5d,%cl
je     127d <librfc2874_formatcheck+0x12d>
lea    0x1(%rax),%r8d
lea    0xe23(%rip),%rdx
mov    %r14,%rdi
mov    $0x3ff,%esi
jmp    1271 <librfc2874_formatcheck+0x121>
lea    0xe12(%rip),%rdx
mov    $0x1,%ebp
mov    %r14,%rdi
mov    $0x3ff,%esi
mov    $0x1,%r8d
xor    %eax,%eax
call   1050 <snprintf@plt>
jmp    127d <librfc2874_formatcheck+0x12d>
lea    0xdef(%rip),%rdx
mov    %r14,%rdi
mov    $0x3ff,%esi
mov    $0x2,%r8d
jmp    1271 <librfc2874_formatcheck+0x121>
movsbl 0x2(%rbx),%ecx
lea    0xdd4(%rip),%rdx
mov    %r14,%rdi
mov    $0x3ff,%esi
mov    $0x3,%r8d
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbp,%rax
cmp    %r15d,%eax
jb     11f1 <librfc2874_formatcheck+0xa1>
lea    0xde0(%rip),%rdx
jmp    1179 <librfc2874_formatcheck+0x29>
lea    0xdb0(%rip),%rdx
mov    %r14,%rdi
mov    $0x3ff,%esi
mov    $0x24,%ecx
xor    %eax,%eax
call   1050 <snprintf@plt>
jmp    1278 <librfc2874_formatcheck+0x128>
add    $0x1,%eax
cmp    %r15d,%eax
jae    1352 <librfc2874_formatcheck+0x202>
movsbl 0x1(%rbx,%r12,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     135e <librfc2874_formatcheck+0x20e>
lea    0x2(%r12),%r8
cmp    %r13,%r8
ja     1365 <librfc2874_formatcheck+0x215>
movsbl (%rbx,%r8,1),%edi
mov    %r8,(%rsp)
call   1030 <isdigit@plt>
mov    (%rsp),%r8
test   %rax,%rax
je     1365 <librfc2874_formatcheck+0x215>
lea    0x3(%r12),%r8
cmp    %r13,%r8
ja     1365 <librfc2874_formatcheck+0x215>
movsbl (%rbx,%r8,1),%edi
mov    %r8,(%rsp)
call   1030 <isdigit@plt>
mov    (%rsp),%r8
test   %rax,%rax
je     1365 <librfc2874_formatcheck+0x215>
add    $0x4,%r12
cmp    %r13,%r12
ja     1362 <librfc2874_formatcheck+0x212>
movsbl (%rbx,%r12,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1362 <librfc2874_formatcheck+0x212>
lea    0x1(%r12),%ecx
lea    0xd9b(%rip),%rdx
mov    %r14,%rdi
mov    $0x3ff,%esi
jmp    12ba <librfc2874_formatcheck+0x16a>
lea    0xd56(%rip),%rdx
jmp    1179 <librfc2874_formatcheck+0x29>
add    $0x1,%r12
mov    %r12d,%r8d
cmp    %r15d,%r8d
jae    1392 <librfc2874_formatcheck+0x242>
mov    %r8d,%eax
movsbl (%rbx,%rax,1),%ecx
cmp    $0x5d,%ecx
je     127d <librfc2874_formatcheck+0x12d>
add    $0x1,%r8d
lea    0xcb2(%rip),%rdx
mov    %r14,%rdi
mov    $0x3ff,%esi
jmp    1271 <librfc2874_formatcheck+0x121>
lea    0xd69(%rip),%rdx
jmp    1179 <librfc2874_formatcheck+0x29>

LLVM IR (-O0):
@.str = [55 x i8] c"Error in given bitstring label, has less than 5 chars!\00"
@.str.1 = [38 x i8] c"Char '%c' not expected on position %u\00"
@.str.2 = [36 x i8] c"More than 32 nibbles on position %u\00"
@.str.3 = [46 x i8] c"Unexpected end of string (missing '/' or ']')\00"
@.str.4 = [49 x i8] c"Unexpected end of string (missing prefix length)\00"
@.str.5 = [34 x i8] c"More than 3 digits on position %u\00"
@.str.6 = [39 x i8] c"Unexpected end of string (missing ']')\00"
define i32 @librfc2874_formatcheck(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i64 0
store i8 0, i8* %11
%12 = load i8*, i8** %4
%13 = call i64 @strlen(i8* %12)
%14 = trunc i64 %13 to i32
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = icmp ult i32 %15, 5
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i8*, i8** %5
%19 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %18, i32 1023, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %212
20: ; preds = %2
%21 = load i8*, i8** %4
%22 = load i32, i32* %7
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 92
br i1 %27, label %28, label %39
28: ; preds = %20
%29 = load i8*, i8** %5
%30 = load i8*, i8** %4
%31 = load i32, i32* %7
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = load i32, i32* %7
%37 = add i32 %36, 1
%38 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %29, i32 1023, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %37)
store i32 1, i32* %3
br label %212
39: ; preds = %20
%40 = load i32, i32* %7
%41 = add i32 %40, 1
store i32 %41, i32* %7
%42 = load i8*, i8** %4
%43 = load i32, i32* %7
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 91
br i1 %48, label %49, label %60
49: ; preds = %39
%50 = load i8*, i8** %5
%51 = load i8*, i8** %4
%52 = load i32, i32* %7
%53 = zext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = load i32, i32* %7
%58 = add i32 %57, 1
%59 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %50, i32 1023, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %56, i32 %58)
store i32 1, i32* %3
br label %212
60: ; preds = %39
%61 = load i32, i32* %7
%62 = add i32 %61, 1
store i32 %62, i32* %7
%63 = load i8*, i8** %4
%64 = load i32, i32* %7
%65 = zext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = load i8, i8* %66
%68 = call i64 @tolower(i8 signext %67)
%69 = trunc i64 %68 to i8
%70 = sext i8 %69 to i32
%71 = icmp ne i32 %70, 120
br i1 %71, label %72, label %83
72: ; preds = %60
%73 = load i8*, i8** %5
%74 = load i8*, i8** %4
%75 = load i32, i32* %7
%76 = zext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %74, i64 %76
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = load i32, i32* %7
%81 = add i32 %80, 1
%82 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %73, i32 1023, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %79, i32 %81)
store i32 1, i32* %3
br label %212
83: ; preds = %60
%84 = load i32, i32* %7
%85 = add i32 %84, 1
store i32 %85, i32* %7
br label %86
86: ; preds = %112, %83
%87 = load i8*, i8** %4
%88 = load i32, i32* %7
%89 = zext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %87, i64 %89
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = call i64 @isxdigit(i32 %92)
%94 = icmp ne i64 %93, 0
br i1 %94, label %95, label %113
95: ; preds = %86
%96 = load i32, i32* %8
%97 = add i32 %96, 1
store i32 %97, i32* %8
%98 = load i32, i32* %8
%99 = icmp ugt i32 %98, 32
br i1 %99, label %100, label %105
100: ; preds = %95
%101 = load i8*, i8** %5
%102 = load i32, i32* %7
%103 = add i32 %102, 1
%104 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %101, i32 1023, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %103)
store i32 1, i32* %3
br label %212
105: ; preds = %95
%106 = load i32, i32* %7
%107 = add i32 %106, 1
store i32 %107, i32* %7
%108 = load i32, i32* %7
%109 = load i32, i32* %6
%110 = icmp ugt i32 %108, %109
br i1 %110, label %111, label %112
111: ; preds = %105
br label %113
112: ; preds = %105
br label %86
113: ; preds = %111, %86
%114 = load i32, i32* %7
%115 = load i32, i32* %6
%116 = icmp uge i32 %114, %115
br i1 %116, label %117, label %120
117: ; preds = %113
%118 = load i8*, i8** %5
%119 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %118, i32 1023, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %212
120: ; preds = %113
%121 = load i8*, i8** %4
%122 = load i32, i32* %7
%123 = zext i32 %122 to i64
%124 = getelementptr inbounds i8, i8* %121, i64 %123
%125 = load i8, i8* %124
%126 = sext i8 %125 to i32
%127 = icmp eq i32 %126, 93
br i1 %127, label %128, label %129
128: ; preds = %120
store i32 0, i32* %3
br label %212
129: ; preds = %120
%130 = load i8*, i8** %4
%131 = load i32, i32* %7
%132 = zext i32 %131 to i64
%133 = getelementptr inbounds i8, i8* %130, i64 %132
%134 = load i8, i8* %133
%135 = sext i8 %134 to i32
%136 = icmp ne i32 %135, 47
br i1 %136, label %137, label %148
137: ; preds = %129
%138 = load i8*, i8** %5
%139 = load i8*, i8** %4
%140 = load i32, i32* %7
%141 = zext i32 %140 to i64
%142 = getelementptr inbounds i8, i8* %139, i64 %141
%143 = load i8, i8* %142
%144 = sext i8 %143 to i32
%145 = load i32, i32* %7
%146 = add i32 %145, 1
%147 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %138, i32 1023, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %144, i32 %146)
store i32 1, i32* %3
br label %212
148: ; preds = %129
%149 = load i32, i32* %7
%150 = add i32 %149, 1
store i32 %150, i32* %7
%151 = load i32, i32* %7
%152 = load i32, i32* %6
%153 = icmp uge i32 %151, %152
br i1 %153, label %154, label %157
154: ; preds = %148
%155 = load i8*, i8** %5
%156 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %155, i32 1023, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %212
157: ; preds = %148
br label %158
158: ; preds = %184, %157
%159 = load i8*, i8** %4
%160 = load i32, i32* %7
%161 = zext i32 %160 to i64
%162 = getelementptr inbounds i8, i8* %159, i64 %161
%163 = load i8, i8* %162
%164 = sext i8 %163 to i32
%165 = call i64 @isdigit(i32 %164)
%166 = icmp ne i64 %165, 0
br i1 %166, label %167, label %185
167: ; preds = %158
%168 = load i32, i32* %9
%169 = add i32 %168, 1
store i32 %169, i32* %9
%170 = load i32, i32* %9
%171 = icmp ugt i32 %170, 3
br i1 %171, label %172, label %177
172: ; preds = %167
%173 = load i8*, i8** %5
%174 = load i32, i32* %7
%175 = add i32 %174, 1
%176 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %173, i32 1023, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %175)
store i32 1, i32* %3
br label %212
177: ; preds = %167
%178 = load i32, i32* %7
%179 = add i32 %178, 1
store i32 %179, i32* %7
%180 = load i32, i32* %7
%181 = load i32, i32* %6
%182 = icmp ugt i32 %180, %181
br i1 %182, label %183, label %184
183: ; preds = %177
br label %185
184: ; preds = %177
br label %158
185: ; preds = %183, %158
%186 = load i32, i32* %7
%187 = load i32, i32* %6
%188 = icmp uge i32 %186, %187
br i1 %188, label %189, label %192
189: ; preds = %185
%190 = load i8*, i8** %5
%191 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %190, i32 1023, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %212
192: ; preds = %185
%193 = load i8*, i8** %4
%194 = load i32, i32* %7
%195 = zext i32 %194 to i64
%196 = getelementptr inbounds i8, i8* %193, i64 %195
%197 = load i8, i8* %196
%198 = sext i8 %197 to i32
%199 = icmp eq i32 %198, 93
br i1 %199, label %200, label %201
200: ; preds = %192
store i32 0, i32* %3
br label %212
201: ; preds = %192
%202 = load i8*, i8** %5
%203 = load i8*, i8** %4
%204 = load i32, i32* %7
%205 = zext i32 %204 to i64
%206 = getelementptr inbounds i8, i8* %203, i64 %205
%207 = load i8, i8* %206
%208 = sext i8 %207 to i32
%209 = load i32, i32* %7
%210 = add i32 %209, 1
%211 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %202, i32 1023, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %208, i32 %210)
store i32 1, i32* %3
br label %212
212: ; preds = %201, %200, %189, %172, %154, %137, %128, %117, %100, %72, %49, %28, %17
%213 = load i32, i32* %3
ret i32 %213
}

LLVM IR (-O2):
@.str = [55 x i8] c"Error in given bitstring label, has less than 5 chars!\00"
@.str.1 = [38 x i8] c"Char '%c' not expected on position %u\00"
@.str.2 = [36 x i8] c"More than 32 nibbles on position %u\00"
@.str.3 = [46 x i8] c"Unexpected end of string (missing '/' or ']')\00"
@.str.4 = [49 x i8] c"Unexpected end of string (missing prefix length)\00"
@.str.5 = [34 x i8] c"More than 3 digits on position %u\00"
@.str.6 = [39 x i8] c"Unexpected end of string (missing ']')\00"
define i32 @librfc2874_formatcheck(i8* nocapture %0, i8* %1) {
store i8 0, i8* %1
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = trunc i64 %3 to i32
%5 = icmp ult i32 %4, 5
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 1023, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
br label %121
8: ; preds = %2
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 92
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = sext i8 %9 to i32
%13 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 1023, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 1)
br label %121
14: ; preds = %8
%15 = getelementptr inbounds i8, i8* %0, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 91
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = sext i8 %16 to i32
%20 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 1023, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 2)
br label %121
21: ; preds = %14
%22 = getelementptr inbounds i8, i8* %0, i64 2
%23 = load i8, i8* %22
%24 = tail call i64 @tolower(i8 signext %23)
%25 = and i64 %24, 255
%26 = icmp eq i64 %25, 120
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = and i64 %3, 4294967295
br label %33
29: ; preds = %21
%30 = load i8, i8* %22
%31 = sext i8 %30 to i32
%32 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 1023, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 3)
br label %121
33: ; preds = %27, %44
%34 = phi i64 [ 3, %27 ], [ %45, %44 ]
%35 = getelementptr inbounds i8, i8* %0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = tail call i64 @isxdigit(i32 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %47, label %40
40: ; preds = %33
%41 = icmp eq i64 %34, 35
br i1 %41, label %42, label %44
42: ; preds = %40
%43 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 1023, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 36)
br label %121
44: ; preds = %40
%45 = add nuw nsw i64 %34, 1
%46 = icmp ult i64 %34, %28
br i1 %46, label %33, label %47
47: ; preds = %44, %33
%48 = phi i64 [ %45, %44 ], [ %34, %33 ]
%49 = trunc i64 %48 to i32
%50 = icmp ult i32 %49, %4
br i1 %50, label %53, label %51
51: ; preds = %47
%52 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 1023, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
br label %121
53: ; preds = %47
%54 = and i64 %48, 4294967295
%55 = getelementptr inbounds i8, i8* %0, i64 %54
%56 = load i8, i8* %55
switch i8 %56, label %57 [
i8 93, label %121
i8 47, label %61
]
57: ; preds = %53
%58 = sext i8 %56 to i32
%59 = add nuw i32 %49, 1
%60 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 1023, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %58, i32 %59)
br label %121
61: ; preds = %53
%62 = add nuw i32 %49, 1
%63 = icmp ult i32 %62, %4
br i1 %63, label %64, label %72
64: ; preds = %61
%65 = add nuw nsw i64 %54, 1
%66 = getelementptr inbounds i8, i8* %0, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = tail call i64 @isdigit(i32 %68)
%70 = icmp eq i64 %69, 0
%71 = trunc i64 %65 to i32
br i1 %70, label %107, label %74
72: ; preds = %61
%73 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 1023, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
br label %121
74: ; preds = %64
%75 = add nuw nsw i64 %54, 2
%76 = trunc i64 %75 to i32
%77 = icmp ugt i64 %75, %28
br i1 %77, label %107, label %81
78: ; preds = %101
%79 = add i32 %99, 1
%80 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 1023, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %79)
br label %121
81: ; preds = %74
%82 = getelementptr inbounds i8, i8* %0, i64 %75
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = tail call i64 @isdigit(i32 %84)
%86 = icmp eq i64 %85, 0
br i1 %86, label %107, label %87
87: ; preds = %81
%88 = add nuw nsw i64 %54, 3
%89 = trunc i64 %88 to i32
%90 = icmp ugt i64 %88, %28
br i1 %90, label %107, label %91
91: ; preds = %87
%92 = getelementptr inbounds i8, i8* %0, i64 %88
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = tail call i64 @isdigit(i32 %94)
%96 = icmp eq i64 %95, 0
br i1 %96, label %107, label %97
97: ; preds = %91
%98 = add nuw nsw i64 %54, 4
%99 = trunc i64 %98 to i32
%100 = icmp ugt i64 %98, %28
br i1 %100, label %107, label %101
101: ; preds = %97
%102 = getelementptr inbounds i8, i8* %0, i64 %98
%103 = load i8, i8* %102
%104 = sext i8 %103 to i32
%105 = tail call i64 @isdigit(i32 %104)
%106 = icmp eq i64 %105, 0
br i1 %106, label %107, label %78
107: ; preds = %101, %97, %91, %87, %81, %74, %64
%108 = phi i32 [ %76, %74 ], [ %71, %64 ], [ %76, %81 ], [ %89, %87 ], [ %89, %91 ], [ %99, %97 ], [ %99, %101 ]
%109 = icmp ult i32 %108, %4
br i1 %109, label %112, label %110
110: ; preds = %107
%111 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 1023, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
br label %121
112: ; preds = %107
%113 = zext i32 %108 to i64
%114 = getelementptr inbounds i8, i8* %0, i64 %113
%115 = load i8, i8* %114
%116 = icmp eq i8 %115, 93
br i1 %116, label %121, label %117
117: ; preds = %112
%118 = sext i8 %115 to i32
%119 = add nuw i32 %108, 1
%120 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 1023, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %118, i32 %119)
br label %121
121: ; preds = %112, %53, %117, %110, %78, %72, %57, %51, %42, %29, %18, %11, %6
%122 = phi i32 [ 1, %6 ], [ 1, %11 ], [ 1, %18 ], [ 1, %29 ], [ 1, %42 ], [ 1, %51 ], [ 1, %57 ], [ 1, %72 ], [ 1, %78 ], [ 1, %110 ], [ 1, %117 ], [ 0, %53 ], [ 0, %112 ]
ret i32 %122
}