#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*/ memmove(char *, char *, scalar_t__);
scalar_t__ strlen(char *);
char *sp_fix_slash_repeated(char *path) {
  char *p = path;
  while (*path) {
    if ((*path == '/' || *path == '\\')) {
      char *save = path + 1;
      *path = '/';
      while ((*path == '/' || *path == '\\'))
        path++;
      if (path != save) {
        memmove(save, path, strlen(path) + 1);
        path = save + 1;
      }
    } else
      path++;
  }
  return p;
}


x86 assembly (clang, -O0):
<sp_fix_slash_repeated>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1217 <sp_fix_slash_repeated+0xf7>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1161 <sp_fix_slash_repeated+0x41>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1206 <sp_fix_slash_repeated+0xe6>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2f,%ecx
mov    %al,-0x19(%rbp)
je     1199 <sp_fix_slash_repeated+0x79>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11a9 <sp_fix_slash_repeated+0x89>
jmp    11ba <sp_fix_slash_repeated+0x9a>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1174 <sp_fix_slash_repeated+0x54>
mov    -0x8(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     1201 <sp_fix_slash_repeated+0xe1>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1040 <memmove@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1212 <sp_fix_slash_repeated+0xf2>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1134 <sp_fix_slash_repeated+0x14>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sp_fix_slash_repeated>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rdi,%r12
xchg   %ax,%ax
mov    %r12,%rbx
mov    (%r12),%al
cmp    $0x2f,%al
je     1150 <sp_fix_slash_repeated+0x30>
cmp    $0x5c,%al
je     1150 <sp_fix_slash_repeated+0x30>
test   %al,%al
je     11a1 <sp_fix_slash_repeated+0x81>
add    $0x1,%rbx
mov    %rbx,%r12
jmp    1130 <sp_fix_slash_repeated+0x10>
nopl   0x0(%rax)
movb   $0x2f,(%rbx)
mov    $0x2f,%cl
xor    %eax,%eax
jmp    1169 <sp_fix_slash_repeated+0x49>
nopl   0x0(%rax)
movzbl 0x1(%rbx,%rax,1),%ecx
add    $0x1,%rax
cmp    $0x5c,%cl
je     1160 <sp_fix_slash_repeated+0x40>
cmp    $0x2f,%cl
je     1160 <sp_fix_slash_repeated+0x40>
lea    (%rbx,%rax,1),%r12
cmp    $0x1,%rax
je     1130 <sp_fix_slash_repeated+0x10>
lea    0x1(%rbx),%r15
mov    %r12,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <memmove@plt>
add    $0x2,%rbx
mov    %rbx,%r12
jmp    1130 <sp_fix_slash_repeated+0x10>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @sp_fix_slash_repeated(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
br label %6
6: ; preds = %56, %1
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %57
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 47
br i1 %14, label %20, label %15
15: ; preds = %10
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 92
br i1 %19, label %20, label %53
20: ; preds = %15, %10
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %4
%23 = load i8*, i8** %2
store i8 47, i8* %23
br label %24
24: ; preds = %36, %20
%25 = load i8*, i8** %2
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 47
br i1 %28, label %34, label %29
29: ; preds = %24
%30 = load i8*, i8** %2
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 92
br label %34
34: ; preds = %29, %24
%35 = phi i1 [ true, %24 ], [ %33, %29 ]
br i1 %35, label %36, label %39
36: ; preds = %34
%37 = load i8*, i8** %2
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %2
br label %24
39: ; preds = %34
%40 = load i8*, i8** %2
%41 = load i8*, i8** %4
%42 = icmp ne i8* %40, %41
br i1 %42, label %43, label %52
43: ; preds = %39
%44 = load i8*, i8** %4
%45 = load i8*, i8** %2
%46 = load i8*, i8** %2
%47 = call i64 @strlen(i8* %46)
%48 = add nsw i64 %47, 1
%49 = call i32 @memmove(i8* %44, i8* %45, i64 %48)
%50 = load i8*, i8** %4
%51 = getelementptr inbounds i8, i8* %50, i64 1
store i8* %51, i8** %2
br label %52
52: ; preds = %43, %39
br label %56
53: ; preds = %15
%54 = load i8*, i8** %2
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %2
br label %56
56: ; preds = %53, %52
br label %6
57: ; preds = %6
%58 = load i8*, i8** %3
ret i8* %58
}

LLVM IR (-O2):
define i8* @sp_fix_slash_repeated(i8* returned %0) {
br label %2
2: ; preds = %16, %1
%3 = phi i8* [ %0, %1 ], [ %17, %16 ]
%4 = load i8, i8* %3
switch i8 %4, label %24 [
i8 0, label %26
i8 47, label %5
i8 92, label %5
]
5: ; preds = %2, %2
store i8 47, i8* %3
br label %6
6: ; preds = %9, %5
%7 = phi i8 [ 47, %5 ], [ %12, %9 ]
%8 = phi i64 [ 0, %5 ], [ %10, %9 ]
switch i8 %7, label %13 [
i8 47, label %9
i8 92, label %9
]
9: ; preds = %6, %6
%10 = add nuw nsw i64 %8, 1
%11 = getelementptr inbounds i8, i8* %3, i64 %10
%12 = load i8, i8* %11
br label %6
13: ; preds = %6
%14 = getelementptr inbounds i8, i8* %3, i64 %8
%15 = icmp eq i64 %8, 1
br i1 %15, label %16, label %18
16: ; preds = %13, %18, %24
%17 = phi i8* [ %25, %24 ], [ %23, %18 ], [ %14, %13 ]
br label %2
18: ; preds = %13
%19 = getelementptr inbounds i8, i8* %3, i64 1
%20 = tail call i64 @strlen(i8* %14)
%21 = add nsw i64 %20, 1
%22 = tail call i32 @memmove(i8* %19, i8* %14, i64 %21)
%23 = getelementptr inbounds i8, i8* %3, i64 2
br label %16
24: ; preds = %2
%25 = getelementptr inbounds i8, i8* %3, i64 1
br label %16
26: ; preds = %2
ret i8* %0
}