#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 *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void removeExtension(char *filename, char *noextfile) {
  int i, nchar, ndot;
  nchar = strlen(filename);
  ndot = nchar;
  for (i = 0; i < nchar; i++) {
    if (filename[nchar - i] == '.') {
      ndot = nchar - i;
      break;
    }
  }
  strncpy(noextfile, filename, ndot);
  noextfile[ndot] = '\0';
}


x86 assembly (clang, -O0):
<removeExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1190 <removeExtension+0x70>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    117d <removeExtension+0x5d>
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1190 <removeExtension+0x70>
jmp    1182 <removeExtension+0x62>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <removeExtension+0x29>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeExtension>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1150 <removeExtension+0x30>
mov    %ebp,%eax
nopw   0x0(%rax,%rax,1)
cmpb   $0x2e,(%rbx,%rax,1)
je     114e <removeExtension+0x2e>
add    $0xffffffffffffffff,%rax
jne    1140 <removeExtension+0x20>
jmp    1150 <removeExtension+0x30>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,(%r14,%rax,1)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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