#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 */
scalar_t__ isprint(char);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
char *lexer_char_printable(char character, bool quoted) {
  char *string = malloc(sizeof(char) * 6);
  if (quoted && character == '\\') {
    strcpy(string, "'\\\\'");
  } else if (quoted && character == '\t') {
    strcpy(string, "'\\t'");
  } else if (quoted && character == '\n') {
    strcpy(string, "'\\n'");
  } else if (isprint(character)) {
    sprintf(string, "'%c'", character);
  } else {
    sprintf(string, "0x%X", character);
  }
  return string;
}


x86 assembly (clang, -O0):
<lexer_char_printable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x6,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     118b <lexer_char_printable+0x4b>
movsbl -0x1(%rbp),%eax
cmp    $0x5c,%eax
jne    118b <lexer_char_printable+0x4b>
mov    -0x10(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1232 <lexer_char_printable+0xf2>
cmpl   $0x0,-0x8(%rbp)
je     11b7 <lexer_char_printable+0x77>
movsbl -0x1(%rbp),%eax
cmp    $0x9,%eax
jne    11b7 <lexer_char_printable+0x77>
mov    -0x10(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1030 <strcpy@plt>
jmp    122d <lexer_char_printable+0xed>
cmpl   $0x0,-0x8(%rbp)
je     11e3 <lexer_char_printable+0xa3>
movsbl -0x1(%rbp),%eax
cmp    $0xa,%eax
jne    11e3 <lexer_char_printable+0xa3>
mov    -0x10(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1228 <lexer_char_printable+0xe8>
movsbl -0x1(%rbp),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     120f <lexer_char_printable+0xcf>
mov    -0x10(%rbp),%rdi
lea    0xe0e(%rip),%rsi
movsbl -0x1(%rbp),%edx
call   1060 <sprintf@plt>
jmp    1223 <lexer_char_printable+0xe3>
mov    -0x10(%rbp),%rdi
lea    0xdfa(%rip),%rsi
movsbl -0x1(%rbp),%edx
call   1060 <sprintf@plt>
jmp    1228 <lexer_char_printable+0xe8>
jmp    122d <lexer_char_printable+0xed>
jmp    1232 <lexer_char_printable+0xf2>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lexer_char_printable>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
mov    $0x6,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
cmp    $0x5c,%bpl
jne    1168 <lexer_char_printable+0x28>
test   %ebx,%ebx
je     1168 <lexer_char_printable+0x28>
lea    0xe9a(%rip),%rsi
jmp    118c <lexer_char_printable+0x4c>
cmp    $0x9,%bpl
jne    117b <lexer_char_printable+0x3b>
test   %ebx,%ebx
je     117b <lexer_char_printable+0x3b>
lea    0xe8c(%rip),%rsi
jmp    118c <lexer_char_printable+0x4c>
cmp    $0xa,%bpl
jne    119c <lexer_char_printable+0x5c>
test   %ebx,%ebx
je     119c <lexer_char_printable+0x5c>
lea    0xe7e(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
movsbl %bpl,%ebx
mov    %ebx,%edi
call   1050 <isprint@plt>
test   %rax,%rax
je     11b5 <lexer_char_printable+0x75>
lea    0xe5c(%rip),%rsi
jmp    11bc <lexer_char_printable+0x7c>
lea    0xe58(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
call   1060 <sprintf@plt>
jmp    1194 <lexer_char_printable+0x54>

LLVM IR (-O0):
@.str = [5 x i8] c"'\\\\'\00"
@.str.1 = [5 x i8] c"'\\t'\00"
@.str.2 = [5 x i8] c"'\\n'\00"
@.str.3 = [5 x i8] c"'%c'\00"
@.str.4 = [5 x i8] c"0x%X\00"
define i8* @lexer_char_printable(i8 signext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i8*
store i8 %0, i8* %3
store i32 %1, i32* %4
%6 = call i8* @malloc(i32 6)
store i8* %6, i8** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 92
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i8*, i8** %5
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %51
16: ; preds = %9, %2
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 9
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i8*, i8** %5
%25 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %50
26: ; preds = %19, %16
%27 = load i32, i32* %4
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = load i8, i8* %3
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 10
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i8*, i8** %5
%35 = call i32 @strcpy(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %49
36: ; preds = %29, %26
%37 = load i8, i8* %3
%38 = call i64 @isprint(i8 signext %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = load i8*, i8** %5
%42 = load i8, i8* %3
%43 = call i32 @sprintf(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8 signext %42)
br label %48
44: ; preds = %36
%45 = load i8*, i8** %5
%46 = load i8, i8* %3
%47 = call i32 @sprintf(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8 signext %46)
br label %48
48: ; preds = %44, %40
br label %49
49: ; preds = %48, %33
br label %50
50: ; preds = %49, %23
br label %51
51: ; preds = %50, %13
%52 = load i8*, i8** %5
ret i8* %52
}

LLVM IR (-O2):
@.str = [5 x i8] c"'\\\\'\00"
@.str.1 = [5 x i8] c"'\\t'\00"
@.str.2 = [5 x i8] c"'\\n'\00"
@.str.3 = [5 x i8] c"'%c'\00"
@.str.4 = [5 x i8] c"0x%X\00"
define i8* @lexer_char_printable(i8 signext %0, i32 %1) {
%3 = tail call dereferenceable_or_null(6) i8* @malloc(i32 6)
%4 = icmp ne i32 %1, 0
%5 = icmp eq i8 %0, 92
%6 = and i1 %5, %4
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %26
9: ; preds = %2
%10 = icmp eq i8 %0, 9
%11 = and i1 %10, %4
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %26
14: ; preds = %9
%15 = icmp eq i8 %0, 10
%16 = and i1 %15, %4
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %26
19: ; preds = %14
%20 = tail call i64 @isprint(i8 signext %0)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8 signext %0)
br label %26
24: ; preds = %19
%25 = tail call i32 @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8 signext %0)
br label %26
26: ; preds = %12, %22, %24, %17, %7
ret i8* %3
}