#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
int strlen(char *);
char *stringlist_unescape_string(char *ss) {
  char *retval;
  int ii, iout;
  if (ss == NULL)
    return (NULL);
  if (strlen(ss) == 0) {
    retval = (char *)malloc(sizeof(char));
    *retval = '\0';
    return (retval);
  }
  retval = (char *)malloc(sizeof(char) * strlen(ss) + 1);
  if (retval == NULL) {
    fprintf(stderr,
            "Error in stringlist routine stringlist_unescape_string: could not "
            "allocate new string of length %ld\n",
            (strlen(ss) + 1));
    exit(-1);
  }
  iout = 0;
  for (ii = 0; ii < strlen(ss); ii++) {
    if (ss[ii] == '\\')
      ii++;
    retval[iout++] = ss[ii];
  }
  retval[iout] = '\0';
  return (retval);
}


x86 assembly (clang, -O0):
<stringlist_unescape_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1164 <stringlist_unescape_string+0x24>
movq   $0x0,-0x8(%rbp)
jmp    127e <stringlist_unescape_string+0x13e>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    1198 <stringlist_unescape_string+0x58>
mov    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    127e <stringlist_unescape_string+0x13e>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cltq
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f4 <stringlist_unescape_string+0xb4>
mov    0x2e18(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%edx
add    $0x1,%edx
lea    0xe1b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    126a <stringlist_unescape_string+0x12a>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    123c <stringlist_unescape_string+0xfc>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x20(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1202 <stringlist_unescape_string+0xc2>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringlist_unescape_string>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     11bc <stringlist_unescape_string+0x7c>
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %eax,%eax
je     11c1 <stringlist_unescape_string+0x81>
mov    %r15,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11df <stringlist_unescape_string+0x9f>
mov    %rax,%r14
mov    %r15,%rdi
call   1030 <strlen@plt>
xor    %ebx,%ebx
test   %eax,%eax
jle    11b4 <stringlist_unescape_string+0x74>
xor    %ebp,%ebp
movslq %ebx,%rax
xor    %ecx,%ecx
cmpb   $0x5c,(%r15,%rax,1)
sete   %cl
lea    (%rax,%rcx,1),%edx
movslq %edx,%rdx
movzbl (%r15,%rdx,1),%edx
mov    %dl,(%r14,%rbp,1)
add    $0x1,%rbp
lea    (%rax,%rcx,1),%ebx
add    $0x1,%ebx
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebx
jl     1180 <stringlist_unescape_string+0x40>
mov    %ebp,%ebx
mov    %r14,%rax
add    %rbx,%rax
jmp    11ce <stringlist_unescape_string+0x8e>
xor    %r14d,%r14d
jmp    11d1 <stringlist_unescape_string+0x91>
mov    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
movb   $0x0,(%rax)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dfa(%rip),%rax
mov    (%rax),%ebp
mov    %r15,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%edx
lea    0xe06(%rip),%rsi
mov    %ebp,%edi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [101 x i8] c"Error in stringlist routine stringlist_unescape_string: could not allocate new string of length %ld\0A\00"
define i8* @stringlist_unescape_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store i8* null, i8** %2
br label %74
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = call i64 @malloc(i32 1)
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %4
%17 = load i8*, i8** %4
store i8 0, i8* %17
%18 = load i8*, i8** %4
store i8* %18, i8** %2
br label %74
19: ; preds = %10
%20 = load i8*, i8** %3
%21 = call i32 @strlen(i8* %20)
%22 = sext i32 %21 to i64
%23 = mul i64 1, %22
%24 = add i64 %23, 1
%25 = trunc i64 %24 to i32
%26 = call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %4
%28 = load i8*, i8** %4
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %37
30: ; preds = %19
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %3
%33 = call i32 @strlen(i8* %32)
%34 = add nsw i32 %33, 1
%35 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %19
store i32 0, i32* %6
store i32 0, i32* %5
br label %38
38: ; preds = %65, %37
%39 = load i32, i32* %5
%40 = load i8*, i8** %3
%41 = call i32 @strlen(i8* %40)
%42 = icmp slt i32 %39, %41
br i1 %42, label %43, label %68
43: ; preds = %38
%44 = load i8*, i8** %3
%45 = load i32, i32* %5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 92
br i1 %50, label %51, label %54
51: ; preds = %43
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %5
br label %54
54: ; preds = %51, %43
%55 = load i8*, i8** %3
%56 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
%59 = load i8, i8* %58
%60 = load i8*, i8** %4
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
store i32 %62, i32* %6
%63 = sext i32 %61 to i64
%64 = getelementptr inbounds i8, i8* %60, i64 %63
store i8 %59, i8* %64
br label %65
65: ; preds = %54
%66 = load i32, i32* %5
%67 = add nsw i32 %66, 1
store i32 %67, i32* %5
br label %38
68: ; preds = %38
%69 = load i8*, i8** %4
%70 = load i32, i32* %6
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
store i8 0, i8* %72
%73 = load i8*, i8** %4
store i8* %73, i8** %2
br label %74
74: ; preds = %68, %14, %9
%75 = load i8*, i8** %2
ret i8* %75
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [101 x i8] c"Error in stringlist routine stringlist_unescape_string: could not allocate new string of length %ld\0A\00"
define i8* @stringlist_unescape_string(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %49, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i64 @malloc(i32 1)
%8 = inttoptr i64 %7 to i8*
br label %46
9: ; preds = %3
%10 = tail call i32 @strlen(i8* %0)
%11 = add i32 %10, 1
%12 = tail call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i8*
%14 = icmp eq i64 %12, 0
br i1 %14, label %18, label %15
15: ; preds = %9
%16 = tail call i32 @strlen(i8* %0)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %24, label %43
18: ; preds = %9
%19 = load i32, i32* @stderr
%20 = tail call i32 @strlen(i8* %0)
%21 = add nsw i32 %20, 1
%22 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = tail call i32 @exit(i32 -1)
unreachable
24: ; preds = %15, %24
%25 = phi i64 [ %36, %24 ], [ 0, %15 ]
%26 = phi i32 [ %38, %24 ], [ 0, %15 ]
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 92
%31 = zext i1 %30 to i32
%32 = add nsw i32 %26, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %0, i64 %33
%35 = load i8, i8* %34
%36 = add nuw i64 %25, 1
%37 = getelementptr inbounds i8, i8* %13, i64 %25
store i8 %35, i8* %37
%38 = add nsw i32 %32, 1
%39 = tail call i32 @strlen(i8* %0)
%40 = icmp slt i32 %38, %39
br i1 %40, label %24, label %41
41: ; preds = %24
%42 = and i64 %36, 4294967295
br label %43
43: ; preds = %41, %15
%44 = phi i64 [ 0, %15 ], [ %42, %41 ]
%45 = getelementptr inbounds i8, i8* %13, i64 %44
br label %46
46: ; preds = %6, %43
%47 = phi i8* [ %45, %43 ], [ %8, %6 ]
%48 = phi i8* [ %13, %43 ], [ %8, %6 ]
store i8 0, i8* %47
br label %49
49: ; preds = %46, %1
%50 = phi i8* [ null, %1 ], [ %48, %46 ]
ret i8* %50
}