#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;
  scanf("%s\n%c\n%s", A, &c, B);
  while (A[i] != '\0') {
    if (A[i] == c) {
      printf("%s", B);
    }
    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)
lea    -0x40(%rbp),%rsi
lea    -0x80(%rbp),%rcx
lea    0xeb5(%rip),%rdi
lea    -0x81(%rbp),%rdx
call   1040 <scanf@plt>
movslq -0x88(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11c7 <main+0xa7>
movslq -0x88(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
movsbl -0x81(%rbp),%ecx
cmp    %ecx,%eax
jne    1199 <main+0x79>
lea    -0x80(%rbp),%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x88(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1157 <main+0x37>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
lea    0xebd(%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     11ac <main+0x7c>
lea    0x11(%rsp),%rbx
lea    0xe9b(%rip),%r14
lea    0x50(%rsp),%r15
jmp    1193 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11ac <main+0x7c>
cmp    0xf(%rsp),%al
jne    1180 <main+0x50>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0x1(%rbx),%eax
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
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
store i32 0, i32* %1
store i32 0, i32* %5
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %4, i8* %7)
br label %9
9: ; preds = %28, %0
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %37
16: ; preds = %9
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %21, %23
br i1 %24, label %25, label %28
25: ; preds = %16
%26 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %25, %16
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %9
37: ; preds = %9
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 %26, label %9
9: ; preds = %0, %18
%10 = phi i64 [ %22, %18 ], [ 0, %0 ]
%11 = phi i8 [ %24, %18 ], [ %7, %0 ]
%12 = phi i8* [ %23, %18 ], [ %4, %0 ]
%13 = load i8, i8* %3
%14 = icmp eq i8 %11, %13
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%17 = load i8, i8* %12
br label %18
18: ; preds = %15, %9
%19 = phi i8 [ %17, %15 ], [ %11, %9 ]
%20 = sext i8 %19 to i32
%21 = call i32 @putchar(i32 %20)
%22 = add nuw i64 %10, 1
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %9
26: ; preds = %18, %0
ret i32 0
}