#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 *calloc(scalar_t__, int);
int /*<<< orphan*/ free(char *);
scalar_t__ strcmp(char *, char *);
scalar_t__ strlen(char *);
int strtol(char *, int /*<<< orphan*/, int);
char *_DC_unquote_string(char *str) {
  char *s, *p, *i;
  if (!str)
    return (NULL);
  s = calloc(strlen(str) + 1, 1);
  p = str;
  i = s;
  while (*p != '\0') {
    if (*p != '\\')
      *i = *p;
    else {
      char c, *x = p + 4;
      int l;
      c = *x;
      *x = '\0';
      if (strcmp(p + 1, "nnn") == 0) {
        free(s);
        return (NULL);
      }
      l = strtol(p + 1, 0, 8);
      *i = (char)l;
      *x = c;
      p = x - 1;
    }
    p++;
    i++;
  }
  return (s);
}


x86 assembly (clang, -O0):
<_DC_unquote_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1174 <_DC_unquote_string+0x24>
movq   $0x0,-0x8(%rbp)
jmp    127f <_DC_unquote_string+0x12f>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1277 <_DC_unquote_string+0x127>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
je     11d3 <_DC_unquote_string+0x83>
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
jmp    125a <_DC_unquote_string+0x10a>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x29(%rbp)
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
lea    0xe02(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1223 <_DC_unquote_string+0xd3>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    127f <_DC_unquote_string+0x12f>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <strtol@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x29(%rbp),%cl
mov    -0x38(%rbp),%rax
mov    %cl,(%rax)
mov    -0x38(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11a2 <_DC_unquote_string+0x52>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_DC_unquote_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11f7 <_DC_unquote_string+0xa7>
mov    %rdi,%r12
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%r14
lea    0xe7c(%rip),%r15
mov    %rax,%r13
jmp    1198 <_DC_unquote_string+0x48>
nopl   0x0(%rax)
add    $0x1,%r12
add    $0x1,%r13
movzbl (%r12),%eax
cmp    $0x5c,%al
je     11b0 <_DC_unquote_string+0x60>
test   %al,%al
je     11fa <_DC_unquote_string+0xaa>
mov    %al,0x0(%r13)
jmp    1190 <_DC_unquote_string+0x40>
nopl   0x0(%rax,%rax,1)
movzbl 0x4(%r12),%ebp
movb   $0x0,0x4(%r12)
lea    0x1(%r12),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11ef <_DC_unquote_string+0x9f>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <strtol@plt>
mov    %al,0x0(%r13)
mov    %bpl,0x4(%r12)
add    $0x3,%r12
jmp    1190 <_DC_unquote_string+0x40>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"nnn\00"
define i8* @_DC_unquote_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %3
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %1
store i8* null, i8** %2
br label %65
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i64 @strlen(i8* %14)
%16 = add nsw i64 %15, 1
%17 = call i8* @calloc(i64 %16, i32 1)
store i8* %17, i8** %4
%18 = load i8*, i8** %3
store i8* %18, i8** %5
%19 = load i8*, i8** %4
store i8* %19, i8** %6
br label %20
20: ; preds = %58, %13
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %63
25: ; preds = %20
%26 = load i8*, i8** %5
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 92
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = load i8*, i8** %5
%32 = load i8, i8* %31
%33 = load i8*, i8** %6
store i8 %32, i8* %33
br label %58
34: ; preds = %25
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i64 4
store i8* %36, i8** %8
%37 = load i8*, i8** %8
%38 = load i8, i8* %37
store i8 %38, i8* %7
%39 = load i8*, i8** %8
store i8 0, i8* %39
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %34
%45 = load i8*, i8** %4
%46 = call i32 @free(i8* %45)
store i8* null, i8** %2
br label %65
47: ; preds = %34
%48 = load i8*, i8** %5
%49 = getelementptr inbounds i8, i8* %48, i64 1
%50 = call i32 @strtol(i8* %49, i32 0, i32 8)
store i32 %50, i32* %9
%51 = load i32, i32* %9
%52 = trunc i32 %51 to i8
%53 = load i8*, i8** %6
store i8 %52, i8* %53
%54 = load i8, i8* %7
%55 = load i8*, i8** %8
store i8 %54, i8* %55
%56 = load i8*, i8** %8
%57 = getelementptr inbounds i8, i8* %56, i64 -1
store i8* %57, i8** %5
br label %58
58: ; preds = %47, %30
%59 = load i8*, i8** %5
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %5
%61 = load i8*, i8** %6
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %6
br label %20
63: ; preds = %20
%64 = load i8*, i8** %4
store i8* %64, i8** %2
br label %65
65: ; preds = %63, %44, %12
%66 = load i8*, i8** %2
ret i8* %66
}

LLVM IR (-O2):
@.str = [4 x i8] c"nnn\00"
define i8* @_DC_unquote_string(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %28, label %3
3: ; preds = %1
%4 = tail call i64 @strlen(i8* %0)
%5 = add nsw i64 %4, 1
%6 = tail call i8* @calloc(i64 %5, i32 1)
br label %7
7: ; preds = %24, %3
%8 = phi i8* [ %6, %3 ], [ %27, %24 ]
%9 = phi i8* [ %0, %3 ], [ %26, %24 ]
%10 = load i8, i8* %9
switch i8 %10, label %11 [
i8 0, label %28
i8 92, label %12
]
11: ; preds = %7
store i8 %10, i8* %8
br label %24
12: ; preds = %7
%13 = getelementptr inbounds i8, i8* %9, i64 4
%14 = load i8, i8* %13
store i8 0, i8* %13
%15 = getelementptr inbounds i8, i8* %9, i64 1
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = tail call i32 @free(i8* %6)
br label %28
20: ; preds = %12
%21 = tail call i32 @strtol(i8* %15, i32 0, i32 8)
%22 = trunc i32 %21 to i8
store i8 %22, i8* %8
store i8 %14, i8* %13
%23 = getelementptr inbounds i8, i8* %9, i64 3
br label %24
24: ; preds = %20, %11
%25 = phi i8* [ %9, %11 ], [ %23, %20 ]
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = getelementptr inbounds i8, i8* %8, i64 1
br label %7
28: ; preds = %7, %18, %1
%29 = phi i8* [ null, %1 ], [ null, %18 ], [ %6, %7 ]
ret i8* %29
}