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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1060 <scanf@plt>
lea    -0xb0(%rbp),%rsi
lea    0xe72(%rip),%rdi
call   1060 <scanf@plt>
lea    -0xf0(%rbp),%rsi
lea    0xe5f(%rip),%rdi
call   1060 <scanf@plt>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0xf8(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <length@plt>
mov    %eax,%ecx
mov    -0xf8(%rbp),%eax
cmp    %ecx,%eax
jge    1226 <main+0xd6>
lea    -0x70(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    -0x74(%rbp),%edx
call   1070 <substrCheck@plt>
mov    %eax,-0xf4(%rbp)
cmpl   $0x0,-0xf4(%rbp)
jl     1213 <main+0xc3>
mov    -0x74(%rbp),%eax
mov    %eax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
mov    -0x78(%rbp),%edx
call   1050 <Insert@plt>
jmp    1226 <main+0xd6>
jmp    1218 <main+0xc8>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11ad <main+0x5d>
lea    -0x70(%rbp),%rsi
lea    0xdcf(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xf0,%rsp
lea    0xe9d(%rip),%rbx
lea    0x80(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
lea    0x40(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %r14,%rdi
call   1030 <length@plt>
test   %eax,%eax
jle    11e4 <main+0x94>
xor    %ebx,%ebx
lea    0x80(%rsp),%r14
lea    0x40(%rsp),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1070 <substrCheck@plt>
test   %eax,%eax
jns    11d2 <main+0x82>
add    $0x1,%ebx
mov    %r14,%rdi
call   1030 <length@plt>
cmp    %eax,%ebx
jl     11b0 <main+0x60>
jmp    11e4 <main+0x94>
lea    0x80(%rsp),%rdi
mov    %rsp,%rsi
mov    %ebx,%edx
call   1050 <Insert@plt>
lea    0xe15(%rip),%rdi
lea    0x80(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbx
pop    %r14
pop    %r15
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 [50 x i8]
%6 = alloca [50 x i8]
%7 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %3
store i32 0, i32* %4
%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 [50 x i8], [50 x i8]* %5, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 0, i32* %3
br label %14
14: ; preds = %33, %0
%15 = load i32, i32* %3
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%17 = call i32 @length(i8* %16)
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %36
19: ; preds = %14
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%21 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%22 = load i32, i32* %3
%23 = call i32 @substrCheck(i8* %20, i8* %21, i32 %22)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %19
%27 = load i32, i32* %3
store i32 %27, i32* %4
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%30 = load i32, i32* %4
%31 = call i32 @Insert(i8* %28, i8* %29, i32 %30)
br label %36
32: ; preds = %19
br label %33
33: ; preds = %32
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %14
36: ; preds = %26, %14
%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 [50 x i8]
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %3, 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 = call i32 @length(i8* %4)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %0, %18
%13 = phi i32 [ %19, %18 ], [ 0, %0 ]
%14 = call i32 @substrCheck(i8* %4, i8* %6, i32 %13)
%15 = icmp sgt i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @Insert(i8* %4, i8* %8, i32 %13)
br label %22
18: ; preds = %12
%19 = add nuw nsw i32 %13, 1
%20 = call i32 @length(i8* %4)
%21 = icmp slt i32 %19, %20
br i1 %21, label %12, label %22
22: ; preds = %18, %0, %16
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
ret i32 0
}