#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 < 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
cmp    -0xe8(%rbp),%eax
jge    1271 <main+0x131>
cmpl   $0x0,-0xec(%rbp)
jge    1219 <main+0xd9>
jmp    1271 <main+0x131>
cmpl   $0x0,-0xec(%rbp)
jl     1244 <main+0x104>
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    0xd87(%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,%r15
lea    0x70(%rsp),%rbx
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
mov    $0xffffffff,%r14d
nop
add    $0x1,%r14d
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1170 <main+0x30>
mov    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebx
cmpb   $0x0,(%r15)
lea    0x1(%r15),%r15
jne    1190 <main+0x50>
mov    %rsp,%rdi
lea    0x70(%rsp),%rsi
xor    %edx,%edx
mov    %r14d,%ecx
call   1050 <find_sub@plt>
cmp    %ebx,%eax
jae    11e9 <main+0xa9>
mov    %rsp,%r12
lea    0x70(%rsp),%r15
nopl   0x0(%rax,%rax,1)
lea    (%r14,%rax,1),%ebp
lea    (%r14,%rax,1),%edx
add    $0xffffffff,%edx
mov    %r12,%rdi
mov    %eax,%esi
call   1030 <rev_sub@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1050 <find_sub@plt>
cmp    %ebx,%eax
jb     11c0 <main+0x80>
lea    0xe13(%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 = %55, %31
%37 = load i32, i32* %6
%38 = load i32, i32* %5
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %63
40: ; preds = %36
%41 = load i32, i32* %6
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %40
br label %63
44: ; preds = %40
%45 = load i32, i32* %6
%46 = icmp sge i32 %45, 0
br i1 %46, label %47, label %55
47: ; preds = %44
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%49 = load i32, i32* %6
%50 = load i32, i32* %4
%51 = load i32, i32* %6
%52 = add nsw i32 %50, %51
%53 = sub nsw i32 %52, 1
%54 = call i32 @rev_sub(i8* %48, i32 %49, i32 %53)
br label %55
55: ; preds = %47, %44
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%58 = load i32, i32* %6
%59 = load i32, i32* %4
%60 = add nsw i32 %58, %59
%61 = load i32, i32* %4
%62 = call i32 @find_sub(i8* %56, i8* %57, i32 %60, i32 %61)
store i32 %62, i32* %6
br label %36
63: ; preds = %43, %36
%64 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%65 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %64)
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 = icmp ult i32 %21, %20
br i1 %22, label %23, label %30
23: ; preds = %18, %23
%24 = phi i32 [ %28, %23 ], [ %21, %18 ]
%25 = add nsw i32 %24, %19
%26 = add nsw i32 %25, -1
%27 = call i32 @rev_sub(i8* %3, i32 %24, i32 %26)
%28 = call i32 @find_sub(i8* %3, i8* %4, i32 %25, i32 %19)
%29 = icmp ult i32 %28, %20
br i1 %29, label %23, label %30
30: ; preds = %23, %18
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret i32 0
}