#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*/ strcpy(char *, char *);
int /*<<< orphan*/ treset(char *);
void strcremplace(char chaine[], char srch, char rep, char chaineR[]) {
  int i;
  char rc[1000];
  char c;
  treset(rc);
  i = 0, c = 'a';
  while (c != '\0') {
    c = chaine[i];
    if (c == srch) {
      rc[i] = rep;
    } else {
      rc[i] = c;
    }
    i++;
  }
  strcpy(chaineR, rc);
}


x86 assembly (clang, -O0):
<strcremplace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %rdi,-0x8(%rbp)
mov    %dl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
mov    %rcx,-0x18(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <treset@plt>
movl   $0x0,-0x1c(%rbp)
movb   $0x61,-0x411(%rbp)
movsbl -0x411(%rbp),%eax
cmp    $0x0,%eax
je     11be <strcremplace+0x9e>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x411(%rbp)
movsbl -0x411(%rbp),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    119f <strcremplace+0x7f>
mov    -0xa(%rbp),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x410(%rbp,%rax,1)
jmp    11b0 <strcremplace+0x90>
mov    -0x411(%rbp),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1158 <strcremplace+0x38>
mov    -0x18(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcremplace>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %rsp,%rdi
call   1040 <treset@plt>
xor    %eax,%eax
movzbl %r15b,%ecx
cs nopw 0x0(%rax,%rax,1)
movzbl (%rbx,%rax,1),%edx
cmp    %bpl,%dl
mov    %edx,%esi
cmove  %ecx,%esi
mov    %sil,(%rsp,%rax,1)
add    $0x1,%rax
test   %dl,%dl
jne    1150 <strcremplace+0x30>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @strcremplace(i8* %0, i8 signext %1, i8 signext %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [1000 x i8]
%11 = alloca i8
store i8* %0, i8** %5
store i8 %1, i8* %6
store i8 %2, i8* %7
store i8* %3, i8** %8
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%13 = call i32 @treset(i8* %12)
store i32 0, i32* %9
store i8 97, i8* %11
br label %14
14: ; preds = %39, %4
%15 = load i8, i8* %11
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %42
18: ; preds = %14
%19 = load i8*, i8** %5
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
store i8 %23, i8* %11
%24 = load i8, i8* %11
%25 = sext i8 %24 to i32
%26 = load i8, i8* %6
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %25, %27
br i1 %28, label %29, label %34
29: ; preds = %18
%30 = load i8, i8* %7
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 %32
store i8 %30, i8* %33
br label %39
34: ; preds = %18
%35 = load i8, i8* %11
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 %37
store i8 %35, i8* %38
br label %39
39: ; preds = %34, %29
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %14
42: ; preds = %14
%43 = load i8*, i8** %8
%44 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%45 = call i32 @strcpy(i8* %43, i8* %44)
ret void
}

LLVM IR (-O2):
define void @strcremplace(i8* nocapture %0, i8 signext %1, i8 signext %2, i8* %3) {
%5 = alloca [1000 x i8]
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%7 = call i32 @treset(i8* %6)
br label %8
8: ; preds = %4, %8
%9 = phi i64 [ 0, %4 ], [ %15, %8 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, %1
%13 = select i1 %12, i8 %2, i8 %11
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %9
store i8 %13, i8* %14
%15 = add nuw i64 %9, 1
%16 = icmp eq i8 %11, 0
br i1 %16, label %17, label %8
17: ; preds = %8
%18 = call i32 @strcpy(i8* %3, i8* %6)
ret void
}