#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*/ OPENSSL_free(unsigned char *);
unsigned char *OPENSSL_malloc(size_t);
unsigned char *OPENSSL_zalloc(int);
int /*<<< orphan*/ test_error(char *, int, char *);
int /*<<< orphan*/ test_ptr(char *, int, char *, unsigned char *);
unsigned char *unescape(const char *input, size_t input_len, size_t *out_len) {
  unsigned char *ret, *p;
  size_t i;
  if (input_len == 0) {
    *out_len = 0;
    return OPENSSL_zalloc(1);
  }
  if (!test_ptr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/"
                "refs/heads/master/Src/OSF/OpenSSL-111/test/evp_test.c",
                238, "ret = p = OPENSSL_malloc(input_len)",
                ret = p = OPENSSL_malloc(input_len)))
    return NULL;
  for (i = 0; i < input_len; i++) {
    if (*input == '\\') {
      if (i == input_len - 1 || *++input != 'n') {
        test_error(
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
            "master/Src/OSF/OpenSSL-111/test/evp_test.c",
            244, "Bad escape sequence in file");
        goto err;
      }
      *p++ = '\n';
      i++;
      input++;
    } else {
      *p++ = *input++;
    }
  }
  *out_len = p - ret;
  return ret;
err:
  OPENSSL_free(ret);
  return NULL;
}


