#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 */
char *match(char *, char const *);
int del_substr(char *str, char const *substr) {
  char *end;
  while (*str) {
    end = match(str, substr);
    if (end != NULL) {
      while ((*str++ = *end++)) {
        ;
      }
      return 1;
    }
    str++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<del_substr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     119a <del_substr+0x8a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <match@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1189 <del_substr+0x79>
jmp    114e <del_substr+0x3e>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%al
mov    -0x10(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %al,(%rcx)
cmp    $0x0,%al
je     117d <del_substr+0x6d>
jmp    114e <del_substr+0x3e>
movl   $0x1,-0x4(%rbp)
jmp    11a1 <del_substr+0x91>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <del_substr+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<del_substr>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
cmpb   $0x0,(%rdi)
je     1165 <del_substr+0x55>
mov    %rsi,%rbp
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <match@plt>
test   %rax,%rax
jne    114c <del_substr+0x3c>
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    1130 <del_substr+0x20>
jmp    1165 <del_substr+0x55>
xor    %ecx,%ecx
xchg   %ax,%ax
movzbl (%rax,%rcx,1),%edx
mov    %dl,(%rbx,%rcx,1)
add    $0x1,%rcx
test   %dl,%dl
jne    1150 <del_substr+0x40>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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