#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*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
void strkey(char *s, int k) {
  k &= 255;
  if (k == 27)
    strcpy(s, " ESC");
  else if (k < 32 || k == 127)
    sprintf(s, " ^%c", k ^ 64);
  else if (k < 127)
    sprintf(s, " %c", k);
  else
    sprintf(s, " <0x%2X>", k);
}


x86 assembly (clang, -O0):
<strkey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1b,-0xc(%rbp)
jne    1159 <strkey+0x39>
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11c7 <strkey+0xa7>
cmpl   $0x20,-0xc(%rbp)
jl     116d <strkey+0x4d>
cmpl   $0x7f,-0xc(%rbp)
jne    1188 <strkey+0x68>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
xor    $0x40,%edx
lea    0xe87(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11c2 <strkey+0xa2>
cmpl   $0x7f,-0xc(%rbp)
jge    11aa <strkey+0x8a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe6a(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11bd <strkey+0x9d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe56(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11c2 <strkey+0xa2>
jmp    11c7 <strkey+0xa7>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strkey>:
movzbl %sil,%edx
cmp    $0x1b,%edx
jne    1135 <strkey+0x15>
lea    0xed0(%rip),%rsi
jmp    1030 <strcpy@plt>
cmp    $0x20,%edx
jb     114d <strkey+0x2d>
cmp    $0x7f,%edx
je     114d <strkey+0x2d>
jae    115c <strkey+0x3c>
lea    0xec2(%rip),%rsi
jmp    1040 <sprintf@plt>
xor    $0x40,%edx
lea    0xeae(%rip),%rsi
jmp    1040 <sprintf@plt>
lea    0xeab(%rip),%rsi
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c" ESC\00"
@.str.1 = [5 x i8] c" ^%c\00"
@.str.2 = [4 x i8] c" %c\00"
@.str.3 = [9 x i8] c" <0x%2X>\00"
define void @strkey(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = and i32 %5, 255
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 27
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %36
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 32
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 127
br i1 %17, label %18, label %23
18: ; preds = %15, %12
%19 = load i8*, i8** %3
%20 = load i32, i32* %4
%21 = xor i32 %20, 64
%22 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %35
23: ; preds = %15
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 127
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i8*, i8** %3
%28 = load i32, i32* %4
%29 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %34
30: ; preds = %23
%31 = load i8*, i8** %3
%32 = load i32, i32* %4
%33 = call i32 @sprintf(i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %30, %26
br label %35
35: ; preds = %34, %18
br label %36
36: ; preds = %35, %9
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c" ESC\00"
@.str.1 = [5 x i8] c" ^%c\00"
@.str.2 = [4 x i8] c" %c\00"
@.str.3 = [9 x i8] c" <0x%2X>\00"
define void @strkey(i8* %0, i32 %1) {
%3 = and i32 %1, 255
%4 = icmp eq i32 %3, 27
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %20
7: ; preds = %2
%8 = icmp ult i32 %3, 32
%9 = icmp eq i32 %3, 127
%10 = or i1 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = xor i32 %3, 64
%13 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %20
14: ; preds = %7
%15 = icmp ult i32 %3, 127
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %3)
br label %20
18: ; preds = %14
%19 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %3)
br label %20
20: ; preds = %11, %18, %16, %5
ret void
}