#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*/ write(int, char *, int);
void outputreplace(char *text, char *s, char *e, char *to) {
  int i, j;
  for (i = 0; *(to + i) != '\0'; ++i)
    ;
  for (j = 0; *(e + j) != '\n'; ++j)
    ;
  write(1, text, s - text);
  write(1, to, i);
  write(1, e, j + 1);
}


x86 assembly (clang, -O0):
<outputreplace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1157 <outputreplace+0x47>
jmp    1149 <outputreplace+0x39>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112f <outputreplace+0x1f>
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     1186 <outputreplace+0x76>
jmp    1178 <outputreplace+0x68>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    115e <outputreplace+0x4e>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%edx
add    $0x1,%edx
mov    $0x1,%edi
call   1030 <write@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<outputreplace>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rdx
mov    %rdi,%rsi
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
cmpb   $0x0,(%r15,%r12,1)
lea    0x1(%r12),%r12
jne    1130 <outputreplace+0x20>
xor    %ebx,%ebx
xchg   %ax,%ax
cmpb   $0xa,(%r14,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1140 <outputreplace+0x30>
add    $0xffffffff,%r12d
sub    %esi,%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r15,%rsi
mov    %r12d,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r14,%rsi
mov    %ebx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <write@plt>

LLVM IR (-O0):
define void @outputreplace(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 0, i32* %9
br label %11
11: ; preds = %20, %4
%12 = load i8*, i8** %8
%13 = load i32, i32* %9
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %11
br label %20
20: ; preds = %19
%21 = load i32, i32* %9
%22 = add nsw i32 %21, 1
store i32 %22, i32* %9
br label %11
23: ; preds = %11
store i32 0, i32* %10
br label %24
24: ; preds = %33, %23
%25 = load i8*, i8** %7
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 10
br i1 %31, label %32, label %36
32: ; preds = %24
br label %33
33: ; preds = %32
%34 = load i32, i32* %10
%35 = add nsw i32 %34, 1
store i32 %35, i32* %10
br label %24
36: ; preds = %24
%37 = load i8*, i8** %5
%38 = load i8*, i8** %6
%39 = load i8*, i8** %5
%40 = ptrtoint i8* %38 to i64
%41 = ptrtoint i8* %39 to i64
%42 = sub i64 %40, %41
%43 = trunc i64 %42 to i32
%44 = call i32 @write(i32 1, i8* %37, i32 %43)
%45 = load i8*, i8** %8
%46 = load i32, i32* %9
%47 = call i32 @write(i32 1, i8* %45, i32 %46)
%48 = load i8*, i8** %7
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
%51 = call i32 @write(i32 1, i8* %48, i32 %50)
ret void
}

LLVM IR (-O2):
define void @outputreplace(i8* %0, i8* %1, i8* nocapture %2, i8* nocapture %3) {
br label %5
5: ; preds = %5, %4
%6 = phi i64 [ %10, %5 ], [ 0, %4 ]
%7 = getelementptr inbounds i8, i8* %3, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
%10 = add nuw i64 %6, 1
br i1 %9, label %11, label %5
11: ; preds = %5, %11
%12 = phi i64 [ %16, %11 ], [ 0, %5 ]
%13 = getelementptr inbounds i8, i8* %2, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 10
%16 = add nuw i64 %12, 1
br i1 %15, label %17, label %11
17: ; preds = %11
%18 = trunc i64 %6 to i32
%19 = trunc i64 %12 to i32
%20 = ptrtoint i8* %1 to i64
%21 = ptrtoint i8* %0 to i64
%22 = sub i64 %20, %21
%23 = trunc i64 %22 to i32
%24 = tail call i32 @write(i32 1, i8* %0, i32 %23)
%25 = tail call i32 @write(i32 1, i8* %3, i32 %18)
%26 = add nuw nsw i32 %19, 1
%27 = tail call i32 @write(i32 1, i8* %2, i32 %26)
ret void
}