#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*/ resize_buffer(char **, int *, int const);
int strlen(char const *);
const char *strip_escapes(const char *p) {
  static char *buf = 0;
  static int bufsz = 0;
  const int len = strlen(p);
  int i = 0;
  if (!resize_buffer(&buf, &bufsz, len + 1))
    return 0;
  while ((buf[i++] = ((*p == '\\') ? *++p : *p)))
    ++p;
  return buf;
}


x86 assembly (clang, -O0):
<strip_escapes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%edx
add    $0x1,%edx
lea    0x2eec(%rip),%rdi
lea    0x2eed(%rip),%rsi
call   1040 <resize_buffer@plt>
cmp    $0x0,%eax
jne    116e <strip_escapes+0x4e>
movq   $0x0,-0x8(%rbp)
jmp    11e7 <strip_escapes+0xc7>
jmp    1173 <strip_escapes+0x53>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    119e <strip_escapes+0x7e>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    11a8 <strip_escapes+0x88>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e86(%rip),%rcx
mov    -0x18(%rbp),%edx
mov    %edx,%esi
add    $0x1,%esi
mov    %esi,-0x18(%rbp)
movslq %edx,%rdx
mov    %al,(%rcx,%rdx,1)
cmp    $0x0,%al
je     11dc <strip_escapes+0xbc>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1173 <strip_escapes+0x53>
mov    0x2e55(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_escapes>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    0x1(%rax),%edx
lea    0x2f05(%rip),%rdi
lea    0x2f06(%rip),%rsi
call   1040 <resize_buffer@plt>
test   %eax,%eax
je     1181 <strip_escapes+0x61>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx),%ecx
cmp    $0x5c,%cl
jne    1160 <strip_escapes+0x40>
movzbl 0x1(%rbx),%ecx
add    $0x1,%rbx
mov    0x2ed1(%rip),%rdx
mov    %cl,(%rdx,%rax,1)
test   %cl,%cl
je     1178 <strip_escapes+0x58>
add    $0x1,%rax
add    $0x1,%rbx
jmp    1150 <strip_escapes+0x30>
mov    0x2eb9(%rip),%rax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@strip_escapes.buf = internal global i8* null
@strip_escapes.bufsz = internal global i32 0
define i8* @strip_escapes(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %4
store i32 0, i32* %5
%8 = load i32, i32* %4
%9 = add nsw i32 %8, 1
%10 = call i32 @resize_buffer(i8** @strip_escapes.buf, i32* @strip_escapes.bufsz, i32 %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %1
store i8* null, i8** %2
br label %42
13: ; preds = %1
br label %14
14: ; preds = %37, %13
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 92
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
br label %28
24: ; preds = %14
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
br label %28
28: ; preds = %24, %19
%29 = phi i32 [ %23, %19 ], [ %27, %24 ]
%30 = trunc i32 %29 to i8
%31 = load i8*, i8** @strip_escapes.buf
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
%34 = sext i32 %32 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
store i8 %30, i8* %35
%36 = icmp ne i8 %30, 0
br i1 %36, label %37, label %40
37: ; preds = %28
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %3
br label %14
40: ; preds = %28
%41 = load i8*, i8** @strip_escapes.buf
store i8* %41, i8** %2
br label %42
42: ; preds = %40, %12
%43 = load i8*, i8** %2
ret i8* %43
}

LLVM IR (-O2):
@strip_escapes.buf = internal global i8* null
@strip_escapes.bufsz = internal global i32 0
define i8* @strip_escapes(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, 1
%4 = tail call i32 @resize_buffer(i8** @strip_escapes.buf, i32* @strip_escapes.bufsz, i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %25, label %6
6: ; preds = %1, %20
%7 = phi i64 [ %21, %20 ], [ 0, %1 ]
%8 = phi i8* [ %22, %20 ], [ %0, %1 ]
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 92
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %8, i64 1
%13 = load i8, i8* %12
br label %14
14: ; preds = %6, %11
%15 = phi i8* [ %12, %11 ], [ %8, %6 ]
%16 = phi i8 [ %13, %11 ], [ %9, %6 ]
%17 = load i8*, i8** @strip_escapes.buf
%18 = getelementptr inbounds i8, i8* %17, i64 %7
store i8 %16, i8* %18
%19 = icmp eq i8 %16, 0
br i1 %19, label %23, label %20
20: ; preds = %14
%21 = add nuw i64 %7, 1
%22 = getelementptr inbounds i8, i8* %15, i64 1
br label %6
23: ; preds = %14
%24 = load i8*, i8** @strip_escapes.buf
br label %25
25: ; preds = %1, %23
%26 = phi i8* [ %24, %23 ], [ null, %1 ]
ret i8* %26
}