#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 */
char *SV_ExpandNewlines(char *in) {
  static char string[1024];
  int l;
  l = 0;
  while (*in && l < sizeof(string) - 3) {
    if (*in == '\n') {
      string[l++] = '\\';
      string[l++] = 'n';
    } else {
      string[l++] = *in;
    }
    in++;
  }
  string[l] = 0;
  return string;
}


x86 assembly (clang, -O0):
<SV_ExpandNewlines>:
push   %rbp
mov    %rsp,%rbp
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     1134 <SV_ExpandNewlines+0x34>
movslq -0xc(%rbp),%rax
cmp    $0x3fd,%rax
setb   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1144 <SV_ExpandNewlines+0x44>
jmp    11ba <SV_ExpandNewlines+0xba>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    118b <SV_ExpandNewlines+0x8b>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
movslq %eax,%rcx
lea    0x2ec7(%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    0x2eae(%rip),%rax
movb   $0x6e,(%rax,%rcx,1)
jmp    11a9 <SV_ExpandNewlines+0xa9>
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    0x2e8a(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    110f <SV_ExpandNewlines+0xf>
movslq -0xc(%rbp),%rcx
lea    0x2e6b(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e60(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<SV_ExpandNewlines>:
mov    (%rdi),%dl
xor    %ecx,%ecx
test   %dl,%dl
je     1152 <SV_ExpandNewlines+0x52>
add    $0x1,%rdi
lea    0x2f1d(%rip),%r8
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0xa,%dl
jne    1132 <SV_ExpandNewlines+0x32>
add    $0x1,%ecx
movb   $0x5c,(%rsi,%r8,1)
mov    $0x6e,%dl
mov    %rcx,%rsi
mov    %ecx,%eax
mov    %dl,(%rsi,%r8,1)
lea    0x1(%rax),%ecx
movzbl (%rdi),%edx
test   %dl,%dl
je     1150 <SV_ExpandNewlines+0x50>
add    $0x1,%rdi
mov    %rcx,%rsi
cmp    $0x3fc,%eax
jb     1120 <SV_ExpandNewlines+0x20>
mov    %ecx,%ecx
lea    0x2ed7(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
ret

LLVM IR (-O0):
@SV_ExpandNewlines.string = internal global [1024 x i8] zeroinitializer
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 = %36, %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 %39
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 %36
29: ; preds = %15
%30 = load i8*, i8** %2
%31 = load i8, i8* %30
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
%34 = sext i32 %32 to i64
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 %34
store i8 %31, i8* %35
br label %36
36: ; preds = %29, %20
%37 = load i8*, i8** %2
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %2
br label %4
39: ; preds = %13
%40 = load i32, i32* %3
%41 = sext 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)
}

LLVM IR (-O2):
@SV_ExpandNewlines.string = internal global [1024 x i8] zeroinitializer
define i8* @SV_ExpandNewlines(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %28, label %4
4: ; preds = %1, %14
%5 = phi i64 [ %23, %14 ], [ 0, %1 ]
%6 = phi i8 [ %21, %14 ], [ %2, %1 ]
%7 = phi i32 [ %19, %14 ], [ 0, %1 ]
%8 = phi i8* [ %20, %14 ], [ %0, %1 ]
%9 = icmp eq i8 %6, 10
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = add nuw nsw i32 %7, 1
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 %5
store i8 92, i8* %12
%13 = zext i32 %11 to i64
br label %14
14: ; preds = %4, %10
%15 = phi i64 [ %13, %10 ], [ %5, %4 ]
%16 = phi i8 [ 110, %10 ], [ %6, %4 ]
%17 = phi i32 [ %11, %10 ], [ %7, %4 ]
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 %15
store i8 %16, i8* %18
%19 = add nuw nsw i32 %17, 1
%20 = getelementptr inbounds i8, i8* %8, i64 1
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
%23 = zext i32 %19 to i64
%24 = icmp ult i32 %17, 1020
%25 = select i1 %22, i1 %24, i1 false
br i1 %25, label %4, label %26
26: ; preds = %14
%27 = zext i32 %19 to i64
br label %28
28: ; preds = %1, %26
%29 = phi i64 [ %27, %26 ], [ 0, %1 ]
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 %29
store i8 0, i8* %30
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @SV_ExpandNewlines.string, i64 0, i64 0)
}