#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 */
char *DupStr(char *);
int strlen(char *);
char *ExtractPathFromFSpec(register char *filespec) {
  register char *p;
  register char *savfilespec;
  savfilespec = DupStr(filespec);
  for (p = savfilespec + strlen(savfilespec);
       p != savfilespec &&
       !((*(p - 1)) == '\\' || (*(p - 1)) == ':' || (*(p - 1)) == '/');
       p--)
    ;
  *p = '\0';
  return savfilespec;
}


x86 assembly (clang, -O0):
<ExtractPathFromFSpec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <DupStr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x21(%rbp)
je     11b2 <ExtractPathFromFSpec+0x92>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%ecx
mov    $0x1,%al
cmp    $0x5c,%ecx
mov    %al,-0x22(%rbp)
je     11aa <ExtractPathFromFSpec+0x8a>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%ecx
mov    $0x1,%al
cmp    $0x3a,%ecx
mov    %al,-0x22(%rbp)
je     11aa <ExtractPathFromFSpec+0x8a>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
xor    $0xff,%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11c2 <ExtractPathFromFSpec+0xa2>
jmp    11d8 <ExtractPathFromFSpec+0xb8>
jmp    11c7 <ExtractPathFromFSpec+0xa7>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    115a <ExtractPathFromFSpec+0x3a>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ExtractPathFromFSpec>:
push   %rbx
call   1040 <DupStr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <strlen@plt>
cltq
movabs $0x200000000801,%rcx
nopl   (%rax)
test   %rax,%rax
je     1168 <ExtractPathFromFSpec+0x48>
movzbl -0x1(%rbx,%rax,1),%edx
add    $0xffffffffffffffff,%rax
add    $0xd1,%dl
cmp    $0x2d,%dl
ja     1140 <ExtractPathFromFSpec+0x20>
movzbl %dl,%edx
bt     %rdx,%rcx
jae    1140 <ExtractPathFromFSpec+0x20>
add    %rbx,%rax
add    $0x1,%rax
jmp    116b <ExtractPathFromFSpec+0x4b>
mov    %rbx,%rax
movb   $0x0,(%rax)
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @ExtractPathFromFSpec(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @DupStr(i8* %5)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
store i8* %11, i8** %3
br label %12
12: ; preds = %40, %1
%13 = load i8*, i8** %3
%14 = load i8*, i8** %4
%15 = icmp ne i8* %13, %14
br i1 %15, label %16, label %37
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 -1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 92
br i1 %21, label %34, label %22
22: ; preds = %16
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 -1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 58
br i1 %27, label %34, label %28
28: ; preds = %22
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i64 -1
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 47
br label %34
34: ; preds = %28, %22, %16
%35 = phi i1 [ true, %22 ], [ true, %16 ], [ %33, %28 ]
%36 = xor i1 %35, true
br label %37
37: ; preds = %34, %12
%38 = phi i1 [ false, %12 ], [ %36, %34 ]
br i1 %38, label %39, label %43
39: ; preds = %37
br label %40
40: ; preds = %39
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i32 -1
store i8* %42, i8** %3
br label %12
43: ; preds = %37
%44 = load i8*, i8** %3
store i8 0, i8* %44
%45 = load i8*, i8** %4
ret i8* %45
}

LLVM IR (-O2):
define i8* @ExtractPathFromFSpec(i8* %0) {
%2 = tail call i8* @DupStr(i8* %0)
%3 = tail call i32 @strlen(i8* %2)
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %2, i64 %4
br label %6
6: ; preds = %9, %1
%7 = phi i8* [ %5, %1 ], [ %10, %9 ]
%8 = icmp eq i8* %7, %2
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %7, i64 -1
%11 = load i8, i8* %10
switch i8 %11, label %6 [
i8 92, label %12
i8 58, label %12
i8 47, label %12
]
12: ; preds = %9, %9, %9, %6
%13 = phi i8* [ %7, %9 ], [ %7, %9 ], [ %7, %9 ], [ %2, %6 ]
store i8 0, i8* %13
ret i8* %2
}