#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);
int strlen(char const *);
char *strstr(char *, char const *);
void drop_path_component(char *string, const char *drop) {
  char *c;
  int m;
  m = strlen(drop);
  while ((c = strstr(string, drop)) && (c == string || c[-1] == '/')) {
    int l = strlen(c);
    memmove(c, c + m, l - m + 1);
  }
}


x86 assembly (clang, -O0):
<drop_path_component>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
je     1199 <drop_path_component+0x69>
mov    -0x18(%rbp),%rcx
mov    $0x1,%al
cmp    -0x8(%rbp),%rcx
mov    %al,-0x22(%rbp)
je     1193 <drop_path_component+0x63>
mov    -0x18(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11a9 <drop_path_component+0x79>
jmp    11d7 <drop_path_component+0xa7>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x1c(%rbp),%rax
add    %rax,%rsi
mov    -0x20(%rbp),%edx
sub    -0x1c(%rbp),%edx
add    $0x1,%edx
call   1040 <memmove@plt>
jmp    114c <drop_path_component+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drop_path_component>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     11a5 <drop_path_component+0x75>
mov    %rax,%rbx
movslq %ebp,%r12
mov    $0x1,%ebp
sub    %r12d,%ebp
jmp    119a <drop_path_component+0x6a>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    (%rbx,%r12,1),%rsi
lea    (%rax,%rbp,1),%edx
mov    %rbx,%rdi
call   1040 <memmove@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11a5 <drop_path_component+0x75>
cmp    %r15,%rbx
je     1170 <drop_path_component+0x40>
cmpb   $0x2f,-0x1(%rbx)
je     1170 <drop_path_component+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @drop_path_component(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
br label %10
10: ; preds = %29, %2
%11 = load i8*, i8** %3
%12 = load i8*, i8** %4
%13 = call i8* @strstr(i8* %11, i8* %12)
store i8* %13, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %27
15: ; preds = %10
%16 = load i8*, i8** %5
%17 = load i8*, i8** %3
%18 = icmp eq i8* %16, %17
br i1 %18, label %25, label %19
19: ; preds = %15
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i64 -1
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 47
br label %25
25: ; preds = %19, %15
%26 = phi i1 [ true, %15 ], [ %24, %19 ]
br label %27
27: ; preds = %25, %10
%28 = phi i1 [ false, %10 ], [ %26, %25 ]
br i1 %28, label %29, label %42
29: ; preds = %27
%30 = load i8*, i8** %5
%31 = call i32 @strlen(i8* %30)
store i32 %31, i32* %7
%32 = load i8*, i8** %5
%33 = load i8*, i8** %5
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i32, i32* %7
%38 = load i32, i32* %6
%39 = sub nsw i32 %37, %38
%40 = add nsw i32 %39, 1
%41 = call i32 @memmove(i8* %32, i8* %36, i32 %40)
br label %10
42: ; preds = %27
ret void
}

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