#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 charCheck(char *, char, int);
int length(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char str[100];
  int i = -1, start = 0;
  scanf("%s", str);
  char c1;
  scanf("\n%c", &c1);
  char subs1[50];
  scanf("%s", subs1);
  for (i = 0; i < length(str); i++) {
    int val = charCheck(str, c1, 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    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1070 <scanf@plt>
lea    0xe7c(%rip),%rdi
lea    -0x79(%rbp),%rsi
call   1070 <scanf@plt>
lea    -0xb0(%rbp),%rsi
lea    0xe62(%rip),%rdi
call   1070 <scanf@plt>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0xb8(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <length@plt>
mov    %eax,%ecx
mov    -0xb8(%rbp),%eax
cmp    %ecx,%eax
jge    1222 <main+0xd2>
lea    -0x70(%rbp),%rdi
mov    -0x79(%rbp),%al
mov    -0x74(%rbp),%edx
movsbl %al,%esi
call   1040 <charCheck@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jl     120f <main+0xbf>
mov    -0x74(%rbp),%eax
mov    %eax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    -0x78(%rbp),%edx
call   1060 <Insert@plt>
jmp    1222 <main+0xd2>
jmp    1214 <main+0xc4>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11aa <main+0x5a>
lea    -0x70(%rbp),%rsi
lea    0xdd3(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xb8,%rsp
lea    0xe9f(%rip),%rbx
lea    0x50(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <scanf@plt>
lea    0xe8b(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1070 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
mov    %r14,%rdi
call   1030 <length@plt>
test   %eax,%eax
jle    11e5 <main+0x95>
xor    %ebx,%ebx
lea    0x50(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl 0xf(%rsp),%esi
mov    %r14,%rdi
mov    %ebx,%edx
call   1040 <charCheck@plt>
test   %eax,%eax
jns    11d4 <main+0x84>
add    $0x1,%ebx
mov    %r14,%rdi
call   1030 <length@plt>
cmp    %eax,%ebx
jl     11b0 <main+0x60>
jmp    11e5 <main+0x95>
lea    0x50(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %ebx,%edx
call   1060 <Insert@plt>
lea    0xe14(%rip),%rdi
lea    0x50(%rsp),%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"\0A%c\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca 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 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = call i32 @length(i8* %4)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %0, %18
%12 = phi i32 [ %19, %18 ], [ 0, %0 ]
%13 = load i8, i8* %2
%14 = call i32 @charCheck(i8* %4, i8 signext %13, i32 %12)
%15 = icmp sgt i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 @Insert(i8* %4, i8* %7, i32 %12)
br label %22
18: ; preds = %11
%19 = add nuw nsw i32 %12, 1
%20 = call i32 @length(i8* %4)
%21 = icmp slt i32 %19, %20
br i1 %21, label %11, 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
}