#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 */
scalar_t__ malloc(scalar_t__);
scalar_t__ strlen(char *);
char *strnl0(char *s) {
  char *t, *u;
  t = (char *)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 i64 @malloc(i64 %7)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %3
%10 = load i8*, i8** %3
store i8* %10, i8** %4
br label %11
11: ; preds = %35, %1
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %40
16: ; preds = %11
%17 = load i8*, i8** %2
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 92
br i1 %20, label %21, label %31
21: ; preds = %16
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 110
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = load i8*, i8** %4
store i8 10, i8* %28
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %2
br label %35
31: ; preds = %21, %16
%32 = load i8*, i8** %2
%33 = load i8, i8* %32
%34 = load i8*, i8** %4
store i8 %33, i8* %34
br label %35
35: ; preds = %31, %27
%36 = load i8*, i8** %2
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %2
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %4
br label %11
40: ; preds = %11
%41 = load i8*, i8** %4
store i8 0, i8* %41
%42 = load i8*, i8** %3
ret i8* %42
}

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