#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 */
char *malloc(scalar_t__);
scalar_t__ strlen(char const *);
char *strnl0(const char *s) {
  char *t, *u;
  t = malloc(strlen(s) + 1);
  u = t;
  while (*s != 0) {
    if ((*s == '\\') && (s[1] == 'n')) {
      *u = '\n';
      s++;
    } else
      *u = *s;
    s++;
    u++;
  }
  *u = 0;
  return t;
}


x86 assembly (clang, -O0):
<strnl0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11bf <strnl0+0x9f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1196 <strnl0+0x76>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6e,%eax
jne    1196 <strnl0+0x76>
mov    -0x18(%rbp),%rax
movb   $0xa,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11a2 <strnl0+0x82>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114d <strnl0+0x2d>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strnl0>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    0x1(%rax),%rdi
call   1040 <malloc@plt>
mov    %rax,%rcx
jmp    114e <strnl0+0x2e>
nopw   0x0(%rax,%rax,1)
test   %dl,%dl
je     1164 <strnl0+0x44>
mov    %dl,(%rcx)
add    $0x1,%rbx
add    $0x1,%rcx
movzbl (%rbx),%edx
cmp    $0x5c,%dl
jne    1140 <strnl0+0x20>
cmpb   $0x6e,0x1(%rbx)
jne    1144 <strnl0+0x24>
add    $0x1,%rbx
mov    $0xa,%dl
jmp    1144 <strnl0+0x24>
movb   $0x0,(%rcx)
pop    %rbx
ret

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

LLVM IR (-O2):
define noalias i8* @strnl0(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 1
%4 = tail call i8* @malloc(i64 %3)
br label %5
5: ; preds = %14, %1
%6 = phi i8* [ %0, %1 ], [ %17, %14 ]
%7 = phi i8* [ %4, %1 ], [ %18, %14 ]
%8 = load i8, i8* %6
switch i8 %8, label %13 [
i8 0, label %19
i8 92, label %9
]
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %6, 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* [ %6, %13 ], [ %10, %9 ]
store i8 %15, i8* %7
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = getelementptr inbounds i8, i8* %7, i64 1
br label %5
19: ; preds = %5
store i8 0, i8* %7
ret i8* %4
}