#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*/ isalnum(char);
int strlen(char *);
short isValidFilePath(char *filepath) {
  int lenght = strlen(filepath);
  short isValid = 1;
  int current = 0;
  int pointsCounter = 0;
  while (current < lenght) {
    if (filepath[current] == '.')
      pointsCounter++;
    if ((!isalnum(filepath[current]) && filepath[current] != ' ' &&
         filepath[current] != '.') ||
        pointsCounter == 2) {
      isValid = 0;
      break;
    }
    current++;
  }
  return isValid;
}


x86 assembly (clang, -O0):
<isValidFilePath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movw   $0x1,-0xe(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11dd <isValidFilePath+0xbd>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1176 <isValidFilePath+0x56>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%eax
jne    11ba <isValidFilePath+0x9a>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     11ba <isValidFilePath+0x9a>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    11c4 <isValidFilePath+0xa4>
cmpl   $0x2,-0x18(%rbp)
jne    11cf <isValidFilePath+0xaf>
movw   $0x0,-0xe(%rbp)
jmp    11dd <isValidFilePath+0xbd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114c <isValidFilePath+0x2c>
movswl -0xe(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isValidFilePath>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %eax,%eax
jle    1181 <isValidFilePath+0x61>
mov    %eax,%r14d
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    114e <isValidFilePath+0x2e>
nopl   0x0(%rax)
cmp    $0x2,%ebp
je     1187 <isValidFilePath+0x67>
add    $0x1,%rbx
cmp    %rbx,%r14
je     1181 <isValidFilePath+0x61>
mov    %ebp,%eax
movsbl (%r15,%rbx,1),%edi
xor    %ebp,%ebp
cmp    $0x2e,%edi
sete   %bpl
add    %eax,%ebp
call   1040 <isalnum@plt>
test   %eax,%eax
jne    1140 <isValidFilePath+0x20>
movzbl (%r15,%rbx,1),%ecx
cmp    $0x20,%cl
je     1140 <isValidFilePath+0x20>
xor    %eax,%eax
cmp    $0x2e,%cl
jne    1189 <isValidFilePath+0x69>
cmp    $0x2,%ebp
jne    1145 <isValidFilePath+0x25>
jmp    1189 <isValidFilePath+0x69>
mov    $0x1,%ax
jmp    1189 <isValidFilePath+0x69>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define signext i16 @isValidFilePath(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i16
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %3
store i16 1, i16* %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %9
9: ; preds = %52, %1
%10 = load i32, i32* %5
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %55
13: ; preds = %9
%14 = load i8*, i8** %2
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 46
br i1 %20, label %21, label %24
21: ; preds = %13
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %24
24: ; preds = %21, %13
%25 = load i8*, i8** %2
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = call i32 @isalnum(i8 signext %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %48, label %32
32: ; preds = %24
%33 = load i8*, i8** %2
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 32
br i1 %39, label %40, label %48
40: ; preds = %32
%41 = load i8*, i8** %2
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 46
br i1 %47, label %51, label %48
48: ; preds = %40, %32, %24
%49 = load i32, i32* %6
%50 = icmp eq i32 %49, 2
br i1 %50, label %51, label %52
51: ; preds = %48, %40
store i16 0, i16* %4
br label %55
52: ; preds = %48
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
br label %9
55: ; preds = %51, %9
%56 = load i16, i16* %4
ret i16 %56
}

LLVM IR (-O2):
define signext i16 @isValidFilePath(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %28
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %25
%7 = phi i64 [ 0, %4 ], [ %26, %25 ]
%8 = phi i32 [ 0, %4 ], [ %13, %25 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %7
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 46
%12 = zext i1 %11 to i32
%13 = add nuw nsw i32 %8, %12
%14 = tail call i32 @isalnum(i8 signext %10)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %6
%17 = load i8, i8* %9
%18 = icmp eq i8 %17, 32
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = icmp ne i8 %17, 46
%21 = icmp eq i32 %13, 2
%22 = select i1 %20, i1 true, i1 %21
br i1 %22, label %28, label %25
23: ; preds = %16, %6
%24 = icmp eq i32 %13, 2
br i1 %24, label %28, label %25
25: ; preds = %19, %23
%26 = add nuw nsw i64 %7, 1
%27 = icmp eq i64 %26, %5
br i1 %27, label %28, label %6
28: ; preds = %25, %23, %19, %1
%29 = phi i16 [ 1, %1 ], [ 0, %19 ], [ 0, %23 ], [ 1, %25 ]
ret i16 %29
}