#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 /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void remove_ext(char *src, char *dest) {
  char *p;
  strcpy(dest, src);
  p = dest + strlen(dest) - 1;
  while ((p != dest) && (*p != '.')) {
    --p;
  }
  if (*p == '.')
    *p = 0;
}


x86 assembly (clang, -O0):
<remove_ext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%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),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x21(%rbp)
je     1185 <remove_ext+0x65>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1195 <remove_ext+0x75>
jmp    11a6 <remove_ext+0x86>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1162 <remove_ext+0x42>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11bd <remove_ext+0x9d>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_ext>:
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
nopl   0x0(%rax)
cmp    $0x1,%rax
je     1159 <remove_ext+0x39>
lea    -0x1(%rax),%rcx
cmpb   $0x2e,-0x1(%rbx,%rax,1)
mov    %rcx,%rax
jne    1140 <remove_ext+0x20>
add    %rcx,%rbx
jmp    115e <remove_ext+0x3e>
cmpb   $0x2e,(%rbx)
jne    1161 <remove_ext+0x41>
movb   $0x0,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @remove_ext(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** %4
%7 = load i8*, i8** %3
%8 = call i32 @strcpy(i8* %6, i8* %7)
%9 = load i8*, i8** %4
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %9, i64 %12
%14 = getelementptr inbounds i8, i8* %13, i64 -1
store i8* %14, i8** %5
br label %15
15: ; preds = %26, %2
%16 = load i8*, i8** %5
%17 = load i8*, i8** %4
%18 = icmp ne i8* %16, %17
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load i8*, i8** %5
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 46
br label %24
24: ; preds = %19, %15
%25 = phi i1 [ false, %15 ], [ %23, %19 ]
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i32 -1
store i8* %28, i8** %5
br label %15
29: ; preds = %24
%30 = load i8*, i8** %5
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 46
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = load i8*, i8** %5
store i8 0, i8* %35
br label %36
36: ; preds = %34, %29
ret void
}

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