#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;
  size_t 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    $0x30,%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    12b3 <cgi_check_strlen_x2+0x193>
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     12ac <cgi_check_strlen_x2+0x18c>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    122e <cgi_check_strlen_x2+0x10e>
cmpl   $0x0,-0x18(%rbp)
je     11bd <cgi_check_strlen_x2+0x9d>
mov    -0x10(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1040 <cgi_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b3 <cgi_check_strlen_x2+0x193>
cmpl   $0x0,-0x14(%rbp)
jne    11e3 <cgi_check_strlen_x2+0xc3>
mov    -0x10(%rbp),%rsi
lea    0xe8e(%rip),%rdi
call   1040 <cgi_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b3 <cgi_check_strlen_x2+0x193>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jne    1225 <cgi_check_strlen_x2+0x105>
mov    -0x10(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1040 <cgi_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b3 <cgi_check_strlen_x2+0x193>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1246 <cgi_check_strlen_x2+0x126>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    124f <cgi_check_strlen_x2+0x12f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x20,-0x14(%rbp)
jle    1275 <cgi_check_strlen_x2+0x155>
mov    -0x10(%rbp),%rsi
lea    0xe50(%rip),%rdi
call   1040 <cgi_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b3 <cgi_check_strlen_x2+0x193>
cmpl   $0x22,-0x18(%rbp)
jle    129b <cgi_check_strlen_x2+0x17b>
mov    -0x10(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1040 <cgi_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b3 <cgi_check_strlen_x2+0x193>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1170 <cgi_check_strlen_x2+0x50>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgi_check_strlen_x2>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
cmp    $0x41,%eax
jle    114c <cgi_check_strlen_x2+0x2c>
lea    0xec7(%rip),%rdi
mov    %r14,%rsi
call   1040 <cgi_error@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %r15d,%r15d
xor    %eax,%eax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%r14,%rbx,1),%ecx
cmp    $0x2f,%cl
je     1170 <cgi_check_strlen_x2+0x50>
test   %cl,%cl
jne    1191 <cgi_check_strlen_x2+0x71>
jmp    11ca <cgi_check_strlen_x2+0xaa>
test   %eax,%eax
jne    11d1 <cgi_check_strlen_x2+0xb1>
test   %r15d,%r15d
je     11dd <cgi_check_strlen_x2+0xbd>
mov    %r14,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
movslq %eax,%rcx
mov    $0x1,%eax
cmp    %rcx,%rbx
je     11e9 <cgi_check_strlen_x2+0xc9>
mov    %eax,%ecx
lea    0x1(%rcx),%eax
xor    %edx,%edx
test   %ecx,%ecx
sete   %dl
cmove  %ecx,%eax
add    %edx,%r15d
cmp    $0x21,%r15d
jae    11be <cgi_check_strlen_x2+0x9e>
add    $0x1,%rbx
cmp    $0x23,%eax
jl     1160 <cgi_check_strlen_x2+0x40>
lea    0xf2b(%rip),%rdi
jmp    1139 <cgi_check_strlen_x2+0x19>
lea    0xeef(%rip),%rdi
jmp    1139 <cgi_check_strlen_x2+0x19>
xor    %eax,%eax
jmp    1146 <cgi_check_strlen_x2+0x26>
lea    0xe4d(%rip),%rdi
jmp    1139 <cgi_check_strlen_x2+0x19>
lea    0xe7c(%rip),%rdi
jmp    1139 <cgi_check_strlen_x2+0x19>
lea    0xe95(%rip),%rdi
jmp    1139 <cgi_check_strlen_x2+0x19>

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 i64
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 %77
13: ; preds = %1
store i64 0, i64* %6
store i32 0, i32* %4
store i32 0, i32* %5
br label %14
14: ; preds = %73, %13
%15 = load i8*, i8** %3
%16 = load i64, i64* %6
%17 = getelementptr inbounds i8, i8* %15, i64 %16
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %76
20: ; preds = %14
%21 = load i8*, i8** %3
%22 = load i64, i64* %6
%23 = getelementptr inbounds i8, i8* %21, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 47
br i1 %26, label %27, label %52
27: ; preds = %20
%28 = load i32, i32* %5
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i8*, i8** %3
%32 = call i32 @cgi_error(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0), i8* %31)
store i32 1, i32* %2
br label %77
33: ; preds = %27
%34 = load i32, i32* %4
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i8*, i8** %3
%38 = call i32 @cgi_error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %37)
store i32 1, i32* %2
br label %77
39: ; preds = %33
%40 = load i64, i64* %6
%41 = load i8*, i8** %3
%42 = call i32 @strlen(i8* %41)
%43 = sub nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = icmp eq i64 %40, %44
br i1 %45, label %46, label %49
46: ; preds = %39
%47 = load i8*, i8** %3
%48 = call i32 @cgi_error(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %47)
store i32 1, i32* %2
br label %77
49: ; preds = %39
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
br label %52
52: ; preds = %49, %20
%53 = load i32, i32* %5
%54 = icmp ne i32 %53, 0
br i1 %54, label %58, label %55
55: ; preds = %52
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 1
store i32 %57, i32* %4
br label %61
58: ; preds = %52
%59 = load i32, i32* %5
%60 = add nsw i32 %59, 1
store i32 %60, i32* %5
br label %61
61: ; preds = %58, %55
%62 = load i32, i32* %4
%63 = icmp sgt i32 %62, 32
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = load i8*, i8** %3
%66 = call i32 @cgi_error(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i8* %65)
store i32 1, i32* %2
br label %77
67: ; preds = %61
%68 = load i32, i32* %5
%69 = icmp sgt i32 %68, 34
br i1 %69, label %70, label %73
70: ; preds = %67
%71 = load i8*, i8** %3
%72 = call i32 @cgi_error(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i8* %71)
store i32 1, i32* %2
br label %77
73: ; preds = %67
%74 = load i64, i64* %6
%75 = add i64 %74, 1
store i64 %75, i64* %6
br label %14
76: ; preds = %14
store i32 0, i32* %2
br label %77
77: ; preds = %76, %70, %64, %46, %36, %30, %10
%78 = load i32, i32* %2
ret i32 %78
}

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 i32 [ %32, %37 ], [ 0, %1 ]
%8 = phi i32 [ %33, %37 ], [ 0, %1 ]
%9 = phi i64 [ %39, %37 ], [ 0, %1 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%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 %8, 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 %7, 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 = sext i32 %22 to i64
%24 = icmp eq i64 %9, %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 [ %8, %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 %7, %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 i64 %9, 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
}