#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void decode_string(char *dest, const char *src, size_t len) {
  for (size_t i = 0; i < len - 1; ++i) {
    char c = src[i];
    if (c != '\\') {
      *(dest++) = c;
      continue;
    }
    if (*src == '\0') {
      do {
        if (1)
          fprintf(stderr, "("
                          "/scratch/repos/new/home/jordi_armengol_estape/"
                          "c-scraper/outputs/2022-01-22/02-19-57/repos/Tharre/"
                          "redo/refs/heads/master/src/DSV.c"
                          ":"
                          "54"
                          "): "
                          "DSV: ignored extra '\\' at end of string\n");
      } while (0);
      break;
    }
    switch (c = *(src++)) {
    case 'n':
      *(dest++) = '\n';
      break;
    default:
      *(dest++) = c;
    }
  }
  *dest = '\0';
}


x86 assembly (clang, -O0):
<decode_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jae    1206 <decode_string+0xf6>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0x5c,%eax
je     1175 <decode_string+0x65>
mov    -0x21(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    11f5 <decode_string+0xe5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11a4 <decode_string+0x94>
jmp    118a <decode_string+0x7a>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xe66(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1206 <decode_string+0xf6>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x21(%rbp)
sub    $0x6e,%al
jne    11dc <decode_string+0xcc>
jmp    11c5 <decode_string+0xb5>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0xa,(%rax)
jmp    11f0 <decode_string+0xe0>
mov    -0x21(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    11f5 <decode_string+0xe5>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <decode_string+0x1c>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_string>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
add    $0xffffffffffffffff,%rdx
je     1174 <decode_string+0x64>
xor    %ebx,%ebx
mov    $0xa,%eax
jmp    113d <decode_string+0x2d>
cs nopw 0x0(%rax,%rax,1)
mov    %cl,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rdx
je     1171 <decode_string+0x61>
movzbl (%rsi,%rbx,1),%ecx
cmp    $0x5c,%cl
jne    1130 <decode_string+0x20>
movzbl (%rsi),%ecx
test   %cl,%cl
je     115c <decode_string+0x4c>
add    $0x1,%rsi
cmp    $0x6e,%cl
movzbl %cl,%ecx
cmove  %eax,%ecx
jmp    1130 <decode_string+0x20>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
call   1030 <fprintf@plt>
add    %rbx,%r14
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [177 x i8] c"(/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Tharre/redo/refs/heads/master/src/DSV.c:54): DSV: ignored extra '\\' at end of string\0A\00"
define void @decode_string(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
store i64 0, i64* %7
br label %9
9: ; preds = %49, %3
%10 = load i64, i64* %7
%11 = load i64, i64* %6
%12 = sub i64 %11, 1
%13 = icmp ult i64 %10, %12
br i1 %13, label %14, label %52
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = load i64, i64* %7
%17 = getelementptr inbounds i8, i8* %15, i64 %16
%18 = load i8, i8* %17
store i8 %18, i8* %8
%19 = load i8, i8* %8
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 92
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = load i8, i8* %8
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %4
store i8 %23, i8* %24
br label %49
26: ; preds = %14
%27 = load i8*, i8** %5
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %26
br label %32
32: ; preds = %31
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0))
br label %35
35: ; preds = %32
br label %52
36: ; preds = %26
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %5
%39 = load i8, i8* %37
store i8 %39, i8* %8
%40 = sext i8 %39 to i32
switch i32 %40, label %44 [
i32 110, label %41
]
41: ; preds = %36
%42 = load i8*, i8** %4
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %4
store i8 10, i8* %42
br label %48
44: ; preds = %36
%45 = load i8, i8* %8
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %4
store i8 %45, i8* %46
br label %48
48: ; preds = %44, %41
br label %49
49: ; preds = %48, %22
%50 = load i64, i64* %7
%51 = add i64 %50, 1
store i64 %51, i64* %7
br label %9
52: ; preds = %35, %9
%53 = load i8*, i8** %4
store i8 0, i8* %53
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [177 x i8] c"(/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Tharre/redo/refs/heads/master/src/DSV.c:54): DSV: ignored extra '\\' at end of string\0A\00"
define void @decode_string(i8* nocapture writeonly %0, i8* nocapture %1, i64 %2) {
%4 = add i64 %2, -1
%5 = icmp eq i64 %4, 0
br i1 %5, label %29, label %6
6: ; preds = %3, %23
%7 = phi i64 [ %27, %23 ], [ 0, %3 ]
%8 = phi i8* [ %26, %23 ], [ %0, %3 ]
%9 = phi i8* [ %25, %23 ], [ %1, %3 ]
%10 = getelementptr inbounds i8, i8* %9, i64 %7
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 92
br i1 %12, label %13, label %23
13: ; preds = %6
%14 = load i8, i8* %9
%15 = icmp eq i8 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = getelementptr inbounds i8, i8* %9, i64 1
%18 = icmp eq i8 %14, 110
%19 = select i1 %18, i8 10, i8 %14
br label %23
20: ; preds = %13
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0))
br label %29
23: ; preds = %6, %16
%24 = phi i8 [ %19, %16 ], [ %11, %6 ]
%25 = phi i8* [ %17, %16 ], [ %9, %6 ]
%26 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %24, i8* %8
%27 = add nuw i64 %7, 1
%28 = icmp eq i64 %27, %4
br i1 %28, label %29, label %6
29: ; preds = %23, %3, %20
%30 = phi i8* [ %8, %20 ], [ %0, %3 ], [ %26, %23 ]
store i8 0, i8* %30
ret void
}