#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 removeExtention(char *filename) {
  int i;
  for (i = strlen(filename); i >= 0; i--) {
    if (filename[i] == '.') {
      filename[i] = 0;
      break;
    }
    if (filename[i] == '/') {
      break;
    }
  }
}


x86 assembly (clang, -O0):
<removeExtention>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1185 <removeExtention+0x75>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1158 <removeExtention+0x48>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1185 <removeExtention+0x75>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1172 <removeExtention+0x62>
jmp    1185 <removeExtention+0x75>
jmp    1177 <removeExtention+0x67>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1128 <removeExtention+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeExtention>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
js     113a <removeExtention+0x2a>
mov    %eax,%eax
nop
movzbl (%rbx,%rax,1),%ecx
cmp    $0x2f,%cl
je     113a <removeExtention+0x2a>
cmp    $0x2e,%cl
je     113c <removeExtention+0x2c>
lea    -0x1(%rax),%rcx
test   %rax,%rax
mov    %rcx,%rax
jg     1120 <removeExtention+0x10>
pop    %rbx
ret
mov    %eax,%eax
movb   $0x0,(%rbx,%rax,1)
pop    %rbx
ret

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

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