#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*/ assert(char *);
char *strchr(char *, char);
char *COM_SanitizeFilePath(char *path) {
  char *p;
  assert(path);
  p = path;
  while (*p && (p = strchr(p, '\\'))) {
    *p = '/';
    p++;
  }
  return path;
}


x86 assembly (clang, -O0):
<COM_SanitizeFilePath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     116e <COM_SanitizeFilePath+0x4e>
mov    -0x10(%rbp),%rdi
mov    $0x5c,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    117e <COM_SanitizeFilePath+0x5e>
jmp    1196 <COM_SanitizeFilePath+0x76>
mov    -0x10(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113d <COM_SanitizeFilePath+0x1d>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<COM_SanitizeFilePath>:
push   %rbx
mov    %rdi,%rbx
call   1040 <assert@plt>
cmpb   $0x0,(%rbx)
je     115f <COM_SanitizeFilePath+0x3f>
mov    %rbx,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x5c,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     115f <COM_SanitizeFilePath+0x3f>
movb   $0x2f,(%rax)
mov    %rax,%rdi
add    $0x1,%rdi
cmpb   $0x0,0x1(%rax)
jne    1140 <COM_SanitizeFilePath+0x20>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @COM_SanitizeFilePath(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @assert(i8* %4)
%6 = load i8*, i8** %2
store i8* %6, i8** %3
br label %7
7: ; preds = %18, %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i8* @strchr(i8* %13, i8 signext 92)
store i8* %14, i8** %3
%15 = icmp ne i8* %14, null
br label %16
16: ; preds = %12, %7
%17 = phi i1 [ false, %7 ], [ %15, %12 ]
br i1 %17, label %18, label %22
18: ; preds = %16
%19 = load i8*, i8** %3
store i8 47, i8* %19
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
br label %7
22: ; preds = %16
%23 = load i8*, i8** %2
ret i8* %23
}

LLVM IR (-O2):
define i8* @COM_SanitizeFilePath(i8* returned %0) {
%2 = tail call i32 @assert(i8* %0)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %1, %9
%6 = phi i8* [ %10, %9 ], [ %0, %1 ]
%7 = tail call i8* @strchr(i8* %6, i8 signext 92)
%8 = icmp eq i8* %7, null
br i1 %8, label %13, label %9
9: ; preds = %5
store i8 47, i8* %7
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %5
13: ; preds = %5, %9, %1
ret i8* %0
}