#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*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int FSqueryValidator(char *value) {
  char testValue[1000] = {'\0'};
  int numslash = 1;
  int slashResult = 0;
  strcpy(testValue, value + 5);
  while (strncmp(testValue + numslash, "/", 1) == 0)
    numslash++;
  switch (numslash) {
  case 2:
    if (strlen(testValue + numslash))
      slashResult = 2;
    else
      slashResult = 0;
    break;
  case 3:
    if (strlen(testValue + numslash))
      slashResult = 3;
    else
      slashResult = 0;
    break;
  default:
    slashResult = 0;
    break;
  }
  return slashResult;
}


x86 assembly (clang, -O0):
<FSqueryValidator>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x3f0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1060 <memset@plt>
movl   $0x1,-0x3f4(%rbp)
movl   $0x0,-0x3f8(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x5,%rsi
call   1040 <strcpy@plt>
lea    -0x3f0(%rbp),%rdi
movslq -0x3f4(%rbp),%rax
add    %rax,%rdi
lea    0xe5e(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ca <FSqueryValidator+0x8a>
mov    -0x3f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f4(%rbp)
jmp    118a <FSqueryValidator+0x4a>
mov    -0x3f4(%rbp),%eax
mov    %eax,-0x3fc(%rbp)
sub    $0x2,%eax
je     11f8 <FSqueryValidator+0xb8>
jmp    11e4 <FSqueryValidator+0xa4>
mov    -0x3fc(%rbp),%eax
sub    $0x3,%eax
je     1235 <FSqueryValidator+0xf5>
jmp    1272 <FSqueryValidator+0x132>
lea    -0x3f0(%rbp),%rdi
movslq -0x3f4(%rbp),%rax
add    %rax,%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
je     1226 <FSqueryValidator+0xe6>
movl   $0x2,-0x3f8(%rbp)
jmp    1230 <FSqueryValidator+0xf0>
movl   $0x0,-0x3f8(%rbp)
jmp    127c <FSqueryValidator+0x13c>
lea    -0x3f0(%rbp),%rdi
movslq -0x3f4(%rbp),%rax
add    %rax,%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
je     1263 <FSqueryValidator+0x123>
movl   $0x3,-0x3f8(%rbp)
jmp    126d <FSqueryValidator+0x12d>
movl   $0x0,-0x3f8(%rbp)
jmp    127c <FSqueryValidator+0x13c>
movl   $0x0,-0x3f8(%rbp)
mov    -0x3f8(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FSqueryValidator>:
push   %rbp
push   %r14
push   %rbx
sub    $0x3f0,%rsp
mov    %rdi,%r14
mov    %rsp,%rbx
xor    %ebp,%ebp
mov    $0x3e8,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
add    $0x5,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0xe88(%rip),%r14
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
add    $0x1,%ebp
test   %rax,%rax
je     1180 <FSqueryValidator+0x40>
cmp    $0x3,%ebp
je     11aa <FSqueryValidator+0x6a>
xor    %eax,%eax
cmp    $0x2,%ebp
je     11af <FSqueryValidator+0x6f>
jmp    11be <FSqueryValidator+0x7e>
mov    $0x3,%ebp
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
cmove  %eax,%ebp
mov    %ebp,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define i32 @FSqueryValidator(i8* %0) {
%2 = alloca i8*
%3 = alloca [1000 x i8]
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = bitcast [1000 x i8]* %3 to i8*
store i32 1, i32* %4
store i32 0, i32* %5
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 5
%10 = call i32 @strcpy(i8* %7, i8* %9)
br label %11
11: ; preds = %18, %1
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %11
21: ; preds = %11
%22 = load i32, i32* %4
switch i32 %22, label %43 [
i32 2, label %23
i32 3, label %33
]
23: ; preds = %21
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = call i32 @strlen(i8* %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %23
store i32 2, i32* %5
br label %32
31: ; preds = %23
store i32 0, i32* %5
br label %32
32: ; preds = %31, %30
br label %44
33: ; preds = %21
%34 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = call i32 @strlen(i8* %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %33
store i32 3, i32* %5
br label %42
41: ; preds = %33
store i32 0, i32* %5
br label %42
42: ; preds = %41, %40
br label %44
43: ; preds = %21
store i32 0, i32* %5
br label %44
44: ; preds = %43, %42, %32
%45 = load i32, i32* %5
ret i32 %45
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define i32 @FSqueryValidator(i8* %0) {
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds i8, i8* %0, i64 5
%5 = call i32 @strcpy(i8* %3, i8* %4)
br label %6
6: ; preds = %6, %1
%7 = phi i64 [ %11, %6 ], [ 1, %1 ]
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %7
%9 = call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%10 = icmp eq i64 %9, 0
%11 = add nuw i64 %7, 1
br i1 %10, label %6, label %12
12: ; preds = %6
%13 = trunc i64 %7 to i32
switch i32 %13, label %20 [
i32 2, label %15
i32 3, label %14
]
14: ; preds = %12
br label %15
15: ; preds = %12, %14
%16 = phi i32 [ 3, %14 ], [ %13, %12 ]
%17 = call i32 @strlen(i8* %8)
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i32 0, i32 %16
br label %20
20: ; preds = %15, %12
%21 = phi i32 [ 0, %12 ], [ %19, %15 ]
ret i32 %21
}