#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 const *);
char *strrchr(char const *, char);
void COM_StripExtension(const char *in, char *out) {
  char *dot;
  if (!(dot = strrchr(in, '.'))) {
    strcpy(out, in);
    return;
  }
  while (*in && in != dot)
    *out++ = *in++;
  *out = 0;
}


x86 assembly (clang, -O0):
<COM_StripExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    115e <COM_StripExtension+0x3e>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11c4 <COM_StripExtension+0xa4>
jmp    1163 <COM_StripExtension+0x43>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1186 <COM_StripExtension+0x66>
mov    -0x8(%rbp),%rax
cmp    -0x18(%rbp),%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1196 <COM_StripExtension+0x76>
jmp    11bd <COM_StripExtension+0x9d>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1163 <COM_StripExtension+0x43>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<COM_StripExtension>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x2e,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     1176 <COM_StripExtension+0x56>
mov    (%rbx),%cl
test   %cl,%cl
je     116a <COM_StripExtension+0x4a>
cmp    %rbx,%rax
je     116a <COM_StripExtension+0x4a>
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
mov    %cl,(%r14)
add    $0x1,%r14
movzbl (%rbx),%ecx
test   %cl,%cl
je     116a <COM_StripExtension+0x4a>
lea    0x1(%rbx),%rdx
cmp    %rax,%rbx
mov    %rdx,%rbx
jne    1150 <COM_StripExtension+0x30>
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strcpy@plt>

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

LLVM IR (-O2):
define void @COM_StripExtension(i8* %0, i8* %1) {
%3 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%4 = icmp eq i8* %3, null
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i8, i8* %0
%7 = icmp ne i8 %6, 0
%8 = icmp ne i8* %3, %0
%9 = select i1 %7, i1 %8, i1 false
br i1 %9, label %12, label %22
10: ; preds = %2
%11 = tail call i32 @strcpy(i8* %1, i8* %0)
br label %24
12: ; preds = %5, %12
%13 = phi i8 [ %18, %12 ], [ %6, %5 ]
%14 = phi i8* [ %16, %12 ], [ %0, %5 ]
%15 = phi i8* [ %17, %12 ], [ %1, %5 ]
%16 = getelementptr inbounds i8, i8* %14, i64 1
%17 = getelementptr inbounds i8, i8* %15, i64 1
store i8 %13, i8* %15
%18 = load i8, i8* %16
%19 = icmp ne i8 %18, 0
%20 = icmp ne i8* %16, %3
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %12, label %22
22: ; preds = %12, %5
%23 = phi i8* [ %1, %5 ], [ %17, %12 ]
store i8 0, i8* %23
br label %24
24: ; preds = %22, %10
ret void
}