#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 *);
void delete_ext(char *filename) {
  size_t i;
  i = strlen(filename);
  while (i > 0 && filename[i] != '.')
    i--;
  if (i > 0)
    filename[i] = '\0';
}


x86 assembly (clang, -O0):
<delete_ext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jbe    114e <delete_ext+0x3e>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    115e <delete_ext+0x4e>
jmp    116f <delete_ext+0x5f>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1129 <delete_ext+0x19>
cmpq   $0x0,-0x10(%rbp)
jbe    1186 <delete_ext+0x76>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete_ext>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %rax,%rax
je     112c <delete_ext+0x1c>
xchg   %ax,%ax
cmpb   $0x2e,(%rbx,%rax,1)
je     112e <delete_ext+0x1e>
add    $0xffffffffffffffff,%rax
jne    1120 <delete_ext+0x10>
pop    %rbx
ret
movb   $0x0,(%rbx,%rax,1)
pop    %rbx
ret

LLVM IR (-O0):
define void @delete_ext(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strlen(i8* %4)
store i64 %5, i64* %3
br label %6
6: ; preds = %18, %1
%7 = load i64, i64* %3
%8 = icmp ugt i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i8*, i8** %2
%11 = load i64, i64* %3
%12 = getelementptr inbounds i8, i8* %10, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 46
br label %16
16: ; preds = %9, %6
%17 = phi i1 [ false, %6 ], [ %15, %9 ]
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = load i64, i64* %3
%20 = add i64 %19, -1
store i64 %20, i64* %3
br label %6
21: ; preds = %16
%22 = load i64, i64* %3
%23 = icmp ugt i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i8*, i8** %2
%26 = load i64, i64* %3
%27 = getelementptr inbounds i8, i8* %25, i64 %26
store i8 0, i8* %27
br label %28
28: ; preds = %24, %21
ret void
}

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