#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 find_sub(char *, char *, int, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ rev_sub(char *, int, int);
int /*<<< orphan*/ scanf(char *, char *, char *);
int main() {
  char s1[100], s2[100];
  scanf("%s %s", s1, s2);
  int l = 0, le = 0, x;
  while (s2[l] != '\0')
    l++;
  while (s1[le] != '\0')
    le++;
  x = find_sub(s1, s2, 0, l);
  while (x + l < le) {
    if (x < 0)
      break;
    if (x >= 0)
      rev_sub(s1, x, (l + x - 1));
    x = find_sub(s1, s2, x + l, l);
  }
  printf("%s", s1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rsi
lea    -0xe0(%rbp),%rdx
lea    0xe9c(%rip),%rdi
call   1060 <scanf@plt>
movl   $0x0,-0xe4(%rbp)
movl   $0x0,-0xe8(%rbp)
movslq -0xe4(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     11a9 <main+0x69>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    117d <main+0x3d>
jmp    11ae <main+0x6e>
movslq -0xe8(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11d7 <main+0x97>
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    11ae <main+0x6e>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    -0xe4(%rbp),%ecx
xor    %edx,%edx
call   1050 <find_sub@plt>
mov    %eax,-0xec(%rbp)
mov    -0xec(%rbp),%eax
add    -0xe4(%rbp),%eax
cmp    -0xe8(%rbp),%eax
jge    1277 <main+0x137>
cmpl   $0x0,-0xec(%rbp)
jge    121f <main+0xdf>
jmp    1277 <main+0x137>
cmpl   $0x0,-0xec(%rbp)
jl     124a <main+0x10a>
lea    -0x70(%rbp),%rdi
mov    -0xec(%rbp),%esi
mov    -0xe4(%rbp),%edx
add    -0xec(%rbp),%edx
sub    $0x1,%edx
call   1030 <rev_sub@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    -0xec(%rbp),%edx
add    -0xe4(%rbp),%edx
mov    -0xe4(%rbp),%ecx
call   1050 <find_sub@plt>
mov    %eax,-0xec(%rbp)
jmp    11f5 <main+0xb5>
lea    -0x70(%rbp),%rsi
lea    0xd81(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xe0,%rsp
lea    0xeaa(%rip),%rdi
mov    %rsp,%r14
lea    0x70(%rsp),%rbx
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
mov    $0xffffffff,%r15d
nop
add    $0x1,%r15d
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1170 <main+0x30>
mov    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
cmpb   $0x0,(%r14)
lea    0x1(%r14),%r14
jne    1190 <main+0x50>
mov    %rsp,%rdi
lea    0x70(%rsp),%rsi
xor    %edx,%edx
mov    %r15d,%ecx
call   1050 <find_sub@plt>
test   %eax,%eax
js     11fa <main+0xba>
lea    (%rax,%r15,1),%ebx
cmp    %ebp,%ebx
jge    11fa <main+0xba>
mov    %rsp,%r14
lea    0x70(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x1(%rbx),%edx
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <rev_sub@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
mov    %r15d,%ecx
call   1050 <find_sub@plt>
test   %eax,%eax
js     11fa <main+0xba>
mov    %eax,%ebx
add    %r15d,%ebx
cmp    %ebp,%ebx
jl     11d0 <main+0x90>
lea    0xe02(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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 [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8)
store i32 0, i32* %4
store i32 0, i32* %5
br label %10
10: ; preds = %17, %0
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %10
20: ; preds = %10
br label %21
21: ; preds = %28, %20
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %21
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %21
31: ; preds = %21
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%34 = load i32, i32* %4
%35 = call i32 @find_sub(i8* %32, i8* %33, i32 0, i32 %34)
store i32 %35, i32* %6
br label %36
36: ; preds = %57, %31
%37 = load i32, i32* %6
%38 = load i32, i32* %4
%39 = add nsw i32 %37, %38
%40 = load i32, i32* %5
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %65
42: ; preds = %36
%43 = load i32, i32* %6
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %42
br label %65
46: ; preds = %42
%47 = load i32, i32* %6
%48 = icmp sge i32 %47, 0
br i1 %48, label %49, label %57
49: ; preds = %46
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%51 = load i32, i32* %6
%52 = load i32, i32* %4
%53 = load i32, i32* %6
%54 = add nsw i32 %52, %53
%55 = sub nsw i32 %54, 1
%56 = call i32 @rev_sub(i8* %50, i32 %51, i32 %55)
br label %57
57: ; preds = %49, %46
%58 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%60 = load i32, i32* %6
%61 = load i32, i32* %4
%62 = add nsw i32 %60, %61
%63 = load i32, i32* %4
%64 = call i32 @find_sub(i8* %58, i8* %59, i32 %62, i32 %63)
store i32 %64, i32* %6
br label %36
65: ; preds = %45, %36
%66 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%67 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %66)
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 [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 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)
br label %6
6: ; preds = %6, %0
%7 = phi i64 [ %11, %6 ], [ 0, %0 ]
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
%11 = add nuw i64 %7, 1
br i1 %10, label %12, label %6
12: ; preds = %6, %12
%13 = phi i64 [ %17, %12 ], [ 0, %6 ]
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
%17 = add nuw i64 %13, 1
br i1 %16, label %18, label %12
18: ; preds = %12
%19 = trunc i64 %7 to i32
%20 = trunc i64 %13 to i32
%21 = call i32 @find_sub(i8* %3, i8* %4, i32 0, i32 %19)
%22 = add nsw i32 %21, %19
%23 = icmp sge i32 %22, %20
%24 = icmp slt i32 %21, 0
%25 = or i1 %24, %23
br i1 %25, label %36, label %26
26: ; preds = %18, %26
%27 = phi i32 [ %32, %26 ], [ %22, %18 ]
%28 = phi i32 [ %31, %26 ], [ %21, %18 ]
%29 = add nsw i32 %27, -1
%30 = call i32 @rev_sub(i8* %3, i32 %28, i32 %29)
%31 = call i32 @find_sub(i8* %3, i8* %4, i32 %27, i32 %19)
%32 = add nsw i32 %31, %19
%33 = icmp sge i32 %32, %20
%34 = icmp slt i32 %31, 0
%35 = or i1 %34, %33
br i1 %35, label %36, label %26
36: ; preds = %26, %18
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret i32 0
}