#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*/ strcat(char *, char const *);
int strlen(char *);
void DefaultExtension(char *path, const char *extension) {
  char *src;
  src = path + strlen(path) - 1;
  while (*src != '/' && *src != '\\' && src != path) {
    if (*src == '.')
      return;
    src--;
  }
  strcat(path, extension);
}


x86 assembly (clang, -O0):
<DefaultExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <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),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0x21(%rbp)
je     118d <DefaultExtension+0x6d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x5c,%ecx
mov    %al,-0x21(%rbp)
je     118d <DefaultExtension+0x6d>
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    119d <DefaultExtension+0x7d>
jmp    11c3 <DefaultExtension+0xa3>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11b2 <DefaultExtension+0x92>
jmp    11d0 <DefaultExtension+0xb0>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1155 <DefaultExtension+0x35>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DefaultExtension>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl -0x1(%rbx,%rax,1),%ecx
cmp    $0x2f,%cl
je     1162 <DefaultExtension+0x42>
cmp    $0x5c,%cl
je     1162 <DefaultExtension+0x42>
add    $0xffffffffffffffff,%rax
je     1162 <DefaultExtension+0x42>
cmp    $0x2e,%cl
jne    1140 <DefaultExtension+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <strcat@plt>

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

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