#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*/ bzero(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *strdup(char *);
int /*<<< orphan*/ strlen(char *);
void lfreplace(char *text) {
  char *work = strdup(text);
  char *tok;
  bzero(text, strlen(work));
  tok = work;
  while (*tok != 0) {
    if (*tok == '\\' && *(tok + 1) == 'n') {
      *text = '\n';
      tok++;
    } else {
      *text = *tok;
    }
    tok++;
    text++;
  }
  free(work);
}


x86 assembly (clang, -O0):
<lfreplace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1050 <bzero@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ef <lfreplace+0xaf>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11c6 <lfreplace+0x86>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6e,%eax
jne    11c6 <lfreplace+0x86>
mov    -0x8(%rbp),%rax
movb   $0xa,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11d2 <lfreplace+0x92>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    117d <lfreplace+0x3d>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lfreplace>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1060 <strdup@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <bzero@plt>
mov    %r14,%rax
jmp    117e <lfreplace+0x3e>
cs nopw 0x0(%rax,%rax,1)
test   %cl,%cl
je     1194 <lfreplace+0x54>
mov    %cl,(%rbx)
add    $0x1,%rax
add    $0x1,%rbx
movzbl (%rax),%ecx
cmp    $0x5c,%cl
jne    1170 <lfreplace+0x30>
cmpb   $0x6e,0x1(%rax)
jne    1174 <lfreplace+0x34>
add    $0x1,%rax
mov    $0xa,%cl
jmp    1174 <lfreplace+0x34>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @lfreplace(i8* nocapture %0) {
%2 = tail call i8* @strdup(i8* %0)
%3 = tail call i32 @strlen(i8* %2)
%4 = tail call i32 @bzero(i8* %0, i32 %3)
br label %5
5: ; preds = %14, %1
%6 = phi i8* [ %0, %1 ], [ %18, %14 ]
%7 = phi i8* [ %2, %1 ], [ %17, %14 ]
%8 = load i8, i8* %7
switch i8 %8, label %13 [
i8 0, label %19
i8 92, label %9
]
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 110
br i1 %12, label %14, label %13
13: ; preds = %5, %9
br label %14
14: ; preds = %9, %13
%15 = phi i8 [ %8, %13 ], [ 10, %9 ]
%16 = phi i8* [ %7, %13 ], [ %10, %9 ]
store i8 %15, i8* %6
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = getelementptr inbounds i8, i8* %6, i64 1
br label %5
19: ; preds = %5
%20 = tail call i32 @free(i8* %2)
ret void
}