#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 strlen(char *);
void remove_extension_from_filename(char *str) {
  int i, len;
  len = strlen(str);
  if (len < 1) {
    return;
  }
  for (i = len - 1; i >= 0; i--) {
    if ((str[i] == '/') || (str[i] == '\\')) {
      return;
    }
    if (str[i] == '.') {
      str[i] = 0;
      return;
    }
  }
}


x86 assembly (clang, -O0):
<remove_extension_from_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jge    1137 <remove_extension_from_filename+0x27>
jmp    11b2 <remove_extension_from_filename+0xa2>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     11b2 <remove_extension_from_filename+0xa2>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     1174 <remove_extension_from_filename+0x64>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    1179 <remove_extension_from_filename+0x69>
jmp    11b2 <remove_extension_from_filename+0xa2>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    119f <remove_extension_from_filename+0x8f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11b2 <remove_extension_from_filename+0xa2>
jmp    11a4 <remove_extension_from_filename+0x94>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1140 <remove_extension_from_filename+0x30>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_extension_from_filename>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    1142 <remove_extension_from_filename+0x32>
mov    %eax,%eax
nop
test   %rax,%rax
jle    1142 <remove_extension_from_filename+0x32>
add    $0xffffffffffffffff,%rax
mov    %eax,%ecx
movzbl (%rbx,%rcx,1),%edx
cmp    $0x5c,%dl
je     1142 <remove_extension_from_filename+0x32>
cmp    $0x2f,%dl
je     1142 <remove_extension_from_filename+0x32>
cmp    $0x2e,%dl
jne    1120 <remove_extension_from_filename+0x10>
movb   $0x0,(%rbx,%rcx,1)
pop    %rbx
ret

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

LLVM IR (-O2):
define void @remove_extension_from_filename(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp slt i32 %2, 1
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %10
%7 = phi i64 [ %5, %4 ], [ %8, %10 ]
%8 = add nsw i64 %7, -1
%9 = icmp sgt i64 %7, 0
br i1 %9, label %10, label %16
10: ; preds = %6
%11 = and i64 %8, 4294967295
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
switch i8 %13, label %6 [
i8 47, label %16
i8 92, label %16
i8 46, label %14
]
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %0, i64 %11
store i8 0, i8* %15
br label %16
16: ; preds = %6, %10, %10, %1, %14
ret void
}