#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 */
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int /*<<< orphan*/);
char *strdup(char *);
int /*<<< orphan*/ strlen(char *);
char *fix_full_type(char *str) {
  char *s = str;
  char *r;
  char *tmp = (char *)malloc(strlen(str));
  char *result;
  int seen_backslash = 0;
  for (r = tmp; *s != '\0'; s++) {
    switch (*s) {
    case '\\':
      ++seen_backslash;
      break;
    case 'n':
      if (seen_backslash) {
        *r++ = '\n';
        seen_backslash = 0;
        break;
      }
    default:
      *r++ = *s;
      seen_backslash = 0;
    }
  }
  *r = '\0';
  result = strdup(tmp);
  free(tmp);
  free(str);
  return result;
}


x86 assembly (clang, -O0):
<fix_full_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     121f <fix_full_type+0xdf>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x30(%rbp)
sub    $0x5c,%eax
je     11b0 <fix_full_type+0x70>
jmp    119f <fix_full_type+0x5f>
mov    -0x30(%rbp),%eax
sub    $0x6e,%eax
je     11be <fix_full_type+0x7e>
jmp    11eb <fix_full_type+0xab>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1209 <fix_full_type+0xc9>
cmpl   $0x0,-0x2c(%rbp)
je     11e6 <fix_full_type+0xa6>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0xa,(%rax)
movl   $0x0,-0x2c(%rbp)
jmp    1209 <fix_full_type+0xc9>
jmp    11eb <fix_full_type+0xab>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
movl   $0x0,-0x2c(%rbp)
jmp    120e <fix_full_type+0xce>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1177 <fix_full_type+0x37>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_full_type>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    (%r15),%bl
test   %bl,%bl
je     11a3 <fix_full_type+0x63>
lea    0x1(%r15),%rax
xor    %edx,%edx
mov    %r14,%rcx
jmp    117e <fix_full_type+0x3e>
nopl   0x0(%rax)
add    $0x1,%edx
movzbl (%rax),%ebx
add    $0x1,%rax
test   %bl,%bl
je     11a6 <fix_full_type+0x66>
movsbl %bl,%esi
cmp    $0x6e,%esi
je     1190 <fix_full_type+0x50>
cmp    $0x5c,%esi
je     1170 <fix_full_type+0x30>
jmp    1194 <fix_full_type+0x54>
nopl   (%rax)
test   %edx,%edx
jne    119e <fix_full_type+0x5e>
mov    %bl,(%rcx)
add    $0x1,%rcx
xor    %edx,%edx
jmp    1173 <fix_full_type+0x33>
movb   $0xa,(%rcx)
jmp    1196 <fix_full_type+0x56>
mov    %r14,%rcx
movb   $0x0,(%rcx)
mov    %r14,%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define noalias i8* @fix_full_type(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i64 @malloc(i32 %2)
%4 = inttoptr i64 %3 to i8*
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %27, label %7
7: ; preds = %1, %21
%8 = phi i8 [ %25, %21 ], [ %5, %1 ]
%9 = phi i32 [ %23, %21 ], [ 0, %1 ]
%10 = phi i8* [ %24, %21 ], [ %0, %1 ]
%11 = phi i8* [ %22, %21 ], [ %4, %1 ]
%12 = sext i8 %8 to i32
switch i32 %12, label %19 [
i32 92, label %13
i32 110, label %15
]
13: ; preds = %7
%14 = add nsw i32 %9, 1
br label %21
15: ; preds = %7
%16 = icmp eq i32 %9, 0
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = getelementptr inbounds i8, i8* %11, i64 1
store i8 10, i8* %11
br label %21
19: ; preds = %15, %7
%20 = getelementptr inbounds i8, i8* %11, i64 1
store i8 %8, i8* %11
br label %21
21: ; preds = %13, %17, %19
%22 = phi i8* [ %20, %19 ], [ %18, %17 ], [ %11, %13 ]
%23 = phi i32 [ 0, %19 ], [ 0, %17 ], [ %14, %13 ]
%24 = getelementptr inbounds i8, i8* %10, i64 1
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %7
27: ; preds = %21, %1
%28 = phi i8* [ %4, %1 ], [ %22, %21 ]
store i8 0, i8* %28
%29 = tail call i8* @strdup(i8* %4)
%30 = tail call i32 @free(i8* %4)
%31 = tail call i32 @free(i8* %0)
ret i8* %29
}