#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*/ ReverseString(char *, int, int);
int length(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int substrCheck(char *, char *, int);
int main() {
  char s1[100];
  int i = -1, start = 0, end = 0;
  scanf("%s", s1);
  char s2[100];
  scanf("%s", s2);
  for (i = 0; i < length(s1); i++) {
    int val = substrCheck(s1, s2, i);
    if (val >= 0) {
      start = i;
      end = val;
      ReverseString(s1, start, end);
      i = end;
    }
  }
  printf("%s", s1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1060 <scanf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1060 <scanf@plt>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0xe8(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <length@plt>
mov    %eax,%ecx
mov    -0xe8(%rbp),%eax
cmp    %ecx,%eax
jge    1220 <main+0xd0>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    -0x74(%rbp),%edx
call   1070 <substrCheck@plt>
mov    %eax,-0xe4(%rbp)
cmpl   $0x0,-0xe4(%rbp)
jl     120d <main+0xbd>
mov    -0x74(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0xe4(%rbp),%eax
mov    %eax,-0x7c(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%esi
mov    -0x7c(%rbp),%edx
call   1050 <ReverseString@plt>
mov    -0x7c(%rbp),%eax
mov    %eax,-0x74(%rbp)
jmp    1212 <main+0xc2>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11a1 <main+0x51>
lea    -0x70(%rbp),%rsi
lea    0xdd5(%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   %rbx
sub    $0xd8,%rsp
lea    0xe9c(%rip),%rbx
mov    %rsp,%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
lea    0x70(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %rbp,%rdi
call   1030 <length@plt>
test   %eax,%eax
jle    11d2 <main+0x82>
xor    %ebp,%ebp
mov    %rsp,%r15
lea    0x70(%rsp),%r14
jmp    11af <main+0x5f>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %r15,%rdi
call   1030 <length@plt>
cmp    %eax,%ebp
jge    11d2 <main+0x82>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1070 <substrCheck@plt>
test   %eax,%eax
js     11a0 <main+0x50>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1050 <ReverseString@plt>
mov    %ebx,%ebp
jmp    11a0 <main+0x50>
lea    0xe27(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [100 x i8]
%7 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
store i32 0, i32* %3
br label %12
12: ; preds = %33, %0
%13 = load i32, i32* %3
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 @length(i8* %14)
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %36
17: ; preds = %12
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%20 = load i32, i32* %3
%21 = call i32 @substrCheck(i8* %18, i8* %19, i32 %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %17
%25 = load i32, i32* %3
store i32 %25, i32* %4
%26 = load i32, i32* %7
store i32 %26, i32* %5
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = call i32 @ReverseString(i8* %27, i32 %28, i32 %29)
%31 = load i32, i32* %5
store i32 %31, i32* %3
br label %32
32: ; preds = %24, %17
br label %33
33: ; preds = %32
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %12
36: ; preds = %12
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%38 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [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 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = call i32 @length(i8* %3)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %0, %15
%10 = phi i32 [ %17, %15 ], [ 0, %0 ]
%11 = call i32 @substrCheck(i8* %3, i8* %5, i32 %10)
%12 = icmp sgt i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @ReverseString(i8* %3, i32 %10, i32 %11)
br label %15
15: ; preds = %13, %9
%16 = phi i32 [ %11, %13 ], [ %10, %9 ]
%17 = add nsw i32 %16, 1
%18 = call i32 @length(i8* %3)
%19 = icmp slt i32 %17, %18
br i1 %19, label %9, label %20
20: ; preds = %15, %0
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
ret i32 0
}