#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 */
typedef int /*<<< orphan*/ string;

/* Variables and functions */
int /*<<< orphan*/ Q_strncmp(char *, char *, int);
char *SV_ExpandNewlines(char *in) {
  static char string[1024];
  int l = 0;
  while (*in && l < sizeof(string) - 3) {
    if (*in == '\n') {
      string[l++] = '\\';
      string[l++] = 'n';
    } else {
      if (!Q_strncmp(in, "[lon]", 5) || !Q_strncmp(in, "[lof]", 5)) {
        in += 5;
        continue;
      }
      string[l++] = *in;
    }
    in++;
  }
  string[l] = 0;
  return string;
}


x86 assembly (clang, -O0):
<SV_ExpandNewlines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xd(%rbp)
je     1148 <SV_ExpandNewlines+0x38>
movslq -0xc(%rbp),%rax
cmp    $0x3fd,%rax
setb   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1158 <SV_ExpandNewlines+0x48>
jmp    121b <SV_ExpandNewlines+0x10b>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    119f <SV_ExpandNewlines+0x8f>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
movslq %eax,%rcx
lea    0x2ec3(%rip),%rax
movb   $0x5c,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
movslq %eax,%rcx
lea    0x2eaa(%rip),%rax
movb   $0x6e,(%rax,%rcx,1)
jmp    120a <SV_ExpandNewlines+0xfa>
mov    -0x8(%rbp),%rdi
lea    0xe56(%rip),%rsi
mov    $0x5,%edx
call   1030 <Q_strncmp@plt>
cmp    $0x0,%eax
je     11db <SV_ExpandNewlines+0xcb>
mov    -0x8(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x5,%edx
call   1030 <Q_strncmp@plt>
cmp    $0x0,%eax
jne    11ec <SV_ExpandNewlines+0xdc>
mov    -0x8(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x8(%rbp)
jmp    1123 <SV_ExpandNewlines+0x13>
mov    -0x8(%rbp),%rax
mov    (%rax),%dl
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
movslq %eax,%rcx
lea    0x2e39(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1123 <SV_ExpandNewlines+0x13>
movslq -0xc(%rbp),%rcx
lea    0x2e1a(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e0f(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SV_ExpandNewlines>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     11aa <SV_ExpandNewlines+0x9a>
mov    %rdi,%rbx
xor    %ebp,%ebp
lea    0x2f12(%rip),%r12
lea    0xecb(%rip),%r14
lea    0xeca(%rip),%r15
jmp    114c <SV_ExpandNewlines+0x3c>
xchg   %ax,%ax
movzbl 0x5(%rbx),%eax
add    $0x5,%rbx
test   %al,%al
je     11ac <SV_ExpandNewlines+0x9c>
cmp    $0xa,%al
je     117d <SV_ExpandNewlines+0x6d>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <Q_strncmp@plt>
test   %eax,%eax
je     1140 <SV_ExpandNewlines+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x5,%edx
call   1030 <Q_strncmp@plt>
test   %eax,%eax
je     1140 <SV_ExpandNewlines+0x30>
movzbl (%rbx),%eax
jmp    1189 <SV_ExpandNewlines+0x79>
mov    %ebp,%eax
add    $0x1,%ebp
movb   $0x5c,(%rax,%r12,1)
mov    $0x6e,%al
mov    %ebp,%ecx
mov    %ebp,%edx
mov    %al,(%rdx,%r12,1)
lea    0x1(%rcx),%ebp
movzbl 0x1(%rbx),%eax
test   %al,%al
je     11ac <SV_ExpandNewlines+0x9c>
add    $0x1,%rbx
cmp    $0x3fc,%ecx
jb     114c <SV_ExpandNewlines+0x3c>
jmp    11ac <SV_ExpandNewlines+0x9c>
xor    %ebp,%ebp
mov    %ebp,%ecx
lea    0x2e8b(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SV_ExpandNewlines.string = internal global [1024 x i8] zeroinitializer
@.str = [6 x i8] c"[lon]\00"
@.str.1 = [6 x i8] c"[lof]\00"
define i8* @SV_ExpandNewlines(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %47, %37, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = icmp ult i64 %11, 1021
br label %13
13: ; preds = %9, %4
%14 = phi i1 [ false, %4 ], [ %12, %9 ]
br i1 %14, label %15, label %50
15: ; preds = %13
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %29
20: ; preds = %15
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 %23
store i8 92, i8* %24
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 %27
store i8 110, i8* %28
br label %47
29: ; preds = %15
%30 = load i8*, i8** %2
%31 = call i32 @Q_strncmp(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i8*, i8** %2
%35 = call i32 @Q_strncmp(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%36 = icmp ne i32 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %33, %29
%38 = load i8*, i8** %2
%39 = getelementptr inbounds i8, i8* %38, i64 5
store i8* %39, i8** %2
br label %4
40: ; preds = %33
%41 = load i8*, i8** %2
%42 = load i8, i8* %41
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 %45
store i8 %42, i8* %46
br label %47
47: ; preds = %40, %20
%48 = load i8*, i8** %2
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %2
br label %4
50: ; preds = %13
%51 = load i32, i32* %3
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 %52
store i8 0, i8* %53
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 0)
}

LLVM IR (-O2):
@SV_ExpandNewlines.string = internal global [1024 x i8] zeroinitializer
@.str = [6 x i8] c"[lon]\00"
@.str.1 = [6 x i8] c"[lof]\00"
define i8* @SV_ExpandNewlines(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %39, label %4
4: ; preds = %1, %28
%5 = phi i8 [ %36, %28 ], [ %2, %1 ]
%6 = phi i32 [ %33, %28 ], [ 0, %1 ]
%7 = phi i8* [ %34, %28 ], [ %0, %1 ]
br label %8
8: ; preds = %4, %22
%9 = phi i8 [ %5, %4 ], [ %24, %22 ]
%10 = phi i8* [ %7, %4 ], [ %23, %22 ]
%11 = icmp eq i8 %9, 10
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = zext i32 %6 to i64
%14 = add nuw nsw i32 %6, 1
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 %13
store i8 92, i8* %15
br label %28
16: ; preds = %8
%17 = tail call i32 @Q_strncmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%18 = icmp eq i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = tail call i32 @Q_strncmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19, %16
%23 = getelementptr inbounds i8, i8* %10, i64 5
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %39, label %8
26: ; preds = %19
%27 = load i8, i8* %10
br label %28
28: ; preds = %26, %12
%29 = phi i32 [ %6, %26 ], [ %14, %12 ]
%30 = phi i8 [ %27, %26 ], [ 110, %12 ]
%31 = zext i32 %29 to i64
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 %31
store i8 %30, i8* %32
%33 = add nuw nsw i32 %29, 1
%34 = getelementptr inbounds i8, i8* %10, i64 1
%35 = icmp ult i32 %29, 1020
%36 = load i8, i8* %34
%37 = icmp ne i8 %36, 0
%38 = select i1 %37, i1 %35, i1 false
br i1 %38, label %4, label %39
39: ; preds = %28, %22, %1
%40 = phi i32 [ 0, %1 ], [ %6, %22 ], [ %33, %28 ]
%41 = zext i32 %40 to i64
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 %41
store i8 0, i8* %42
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 0)
}