#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *, char *, char *);
int main() {
  char A[50], B[50];
  char c;
  int i = 0, flag = 0;
  scanf("%s\n%c\n%s", A, &c, B);
  while (A[i] != '\0') {
    if (A[i] == c) {
      if (flag == 0) {
        printf("%s", B);
        flag = 1;
      }
    }
    printf("%c", A[i]);
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x88(%rbp)
movl   $0x0,-0x8c(%rbp)
lea    -0x40(%rbp),%rsi
lea    -0x80(%rbp),%rcx
lea    0xeab(%rip),%rdi
lea    -0x81(%rbp),%rdx
call   1040 <scanf@plt>
movslq -0x88(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11ed <main+0xcd>
movslq -0x88(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
movsbl -0x81(%rbp),%ecx
cmp    %ecx,%eax
jne    11bf <main+0x9f>
cmpl   $0x0,-0x8c(%rbp)
jne    11ba <main+0x9a>
lea    -0x80(%rbp),%rsi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8c(%rbp)
jmp    11bf <main+0x9f>
movslq -0x88(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1161 <main+0x41>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
lea    0xebc(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xf(%rsp),%rdx
lea    0x50(%rsp),%rcx
call   1050 <scanf@plt>
mov    0x10(%rsp),%al
test   %al,%al
je     11b5 <main+0x85>
lea    0x11(%rsp),%rbx
lea    0xe9a(%rip),%r14
lea    0x50(%rsp),%r15
xor    %ebp,%ebp
jmp    1193 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11b5 <main+0x85>
cmp    0xf(%rsp),%al
jne    1180 <main+0x50>
test   %ebp,%ebp
jne    1180 <main+0x50>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0x1(%rbx),%eax
mov    $0x1,%ebp
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%s\0A%c\0A%s\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %4, i8* %8)
br label %10
10: ; preds = %33, %0
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %2, 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 %42
17: ; preds = %10
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = load i8, i8* %4
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %22, %24
br i1 %25, label %26, label %33
26: ; preds = %17
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %30)
store i32 1, i32* %6
br label %32
32: ; preds = %29, %26
br label %33
33: ; preds = %32, %17
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %10
42: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s\0A%c\0A%s\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = alloca 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 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %3, i8* %5)
%7 = load i8, i8* %4
%8 = icmp eq i8 %7, 0
br i1 %8, label %30, label %9
9: ; preds = %0, %21
%10 = phi i64 [ %26, %21 ], [ 0, %0 ]
%11 = phi i8 [ %28, %21 ], [ %7, %0 ]
%12 = phi i8* [ %27, %21 ], [ %4, %0 ]
%13 = phi i32 [ %23, %21 ], [ 0, %0 ]
%14 = load i8, i8* %3
%15 = icmp eq i8 %11, %14
%16 = icmp eq i32 %13, 0
%17 = select i1 %15, i1 %16, i1 false
br i1 %17, label %18, label %21
18: ; preds = %9
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%20 = load i8, i8* %12
br label %21
21: ; preds = %18, %9
%22 = phi i8 [ %20, %18 ], [ %11, %9 ]
%23 = phi i32 [ 1, %18 ], [ %13, %9 ]
%24 = sext i8 %22 to i32
%25 = call i32 @putchar(i32 %24)
%26 = add nuw i64 %10, 1
%27 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %9
30: ; preds = %21, %0
ret i32 0
}