#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 */
void readstat_copy_quoted(char *buf, size_t buf_len, const char *str_start,
                          size_t str_len) {
  size_t this_len = str_len;
  if (this_len >= buf_len) {
    this_len = buf_len - 1;
  }
  size_t i = 0;
  size_t j = 0;
  int slash = 0;
  for (i = 0; i < this_len; i++) {
    if (slash) {
      if (str_start[i] == 't') {
        buf[j++] = '\t';
      } else {
        buf[j++] = str_start[i];
      }
      slash = 0;
    } else {
      if (str_start[i] == '\\') {
        slash = 1;
      } else {
        buf[j++] = str_start[i];
      }
    }
  }
  buf[j] = '\0';
}


x86 assembly (clang, -O0):
<readstat_copy_quoted>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     1136 <readstat_copy_quoted+0x36>
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1228 <readstat_copy_quoted+0x128>
cmpl   $0x0,-0x3c(%rbp)
je     11cb <readstat_copy_quoted+0xcb>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x74,%eax
jne    119e <readstat_copy_quoted+0x9e>
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x38(%rbp)
movb   $0x9,(%rax,%rcx,1)
jmp    11bf <readstat_copy_quoted+0xbf>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x38(%rbp)
mov    %dl,(%rax,%rcx,1)
movl   $0x0,-0x3c(%rbp)
jmp    1212 <readstat_copy_quoted+0x112>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    11ec <readstat_copy_quoted+0xec>
movl   $0x1,-0x3c(%rbp)
jmp    120d <readstat_copy_quoted+0x10d>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x38(%rbp)
mov    %dl,(%rax,%rcx,1)
jmp    1212 <readstat_copy_quoted+0x112>
jmp    1217 <readstat_copy_quoted+0x117>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1155 <readstat_copy_quoted+0x55>
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
pop    %rbp
ret

x86 assembly (clang, -O2):
<readstat_copy_quoted>:
lea    -0x1(%rsi),%r9
cmp    %rsi,%rcx
cmovb  %rcx,%r9
xor    %eax,%eax
test   %r9,%r9
je     115b <readstat_copy_quoted+0x5b>
mov    $0x9,%r8d
xor    %r10d,%r10d
xor    %esi,%esi
jmp    113d <readstat_copy_quoted+0x3d>
nop
cmp    $0x74,%cl
movzbl %cl,%eax
cmove  %r8d,%eax
mov    %al,(%rdi,%r10,1)
add    $0x1,%r10
xor    %eax,%eax
add    $0x1,%rsi
cmp    %rsi,%r9
je     1155 <readstat_copy_quoted+0x55>
movzbl (%rdx,%rsi,1),%ecx
test   %eax,%eax
jne    1120 <readstat_copy_quoted+0x20>
mov    $0x1,%eax
cmp    $0x5c,%cl
je     1134 <readstat_copy_quoted+0x34>
mov    %cl,(%rdi,%r10,1)
jmp    112e <readstat_copy_quoted+0x2e>
movb   $0x0,(%rdi,%r10,1)
ret
xor    %r10d,%r10d
movb   $0x0,(%rdi,%r10,1)
ret

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

LLVM IR (-O2):
define void @readstat_copy_quoted(i8* nocapture writeonly %0, i64 %1, i8* nocapture %2, i64 %3) {
%5 = icmp ult i64 %3, %1
%6 = add i64 %1, -1
%7 = select i1 %5, i64 %3, i64 %6
%8 = icmp eq i64 %7, 0
br i1 %8, label %31, label %9
9: ; preds = %4, %26
%10 = phi i32 [ %28, %26 ], [ 0, %4 ]
%11 = phi i64 [ %27, %26 ], [ 0, %4 ]
%12 = phi i64 [ %29, %26 ], [ 0, %4 ]
%13 = icmp eq i32 %10, 0
%14 = getelementptr inbounds i8, i8* %2, i64 %12
%15 = load i8, i8* %14
br i1 %13, label %21, label %16
16: ; preds = %9
%17 = icmp eq i8 %15, 116
%18 = select i1 %17, i8 9, i8 %15
%19 = getelementptr inbounds i8, i8* %0, i64 %11
store i8 %18, i8* %19
%20 = add i64 %11, 1
br label %26
21: ; preds = %9
%22 = icmp eq i8 %15, 92
br i1 %22, label %26, label %23
23: ; preds = %21
%24 = add i64 %11, 1
%25 = getelementptr inbounds i8, i8* %0, i64 %11
store i8 %15, i8* %25
br label %26
26: ; preds = %21, %16, %23
%27 = phi i64 [ %20, %16 ], [ %24, %23 ], [ %11, %21 ]
%28 = phi i32 [ 0, %16 ], [ 0, %23 ], [ 1, %21 ]
%29 = add nuw i64 %12, 1
%30 = icmp eq i64 %29, %7
br i1 %30, label %31, label %9
31: ; preds = %26, %4
%32 = phi i64 [ 0, %4 ], [ %27, %26 ]
%33 = getelementptr inbounds i8, i8* %0, i64 %32
store i8 0, i8* %33
ret void
}