#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 const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
void removeFileExtention(const char *original, char *fixed) {
  if (!original)
    return;
  const char *end = original + strlen(original) - 1;
  while (end > original) {
    if (*end != '.')
      end--;
    else
      break;
  }
  strncpy(fixed, original, end - original);
}


x86 assembly (clang, -O0):
<removeFileExtention>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1140 <removeFileExtention+0x20>
jmp    11b8 <removeFileExtention+0x98>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    119e <removeFileExtention+0x7e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     1194 <removeFileExtention+0x74>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1199 <removeFileExtention+0x79>
jmp    119e <removeFileExtention+0x7e>
jmp    1165 <removeFileExtention+0x45>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeFileExtention>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1165 <removeFileExtention+0x45>
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
cltq
lea    -0x1(%rax),%ecx
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
mov    %ecx,%edx
cmp    %rbx,%rax
jbe    1153 <removeFileExtention+0x33>
lea    -0x1(%rdx),%ecx
cmpb   $0x2e,(%rax)
lea    -0x1(%rax),%rax
jne    1140 <removeFileExtention+0x20>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strncpy@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @removeFileExtention(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %21, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %0)
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
br label %8
8: ; preds = %12, %4
%9 = phi i8* [ %7, %4 ], [ %10, %12 ]
%10 = getelementptr inbounds i8, i8* %9, i64 -1
%11 = icmp ugt i8* %10, %0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i8, i8* %10
%14 = icmp eq i8 %13, 46
br i1 %14, label %15, label %8
15: ; preds = %12, %8
%16 = ptrtoint i8* %10 to i64
%17 = ptrtoint i8* %0 to i64
%18 = sub i64 %16, %17
%19 = trunc i64 %18 to i32
%20 = tail call i32 @strncpy(i8* %1, i8* %0, i32 %19)
br label %21
21: ; preds = %2, %15
ret void
}