#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 *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strreplace(char *, char *, char *);
int main(int argc, char **argv) {
  int ret;
  char a[100] = "abcdefg, abcdefg, abcdefg";
  char b[] = "bcd";
  char c[] = "12345678";
  char d[] = "xzy";
  printf("before: %s\n", a);
  printf("sub   : %s\n", b);
  printf("rep   : %s\n", c);
  strreplace(a, b, c);
  printf("after : %s\n", a);
  puts("=================================");
  printf("before: %s\n", a);
  printf("sub   : %s\n", c);
  printf("rep   : %s\n", d);
  strreplace(a, c, d);
  printf("after : %s\n", a);
  puts("=================================");
  printf("before: %s\n", a);
  printf("sub   : %s\n", d);
  printf("rep   : %s\n", b);
  strreplace(a, d, b);
  printf("after : %s\n", a);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe9c(%rip),%rsi
mov    $0x64,%edx
call   1060 <memcpy@plt>
mov    0xef0(%rip),%eax
mov    %eax,-0x84(%rbp)
mov    0xee7(%rip),%rax
mov    %rax,-0x8d(%rbp)
mov    0xee2(%rip),%al
mov    %al,-0x85(%rbp)
mov    0xed7(%rip),%eax
mov    %eax,-0x91(%rbp)
lea    -0x80(%rbp),%rsi
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
lea    -0x84(%rbp),%rsi
lea    0xec3(%rip),%rdi
call   1040 <printf@plt>
lea    -0x8d(%rbp),%rsi
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    -0x84(%rbp),%rsi
lea    -0x8d(%rbp),%rdx
call   1050 <strreplace@plt>
lea    -0x80(%rbp),%rsi
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
lea    -0x80(%rbp),%rsi
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
lea    -0x8d(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
lea    -0x91(%rbp),%rsi
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    -0x8d(%rbp),%rsi
lea    -0x91(%rbp),%rdx
call   1050 <strreplace@plt>
lea    -0x80(%rbp),%rsi
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
lea    -0x80(%rbp),%rsi
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
lea    -0x91(%rbp),%rsi
lea    0xdf1(%rip),%rdi
call   1040 <printf@plt>
lea    -0x84(%rbp),%rsi
lea    0xdea(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    -0x91(%rbp),%rsi
lea    -0x84(%rbp),%rdx
call   1050 <strreplace@plt>
lea    -0x80(%rbp),%rsi
lea    0xdcf(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
movaps 0xf08(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xeec(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe7c(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x80(%rsp)
movl   $0x646362,0x8(%rsp)
movabs $0x3837363534333231,%rax
36 37 38
mov    %rax,0x10(%rsp)
movb   $0x0,0x18(%rsp)
movl   $0x797a78,0xc(%rsp)
lea    0xeae(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xea6(%rip),%r12
lea    0x8(%rsp),%rbp
mov    %r12,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
lea    0xe9b(%rip),%r14
lea    0x10(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1050 <strreplace@plt>
lea    0xe82(%rip),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe7c(%rip),%r13
mov    %r13,%rdi
call   1030 <puts@plt>
lea    0xe3d(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
lea    0xc(%rsp),%r12
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <strreplace@plt>
mov    %rbp,%rdi
mov    %rbp,%r15
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
lea    0xdef(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xdec(%rip),%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
mov    %r14,%rdi
lea    0x8(%rsp),%rbp
mov    %rbp,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1050 <strreplace@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.a = [100 x i8] c"abcdefg, abcdefg, abcdefg\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.b = [4 x i8] c"bcd\00"
@__const.main.c = [9 x i8] c"12345678\00"
@__const.main.d = [4 x i8] c"xzy\00"
@.str = [12 x i8] c"before: %s\0A\00"
@.str.1 = [12 x i8] c"sub : %s\0A\00"
@.str.2 = [12 x i8] c"rep : %s\0A\00"
@.str.3 = [12 x i8] c"after : %s\0A\00"
@.str.4 = [34 x i8] c"=================================\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca [4 x i8]
%9 = alloca [9 x i8]
%10 = alloca [4 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [100 x i8]* %7 to i8*
%12 = bitcast [4 x i8]* %8 to i8*
%13 = bitcast [9 x i8]* %9 to i8*
%14 = bitcast [4 x i8]* %10 to i8*
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%23 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%24 = call i32 @strreplace(i8* %21, i8* %22, i8* %23)
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %25)
%27 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%29 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%31 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%35 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%36 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%37 = call i32 @strreplace(i8* %34, i8* %35, i8* %36)
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%39 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %38)
%40 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%42 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %41)
%43 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%44 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %43)
%45 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%46 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %45)
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%48 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%49 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%50 = call i32 @strreplace(i8* %47, i8* %48, i8* %49)
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%52 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %51)
%53 = load i32, i32* %6
ret i32 %53
}

LLVM IR (-O2):
@__const.main.a = [100 x i8] c"abcdefg, abcdefg, abcdefg\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.c = [9 x i8] c"12345678\00"
@.str = [12 x i8] c"before: %s\0A\00"
@.str.1 = [12 x i8] c"sub : %s\0A\00"
@.str.2 = [12 x i8] c"rep : %s\0A\00"
@.str.3 = [12 x i8] c"after : %s\0A\00"
@.str.4 = [34 x i8] c"=================================\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca [9 x i8]
%6 = alloca i32
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = bitcast i32* %4 to i8*
store i32 6579042, i32* %4
%9 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%10 = bitcast i32* %6 to i8*
store i32 7961208, i32* %6
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %7)
%12 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%14 = call i32 @strreplace(i8* %7, i8* %8, i8* %9)
%15 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %7)
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%20 = call i32 @strreplace(i8* %7, i8* %9, i8* %10)
%21 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %7)
%24 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%25 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%26 = call i32 @strreplace(i8* %7, i8* %10, i8* %8)
%27 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %7)
ret i32 undef
}