#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*/ assert(int);
scalar_t__ esc_decode(char *, char **);
size_t esc_decstr(char *dst, const char *src) {
  char *s = (char *)src;
  char *d = dst;
  assert(dst && src);
  while (*s)
    *d++ = (char)esc_decode(s, &s);
  *d = '\0';
  return (size_t)(d - dst);
}


x86 assembly (clang, -O0):
<esc_decstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x21(%rbp)
je     115b <esc_decstr+0x3b>
cmpq   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     119a <esc_decstr+0x7a>
mov    -0x18(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <esc_decode@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    1168 <esc_decstr+0x48>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<esc_decstr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,(%rsp)
test   %rdi,%rdi
setne  %al
test   %rsi,%rsi
setne  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
cmpb   $0x0,(%r15)
mov    %r14,%rbx
je     117b <esc_decstr+0x5b>
mov    %rsp,%r12
mov    %r14,%rbx
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <esc_decode@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
mov    (%rsp),%r15
cmpb   $0x0,(%r15)
jne    1160 <esc_decstr+0x40>
movb   $0x0,(%rbx)
sub    %r14,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @esc_decstr(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
store i8* %7, i8** %5
%8 = load i8*, i8** %3
store i8* %8, i8** %6
%9 = load i8*, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
br label %14
14: ; preds = %11, %2
%15 = phi i1 [ false, %2 ], [ %13, %11 ]
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
br label %18
18: ; preds = %22, %14
%19 = load i8*, i8** %5
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load i8*, i8** %5
%24 = call i64 @esc_decode(i8* %23, i8** %5)
%25 = trunc i64 %24 to i8
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %6
store i8 %25, i8* %26
br label %18
28: ; preds = %18
%29 = load i8*, i8** %6
store i8 0, i8* %29
%30 = load i8*, i8** %6
%31 = load i8*, i8** %3
%32 = ptrtoint i8* %30 to i64
%33 = ptrtoint i8* %31 to i64
%34 = sub i64 %32, %33
ret i64 %34
}

LLVM IR (-O2):
define i64 @esc_decstr(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* %1, i8** %3
%5 = icmp ne i8* %0, null
%6 = icmp ne i8* %1, null
%7 = and i1 %5, %6
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = load i8, i8* %1
%11 = icmp eq i8 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %2, %12
%13 = phi i8* [ %18, %12 ], [ %1, %2 ]
%14 = phi i8* [ %17, %12 ], [ %0, %2 ]
%15 = call i64 @esc_decode(i8* %13, i8** %3)
%16 = trunc i64 %15 to i8
%17 = getelementptr inbounds i8, i8* %14, i64 1
store i8 %16, i8* %14
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %12
21: ; preds = %12, %2
%22 = phi i8* [ %0, %2 ], [ %17, %12 ]
store i8 0, i8* %22
%23 = ptrtoint i8* %22 to i64
%24 = ptrtoint i8* %0 to i64
%25 = sub i64 %23, %24
ret i64 %25
}