#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*/ SubStrings_Copy(char *, char *, unsigned int const);
char *SubStrings_Find(char const *const, int, char *);
unsigned int SubStrings_Length(char const *const);
unsigned SubStrings_Strip(const char *const Match, char *const Source) {
  register char *Worker = Source;
  const unsigned Len = SubStrings_Length(Source);
  const unsigned MatchLen = SubStrings_Length(Match);
  register unsigned Inc = 0;
  for (; (Worker = SubStrings_Find(Match, 1, Worker)); ++Inc) {
    SubStrings_Copy(Worker, Worker + MatchLen, Len);
  }
  return Inc;
}


x86 assembly (clang, -O0):
<SubStrings_Strip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <SubStrings_Length@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <SubStrings_Length@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x1,%esi
call   1040 <SubStrings_Find@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11ab <SubStrings_Strip+0x7b>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%eax
add    %rax,%rsi
mov    -0x1c(%rbp),%edx
call   1030 <SubStrings_Copy@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1167 <SubStrings_Strip+0x37>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SubStrings_Strip>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbp
mov    %rdi,%r15
mov    %rsi,%rdi
call   1050 <SubStrings_Length@plt>
mov    %eax,%r14d
mov    %r15,%rdi
call   1050 <SubStrings_Length@plt>
mov    %eax,%ebx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
call   1040 <SubStrings_Find@plt>
test   %rax,%rax
je     119c <SubStrings_Strip+0x6c>
mov    %rax,%rbp
mov    %ebx,%r12d
xor    %ebx,%ebx
lea    (%r12,%rbp,1),%rsi
mov    %rbp,%rdi
mov    %r14d,%edx
call   1030 <SubStrings_Copy@plt>
add    $0x1,%ebx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
call   1040 <SubStrings_Find@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1170 <SubStrings_Strip+0x40>
jmp    119e <SubStrings_Strip+0x6e>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @SubStrings_Strip(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %4
store i8* %9, i8** %5
%10 = load i8*, i8** %4
%11 = call i32 @SubStrings_Length(i8* %10)
store i32 %11, i32* %6
%12 = load i8*, i8** %3
%13 = call i32 @SubStrings_Length(i8* %12)
store i32 %13, i32* %7
store i32 0, i32* %8
br label %14
14: ; preds = %27, %2
%15 = load i8*, i8** %3
%16 = load i8*, i8** %5
%17 = call i8* @SubStrings_Find(i8* %15, i32 1, i8* %16)
store i8* %17, i8** %5
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %30
19: ; preds = %14
%20 = load i8*, i8** %5
%21 = load i8*, i8** %5
%22 = load i32, i32* %7
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i32, i32* %6
%26 = call i32 @SubStrings_Copy(i8* %20, i8* %24, i32 %25)
br label %27
27: ; preds = %19
%28 = load i32, i32* %8
%29 = add i32 %28, 1
store i32 %29, i32* %8
br label %14
30: ; preds = %14
%31 = load i32, i32* %8
ret i32 %31
}

LLVM IR (-O2):
define i32 @SubStrings_Strip(i8* %0, i8* %1) {
%3 = tail call i32 @SubStrings_Length(i8* %1)
%4 = tail call i32 @SubStrings_Length(i8* %0)
%5 = tail call i8* @SubStrings_Find(i8* %0, i32 1, i8* %1)
%6 = icmp eq i8* %5, null
br i1 %6, label %17, label %7
7: ; preds = %2
%8 = zext i32 %4 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i8* [ %5, %7 ], [ %15, %9 ]
%11 = phi i32 [ 0, %7 ], [ %14, %9 ]
%12 = getelementptr inbounds i8, i8* %10, i64 %8
%13 = tail call i32 @SubStrings_Copy(i8* %10, i8* %12, i32 %3)
%14 = add i32 %11, 1
%15 = tail call i8* @SubStrings_Find(i8* %0, i32 1, i8* %10)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %9
17: ; preds = %9, %2
%18 = phi i32 [ 0, %2 ], [ %14, %9 ]
ret i32 %18
}