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


x86 assembly (clang, -O0):
<FIL_ForceExtension>:
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     1178 <FIL_ForceExtension+0x58>
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1188 <FIL_ForceExtension+0x68>
jmp    11b5 <FIL_ForceExtension+0x95>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11a4 <FIL_ForceExtension+0x84>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    11b5 <FIL_ForceExtension+0x95>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1155 <FIL_ForceExtension+0x35>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FIL_ForceExtension>:
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     115d <FIL_ForceExtension+0x3d>
cmp    $0x1,%rax
je     115d <FIL_ForceExtension+0x3d>
add    $0xffffffffffffffff,%rax
cmp    $0x2e,%cl
jne    1140 <FIL_ForceExtension+0x20>
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <strcat@plt>

LLVM IR (-O0):
define void @FIL_ForceExtension(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 = %30, %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 %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 %33
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 %30
28: ; preds = %23
%29 = load i8*, i8** %5
store i8 0, i8* %29
br label %33
30: ; preds = %23
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i32 -1
store i8* %32, i8** %5
br label %12
33: ; preds = %28, %21
%34 = load i8*, i8** %3
%35 = load i8*, i8** %4
%36 = call i32 @strcat(i8* %34, i8* %35)
ret void
}

LLVM IR (-O2):
define void @FIL_ForceExtension(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, 47
%11 = icmp ne i8* %8, %0
%12 = and i1 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %6
%14 = icmp eq i8 %9, 46
br i1 %14, label %15, label %6
15: ; preds = %13
store i8 0, i8* %8
br label %16
16: ; preds = %6, %15
%17 = tail call i32 @strcat(i8* %0, i8* %1)
ret void
}