#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 *);
char *eatext(char *fname) {
  register int n;
  if (!fname)
    return NULL;
  n = strlen(fname);
  while (n--) {
    if (fname[n] == '.') {
      fname[n] = '\0';
      break;
    }
  }
  return fname;
}


x86 assembly (clang, -O0):
<eatext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1134 <eatext+0x24>
movq   $0x0,-0x8(%rbp)
jmp    1187 <eatext+0x77>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     117f <eatext+0x6f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    117a <eatext+0x6a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    117f <eatext+0x6f>
jmp    1140 <eatext+0x30>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eatext>:
push   %rbx
mov    %rdi,%rbx
test   %rdi,%rdi
je     1144 <eatext+0x34>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
mov    %rcx,%rax
nopw   0x0(%rax,%rax,1)
sub    $0x1,%rax
jb     1144 <eatext+0x34>
cmpb   $0x2e,-0x1(%rbx,%rcx,1)
mov    %rax,%rcx
jne    1130 <eatext+0x20>
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rax
pop    %rbx
ret

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

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