#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 */
size_t strlen(char *);
char *removeExt(char *path) {
  size_t i;
  i = strlen(path);
  if (i > 1) {
    i--;
    for (; i > 0; i--) {
      char c = path[i];
      if (c == '.') {
        path[i] = '\0';
        break;
      } else if (c == '/' || c == '\\') {
        break;
      }
    }
  }
  return path;
}


x86 assembly (clang, -O0):
<removeExt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x1,-0x10(%rbp)
jbe    11b6 <removeExt+0xa6>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jbe    11b1 <removeExt+0xa1>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x2e,%eax
jne    1177 <removeExt+0x67>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11b1 <removeExt+0xa1>
movsbl -0x11(%rbp),%eax
cmp    $0x2f,%eax
je     1191 <removeExt+0x81>
movsbl -0x11(%rbp),%eax
cmp    $0x5c,%eax
jne    1196 <removeExt+0x86>
jmp    11b1 <removeExt+0xa1>
jmp    119b <removeExt+0x8b>
jmp    11a0 <removeExt+0x90>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1140 <removeExt+0x30>
jmp    11b6 <removeExt+0xa6>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeExt>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x2,%rax
jb     1142 <removeExt+0x32>
nop
cmp    $0x1,%rax
je     1142 <removeExt+0x32>
movzbl -0x1(%rbx,%rax,1),%ecx
cmp    $0x5c,%cl
je     1142 <removeExt+0x32>
cmp    $0x2f,%cl
je     1142 <removeExt+0x32>
add    $0xffffffffffffffff,%rax
cmp    $0x2e,%cl
jne    1120 <removeExt+0x10>
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rax
pop    %rbx
ret

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

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