#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(int);
int /*<<< orphan*/ remove_component(char *, char *);
scalar_t__ strcmp(char *, char *);
void test_remove_components(void) {
  char path[100] = "./path/to/src";
  remove_component(path, "src");
  assert(0 == strcmp("./path/to", path));
  remove_component(path, "to");
  assert(0 == strcmp("./path", path));
  remove_component(path, "path");
  assert(0 == strcmp(".", path));
}


x86 assembly (clang, -O0):
<test_remove_components>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x70(%rbp),%rdi
lea    0xead(%rip),%rsi
mov    $0x64,%edx
call   1050 <memcpy@plt>
lea    -0x70(%rbp),%rdi
lea    0xefc(%rip),%rsi
call   1060 <remove_component@plt>
lea    -0x70(%rbp),%rsi
lea    0xef0(%rip),%rdi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x70(%rbp),%rdi
lea    0xed2(%rip),%rsi
call   1060 <remove_component@plt>
lea    -0x70(%rbp),%rsi
lea    0xec5(%rip),%rdi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x70(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1060 <remove_component@plt>
lea    -0x70(%rbp),%rsi
lea    0xe97(%rip),%rdi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_remove_components>:
push   %rbx
sub    $0x70,%rsp
movaps 0xf14(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xef8(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xedc(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe88(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0xed9(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <remove_component@plt>
lea    0xecb(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1050 <remove_component@plt>
lea    0xea9(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1050 <remove_component@plt>
lea    0xe84(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_remove_components.path = [100 x i8] c"./path/to/src\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [4 x i8] c"src\00"
@.str.1 = [10 x i8] c"./path/to\00"
@.str.2 = [3 x i8] c"to\00"
@.str.3 = [7 x i8] c"./path\00"
@.str.4 = [5 x i8] c"path\00"
@.str.5 = [2 x i8] c".\00"
define void @test_remove_components() {
%1 = alloca [100 x i8]
%2 = bitcast [100 x i8]* %1 to i8*
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = call i32 @remove_component(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = call i64 @strcmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = icmp eq i64 0, %6
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%11 = call i32 @remove_component(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%13 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = icmp eq i64 0, %13
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%18 = call i32 @remove_component(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%20 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%21 = icmp eq i64 0, %20
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
ret void
}

LLVM IR (-O2):
@__const.test_remove_components.path = [100 x i8] c"./path/to/src\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [4 x i8] c"src\00"
@.str.1 = [10 x i8] c"./path/to\00"
@.str.2 = [3 x i8] c"to\00"
@.str.3 = [7 x i8] c"./path\00"
@.str.4 = [5 x i8] c"path\00"
@.str.5 = [2 x i8] c".\00"
define void @test_remove_components() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @remove_component(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = call i64 @strcmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = icmp eq i64 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = call i32 @remove_component(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%9 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i32 @remove_component(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%14 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
ret void
}