#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 *, int /*<<< orphan*/);
char *strchr(char *, char);
int /*<<< orphan*/ strlen(char *);
char *removeEmptySegments(char *pcPath) {
  char *es = pcPath;
  if (pcPath && *pcPath) {
    while ((es = strchr(es, '/'))) {
      if (*(es + 1) == '/') {
        memmove(es, (es + 1), strlen(es));
        continue;
      }
      es++;
    }
  }
  return pcPath;
}


x86 assembly (clang, -O0):
<removeEmptySegments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11d8 <removeEmptySegments+0xa8>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d8 <removeEmptySegments+0xa8>
jmp    1164 <removeEmptySegments+0x34>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11d3 <removeEmptySegments+0xa3>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    11c2 <removeEmptySegments+0x92>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1050 <memmove@plt>
jmp    1164 <removeEmptySegments+0x34>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1164 <removeEmptySegments+0x34>
jmp    11d8 <removeEmptySegments+0xa8>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeEmptySegments>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %rdi,%rdi
je     1199 <removeEmptySegments+0x69>
cmpb   $0x0,(%r14)
je     1199 <removeEmptySegments+0x69>
mov    %r14,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1199 <removeEmptySegments+0x69>
mov    %rax,%rbx
jmp    118a <removeEmptySegments+0x5a>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1050 <memmove@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1199 <removeEmptySegments+0x69>
lea    0x1(%rbx),%r15
cmpb   $0x2f,0x1(%rbx)
je     1160 <removeEmptySegments+0x30>
mov    %r15,%rbx
jmp    1175 <removeEmptySegments+0x45>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @removeEmptySegments(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %34
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %34
12: ; preds = %7
br label %13
13: ; preds = %30, %23, %12
%14 = load i8*, i8** %3
%15 = call i8* @strchr(i8* %14, i8 signext 47)
store i8* %15, i8** %3
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %33
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 47
br i1 %22, label %23, label %30
23: ; preds = %17
%24 = load i8*, i8** %3
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8*, i8** %3
%28 = call i32 @strlen(i8* %27)
%29 = call i32 @memmove(i8* %24, i8* %26, i32 %28)
br label %13
30: ; preds = %17
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
br label %13
33: ; preds = %13
br label %34
34: ; preds = %33, %7, %1
%35 = load i8*, i8** %2
ret i8* %35
}

LLVM IR (-O2):
define i8* @removeEmptySegments(i8* returned %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %21, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %3
%7 = tail call i8* @strchr(i8* %0, i8 signext 47)
%8 = icmp eq i8* %7, null
br i1 %8, label %21, label %9
9: ; preds = %6, %17
%10 = phi i8* [ %19, %17 ], [ %7, %6 ]
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 47
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = tail call i32 @strlen(i8* %10)
%16 = tail call i32 @memmove(i8* %10, i8* %11, i32 %15)
br label %17
17: ; preds = %14, %9
%18 = phi i8* [ %10, %14 ], [ %11, %9 ]
%19 = tail call i8* @strchr(i8* %18, i8 signext 47)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %9
21: ; preds = %17, %6, %3, %1
ret i8* %0
}