#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 check_substring(char *, char *, int, int);
int /*<<< orphan*/ printf(char *, char);
int read_string(char *);
int main() {
  char str[50], s1[50], s2[50];
  int length, length1, length2, place, i, newlength;
  length = read_string(str);
  length1 = read_string(s1);
  length2 = read_string(s2);
  place = check_substring(str, s1, length, length1);
  {
    for (i = 0; i < place; i++) {
      printf("%c", str[i]);
    }
    for (i = 0; i < length2; i++) {
      printf("%c", s2[i]);
    }
    for (i = place; i < length; i++) {
      printf("%c", str[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <read_string@plt>
mov    %eax,-0xc4(%rbp)
lea    -0x80(%rbp),%rdi
call   1040 <read_string@plt>
mov    %eax,-0xc8(%rbp)
lea    -0xc0(%rbp),%rdi
call   1040 <read_string@plt>
mov    %eax,-0xcc(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    -0xc4(%rbp),%edx
mov    -0xc8(%rbp),%ecx
call   1050 <check_substring@plt>
mov    %eax,-0xd0(%rbp)
movl   $0x0,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
cmp    -0xd0(%rbp),%eax
jge    11d9 <main+0xa9>
movslq -0xd4(%rbp),%rax
lea    0xe45(%rip),%rdi
movsbl -0x40(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    119b <main+0x6b>
movl   $0x0,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
cmp    -0xcc(%rbp),%eax
jge    1224 <main+0xf4>
movslq -0xd4(%rbp),%rax
lea    0xdfd(%rip),%rdi
movsbl -0xc0(%rbp,%rax,1),%esi
ff
call   1030 <printf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    11e3 <main+0xb3>
mov    -0xd0(%rbp),%eax
mov    %eax,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
cmp    -0xc4(%rbp),%eax
jge    126e <main+0x13e>
movslq -0xd4(%rbp),%rax
lea    0xdb0(%rip),%rdi
movsbl -0x40(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1230 <main+0x100>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %rsp,%r15
mov    %r15,%rdi
call   1040 <read_string@plt>
mov    %eax,%r13d
lea    0x80(%rsp),%r12
mov    %r12,%rdi
call   1040 <read_string@plt>
mov    %eax,%ebp
lea    0x40(%rsp),%rdi
call   1040 <read_string@plt>
mov    %eax,%r14d
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
mov    %ebp,%ecx
call   1050 <check_substring@plt>
mov    %eax,%r15d
test   %eax,%eax
jle    11b5 <main+0x85>
mov    %r15d,%ebx
xor    %ebp,%ebp
lea    0xe6f(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%rsp,%rbp,1),%esi
mov    %r12,%rdi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11a0 <main+0x70>
test   %r14d,%r14d
jle    11e6 <main+0xb6>
mov    %r14d,%ebx
xor    %ebp,%ebp
lea    0xe3a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
movsbl 0x40(%rsp,%rbp,1),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11d0 <main+0xa0>
cmp    %r13d,%r15d
jge    1215 <main+0xe5>
movslq %r15d,%rax
lea    (%rsp,%rax,1),%rbx
sub    %r15d,%r13d
xor    %ebp,%ebp
lea    0xe02(%rip),%r14
xchg   %ax,%ax
movsbl (%rbx,%rbp,1),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %ebp,%r13d
jne    1200 <main+0xd0>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%12 = call i32 @read_string(i8* %11)
store i32 %12, i32* %5
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%14 = call i32 @read_string(i8* %13)
store i32 %14, i32* %6
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%16 = call i32 @read_string(i8* %15)
store i32 %16, i32* %7
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = call i32 @check_substring(i8* %17, i8* %18, i32 %19, i32 %20)
store i32 %21, i32* %8
store i32 0, i32* %9
br label %22
22: ; preds = %32, %0
%23 = load i32, i32* %9
%24 = load i32, i32* %8
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %30)
br label %32
32: ; preds = %26
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %22
35: ; preds = %22
store i32 0, i32* %9
br label %36
36: ; preds = %46, %35
%37 = load i32, i32* %9
%38 = load i32, i32* %7
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %49
40: ; preds = %36
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %44)
br label %46
46: ; preds = %40
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %36
49: ; preds = %36
%50 = load i32, i32* %8
store i32 %50, i32* %9
br label %51
51: ; preds = %61, %49
%52 = load i32, i32* %9
%53 = load i32, i32* %5
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %64
55: ; preds = %51
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %59)
br label %61
61: ; preds = %55
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
store i32 %63, i32* %9
br label %51
64: ; preds = %51
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%7 = call i32 @read_string(i8* %4)
%8 = call i32 @read_string(i8* %5)
%9 = call i32 @read_string(i8* %6)
%10 = call i32 @check_substring(i8* %4, i8* %5, i32 %7, i32 %8)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = zext i32 %10 to i64
br label %18
14: ; preds = %18, %0
%15 = icmp sgt i32 %9, 0
br i1 %15, label %16, label %25
16: ; preds = %14
%17 = zext i32 %9 to i64
br label %29
18: ; preds = %12, %18
%19 = phi i64 [ 0, %12 ], [ %23, %18 ]
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %21)
%23 = add nuw nsw i64 %19, 1
%24 = icmp eq i64 %23, %13
br i1 %24, label %14, label %18
25: ; preds = %29, %14
%26 = icmp slt i32 %10, %7
br i1 %26, label %27, label %44
27: ; preds = %25
%28 = sext i32 %10 to i64
br label %36
29: ; preds = %16, %29
%30 = phi i64 [ 0, %16 ], [ %34, %29 ]
%31 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %32)
%34 = add nuw nsw i64 %30, 1
%35 = icmp eq i64 %34, %17
br i1 %35, label %25, label %29
36: ; preds = %27, %36
%37 = phi i64 [ %28, %27 ], [ %41, %36 ]
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %39)
%41 = add nsw i64 %37, 1
%42 = trunc i64 %41 to i32
%43 = icmp eq i32 %7, %42
br i1 %43, label %44, label %36
44: ; preds = %36, %25
ret i32 0
}