#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*/ free(char *);
int /*<<< orphan*/ isprint(int);
char *malloc(int);
int strlen(char const *);
char *conv_expand(const char *str) {
  static char *conv_str;
  static char no_memory[] = "<no memory>";
  char *cp;
  int ch;
  if (conv_str)
    free(conv_str);
  conv_str = malloc(4 * strlen(str) + 1);
  if (!conv_str)
    return no_memory;
  cp = conv_str;
  while ((ch = *(const unsigned char *)str++) != '\0') {
    switch (ch) {
    case '\\':
      ch = '\\';
      break;
    case '\'':
      ch = '\'';
      break;
    case '"':
      ch = '"';
      break;
    case '\a':
      ch = 'a';
      break;
    case '\b':
      ch = 'b';
      break;
    case '\e':
      ch = 'e';
      break;
    case '\f':
      ch = 'f';
      break;
    case '\n':
      ch = 'n';
      break;
    case '\r':
      ch = 'r';
      break;
    case '\t':
      ch = 't';
      break;
    case '\v':
      ch = 'v';
      break;
    default:
      if (isprint(ch)) {
        *cp++ = ch;
        continue;
      }
      *cp++ = '\\';
      if (ch & 0200) {
        *cp++ = 'M';
        ch &= ~0200;
      }
      if (ch == 0177) {
        *cp++ = '^';
        *cp++ = '?';
        continue;
      }
      if (ch < 040) {
        *cp++ = '^';
        *cp++ = ch | 0100;
        continue;
      }
      *cp++ = '-';
      *cp++ = ch;
      continue;
    }
    *cp++ = '\\';
    *cp++ = ch;
  }
  *cp = 0;
  return conv_str;
}


