#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 *);
int strlen(char *);
void DefaultExtension(char *path, char *extension) {
  char *src;
  src = path + strlen(path) - 1;
  while (*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    $0x5c,%ecx
mov    %al,-0x21(%rbp)
je     1178 <DefaultExtension+0x58>
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1188 <DefaultExtension+0x68>
jmp    11ae <DefaultExtension+0x8e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    119d <DefaultExtension+0x7d>
jmp    11bb <DefaultExtension+0x9b>
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
add    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx,%rax,1),%ecx
cmp    $0x5c,%cl
je     115f <DefaultExtension+0x3f>
test   %rax,%rax
je     115f <DefaultExtension+0x3f>
add    $0xffffffffffffffff,%rax
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 = %29, %2
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 92
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = load i8*, i8** %3
%20 = icmp ne i8* %18, %19
br label %21
21: ; preds = %17, %12
%22 = phi i1 [ false, %12 ], [ %20, %17 ]
br i1 %22, label %23, label %32
23: ; preds = %21
%24 = load i8*, i8** %5
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 46
br i1 %27, label %28, label %29
28: ; preds = %23
br label %36
29: ; preds = %23
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i32 -1
store i8* %31, i8** %5
br label %12
32: ; preds = %21
%33 = load i8*, i8** %3
%34 = load i8*, i8** %4
%35 = call i32 @strcat(i8* %33, i8* %34)
br label %36
36: ; preds = %32, %28
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 = %13, %2
%7 = phi i8* [ %5, %2 ], [ %8, %13 ]
%8 = getelementptr inbounds i8, i8* %7, i64 -1
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 92
%11 = icmp ne i8* %8, %0
%12 = and i1 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = icmp eq i8 %9, 46
br i1 %14, label %17, label %6
15: ; preds = %6
%16 = tail call i32 @strcat(i8* %0, i8* %1)
br label %17
17: ; preds = %13, %15
ret void
}