#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*/ CL_TranslateString(char const *, char *);
int strlen(char *);
char *strstr(char *, char *);
const char *CL_TranslateStringBuf(const char *string) {
  char *p;
  int i, l;
  static char buf[32000];
  CL_TranslateString(string, buf);
  while ((p = strstr(buf, "\\n"))) {
    *p = '\n';
    p++;
    l = strlen(p);
    for (i = 0; i < l; i++) {
      *p = *(p + 1);
      p++;
    }
  }
  return buf;
}


x86 assembly (clang, -O0):
<CL_TranslateStringBuf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0x2f09(%rip),%rsi
call   1040 <CL_TranslateString@plt>
lea    0x2efd(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11cb <CL_TranslateStringBuf+0x9b>
mov    -0x10(%rbp),%rax
movb   $0xa,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11c6 <CL_TranslateStringBuf+0x96>
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1193 <CL_TranslateStringBuf+0x63>
jmp    114c <CL_TranslateStringBuf+0x1c>
lea    0x2e7e(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CL_TranslateStringBuf>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0x2f01(%rip),%rbx
mov    %rbx,%rsi
call   1050 <CL_TranslateString@plt>
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     11b9 <CL_TranslateStringBuf+0x79>
mov    %rax,%rbx
lea    0x2edb(%rip),%r14
lea    0xe84(%rip),%r15
jmp    1193 <CL_TranslateStringBuf+0x53>
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11b9 <CL_TranslateStringBuf+0x79>
movb   $0xa,(%rbx)
lea    0x1(%rbx),%r12
mov    %r12,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1180 <CL_TranslateStringBuf+0x40>
add    $0x2,%rbx
mov    %eax,%edx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <memmove@plt>
jmp    1180 <CL_TranslateStringBuf+0x40>
lea    0x2e90(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@CL_TranslateStringBuf.buf = internal global [32000 x i8] zeroinitializer
@.str = [3 x i8] c"\\n\00"
define i8* @CL_TranslateStringBuf(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @CL_TranslateString(i8* %6, i8* getelementptr inbounds ([32000 x i8], [32000 x i8]* @CL_TranslateStringBuf.buf, i64 0, i64 0))
br label %8
8: ; preds = %31, %1
%9 = call i8* @strstr(i8* getelementptr inbounds ([32000 x i8], [32000 x i8]* @CL_TranslateStringBuf.buf, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = load i8*, i8** %3
store i8 10, i8* %12
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %3
%15 = load i8*, i8** %3
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %5
store i32 0, i32* %4
br label %17
17: ; preds = %28, %11
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = load i8, i8* %23
%25 = load i8*, i8** %3
store i8 %24, i8* %25
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %3
br label %28
28: ; preds = %21
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %17
31: ; preds = %17
br label %8
32: ; preds = %8
ret i8* getelementptr inbounds ([32000 x i8], [32000 x i8]* @CL_TranslateStringBuf.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@CL_TranslateStringBuf.buf = internal global [32000 x i8] zeroinitializer
@.str = [3 x i8] c"\\n\00"
define i8* @CL_TranslateStringBuf(i8* %0) {
%2 = tail call i32 @CL_TranslateString(i8* %0, i8* getelementptr inbounds ([32000 x i8], [32000 x i8]* @CL_TranslateStringBuf.buf, i64 0, i64 0))
%3 = tail call i8* @strstr(i8* dereferenceable(1) getelementptr inbounds ([32000 x i8], [32000 x i8]* @CL_TranslateStringBuf.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %16, label %8
5: ; preds = %13, %8
%6 = tail call i8* @strstr(i8* dereferenceable(1) getelementptr inbounds ([32000 x i8], [32000 x i8]* @CL_TranslateStringBuf.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %16, label %8
8: ; preds = %1, %5
%9 = phi i8* [ %6, %5 ], [ %3, %1 ]
store i8 10, i8* %9
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = tail call i32 @strlen(i8* %10)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %5
13: ; preds = %8
%14 = getelementptr i8, i8* %9, i64 2
%15 = zext i32 %11 to i64
br label %5
16: ; preds = %5, %1
ret i8* getelementptr inbounds ([32000 x i8], [32000 x i8]* @CL_TranslateStringBuf.buf, i64 0, i64 0)
}