#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*/ mystrcat(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *, char *);
int strlen(char *);
char *strstr(char *, char *);
int main() {
  char s1[80];
  char s2[80];
  scanf("%s %s", s1, s2);
  int substr_len = strlen(s2);
  char *p = NULL;
  while ((p = strstr(s1, s2))) {
    *p = '\0';
    p += substr_len;
    mystrcat(s1, p);
  }
  printf("%s", s1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rsi
lea    -0xb0(%rbp),%rdx
lea    0xe8c(%rip),%rdi
call   1060 <scanf@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xb4(%rbp)
movq   $0x0,-0xc0(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1070 <strstr@plt>
mov    %rax,-0xc0(%rbp)
cmp    $0x0,%rax
je     11f0 <main+0xa0>
mov    -0xc0(%rbp),%rax
movb   $0x0,(%rax)
mov    -0xb4(%rbp),%ecx
mov    -0xc0(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0xc0(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0xc0(%rbp),%rsi
call   1050 <mystrcat@plt>
jmp    1196 <main+0x46>
lea    -0x60(%rbp),%rsi
lea    0xe08(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xa0,%rsp
lea    0xe9e(%rip),%rdi
mov    %rsp,%r14
lea    0x50(%rsp),%rbx
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <strstr@plt>
test   %rax,%rax
je     11c1 <main+0x71>
movslq %ebp,%rbp
mov    %rsp,%rbx
lea    0x50(%rsp),%r14
nopw   0x0(%rax,%rax,1)
movb   $0x0,(%rax)
add    %rbp,%rax
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <mystrcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strstr@plt>
test   %rax,%rax
jne    11a0 <main+0x50>
lea    0xe3b(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca [80 x i8]
%4 = alloca i32
%5 = alloca i8*
store i32 0, i32* %1
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %7)
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %4
store i8* null, i8** %5
br label %11
11: ; preds = %16, %0
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%14 = call i8* @strstr(i8* %12, i8* %13)
store i8* %14, i8** %5
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %25
16: ; preds = %11
%17 = load i8*, i8** %5
store i8 0, i8* %17
%18 = load i32, i32* %4
%19 = load i8*, i8** %5
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8, i8* %19, i64 %20
store i8* %21, i8** %5
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%23 = load i8*, i8** %5
%24 = call i32 @mystrcat(i8* %22, i8* %23)
br label %11
25: ; preds = %11
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%6 = call i32 @strlen(i8* %4)
%7 = call i8* @strstr(i8* %3, i8* %4)
%8 = icmp eq i8* %7, null
br i1 %8, label %17, label %9
9: ; preds = %0
%10 = sext i32 %6 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i8* [ %7, %9 ], [ %15, %11 ]
store i8 0, i8* %12
%13 = getelementptr inbounds i8, i8* %12, i64 %10
%14 = call i32 @mystrcat(i8* %3, i8* %13)
%15 = call i8* @strstr(i8* %3, i8* %4)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %11
17: ; preds = %11, %0
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret i32 0
}