#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*/ getch();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ rep(char *, char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  char s[50];
  char s1[50], s2[50];
  system("cls");
  puts("Please input the string for s:");
  scanf("%s", s);
  puts("Please input the string for s1:");
  scanf("%s", s1);
  puts("Please input the string for s2:");
  scanf("%s", s2);
  rep(s, s1, s2);
  puts("The string of s after displace is:");
  printf("%s\n", s);
  puts("\n Press any key to quit...");
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe80(%rip),%rdi
call   1050 <system@plt>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
lea    -0x50(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1070 <scanf@plt>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
lea    -0x90(%rbp),%rsi
lea    0xe68(%rip),%rdi
call   1070 <scanf@plt>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
lea    -0xd0(%rbp),%rsi
lea    0xe49(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x50(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0xd0(%rbp),%rdx
call   1040 <rep@plt>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
lea    -0x50(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1060 <printf@plt>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1080 <getch@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xb8,%rsp
lea    0xe8b(%rip),%rdi
call   1050 <system@plt>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
lea    0xe96(%rip),%r12
lea    0x80(%rsp),%r14
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <scanf@plt>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
lea    0x40(%rsp),%r15
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <rep@plt>
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
mov    %r14,%rsi
call   1060 <printf@plt>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getch@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"cls\00"
@.str.1 = [31 x i8] c"Please input the string for s:\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [32 x i8] c"Please input the string for s1:\00"
@.str.4 = [32 x i8] c"Please input the string for s2:\00"
@.str.5 = [35 x i8] c"The string of s after displace is:\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [27 x i8] c"\0A Press any key to quit...\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [50 x i8]
%7 = alloca [50 x i8]
%8 = alloca [50 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%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.2, i64 0, i64 0), i8* %11)
%13 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%21 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%22 = call i32 @rep(i8* %19, i8* %20, i8* %21)
%23 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%26 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%27 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"cls\00"
@.str.1 = [31 x i8] c"Please input the string for s:\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [32 x i8] c"Please input the string for s1:\00"
@.str.4 = [32 x i8] c"Please input the string for s2:\00"
@.str.5 = [35 x i8] c"The string of s after displace is:\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [27 x i8] c"\0A Press any key to quit...\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = alloca [50 x i8]
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%9 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%16 = call i32 @rep(i8* %6, i8* %7, i8* %8)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%20 = call i32 (...) @getch()
ret i32 0
}