#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*/ Q_strcat(char *, int, char const *);
char *strrchr(char *, char);
void COM_DefaultExtension(char *path, int maxSize, const char *extension) {
  const char *dot = strrchr(path, '.'), *slash;
  if (dot && (!(slash = strrchr(path, '/')) || slash < dot)) {
    return;
  } else {
    Q_strcat(path, maxSize, extension);
  }
}


x86 assembly (clang, -O0):
<COM_DefaultExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     117f <COM_DefaultExtension+0x5f>
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     117a <COM_DefaultExtension+0x5a>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    117f <COM_DefaultExtension+0x5f>
jmp    118f <COM_DefaultExtension+0x6f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <Q_strcat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<COM_DefaultExtension>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%rbx
mov    $0x2e,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1159 <COM_DefaultExtension+0x39>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1171 <COM_DefaultExtension+0x51>
cmp    %rbp,%rax
jb     1171 <COM_DefaultExtension+0x51>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <Q_strcat@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @COM_DefaultExtension(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = load i8*, i8** %4
%10 = call i8* @strrchr(i8* %9, i8 signext 46)
store i8* %10, i8** %7
%11 = load i8*, i8** %7
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %22
13: ; preds = %3
%14 = load i8*, i8** %4
%15 = call i8* @strrchr(i8* %14, i8 signext 47)
store i8* %15, i8** %8
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8*, i8** %8
%19 = load i8*, i8** %7
%20 = icmp ult i8* %18, %19
br i1 %20, label %21, label %22
21: ; preds = %17, %13
br label %27
22: ; preds = %17, %3
%23 = load i8*, i8** %4
%24 = load i32, i32* %5
%25 = load i8*, i8** %6
%26 = call i32 @Q_strcat(i8* %23, i32 %24, i8* %25)
br label %27
27: ; preds = %21, %22
ret void
}

LLVM IR (-O2):
define void @COM_DefaultExtension(i8* %0, i32 %1, i8* %2) {
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%5 = icmp eq i8* %4, null
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%8 = icmp eq i8* %7, null
%9 = icmp ult i8* %7, %4
%10 = select i1 %8, i1 true, i1 %9
br i1 %10, label %13, label %11
11: ; preds = %6, %3
%12 = tail call i32 @Q_strcat(i8* %0, i32 %1, i8* %2)
br label %13
13: ; preds = %6, %11
ret void
}