#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*/ printf(char *, ...);
int strlen(char *);
int ValidateFileName(int argc, char *argv[]) {
  int i = 0, special_flag = 0, arglen = 0;
  int arg_max_length = 25;
  ++argv;
  --argc;
  if (argc < 1) {
    printf("\n Programm Requires one Argument (Eneter input PCAP file "
           "name)..!!\n");
    return 0;
  } else if (argc > 1) {
    printf(
        "\n Too many Arguments, Programme Accepts only one Argument. Bye!!\n");
    return 0;
  } else {
    arglen = strlen(argv[0]);
    if (arglen >= arg_max_length - 1) {
      printf("\n File name is too big, Don't try to crash our programme!!!\n");
      return 0;
    }
    for (i = 0; i < arglen; i++) {
      printf("%c", argv[0][i]);
      switch (argv[0][i]) {
      case '\\':
        printf("\n Back slash is detected, It is not allowed in File-name.\n");
        special_flag = 1;
        break;
      case '$':
        printf("\n Back slash is detected, It is not allowed in File-name.\n");
        special_flag = 1;
        break;
      case '#':
        printf("\n Back slash is detected, It is not allowed in File-name.\n");
        special_flag = 1;
        break;
      case '%':
        printf("\n Back slash is detected, It is not allowed in File-name.\n");
        special_flag = 1;
        break;
      case '^':
        printf("\n Back slash is detected, It is not allowed in File-name.\n");
        special_flag = 1;
        break;
      case '\|':
        printf("\n Back slash is detected, It is not allowed in File-name.\n");
        special_flag = 1;
        break;
      case '*':
        printf("\n Star symbol is detected, It is not allowed in File-name.\n");
        special_flag = 1;
        break;
      case '\'':
        printf(
            "\n single quote is detected, It is not allowed in File-name.\n");
        special_flag = 1;
        break;
      case '"':
        printf(
            "\n Double quote is detected, It is not allowed in File-name.\n");
        special_flag = 1;
        break;
      case ' ':
        printf("\n Space is detected, It is not allowed in File-name.\n");
        special_flag = 1;
        break;
      }
      if (special_flag == 1) {
        printf("\n Special characters are not allowed, Don't try to crash our "
               "programme!!!\n");
        return 0;
      }
    }
    printf("\n File Name is Proper and Accepted\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<ValidateFileName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x19,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    1184 <ValidateFileName+0x64>
lea    0x1003(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1392 <ValidateFileName+0x272>
cmpl   $0x1,-0x8(%rbp)
jle    11a8 <ValidateFileName+0x88>
lea    0x1023(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1392 <ValidateFileName+0x272>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     11e2 <ValidateFileName+0xc2>
lea    0x102b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1392 <ValidateFileName+0x272>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    137d <ValidateFileName+0x25d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0x102c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffe0,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5c,%eax
ja     1346 <ValidateFileName+0x226>
mov    -0x28(%rbp),%rax
lea    0xdc2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xfec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    1346 <ValidateFileName+0x226>
lea    0xfd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    1346 <ValidateFileName+0x226>
lea    0xfb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    1346 <ValidateFileName+0x226>
lea    0xf9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    1346 <ValidateFileName+0x226>
lea    0xf84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    1346 <ValidateFileName+0x226>
lea    0xf6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    1346 <ValidateFileName+0x226>
lea    0xf8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    1346 <ValidateFileName+0x226>
lea    0xfad(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    1346 <ValidateFileName+0x226>
lea    0xfd0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    1346 <ValidateFileName+0x226>
lea    0xff3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    136a <ValidateFileName+0x24a>
lea    0x100a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1392 <ValidateFileName+0x272>
jmp    136f <ValidateFileName+0x24f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e9 <ValidateFileName+0xc9>
lea    0x1028(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ValidateFileName>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
cmp    $0x2,%edi
jge    114f <ValidateFileName+0x1f>
lea    0x1236(%rip),%rbx
jmp    11e3 <ValidateFileName+0xb3>
jne    116b <ValidateFileName+0x3b>
mov    %rsi,%r12
mov    0x8(%rsi),%rdi
call   1050 <strlen@plt>
cmp    $0x17,%eax
jle    1174 <ValidateFileName+0x44>
lea    0x119a(%rip),%rbx
jmp    11e3 <ValidateFileName+0xb3>
lea    0x11cd(%rip),%rbx
jmp    11e3 <ValidateFileName+0xb3>
mov    $0x1,%r14d
lea    0xff3(%rip),%rbx
test   %eax,%eax
jle    11e3 <ValidateFileName+0xb3>
mov    %eax,%r15d
mov    0x8(%r12),%rax
xor    %ebp,%ebp
lea    0xe6a(%rip),%r13
jmp    11a9 <ValidateFileName+0x79>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r15
je     11e3 <ValidateFileName+0xb3>
movsbl (%rax,%rbp,1),%edi
call   1030 <putchar@plt>
mov    0x8(%r12),%rax
movsbl (%rax,%rbp,1),%ecx
add    $0xffffffe0,%ecx
cmp    $0x5c,%ecx
ja     11a0 <ValidateFileName+0x70>
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
lea    0x10f5(%rip),%rdi
call   1040 <puts@plt>
xor    %r14d,%r14d
lea    0xfe9(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xf93(%rip),%rdi
jmp    11d4 <ValidateFileName+0xa4>
lea    0x1009(%rip),%rdi
jmp    11d4 <ValidateFileName+0xa4>
lea    0x103c(%rip),%rdi
jmp    11d4 <ValidateFileName+0xa4>
lea    0x106f(%rip),%rdi
jmp    11d4 <ValidateFileName+0xa4>

LLVM IR (-O0):
@.str = [68 x i8] c"\0A Programm Requires one Argument (Eneter input PCAP file name)..!!\0A\00"
@.str.1 = [66 x i8] c"\0A Too many Arguments, Programme Accepts only one Argument. Bye!!\0A\00"
@.str.2 = [61 x i8] c"\0A File name is too big, Don't try to crash our programme!!!\0A\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [59 x i8] c"\0A Back slash is detected, It is not allowed in File-name.\0A\00"
@.str.5 = [60 x i8] c"\0A Star symbol is detected, It is not allowed in File-name.\0A\00"
@.str.6 = [61 x i8] c"\0A single quote is detected, It is not allowed in File-name.\0A\00"
@.str.7 = [61 x i8] c"\0A Double quote is detected, It is not allowed in File-name.\0A\00"
@.str.8 = [54 x i8] c"\0A Space is detected, It is not allowed in File-name.\0A\00"
@.str.9 = [75 x i8] c"\0A Special characters are not allowed, Don't try to crash our programme!!!\0A\00"
@.str.10 = [36 x i8] c"\0A File Name is Proper and Accepted\0A\00"
define i32 @ValidateFileName(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 25, i32* %9
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i32 1
store i8** %11, i8*** %5
%12 = load i32, i32* %4
%13 = add nsw i32 %12, -1
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %88
18: ; preds = %2
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %88
23: ; preds = %18
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @strlen(i8* %26)
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = sub nsw i32 %29, 1
%31 = icmp sge i32 %28, %30
br i1 %31, label %32, label %34
32: ; preds = %23
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %88
34: ; preds = %23
store i32 0, i32* %6
br label %35
35: ; preds = %83, %34
%36 = load i32, i32* %6
%37 = load i32, i32* %8
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %86
39: ; preds = %35
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 0
%42 = load i8*, i8** %41
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %47)
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 0
%51 = load i8*, i8** %50
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
switch i32 %56, label %77 [
i32 92, label %57
i32 36, label %59
i32 35, label %61
i32 37, label %63
i32 94, label %65
i32 124, label %67
i32 42, label %69
i32 39, label %71
i32 34, label %73
i32 32, label %75
]
57: ; preds = %39
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %7
br label %77
59: ; preds = %39
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %7
br label %77
61: ; preds = %39
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %7
br label %77
63: ; preds = %39
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %7
br label %77
65: ; preds = %39
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %7
br label %77
67: ; preds = %39
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %7
br label %77
69: ; preds = %39
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %7
br label %77
71: ; preds = %39
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %7
br label %77
73: ; preds = %39
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %7
br label %77
75: ; preds = %39
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %7
br label %77
77: ; preds = %39, %75, %73, %71, %69, %67, %65, %63, %61, %59, %57
%78 = load i32, i32* %7
%79 = icmp eq i32 %78, 1
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %88
82: ; preds = %77
br label %83
83: ; preds = %82
%84 = load i32, i32* %6
%85 = add nsw i32 %84, 1
store i32 %85, i32* %6
br label %35
86: ; preds = %35
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %3
br label %88
88: ; preds = %86, %80, %32, %21, %16
%89 = load i32, i32* %3
ret i32 %89
}

LLVM IR (-O2):
@str = [35 x i8] c"\0A File Name is Proper and Accepted\00"
@str.11 = [53 x i8] c"\0A Space is detected, It is not allowed in File-name.\00"
@str.12 = [74 x i8] c"\0A Special characters are not allowed, Don't try to crash our programme!!!\00"
@str.13 = [60 x i8] c"\0A Double quote is detected, It is not allowed in File-name.\00"
@str.14 = [60 x i8] c"\0A single quote is detected, It is not allowed in File-name.\00"
@str.15 = [59 x i8] c"\0A Star symbol is detected, It is not allowed in File-name.\00"
@str.21 = [58 x i8] c"\0A Back slash is detected, It is not allowed in File-name.\00"
@str.22 = [60 x i8] c"\0A File name is too big, Don't try to crash our programme!!!\00"
@str.23 = [65 x i8] c"\0A Too many Arguments, Programme Accepts only one Argument. Bye!!\00"
@str.24 = [67 x i8] c"\0A Programm Requires one Argument (Eneter input PCAP file name)..!!\00"
define i32 @ValidateFileName(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = icmp slt i32 %0, 2
br i1 %4, label %42, label %5
5: ; preds = %2
%6 = icmp eq i32 %0, 2
br i1 %6, label %7, label %42
7: ; preds = %5
%8 = load i8*, i8** %3
%9 = tail call i32 @strlen(i8* %8)
%10 = icmp sgt i32 %9, 23
br i1 %10, label %42, label %11
11: ; preds = %7
%12 = icmp sgt i32 %9, 0
br i1 %12, label %13, label %42
13: ; preds = %11
%14 = zext i32 %9 to i64
%15 = load i8*, i8** %3
br label %16
16: ; preds = %13, %39
%17 = phi i8* [ %15, %13 ], [ %23, %39 ]
%18 = phi i64 [ 0, %13 ], [ %40, %39 ]
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = tail call i32 @putchar(i32 %21)
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 %18
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
switch i32 %26, label %39 [
i32 92, label %34
i32 36, label %35
i32 35, label %36
i32 37, label %27
i32 94, label %28
i32 124, label %29
i32 42, label %30
i32 39, label %31
i32 34, label %32
i32 32, label %33
]
27: ; preds = %16
br label %36
28: ; preds = %16
br label %36
29: ; preds = %16
br label %36
30: ; preds = %16
br label %36
31: ; preds = %16
br label %36
32: ; preds = %16
br label %36
33: ; preds = %16
br label %36
34: ; preds = %16
br label %36
35: ; preds = %16
br label %36
36: ; preds = %16, %35, %34, %27, %28, %29, %30, %31, %32, %33
%37 = phi i8* [ getelementptr inbounds ([58 x i8], [58 x i8]* @str.21, i64 0, i64 0), %27 ], [ getelementptr inbounds ([58 x i8], [58 x i8]* @str.21, i64 0, i64 0), %28 ], [ getelementptr inbounds ([58 x i8], [58 x i8]* @str.21, i64 0, i64 0), %29 ], [ getelementptr inbounds ([59 x i8], [59 x i8]* @str.15, i64 0, i64 0), %30 ], [ getelementptr inbounds ([60 x i8], [60 x i8]* @str.14, i64 0, i64 0), %31 ], [ getelementptr inbounds ([60 x i8], [60 x i8]* @str.13, i64 0, i64 0), %32 ], [ getelementptr inbounds ([53 x i8], [53 x i8]* @str.11, i64 0, i64 0), %33 ], [ getelementptr inbounds ([58 x i8], [58 x i8]* @str.21, i64 0, i64 0), %34 ], [ getelementptr inbounds ([58 x i8], [58 x i8]* @str.21, i64 0, i64 0), %35 ], [ getelementptr inbounds ([58 x i8], [58 x i8]* @str.21, i64 0, i64 0), %16 ]
%38 = tail call i32 @puts(i8* dereferenceable(1) %37)
br label %42
39: ; preds = %16
%40 = add nuw nsw i64 %18, 1
%41 = icmp eq i64 %40, %14
br i1 %41, label %42, label %16
42: ; preds = %39, %11, %7, %5, %2, %36
%43 = phi i8* [ getelementptr inbounds ([74 x i8], [74 x i8]* @str.12, i64 0, i64 0), %36 ], [ getelementptr inbounds ([67 x i8], [67 x i8]* @str.24, i64 0, i64 0), %2 ], [ getelementptr inbounds ([65 x i8], [65 x i8]* @str.23, i64 0, i64 0), %5 ], [ getelementptr inbounds ([60 x i8], [60 x i8]* @str.22, i64 0, i64 0), %7 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0), %11 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0), %39 ]
%44 = phi i32 [ 0, %36 ], [ 0, %2 ], [ 0, %5 ], [ 0, %7 ], [ 1, %11 ], [ 1, %39 ]
%45 = tail call i32 @puts(i8* dereferenceable(1) %43)
ret i32 %44
}