#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*/ cgi_error(char *, char const *);
int strlen(char const *);
int cgi_check_strlen_x2(char const *string) {
  int n1, n2, p;
  if (strlen(string) > 65) {
    cgi_error("Name exceeds 65 characters limit: %s", string);
    return 1;
  }
  p = 0;
  n1 = 0;
  n2 = 0;
  while (string[p]) {
    if (string[p] == '/') {
      if (n2 != 0) {
        cgi_error("Zone or Family with base scope should have only one / : %s",
                  string);
        return 1;
      }
      if (n1 == 0) {
        cgi_error("Base part of the name is empty in %s", string);
        return 1;
      }
      if (p == strlen(string) - 1) {
        cgi_error("Zone or Family part of the name is empty in %s", string);
        return 1;
      }
      n2++;
    }
    if (!n2)
      n1++;
    else
      n2++;
    if (n1 > 32) {
      cgi_error("Base part of the name exceed 32 chars limit: %s", string);
      return 1;
    }
    if (n2 > 34) {
      cgi_error("Zone or Family part of the name exceed 32 chars limit: %s",
                string);
      return 1;
    }
    p++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<cgi_check_strlen_x2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x41,%eax
jle    115a <cgi_check_strlen_x2+0x3a>
mov    -0x10(%rbp),%rsi
lea    0xeb7(%rip),%rdi
call   1040 <cgi_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a8 <cgi_check_strlen_x2+0x188>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     12a1 <cgi_check_strlen_x2+0x181>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1226 <cgi_check_strlen_x2+0x106>
cmpl   $0x0,-0x18(%rbp)
je     11bc <cgi_check_strlen_x2+0x9c>
mov    -0x10(%rbp),%rsi
lea    0xe7a(%rip),%rdi
call   1040 <cgi_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a8 <cgi_check_strlen_x2+0x188>
cmpl   $0x0,-0x14(%rbp)
jne    11e2 <cgi_check_strlen_x2+0xc2>
mov    -0x10(%rbp),%rsi
lea    0xe8f(%rip),%rdi
call   1040 <cgi_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a8 <cgi_check_strlen_x2+0x188>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    121d <cgi_check_strlen_x2+0xfd>
mov    -0x10(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1040 <cgi_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a8 <cgi_check_strlen_x2+0x188>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    123e <cgi_check_strlen_x2+0x11e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1247 <cgi_check_strlen_x2+0x127>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x20,-0x14(%rbp)
jle    126d <cgi_check_strlen_x2+0x14d>
mov    -0x10(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   1040 <cgi_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a8 <cgi_check_strlen_x2+0x188>
cmpl   $0x22,-0x18(%rbp)
jle    1293 <cgi_check_strlen_x2+0x173>
mov    -0x10(%rbp),%rsi
lea    0xe62(%rip),%rdi
call   1040 <cgi_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a8 <cgi_check_strlen_x2+0x188>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116f <cgi_check_strlen_x2+0x4f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgi_check_strlen_x2>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
cmp    $0x41,%eax
jle    114a <cgi_check_strlen_x2+0x2a>
lea    0xec8(%rip),%rdi
mov    %r14,%rsi
call   1040 <cgi_error@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %ecx,%ecx
movzbl (%r14,%rbx,1),%eax
cmp    $0x2f,%al
je     1160 <cgi_check_strlen_x2+0x40>
test   %al,%al
jne    117d <cgi_check_strlen_x2+0x5d>
jmp    11ae <cgi_check_strlen_x2+0x8e>
nop
test   %ecx,%ecx
jne    11b2 <cgi_check_strlen_x2+0x92>
test   %ebp,%ebp
je     11be <cgi_check_strlen_x2+0x9e>
mov    %r14,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    %rax,%rbx
je     11ca <cgi_check_strlen_x2+0xaa>
mov    %ecx,%eax
lea    0x1(%rax),%ecx
xor    %edx,%edx
test   %eax,%eax
sete   %dl
cmove  %eax,%ecx
add    %edx,%ebp
cmp    $0x21,%ebp
jae    11a5 <cgi_check_strlen_x2+0x85>
add    $0x1,%rbx
cmp    $0x23,%ecx
jl     1150 <cgi_check_strlen_x2+0x30>
lea    0xf41(%rip),%rdi
jmp    1138 <cgi_check_strlen_x2+0x18>
lea    0xf08(%rip),%rdi
jmp    1138 <cgi_check_strlen_x2+0x18>
xor    %eax,%eax
jmp    1145 <cgi_check_strlen_x2+0x25>
lea    0xe6c(%rip),%rdi
jmp    1138 <cgi_check_strlen_x2+0x18>
lea    0xe9b(%rip),%rdi
jmp    1138 <cgi_check_strlen_x2+0x18>
lea    0xeb4(%rip),%rdi
jmp    1138 <cgi_check_strlen_x2+0x18>

LLVM IR (-O0):
@.str = [37 x i8] c"Name exceeds 65 characters limit: %s\00"
@.str.1 = [59 x i8] c"Zone or Family with base scope should have only one / : %s\00"
@.str.2 = [37 x i8] c"Base part of the name is empty in %s\00"
@.str.3 = [47 x i8] c"Zone or Family part of the name is empty in %s\00"
@.str.4 = [48 x i8] c"Base part of the name exceed 32 chars limit: %s\00"
@.str.5 = [58 x i8] c"Zone or Family part of the name exceed 32 chars limit: %s\00"
define i32 @cgi_check_strlen_x2(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = icmp sgt i32 %8, 65
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @cgi_error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %11)
store i32 1, i32* %2
br label %78
13: ; preds = %1
store i32 0, i32* %6
store i32 0, i32* %4
store i32 0, i32* %5
br label %14
14: ; preds = %74, %13
%15 = load i8*, i8** %3
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %77
21: ; preds = %14
%22 = load i8*, i8** %3
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 47
br i1 %28, label %29, label %53
29: ; preds = %21
%30 = load i32, i32* %5
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i8*, i8** %3
%34 = call i32 @cgi_error(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0), i8* %33)
store i32 1, i32* %2
br label %78
35: ; preds = %29
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i8*, i8** %3
%40 = call i32 @cgi_error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %39)
store i32 1, i32* %2
br label %78
41: ; preds = %35
%42 = load i32, i32* %6
%43 = load i8*, i8** %3
%44 = call i32 @strlen(i8* %43)
%45 = sub nsw i32 %44, 1
%46 = icmp eq i32 %42, %45
br i1 %46, label %47, label %50
47: ; preds = %41
%48 = load i8*, i8** %3
%49 = call i32 @cgi_error(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %48)
store i32 1, i32* %2
br label %78
50: ; preds = %41
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
br label %53
53: ; preds = %50, %21
%54 = load i32, i32* %5
%55 = icmp ne i32 %54, 0
br i1 %55, label %59, label %56
56: ; preds = %53
%57 = load i32, i32* %4
%58 = add nsw i32 %57, 1
store i32 %58, i32* %4
br label %62
59: ; preds = %53
%60 = load i32, i32* %5
%61 = add nsw i32 %60, 1
store i32 %61, i32* %5
br label %62
62: ; preds = %59, %56
%63 = load i32, i32* %4
%64 = icmp sgt i32 %63, 32
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = load i8*, i8** %3
%67 = call i32 @cgi_error(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i8* %66)
store i32 1, i32* %2
br label %78
68: ; preds = %62
%69 = load i32, i32* %5
%70 = icmp sgt i32 %69, 34
br i1 %70, label %71, label %74
71: ; preds = %68
%72 = load i8*, i8** %3
%73 = call i32 @cgi_error(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i8* %72)
store i32 1, i32* %2
br label %78
74: ; preds = %68
%75 = load i32, i32* %6
%76 = add nsw i32 %75, 1
store i32 %76, i32* %6
br label %14
77: ; preds = %14
store i32 0, i32* %2
br label %78
78: ; preds = %77, %71, %65, %47, %38, %32, %10
%79 = load i32, i32* %2
ret i32 %79
}

LLVM IR (-O2):
@.str = [37 x i8] c"Name exceeds 65 characters limit: %s\00"
@.str.1 = [59 x i8] c"Zone or Family with base scope should have only one / : %s\00"
@.str.2 = [37 x i8] c"Base part of the name is empty in %s\00"
@.str.3 = [47 x i8] c"Zone or Family part of the name is empty in %s\00"
@.str.4 = [48 x i8] c"Base part of the name exceed 32 chars limit: %s\00"
@.str.5 = [58 x i8] c"Zone or Family part of the name exceed 32 chars limit: %s\00"
define i32 @cgi_check_strlen_x2(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 65
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @cgi_error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %42
6: ; preds = %1, %37
%7 = phi i64 [ %39, %37 ], [ 0, %1 ]
%8 = phi i32 [ %32, %37 ], [ 0, %1 ]
%9 = phi i32 [ %33, %37 ], [ 0, %1 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %7
%11 = load i8, i8* %10
switch i8 %11, label %27 [
i8 0, label %42
i8 47, label %12
]
12: ; preds = %6
%13 = icmp eq i32 %9, 0
br i1 %13, label %16, label %14
14: ; preds = %12
%15 = tail call i32 @cgi_error(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %42
16: ; preds = %12
%17 = icmp eq i32 %8, 0
br i1 %17, label %18, label %20
18: ; preds = %16
%19 = tail call i32 @cgi_error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %42
20: ; preds = %16
%21 = tail call i32 @strlen(i8* %0)
%22 = add nsw i32 %21, -1
%23 = zext i32 %22 to i64
%24 = icmp eq i64 %7, %23
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = tail call i32 @cgi_error(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %42
27: ; preds = %20, %6
%28 = phi i32 [ %9, %6 ], [ 1, %20 ]
%29 = icmp eq i32 %28, 0
%30 = add nsw i32 %28, 1
%31 = zext i1 %29 to i32
%32 = add nuw nsw i32 %8, %31
%33 = select i1 %29, i32 0, i32 %30
%34 = icmp ugt i32 %32, 32
br i1 %34, label %35, label %37
35: ; preds = %27
%36 = tail call i32 @cgi_error(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %42
37: ; preds = %27
%38 = icmp sgt i32 %33, 34
%39 = add nuw i64 %7, 1
br i1 %38, label %40, label %6
40: ; preds = %37
%41 = tail call i32 @cgi_error(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i8* %0)
br label %42
42: ; preds = %6, %40, %35, %25, %18, %14, %4
%43 = phi i32 [ 1, %4 ], [ 1, %14 ], [ 1, %18 ], [ 1, %25 ], [ 1, %35 ], [ 1, %40 ], [ 0, %6 ]
ret i32 %43
}