x86 assembly (clang, -O0):
<unescape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118d <unescape+0x3d>
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    $0x1,%edi
call   1040 <OPENSSL_zalloc@plt>
mov    %rax,-0x8(%rbp)
jmp    12da <unescape+0x18a>
mov    -0x18(%rbp),%rdi
call   1050 <OPENSSL_malloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,-0x28(%rbp)
lea    0xe58(%rip),%rdi
mov    $0xee,%esi
lea    0xef8(%rip),%rdx
call   1030 <test_ptr@plt>
cmp    $0x0,%eax
jne    11cf <unescape+0x7f>
movq   $0x0,-0x8(%rbp)
jmp    12da <unescape+0x18a>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    12aa <unescape+0x15a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1272 <unescape+0x122>
mov    -0x38(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
je     1226 <unescape+0xd6>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x6e,%eax
je     1243 <unescape+0xf3>
lea    0xdd3(%rip),%rdi
mov    $0xf4,%esi
lea    0xe97(%rip),%rdx
call   1070 <test_error@plt>
jmp    12c9 <unescape+0x179>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0xa,(%rax)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1294 <unescape+0x144>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
jmp    1299 <unescape+0x149>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11d7 <unescape+0x87>
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%rax
sub    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12da <unescape+0x18a>
mov    -0x28(%rbp),%rdi
call   1060 <OPENSSL_free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unescape>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
test   %rsi,%rsi
je     11d7 <unescape+0x87>
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1050 <OPENSSL_malloc@plt>
mov    %rax,%r15
lea    0xe88(%rip),%rdi
lea    0xf2d(%rip),%rdx
mov    $0xee,%esi
mov    %rax,%rcx
call   1030 <test_ptr@plt>
test   %eax,%eax
je     1218 <unescape+0xc8>
lea    -0x1(%r12),%rsi
xor    %eax,%eax
xor    %edx,%edx
jmp    11b5 <unescape+0x65>
nop
add    $0x1,%rbx
mov    %cl,(%r15,%rax,1)
add    $0x1,%rdx
add    $0x1,%rax
cmp    %r12,%rdx
jae    11f3 <unescape+0xa3>
movzbl (%rbx),%ecx
cmp    $0x5c,%cl
jne    11a0 <unescape+0x50>
cmp    %rsi,%rdx
je     11f8 <unescape+0xa8>
cmpb   $0x6e,0x1(%rbx)
jne    11f8 <unescape+0xa8>
movb   $0xa,(%r15,%rax,1)
add    $0x1,%rdx
add    $0x2,%rbx
jmp    11a8 <unescape+0x58>
movq   $0x0,(%r14)
mov    $0x1,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <OPENSSL_zalloc@plt>
mov    %rax,(%r14)
jmp    121b <unescape+0xcb>
lea    0xe01(%rip),%rdi
lea    0xeca(%rip),%rdx
mov    $0xf4,%esi
call   1070 <test_error@plt>
mov    %r15,%rdi
call   1060 <OPENSSL_free@plt>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/master/Src/OSF/OpenSSL-111/test/evp_test.c\00"
@.str.1 = [36 x i8] c"ret = p = OPENSSL_malloc(input_len)\00"
@.str.2 = [28 x i8] c"Bad escape sequence in file\00"
define i8* @unescape(i8* %0, i64 %1, i64* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64* %2, i64** %7
%11 = load i64, i64* %6
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = load i64*, i64** %7
store i64 0, i64* %14
%15 = call i8* @OPENSSL_zalloc(i32 1)
store i8* %15, i8** %4
br label %73
16: ; preds = %3
%17 = load i64, i64* %6
%18 = call i8* @OPENSSL_malloc(i64 %17)
store i8* %18, i8** %9
store i8* %18, i8** %8
%19 = call i32 @test_ptr(i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i32 238, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %16
store i8* null, i8** %4
br label %73
22: ; preds = %16
store i64 0, i64* %10
br label %23
23: ; preds = %59, %22
%24 = load i64, i64* %10
%25 = load i64, i64* %6
%26 = icmp ult i64 %24, %25
br i1 %26, label %27, label %62
27: ; preds = %23
%28 = load i8*, i8** %5
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 92
br i1 %31, label %32, label %52
32: ; preds = %27
%33 = load i64, i64* %10
%34 = load i64, i64* %6
%35 = sub i64 %34, 1
%36 = icmp eq i64 %33, %35
br i1 %36, label %43, label %37
37: ; preds = %32
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %5
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 110
br i1 %42, label %43, label %45
43: ; preds = %37, %32
%44 = call i32 @test_error(i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i32 244, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %70
45: ; preds = %37
%46 = load i8*, i8** %9
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %9
store i8 10, i8* %46
%48 = load i64, i64* %10
%49 = add i64 %48, 1
store i64 %49, i64* %10
%50 = load i8*, i8** %5
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %5
br label %58
52: ; preds = %27
%53 = load i8*, i8** %5
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %5
%55 = load i8, i8* %53
%56 = load i8*, i8** %9
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %9
store i8 %55, i8* %56
br label %58
58: ; preds = %52, %45
br label %59
59: ; preds = %58
%60 = load i64, i64* %10
%61 = add i64 %60, 1
store i64 %61, i64* %10
br label %23
62: ; preds = %23
%63 = load i8*, i8** %9
%64 = load i8*, i8** %8
%65 = ptrtoint i8* %63 to i64
%66 = ptrtoint i8* %64 to i64
%67 = sub i64 %65, %66
%68 = load i64*, i64** %7
store i64 %67, i64* %68
%69 = load i8*, i8** %8
store i8* %69, i8** %4
br label %73
70: ; preds = %43
%71 = load i8*, i8** %8
%72 = call i32 @OPENSSL_free(i8* %71)
store i8* null, i8** %4
br label %73
73: ; preds = %70, %62, %21, %13
%74 = load i8*, i8** %4
ret i8* %74
}

LLVM IR (-O2):
@.str = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/master/Src/OSF/OpenSSL-111/test/evp_test.c\00"
@.str.1 = [36 x i8] c"ret = p = OPENSSL_malloc(input_len)\00"
@.str.2 = [28 x i8] c"Bad escape sequence in file\00"
define i8* @unescape(i8* nocapture %0, i64 %1, i64* nocapture writeonly %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %3
store i64 0, i64* %2
%6 = tail call i8* @OPENSSL_zalloc(i32 1)
br label %43
7: ; preds = %3
%8 = tail call i8* @OPENSSL_malloc(i64 %1)
%9 = tail call i32 @test_ptr(i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i32 238, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %43, label %11
11: ; preds = %7
%12 = add i64 %1, -1
br label %13
13: ; preds = %11, %33
%14 = phi i64 [ 0, %11 ], [ %37, %33 ]
%15 = phi i8* [ %8, %11 ], [ %36, %33 ]
%16 = phi i8* [ %0, %11 ], [ %34, %33 ]
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 92
br i1 %18, label %19, label %31
19: ; preds = %13
%20 = icmp eq i64 %14, %12
br i1 %20, label %25, label %21
21: ; preds = %19
%22 = getelementptr inbounds i8, i8* %16, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 110
br i1 %24, label %28, label %25
25: ; preds = %21, %19
%26 = tail call i32 @test_error(i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i32 244, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%27 = tail call i32 @OPENSSL_free(i8* %8)
br label %43
28: ; preds = %21
store i8 10, i8* %15
%29 = add nuw i64 %14, 1
%30 = getelementptr inbounds i8, i8* %16, i64 2
br label %33
31: ; preds = %13
%32 = getelementptr inbounds i8, i8* %16, i64 1
store i8 %17, i8* %15
br label %33
33: ; preds = %28, %31
%34 = phi i8* [ %30, %28 ], [ %32, %31 ]
%35 = phi i64 [ %29, %28 ], [ %14, %31 ]
%36 = getelementptr inbounds i8, i8* %15, i64 1
%37 = add i64 %35, 1
%38 = icmp ult i64 %37, %1
br i1 %38, label %13, label %39
39: ; preds = %33
%40 = ptrtoint i8* %36 to i64
%41 = ptrtoint i8* %8 to i64
%42 = sub i64 %40, %41
store i64 %42, i64* %2
br label %43
43: ; preds = %7, %25, %39, %5
%44 = phi i8* [ %6, %5 ], [ null, %25 ], [ %8, %39 ], [ null, %7 ]
ret i8* %44
}