#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ strrep(char *, char *, int);
int main() {
  char string1[200];
  char string2[100];
  int pos;
  printf("请输入初始字符串 ==>");
  gets(string1);
  printf("请输入替换字符串 ==>");
  gets(string2);
  printf("请输入替换位置 ==>");
  scanf("%d", &pos);
  strrep(string1, string2, pos);
  printf("替换后的字符串是 %s \n", string1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xd0(%rbp),%rdi
call   1040 <gets@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x140(%rbp),%rdi
call   1040 <gets@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x144(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0xd0(%rbp),%rdi
lea    -0x140(%rbp),%rsi
mov    -0x144(%rbp),%edx
call   1050 <strrep@plt>
lea    -0xd0(%rbp),%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x148,%rsp
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x80(%rsp),%r14
mov    %r14,%rdi
call   1040 <gets@plt>
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <gets@plt>
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strrep@plt>
lea    0xe9f(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\88\9D\E5\A7\8B\E5\AD\97\E7\AC\A6\E4\B8\B2 ==>\00"
@.str.1 = [29 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E6\9B\BF\E6\8D\A2\E5\AD\97\E7\AC\A6\E4\B8\B2 ==>\00"
@.str.2 = [26 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E6\9B\BF\E6\8D\A2\E4\BD\8D\E7\BD\AE ==>\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [30 x i8] c"\E6\9B\BF\E6\8D\A2\E5\90\8E\E7\9A\84\E5\AD\97\E7\AC\A6\E4\B8\B2\E6\98\AF %s \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [200 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%13 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = load i32, i32* %4
%16 = call i32 @strrep(i8* %13, i8* %14, i32 %15)
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E5\88\9D\E5\A7\8B\E5\AD\97\E7\AC\A6\E4\B8\B2 ==>\00"
@.str.1 = [29 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E6\9B\BF\E6\8D\A2\E5\AD\97\E7\AC\A6\E4\B8\B2 ==>\00"
@.str.2 = [26 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E6\9B\BF\E6\8D\A2\E4\BD\8D\E7\BD\AE ==>\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [30 x i8] c"\E6\9B\BF\E6\8D\A2\E5\90\8E\E7\9A\84\E5\AD\97\E7\AC\A6\E4\B8\B2\E6\98\AF %s \0A\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @gets(i8* %5)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = call i32 @strrep(i8* %4, i8* %5, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %4)
ret i32 0
}