#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);
  if (place == 0) {
    for (i = 0; i < length; i++) {
      printf("%c", str[i]);
    }
  } else {
    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)
cmpl   $0x0,-0xd0(%rbp)
jne    11eb <main+0xbb>
movl   $0x0,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
cmp    -0xc4(%rbp),%eax
jge    11e6 <main+0xb6>
movslq -0xd4(%rbp),%rax
lea    0xe38(%rip),%rdi
movsbl -0x40(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    11a8 <main+0x78>
jmp    12cd <main+0x19d>
movl   $0x0,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
cmp    -0xd0(%rbp),%eax
jge    1233 <main+0x103>
movslq -0xd4(%rbp),%rax
lea    0xdeb(%rip),%rdi
movsbl -0x40(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    11f5 <main+0xc5>
movl   $0x0,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
cmp    -0xcc(%rbp),%eax
jge    127e <main+0x14e>
movslq -0xd4(%rbp),%rax
lea    0xda3(%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    123d <main+0x10d>
mov    -0xd0(%rbp),%eax
mov    %eax,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
cmp    -0xc4(%rbp),%eax
jge    12c8 <main+0x198>
movslq -0xd4(%rbp),%rax
lea    0xd56(%rip),%rdi
movsbl -0x40(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    128a <main+0x15a>
jmp    12cd <main+0x19d>
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>
test   %eax,%eax
je     1217 <main+0xe7>
mov    %eax,%r15d
jle    11b5 <main+0x85>
mov    %r15d,%ebx
xor    %ebp,%ebp
lea    0xe69(%rip),%r12
nopw   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    1245 <main+0x115>
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>
jmp    1245 <main+0x115>
test   %r13d,%r13d
jle    1245 <main+0x115>
mov    %r13d,%ebp
xor    %ebx,%ebx
lea    0xdd8(%rip),%r14
nopl   0x0(%rax,%rax,1)
movsbl (%rsp,%rbx,1),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1230 <main+0x100>
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
%22 = load i32, i32* %8
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %39
24: ; preds = %0
store i32 0, i32* %9
br label %25
25: ; preds = %35, %24
%26 = load i32, i32* %9
%27 = load i32, i32* %5
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %38
29: ; preds = %25
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %33)
br label %35
35: ; preds = %29
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %25
38: ; preds = %25
br label %83
39: ; preds = %0
store i32 0, i32* %9
br label %40
40: ; preds = %50, %39
%41 = load i32, i32* %9
%42 = load i32, i32* %8
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %53
44: ; preds = %40
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %48)
br label %50
50: ; preds = %44
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %40
53: ; preds = %40
store i32 0, i32* %9
br label %54
54: ; preds = %64, %53
%55 = load i32, i32* %9
%56 = load i32, i32* %7
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %67
58: ; preds = %54
%59 = load i32, i32* %9
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %62)
br label %64
64: ; preds = %58
%65 = load i32, i32* %9
%66 = add nsw i32 %65, 1
store i32 %66, i32* %9
br label %54
67: ; preds = %54
%68 = load i32, i32* %8
store i32 %68, i32* %9
br label %69
69: ; preds = %79, %67
%70 = load i32, i32* %9
%71 = load i32, i32* %5
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %82
73: ; preds = %69
%74 = load i32, i32* %9
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %75
%77 = load i8, i8* %76
%78 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %77)
br label %79
79: ; preds = %73
%80 = load i32, i32* %9
%81 = add nsw i32 %80, 1
store i32 %81, i32* %9
br label %69
82: ; preds = %69
br label %83
83: ; preds = %82, %38
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 eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %0
%13 = icmp sgt i32 %10, 0
br i1 %13, label %14, label %27
14: ; preds = %12
%15 = zext i32 %10 to i64
br label %31
16: ; preds = %0
%17 = icmp sgt i32 %7, 0
br i1 %17, label %18, label %57
18: ; preds = %16
%19 = zext i32 %7 to i64
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ 0, %18 ], [ %25, %20 ]
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %23)
%25 = add nuw nsw i64 %21, 1
%26 = icmp eq i64 %25, %19
br i1 %26, label %57, label %20
27: ; preds = %31, %12
%28 = icmp sgt i32 %9, 0
br i1 %28, label %29, label %38
29: ; preds = %27
%30 = zext i32 %9 to i64
br label %42
31: ; preds = %14, %31
%32 = phi i64 [ 0, %14 ], [ %36, %31 ]
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %34)
%36 = add nuw nsw i64 %32, 1
%37 = icmp eq i64 %36, %15
br i1 %37, label %27, label %31
38: ; preds = %42, %27
%39 = icmp slt i32 %10, %7
br i1 %39, label %40, label %57
40: ; preds = %38
%41 = sext i32 %10 to i64
br label %49
42: ; preds = %29, %42
%43 = phi i64 [ 0, %29 ], [ %47, %42 ]
%44 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %45)
%47 = add nuw nsw i64 %43, 1
%48 = icmp eq i64 %47, %30
br i1 %48, label %38, label %42
49: ; preds = %40, %49
%50 = phi i64 [ %41, %40 ], [ %54, %49 ]
%51 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %52)
%54 = add nsw i64 %50, 1
%55 = trunc i64 %54 to i32
%56 = icmp eq i32 %7, %55
br i1 %56, label %57, label %49
57: ; preds = %49, %20, %38, %16
ret i32 0
}