x86 assembly (clang, -O0):
<conv_expand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,0x2f04(%rip)
je     1166 <conv_expand+0x26>
mov    0x2ef7(%rip),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
shl    $0x2,%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,0x2ed5(%rip)
cmpq   $0x0,0x2ecd(%rip)
jne    11a1 <conv_expand+0x61>
lea    0x2ea8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    13bc <conv_expand+0x27c>
mov    0x2eb0(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     13aa <conv_expand+0x26a>
mov    -0x1c(%rbp),%eax
add    $0xfffffff9,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x55,%eax
ja     1277 <conv_expand+0x137>
mov    -0x28(%rbp),%rax
lea    0xe16(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x5c,-0x1c(%rbp)
jmp    137d <conv_expand+0x23d>
movl   $0x27,-0x1c(%rbp)
jmp    137d <conv_expand+0x23d>
movl   $0x22,-0x1c(%rbp)
jmp    137d <conv_expand+0x23d>
movl   $0x61,-0x1c(%rbp)
jmp    137d <conv_expand+0x23d>
movl   $0x62,-0x1c(%rbp)
jmp    137d <conv_expand+0x23d>
movl   $0x65,-0x1c(%rbp)
jmp    137d <conv_expand+0x23d>
movl   $0x66,-0x1c(%rbp)
jmp    137d <conv_expand+0x23d>
movl   $0x6e,-0x1c(%rbp)
jmp    137d <conv_expand+0x23d>
movl   $0x72,-0x1c(%rbp)
jmp    137d <conv_expand+0x23d>
movl   $0x74,-0x1c(%rbp)
jmp    137d <conv_expand+0x23d>
movl   $0x76,-0x1c(%rbp)
jmp    137d <conv_expand+0x23d>
mov    -0x1c(%rbp),%edi
call   1060 <isprint@plt>
cmp    $0x0,%eax
je     12a3 <conv_expand+0x163>
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    11ac <conv_expand+0x6c>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x5c,(%rax)
mov    -0x1c(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     12e3 <conv_expand+0x1a3>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x4d,(%rax)
mov    -0x1c(%rbp),%eax
and    $0xffffff7f,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x7f,-0x1c(%rbp)
jne    1316 <conv_expand+0x1d6>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x5e,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x3f,(%rax)
jmp    11ac <conv_expand+0x6c>
cmpl   $0x20,-0x1c(%rbp)
jge    1350 <conv_expand+0x210>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x5e,(%rax)
mov    -0x1c(%rbp),%eax
or     $0x40,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    11ac <conv_expand+0x6c>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x2d,(%rax)
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    11ac <conv_expand+0x6c>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x5c,(%rax)
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    11ac <conv_expand+0x6c>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    0x2ca0(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_expand>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r15
mov    0x2f05(%rip),%rdi
test   %rdi,%rdi
je     115d <conv_expand+0x1d>
call   1030 <free@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    0x1(,%rax,4),%edi
call   1050 <malloc@plt>
mov    %rax,0x2ee0(%rip)
test   %rax,%rax
je     1243 <conv_expand+0x103>
mov    %rax,%r14
lea    0xe75(%rip),%r12
mov    %rax,%r13
jmp    11ad <conv_expand+0x6d>
mov    $0x61,%bl
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movb   $0x5c,0x0(%r13)
mov    %bl,0x1(%r13)
add    $0x2,%r13
movzbl (%r15),%ebx
add    $0x1,%r15
cmp    $0x5c,%rbx
ja     11c8 <conv_expand+0x88>
movslq (%r12,%rbx,4),%rax
add    %r12,%rax
jmp    *%rax
mov    $0x62,%bl
jmp    11a0 <conv_expand+0x60>
mov    %ebx,%edi
call   1060 <isprint@plt>
lea    0x1(%r13),%rcx
test   %eax,%eax
je     11f8 <conv_expand+0xb8>
mov    %bl,0x0(%r13)
mov    %rcx,%r13
jmp    11ad <conv_expand+0x6d>
mov    $0x74,%bl
jmp    11a0 <conv_expand+0x60>
mov    $0x6e,%bl
jmp    11a0 <conv_expand+0x60>
mov    $0x76,%bl
jmp    11a0 <conv_expand+0x60>
mov    $0x66,%bl
jmp    11a0 <conv_expand+0x60>
mov    $0x72,%bl
jmp    11a0 <conv_expand+0x60>
mov    $0x65,%bl
jmp    11a0 <conv_expand+0x60>
movb   $0x5c,0x0(%r13)
test   $0x80,%bl
je     1211 <conv_expand+0xd1>
movb   $0x4d,0x1(%r13)
add    $0x2,%r13
and    $0x7f,%ebx
mov    %r13,%rcx
cmp    $0x7f,%ebx
jne    121d <conv_expand+0xdd>
movw   $0x3f5e,(%rcx)
jmp    1230 <conv_expand+0xf0>
cmp    $0x1f,%ebx
ja     122a <conv_expand+0xea>
movb   $0x5e,(%rcx)
or     $0x40,%bl
jmp    122d <conv_expand+0xed>
movb   $0x2d,(%rcx)
mov    %bl,0x1(%rcx)
add    $0x2,%rcx
mov    %rcx,%r13
jmp    11ad <conv_expand+0x6d>
movb   $0x0,0x0(%r13)
jmp    124a <conv_expand+0x10a>
lea    0x2df6(%rip),%r14
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@conv_expand.conv_str = internal global i8* null
@conv_expand.no_memory = internal global [12 x i8] c"<no memory>\00"
define i8* @conv_expand(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** @conv_expand.conv_str
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i8*, i8** @conv_expand.conv_str
%10 = call i32 @free(i8* %9)
br label %11
11: ; preds = %8, %1
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = mul nsw i32 4, %13
%15 = add nsw i32 %14, 1
%16 = call i8* @malloc(i32 %15)
store i8* %16, i8** @conv_expand.conv_str
%17 = load i8*, i8** @conv_expand.conv_str
%18 = icmp ne i8* %17, null
br i1 %18, label %20, label %19
19: ; preds = %11
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @conv_expand.no_memory, i64 0, i64 0), i8** %2
br label %97
20: ; preds = %11
%21 = load i8*, i8** @conv_expand.conv_str
store i8* %21, i8** %4
br label %22
22: ; preds = %87, %80, %72, %64, %45, %20
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %3
%25 = load i8, i8* %23
%26 = zext i8 %25 to i32
store i32 %26, i32* %5
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %94
28: ; preds = %22
%29 = load i32, i32* %5
switch i32 %29, label %41 [
i32 92, label %30
i32 39, label %31
i32 34, label %32
i32 7, label %33
i32 8, label %34
i32 27, label %35
i32 12, label %36
i32 10, label %37
i32 13, label %38
i32 9, label %39
i32 11, label %40
]
30: ; preds = %28
store i32 92, i32* %5
br label %87
31: ; preds = %28
store i32 39, i32* %5
br label %87
32: ; preds = %28
store i32 34, i32* %5
br label %87
33: ; preds = %28
store i32 97, i32* %5
br label %87
34: ; preds = %28
store i32 98, i32* %5
br label %87
35: ; preds = %28
store i32 101, i32* %5
br label %87
36: ; preds = %28
store i32 102, i32* %5
br label %87
37: ; preds = %28
store i32 110, i32* %5
br label %87
38: ; preds = %28
store i32 114, i32* %5
br label %87
39: ; preds = %28
store i32 116, i32* %5
br label %87
40: ; preds = %28
store i32 118, i32* %5
br label %87
41: ; preds = %28
%42 = load i32, i32* %5
%43 = call i32 @isprint(i32 %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %41
%46 = load i32, i32* %5
%47 = trunc i32 %46 to i8
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %4
store i8 %47, i8* %48
br label %22
50: ; preds = %41
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %4
store i8 92, i8* %51
%53 = load i32, i32* %5
%54 = and i32 %53, 128
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %61
56: ; preds = %50
%57 = load i8*, i8** %4
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %4
store i8 77, i8* %57
%59 = load i32, i32* %5
%60 = and i32 %59, -129
store i32 %60, i32* %5
br label %61
61: ; preds = %56, %50
%62 = load i32, i32* %5
%63 = icmp eq i32 %62, 127
br i1 %63, label %64, label %69
64: ; preds = %61
%65 = load i8*, i8** %4
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %4
store i8 94, i8* %65
%67 = load i8*, i8** %4
%68 = getelementptr inbounds i8, i8* %67, i32 1
store i8* %68, i8** %4
store i8 63, i8* %67
br label %22
69: ; preds = %61
%70 = load i32, i32* %5
%71 = icmp slt i32 %70, 32
br i1 %71, label %72, label %80
72: ; preds = %69
%73 = load i8*, i8** %4
%74 = getelementptr inbounds i8, i8* %73, i32 1
store i8* %74, i8** %4
store i8 94, i8* %73
%75 = load i32, i32* %5
%76 = or i32 %75, 64
%77 = trunc i32 %76 to i8
%78 = load i8*, i8** %4
%79 = getelementptr inbounds i8, i8* %78, i32 1
store i8* %79, i8** %4
store i8 %77, i8* %78
br label %22
80: ; preds = %69
%81 = load i8*, i8** %4
%82 = getelementptr inbounds i8, i8* %81, i32 1
store i8* %82, i8** %4
store i8 45, i8* %81
%83 = load i32, i32* %5
%84 = trunc i32 %83 to i8
%85 = load i8*, i8** %4
%86 = getelementptr inbounds i8, i8* %85, i32 1
store i8* %86, i8** %4
store i8 %84, i8* %85
br label %22
87: ; preds = %40, %39, %38, %37, %36, %35, %34, %33, %32, %31, %30
%88 = load i8*, i8** %4
%89 = getelementptr inbounds i8, i8* %88, i32 1
store i8* %89, i8** %4
store i8 92, i8* %88
%90 = load i32, i32* %5
%91 = trunc i32 %90 to i8
%92 = load i8*, i8** %4
%93 = getelementptr inbounds i8, i8* %92, i32 1
store i8* %93, i8** %4
store i8 %91, i8* %92
br label %22
94: ; preds = %22
%95 = load i8*, i8** %4
store i8 0, i8* %95
%96 = load i8*, i8** @conv_expand.conv_str
store i8* %96, i8** %2
br label %97
97: ; preds = %94, %19
%98 = load i8*, i8** %2
ret i8* %98
}

LLVM IR (-O2):
@conv_expand.conv_str = internal unnamed_addr global i8* null
@conv_expand.no_memory = internal global [12 x i8] c"<no memory>\00"
define i8* @conv_expand(i8* %0) {
%2 = load i8*, i8** @conv_expand.conv_str
%3 = icmp eq i8* %2, null
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @free(i8* %2)
br label %6
6: ; preds = %4, %1
%7 = tail call i32 @strlen(i8* %0)
%8 = shl nsw i32 %7, 2
%9 = or i32 %8, 1
%10 = tail call i8* @malloc(i32 %9)
store i8* %10, i8** @conv_expand.conv_str
%11 = icmp eq i8* %10, null
br i1 %11, label %61, label %12
12: ; preds = %6, %31
%13 = phi i8* [ %15, %31 ], [ %0, %6 ]
%14 = phi i8* [ %32, %31 ], [ %10, %6 ]
%15 = getelementptr inbounds i8, i8* %13, i64 1
%16 = load i8, i8* %13
%17 = zext i8 %16 to i32
switch i8 %16, label %26 [
i8 0, label %60
i8 92, label %56
i8 39, label %56
i8 34, label %56
i8 7, label %18
i8 8, label %19
i8 27, label %20
i8 12, label %21
i8 10, label %22
i8 13, label %23
i8 9, label %24
i8 11, label %25
]
18: ; preds = %12
br label %56
19: ; preds = %12
br label %56
20: ; preds = %12
br label %56
21: ; preds = %12
br label %56
22: ; preds = %12
br label %56
23: ; preds = %12
br label %56
24: ; preds = %12
br label %56
25: ; preds = %12
br label %56
26: ; preds = %12
%27 = tail call i32 @isprint(i32 %17)
%28 = icmp eq i32 %27, 0
%29 = getelementptr inbounds i8, i8* %14, i64 1
br i1 %28, label %33, label %30
30: ; preds = %26
store i8 %16, i8* %14
br label %31
31: ; preds = %30, %43, %49, %53, %56
%32 = phi i8* [ %29, %30 ], [ %45, %43 ], [ %52, %49 ], [ %55, %53 ], [ %59, %56 ]
br label %12
33: ; preds = %26
store i8 92, i8* %14
%34 = and i32 %17, 128
%35 = icmp eq i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = getelementptr inbounds i8, i8* %14, i64 2
store i8 77, i8* %29
%38 = and i32 %17, 127
br label %39
39: ; preds = %36, %33
%40 = phi i8* [ %37, %36 ], [ %29, %33 ]
%41 = phi i32 [ %38, %36 ], [ %17, %33 ]
%42 = icmp eq i32 %41, 127
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = getelementptr inbounds i8, i8* %40, i64 1
store i8 94, i8* %40
%45 = getelementptr inbounds i8, i8* %40, i64 2
store i8 63, i8* %44
br label %31
46: ; preds = %39
%47 = icmp ult i32 %41, 32
%48 = getelementptr inbounds i8, i8* %40, i64 1
br i1 %47, label %49, label %53
49: ; preds = %46
store i8 94, i8* %40
%50 = trunc i32 %41 to i8
%51 = or i8 %50, 64
%52 = getelementptr inbounds i8, i8* %40, i64 2
store i8 %51, i8* %48
br label %31
53: ; preds = %46
store i8 45, i8* %40
%54 = trunc i32 %41 to i8
%55 = getelementptr inbounds i8, i8* %40, i64 2
store i8 %54, i8* %48
br label %31
56: ; preds = %12, %12, %12, %25, %24, %23, %22, %21, %20, %19, %18
%57 = phi i8 [ 118, %25 ], [ 116, %24 ], [ 114, %23 ], [ 110, %22 ], [ 102, %21 ], [ 101, %20 ], [ 98, %19 ], [ 97, %18 ], [ %16, %12 ], [ %16, %12 ], [ %16, %12 ]
%58 = getelementptr inbounds i8, i8* %14, i64 1
store i8 92, i8* %14
%59 = getelementptr inbounds i8, i8* %14, i64 2
store i8 %57, i8* %58
br label %31
60: ; preds = %12
store i8 0, i8* %14
br label %61
61: ; preds = %6, %60
%62 = phi i8* [ %10, %60 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @conv_expand.no_memory, i64 0, i64 0), %6 ]
ret i8* %62
}