#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(int);
int strlen(char const *);
char *interpret_escape_sequences_alloc(const char *s) {
  char *orig_d = (char *)malloc(sizeof(char) * (strlen(s) + 1));
  char *d = orig_d;
  const char *orig_s = s;
  (void)(orig_s);
  while (*s != '\0') {
    if (*s == '\\') {
      const char *sp1 = s + 1;
      if (*sp1 == 'n') {
        s++;
        *d = '\n';
      } else if (*sp1 == 't') {
        s++;
        *d = '\t';
      } else if (*sp1 == '\\') {
        s++;
        *d = '\\';
      } else {
        *d = *s;
      }
    } else {
      *d = *s;
    }
    ++s;
    ++d;
  }
  *d = '\0';
  return orig_d;
}


x86 assembly (clang, -O0):
<interpret_escape_sequences_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1241 <interpret_escape_sequences_alloc+0x121>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1218 <interpret_escape_sequences_alloc+0xf8>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
jne    11ad <interpret_escape_sequences_alloc+0x8d>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
movb   $0xa,(%rax)
jmp    1213 <interpret_escape_sequences_alloc+0xf3>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x74,%eax
jne    11d5 <interpret_escape_sequences_alloc+0xb5>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x9,(%rax)
jmp    120e <interpret_escape_sequences_alloc+0xee>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11fd <interpret_escape_sequences_alloc+0xdd>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x5c,(%rax)
jmp    1209 <interpret_escape_sequences_alloc+0xe9>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
jmp    120e <interpret_escape_sequences_alloc+0xee>
jmp    1213 <interpret_escape_sequences_alloc+0xf3>
jmp    1224 <interpret_escape_sequences_alloc+0x104>
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    1159 <interpret_escape_sequences_alloc+0x39>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interpret_escape_sequences_alloc>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    0x1(%rax),%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
jmp    114e <interpret_escape_sequences_alloc+0x2e>
cs nopw 0x0(%rax,%rax,1)
test   %dl,%dl
je     1186 <interpret_escape_sequences_alloc+0x66>
mov    %dl,(%rcx)
add    $0x1,%rbx
add    $0x1,%rcx
movzbl (%rbx),%edx
cmp    $0x5c,%dl
jne    1140 <interpret_escape_sequences_alloc+0x20>
lea    0x1(%rbx),%rsi
movzbl 0x1(%rbx),%edx
cmp    $0x5c,%dl
je     1174 <interpret_escape_sequences_alloc+0x54>
cmp    $0x6e,%dl
je     117b <interpret_escape_sequences_alloc+0x5b>
cmp    $0x74,%dl
jne    1182 <interpret_escape_sequences_alloc+0x62>
mov    $0x9,%dl
mov    %rsi,%rbx
jmp    1144 <interpret_escape_sequences_alloc+0x24>
mov    $0x5c,%dl
mov    %rsi,%rbx
jmp    1144 <interpret_escape_sequences_alloc+0x24>
mov    $0xa,%dl
mov    %rsi,%rbx
jmp    1144 <interpret_escape_sequences_alloc+0x24>
mov    $0x5c,%dl
jmp    1144 <interpret_escape_sequences_alloc+0x24>
movb   $0x0,(%rcx)
pop    %rbx
ret

LLVM IR (-O0):
define i8* @interpret_escape_sequences_alloc(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = add nsw i32 %8, 1
%10 = sext i32 %9 to i64
%11 = mul i64 1, %10
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %3
%15 = load i8*, i8** %3
store i8* %15, i8** %4
%16 = load i8*, i8** %2
store i8* %16, i8** %5
%17 = load i8*, i8** %5
br label %18
18: ; preds = %68, %1
%19 = load i8*, i8** %2
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %73
23: ; preds = %18
%24 = load i8*, i8** %2
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 92
br i1 %27, label %28, label %64
28: ; preds = %23
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i64 1
store i8* %30, i8** %6
%31 = load i8*, i8** %6
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 110
br i1 %34, label %35, label %39
35: ; preds = %28
%36 = load i8*, i8** %2
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %2
%38 = load i8*, i8** %4
store i8 10, i8* %38
br label %63
39: ; preds = %28
%40 = load i8*, i8** %6
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 116
br i1 %43, label %44, label %48
44: ; preds = %39
%45 = load i8*, i8** %2
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %2
%47 = load i8*, i8** %4
store i8 9, i8* %47
br label %62
48: ; preds = %39
%49 = load i8*, i8** %6
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 92
br i1 %52, label %53, label %57
53: ; preds = %48
%54 = load i8*, i8** %2
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %2
%56 = load i8*, i8** %4
store i8 92, i8* %56
br label %61
57: ; preds = %48
%58 = load i8*, i8** %2
%59 = load i8, i8* %58
%60 = load i8*, i8** %4
store i8 %59, i8* %60
br label %61
61: ; preds = %57, %53
br label %62
62: ; preds = %61, %44
br label %63
63: ; preds = %62, %35
br label %68
64: ; preds = %23
%65 = load i8*, i8** %2
%66 = load i8, i8* %65
%67 = load i8*, i8** %4
store i8 %66, i8* %67
br label %68
68: ; preds = %64, %63
%69 = load i8*, i8** %2
%70 = getelementptr inbounds i8, i8* %69, i32 1
store i8* %70, i8** %2
%71 = load i8*, i8** %4
%72 = getelementptr inbounds i8, i8* %71, i32 1
store i8* %72, i8** %4
br label %18
73: ; preds = %18
%74 = load i8*, i8** %4
store i8 0, i8* %74
%75 = load i8*, i8** %3
ret i8* %75
}

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