main() {
  char s1[20], s2[20];
  int pos;
  puts("Enter s1: ");
  gets(s1);
  puts("Enter s2: ");
  gets(s2);
  printf("enter postion:");
  scanf("%d", &pos);
  memmove(s1 + pos + strlen(s2), s1 + pos, strlen(s1 + pos) + 1);
  strncpy(s1 + pos, s2, strlen(s2));
  printf("%s\n", s1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <puts@plt>
lea    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1070 <gets@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <puts@plt>
lea    -0x40(%rbp),%rdi
mov    $0x0,%al
call   1070 <gets@plt>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe66(%rip),%rdi
lea    -0x44(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    -0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x70(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x68(%rbp)
lea    -0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
lea    -0x20(%rbp),%rdi
movslq -0x44(%rbp),%rax
add    %rax,%rdi
call   1050 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1090 <memmove@plt>
lea    -0x20(%rbp),%rax
movslq -0x44(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    %rax,%rdx
call   1030 <strncpy@plt>
lea    -0x20(%rbp),%rsi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1040 <puts@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <gets@plt>
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1040 <puts@plt>
lea    0x30(%rsp),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <gets@plt>
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe59(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
movslq 0xc(%rsp),%rax
lea    (%rsp,%rax,1),%rbx
add    $0x10,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rax,%r12
lea    (%rbx,%rax,1),%r13
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r13,%rdi
mov    %rbx,%rsi
call   1090 <memmove@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <strncpy@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Enter s1: \00"
@.str.1 = [11 x i8] c"Enter s2: \00"
@.str.2 = [15 x i8] c"enter postion:\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @gets to i32 (i8*, ...)*)(i8* %5)
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @gets to i32 (i8*, ...)*)(i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%17 = call i64 @strlen(i8* %16)
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = call i64 @strlen(i8* %26)
%28 = add i64 %27, 1
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%35 = call i64 @strlen(i8* %34)
%36 = call i8* @strncpy(i8* %32, i8* %33, i64 %35)
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"Enter s1: \00"
@.str.1 = [11 x i8] c"Enter s2: \00"
@.str.2 = [15 x i8] c"enter postion:\00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @gets to i32 (i8*, ...)*)(i8* %4)
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @gets to i32 (i8*, ...)*)(i8* %5)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %14
%16 = call i64 @strlen(i8* %5)
%17 = getelementptr inbounds i8, i8* %15, i64 %16
%18 = call i64 @strlen(i8* %15)
%19 = add i64 %18, 1
%20 = call i8* @strncpy(i8* %15, i8* %5, i64 %16)
%21 = call i32 bitcast (i32 (...)* @puts to i32 (i8*)*)(i8* %4)
ret i32 0
}