#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 */
typedef int wchar_t;

/* Variables and functions */
int /*<<< orphan*/ wcscmp(int *, char *);
scalar_t__ wcspbrk(int const *, char *);
int *wcsrchr(int const *, char);
int fatinvalidpathlong(const wchar_t *path) {
  wchar_t *scan, *last;
  if (wcspbrk(path, L"\"*:<>?\\|"))
    return -1;
  for (scan = (wchar_t *)path; *scan; scan++)
    if (*scan < 32)
      return -1;
  last = wcsrchr(path, '/');
  last = last == NULL ? (wchar_t *)path : last + 1;
  if (!wcscmp(last, L".") || !wcscmp(last, L".."))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<fatinvalidpathlong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <wcspbrk@plt>
cmp    $0x0,%rax
je     1162 <fatinvalidpathlong+0x32>
movl   $0xffffffff,-0x4(%rbp)
jmp    1229 <fatinvalidpathlong+0xf9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     11a6 <fatinvalidpathlong+0x76>
mov    -0x18(%rbp),%rax
cmpl   $0x20,(%rax)
jge    1190 <fatinvalidpathlong+0x60>
movl   $0xffffffff,-0x4(%rbp)
jmp    1229 <fatinvalidpathlong+0xf9>
jmp    1195 <fatinvalidpathlong+0x65>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    116a <fatinvalidpathlong+0x3a>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <wcsrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d0 <fatinvalidpathlong+0xa0>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11dc <fatinvalidpathlong+0xac>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1030 <wcscmp@plt>
cmp    $0x0,%eax
je     1216 <fatinvalidpathlong+0xe6>
mov    -0x20(%rbp),%rdi
lea    0xe1c(%rip),%rsi
call   1030 <wcscmp@plt>
cmp    $0x0,%eax
jne    1222 <fatinvalidpathlong+0xf2>
movl   $0x1,-0x4(%rbp)
jmp    1229 <fatinvalidpathlong+0xf9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fatinvalidpathlong>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec2(%rip),%rsi
call   1050 <wcspbrk@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    11b9 <fatinvalidpathlong+0x89>
mov    (%rbx),%ecx
test   %ecx,%ecx
je     116f <fatinvalidpathlong+0x3f>
lea    0x4(%rbx),%rdx
nopw   0x0(%rax,%rax,1)
cmp    $0x20,%ecx
jl     11b9 <fatinvalidpathlong+0x89>
mov    (%rdx),%ecx
add    $0x4,%rdx
test   %ecx,%ecx
jne    1160 <fatinvalidpathlong+0x30>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <wcsrchr@plt>
lea    0x4(%rax),%r14
test   %rax,%rax
cmove  %rbx,%r14
lea    0xe9a(%rip),%rsi
mov    %r14,%rdi
call   1030 <wcscmp@plt>
test   %eax,%eax
je     11b4 <fatinvalidpathlong+0x84>
lea    0xe83(%rip),%rsi
mov    %r14,%rdi
call   1030 <wcscmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
jmp    11b9 <fatinvalidpathlong+0x89>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i32] [i32 34, i32 42, i32 58, i32 60, i32 62, i32 63, i32 92, i32 124, i32 0]
@.str.1 = [2 x i32] [i32 46, i32 0]
@.str.2 = [3 x i32] [i32 46, i32 46, i32 0]
define i32 @fatinvalidpathlong(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i64 @wcspbrk(i32* %6, i8* bitcast ([9 x i32]* @.str to i8*))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 -1, i32* %2
br label %46
10: ; preds = %1
%11 = load i32*, i32** %3
store i32* %11, i32** %4
br label %12
12: ; preds = %22, %10
%13 = load i32*, i32** %4
%14 = load i32, i32* %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load i32*, i32** %4
%18 = load i32, i32* %17
%19 = icmp slt i32 %18, 32
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 -1, i32* %2
br label %46
21: ; preds = %16
br label %22
22: ; preds = %21
%23 = load i32*, i32** %4
%24 = getelementptr inbounds i32, i32* %23, i32 1
store i32* %24, i32** %4
br label %12
25: ; preds = %12
%26 = load i32*, i32** %3
%27 = call i32* @wcsrchr(i32* %26, i8 signext 47)
store i32* %27, i32** %5
%28 = load i32*, i32** %5
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = load i32*, i32** %3
br label %35
32: ; preds = %25
%33 = load i32*, i32** %5
%34 = getelementptr inbounds i32, i32* %33, i64 1
br label %35
35: ; preds = %32, %30
%36 = phi i32* [ %31, %30 ], [ %34, %32 ]
store i32* %36, i32** %5
%37 = load i32*, i32** %5
%38 = call i32 @wcscmp(i32* %37, i8* bitcast ([2 x i32]* @.str.1 to i8*))
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %35
%41 = load i32*, i32** %5
%42 = call i32 @wcscmp(i32* %41, i8* bitcast ([3 x i32]* @.str.2 to i8*))
%43 = icmp ne i32 %42, 0
br i1 %43, label %45, label %44
44: ; preds = %40, %35
store i32 1, i32* %2
br label %46
45: ; preds = %40
store i32 0, i32* %2
br label %46
46: ; preds = %45, %44, %20, %9
%47 = load i32, i32* %2
ret i32 %47
}

LLVM IR (-O2):
@.str = [9 x i32] [i32 34, i32 42, i32 58, i32 60, i32 62, i32 63, i32 92, i32 124, i32 0]
@.str.1 = [2 x i32] [i32 46, i32 0]
@.str.2 = [3 x i32] [i32 46, i32 46, i32 0]
define i32 @fatinvalidpathlong(i32* %0) {
%2 = tail call i64 @wcspbrk(i32* %0, i8* bitcast ([9 x i32]* @.str to i8*))
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %26
4: ; preds = %1
%5 = load i32, i32* %0
%6 = icmp eq i32 %5, 0
br i1 %6, label %15, label %10
7: ; preds = %10
%8 = load i32, i32* %14
%9 = icmp eq i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %4, %7
%11 = phi i32 [ %8, %7 ], [ %5, %4 ]
%12 = phi i32* [ %14, %7 ], [ %0, %4 ]
%13 = icmp slt i32 %11, 32
%14 = getelementptr inbounds i32, i32* %12, i64 1
br i1 %13, label %26, label %7
15: ; preds = %7, %4
%16 = tail call i32* @wcsrchr(i32* %0, i8 signext 47)
%17 = icmp eq i32* %16, null
%18 = getelementptr inbounds i32, i32* %16, i64 1
%19 = select i1 %17, i32* %0, i32* %18
%20 = tail call i32 @wcscmp(i32* %19, i8* bitcast ([2 x i32]* @.str.1 to i8*))
%21 = icmp eq i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %15
%23 = tail call i32 @wcscmp(i32* %19, i8* bitcast ([3 x i32]* @.str.2 to i8*))
%24 = icmp eq i32 %23, 0
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %10, %22, %15, %1
%27 = phi i32 [ -1, %1 ], [ 1, %15 ], [ %25, %22 ], [ -1, %10 ]
ret i32 %27
}