#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 */
__attribute__((unused)) char *WDL_remove_fileext(char *str) {
  char *p = str;
  while (*p)
    p++;
  while (p >= str && !((*p) == '\\' || (*p) == '/')) {
    if (*p == '.') {
      *p = 0;
      return p + 1;
    }
    --p;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<WDL_remove_fileext>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     112e <WDL_remove_fileext+0x2e>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1110 <WDL_remove_fileext+0x10>
jmp    1133 <WDL_remove_fileext+0x33>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x19(%rbp)
jb     1173 <WDL_remove_fileext+0x73>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x5c,%ecx
mov    %al,-0x1a(%rbp)
je     116b <WDL_remove_fileext+0x6b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
xor    $0xff,%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1183 <WDL_remove_fileext+0x83>
jmp    11bc <WDL_remove_fileext+0xbc>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11ab <WDL_remove_fileext+0xab>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11c4 <WDL_remove_fileext+0xc4>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1133 <WDL_remove_fileext+0x33>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<WDL_remove_fileext>:
lea    -0x1(%rdi),%rcx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x0,0x1(%rcx)
lea    0x1(%rcx),%rcx
jne    1110 <WDL_remove_fileext+0x10>
cmp    %rdi,%rcx
jae    1122 <WDL_remove_fileext+0x22>
xor    %eax,%eax
ret
add    $0xffffffffffffffff,%rcx
xor    %eax,%eax
xor    %edx,%edx
cmp    $0x5c,%dl
je     114b <WDL_remove_fileext+0x4b>
nop
cmp    $0x2f,%dl
je     114b <WDL_remove_fileext+0x4b>
cmp    $0x2e,%dl
je     114c <WDL_remove_fileext+0x4c>
cmp    %rdi,%rcx
jb     114b <WDL_remove_fileext+0x4b>
movzbl (%rcx),%edx
add    $0xffffffffffffffff,%rcx
cmp    $0x5c,%dl
jne    1130 <WDL_remove_fileext+0x30>
ret
movb   $0x0,0x1(%rcx)
add    $0x2,%rcx
mov    %rcx,%rax
ret

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

LLVM IR (-O2):
define i8* @WDL_remove_fileext(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %6, %2 ]
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
%6 = getelementptr inbounds i8, i8* %3, i64 1
br i1 %5, label %7, label %2
7: ; preds = %2
%8 = icmp ult i8* %3, %0
br i1 %8, label %19, label %9
9: ; preds = %7, %17
%10 = phi i8 [ %18, %17 ], [ 0, %7 ]
%11 = phi i8* [ %15, %17 ], [ %3, %7 ]
switch i8 %10, label %14 [
i8 92, label %19
i8 47, label %19
i8 46, label %12
]
12: ; preds = %9
store i8 0, i8* %11
%13 = getelementptr inbounds i8, i8* %11, i64 1
br label %19
14: ; preds = %9
%15 = getelementptr inbounds i8, i8* %11, i64 -1
%16 = icmp ult i8* %15, %0
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = load i8, i8* %15
br label %9
19: ; preds = %14, %9, %9, %7, %12
%20 = phi i8* [ %13, %12 ], [ null, %7 ], [ null, %9 ], [ null, %9 ], [ null, %14 ]
ret i8* %20
}