#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*/ printf(char *, ...);
char *quote_char(char *, char);
int l_quote_data(char *str) {
  char buf[6];
  char *tmp;
  switch (*str) {
  case -3:
    printf("<tpVAL>'%s'", quote_char(buf, *(str + 1)));
    return 2;
  case -4:
    switch (*(str + 1)) {
    case 1:
      printf("<tpBOOL>'<False>'");
      break;
    case 2:
      printf("<tpBOOL>'<True>'");
      break;
    default:
      printf("<tpBOOL>'%s'", quote_char(buf, *(str + 1)));
      break;
    }
    return 2;
  case -2:
    tmp = str;
    printf("<tpSTR>'");
    str++;
    while (*str != 3) {
      printf("%s", quote_char(buf, *str++));
    }
    printf("'<TERM>");
    return (str - tmp + 1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<l_quote_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x24(%rbp)
sub    $0xfffffffc,%eax
je     1194 <l_quote_data+0x74>
jmp    1144 <l_quote_data+0x24>
mov    -0x24(%rbp),%eax
sub    $0xfffffffd,%eax
je     1166 <l_quote_data+0x46>
jmp    1155 <l_quote_data+0x35>
mov    -0x24(%rbp),%eax
sub    $0xfffffffe,%eax
je     1212 <l_quote_data+0xf2>
jmp    129a <l_quote_data+0x17a>
lea    -0x16(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%esi
call   1040 <quote_char@plt>
mov    %rax,%rsi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    12a1 <l_quote_data+0x181>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x28(%rbp)
sub    $0x1,%eax
je     11be <l_quote_data+0x9e>
jmp    11ad <l_quote_data+0x8d>
mov    -0x28(%rbp),%eax
sub    $0x2,%eax
je     11d1 <l_quote_data+0xb1>
jmp    11e4 <l_quote_data+0xc4>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1206 <l_quote_data+0xe6>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1206 <l_quote_data+0xe6>
lea    -0x16(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%esi
call   1040 <quote_char@plt>
mov    %rax,%rsi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    12a1 <l_quote_data+0x181>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3,%eax
je     1275 <l_quote_data+0x155>
lea    -0x16(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%esi
call   1040 <quote_char@plt>
mov    %rax,%rsi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1234 <l_quote_data+0x114>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,-0x4(%rbp)
jmp    12a1 <l_quote_data+0x181>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<l_quote_data>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
movsbl (%rdi),%eax
cmp    $0xfffffffc,%eax
je     115e <l_quote_data+0x3e>
cmp    $0xfffffffe,%eax
je     117a <l_quote_data+0x5a>
xor    %ebx,%ebx
cmp    $0xfffffffd,%eax
jne    120a <l_quote_data+0xea>
movsbl 0x1(%r14),%esi
lea    0x2(%rsp),%rdi
call   1040 <quote_char@plt>
lea    0xea7(%rip),%rdi
jmp    11fb <l_quote_data+0xdb>
movsbl 0x1(%r14),%esi
cmp    $0x2,%esi
je     11da <l_quote_data+0xba>
cmp    $0x1,%esi
jne    11ea <l_quote_data+0xca>
lea    0xe94(%rip),%rdi
jmp    11e1 <l_quote_data+0xc1>
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x1(%r14),%rbx
mov    0x1(%r14),%al
cmp    $0x3,%al
je     11c4 <l_quote_data+0xa4>
lea    0x2(%rsp),%r15
lea    0xea5(%rip),%r12
movsbl %al,%esi
mov    %r15,%rdi
call   1040 <quote_char@plt>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
cmp    $0x3,%al
jne    11a0 <l_quote_data+0x80>
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
sub    %r14d,%ebx
add    $0x1,%ebx
jmp    120a <l_quote_data+0xea>
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1205 <l_quote_data+0xe5>
lea    0x2(%rsp),%rdi
call   1040 <quote_char@plt>
lea    0xe34(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x2,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"<tpVAL>'%s'\00"
@.str.1 = [18 x i8] c"<tpBOOL>'<False>'\00"
@.str.2 = [17 x i8] c"<tpBOOL>'<True>'\00"
@.str.3 = [13 x i8] c"<tpBOOL>'%s'\00"
@.str.4 = [9 x i8] c"<tpSTR>'\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [8 x i8] c"'<TERM>\00"
define i32 @l_quote_data(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [6 x i8]
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %59 [
i32 -3, label %9
i32 -4, label %16
i32 -2, label %33
]
9: ; preds = %1
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = call i8* @quote_char(i8* %10, i8 signext %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 2, i32* %2
br label %60
16: ; preds = %1
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
switch i32 %20, label %25 [
i32 1, label %21
i32 2, label %23
]
21: ; preds = %16
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %32
23: ; preds = %16
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %32
25: ; preds = %16
%26 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = call i8* @quote_char(i8* %26, i8 signext %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %25, %23, %21
store i32 2, i32* %2
br label %60
33: ; preds = %1
%34 = load i8*, i8** %3
store i8* %34, i8** %5
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %3
br label %38
38: ; preds = %43, %33
%39 = load i8*, i8** %3
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 3
br i1 %42, label %43, label %50
43: ; preds = %38
%44 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%45 = load i8*, i8** %3
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %3
%47 = load i8, i8* %45
%48 = call i8* @quote_char(i8* %44, i8 signext %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %48)
br label %38
50: ; preds = %38
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%52 = load i8*, i8** %3
%53 = load i8*, i8** %5
%54 = ptrtoint i8* %52 to i64
%55 = ptrtoint i8* %53 to i64
%56 = sub i64 %54, %55
%57 = add nsw i64 %56, 1
%58 = trunc i64 %57 to i32
store i32 %58, i32* %2
br label %60
59: ; preds = %1
store i32 0, i32* %2
br label %60
60: ; preds = %59, %50, %32, %9
%61 = load i32, i32* %2
ret i32 %61
}

LLVM IR (-O2):
@.str = [12 x i8] c"<tpVAL>'%s'\00"
@.str.1 = [18 x i8] c"<tpBOOL>'<False>'\00"
@.str.2 = [17 x i8] c"<tpBOOL>'<True>'\00"
@.str.3 = [13 x i8] c"<tpBOOL>'%s'\00"
@.str.4 = [9 x i8] c"<tpSTR>'\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [8 x i8] c"'<TERM>\00"
define i32 @l_quote_data(i8* %0) {
%2 = alloca [6 x i8]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
%5 = sext i8 %4 to i32
switch i32 %5, label %43 [
i32 -3, label %6
i32 -4, label %11
i32 -2, label %22
]
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = call i8* @quote_char(i8* %3, i8 signext %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %43
11: ; preds = %1
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
switch i32 %14, label %19 [
i32 1, label %15
i32 2, label %17
]
15: ; preds = %11
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %43
17: ; preds = %11
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %43
19: ; preds = %11
%20 = call i8* @quote_char(i8* %3, i8 signext %13)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %20)
br label %43
22: ; preds = %1
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%24 = getelementptr inbounds i8, i8* %0, i64 1
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 3
br i1 %26, label %35, label %27
27: ; preds = %22, %27
%28 = phi i8 [ %33, %27 ], [ %25, %22 ]
%29 = phi i8* [ %32, %27 ], [ %24, %22 ]
%30 = call i8* @quote_char(i8* %3, i8 signext %28)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds i8, i8* %29, i64 1
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 3
br i1 %34, label %35, label %27
35: ; preds = %27, %22
%36 = phi i8* [ %24, %22 ], [ %32, %27 ]
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%38 = ptrtoint i8* %36 to i64
%39 = ptrtoint i8* %0 to i64
%40 = sub i64 %38, %39
%41 = trunc i64 %40 to i32
%42 = add i32 %41, 1
br label %43
43: ; preds = %1, %15, %17, %19, %35, %6
%44 = phi i32 [ %42, %35 ], [ 2, %6 ], [ 2, %19 ], [ 2, %17 ], [ 2, %15 ], [ 0, %1 ]
ret i32 %44
}