#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 RemoveExt(char *path) {
  int len = strlen(path);
  char *s = path;
  while (len-- > 0)
    if (s[len] == '.')
      s[len] = '\0';
}


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    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
jle    116a <RemoveExt+0x5a>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1165 <RemoveExt+0x55>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1130 <RemoveExt+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RemoveExt>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    1139 <RemoveExt+0x29>
mov    %eax,%ecx
test   $0x1,%cl
je     1134 <RemoveExt+0x24>
add    $0xffffffffffffffff,%rcx
mov    %ecx,%edx
cmpb   $0x2e,(%rbx,%rdx,1)
jne    1134 <RemoveExt+0x24>
movb   $0x0,(%rbx,%rdx,1)
cmp    $0x1,%eax
jne    113b <RemoveExt+0x2b>
pop    %rbx
ret
add    $0xfffffffffffffffe,%rcx
jmp    1161 <RemoveExt+0x51>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rcx),%rax
add    $0x1,%rcx
cmp    $0x1,%rcx
mov    %rax,%rcx
jbe    1139 <RemoveExt+0x29>
lea    0x1(%rcx),%eax
cmpb   $0x2e,(%rbx,%rax,1)
jne    116e <RemoveExt+0x5e>
movb   $0x0,(%rbx,%rax,1)
mov    %ecx,%eax
cmpb   $0x2e,(%rbx,%rax,1)
jne    1150 <RemoveExt+0x40>
movb   $0x0,(%rbx,%rax,1)
jmp    1150 <RemoveExt+0x40>

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

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