#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ basic_io_print(char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned char);
char tolower(char);
void console_def_char(unsigned char code, char *definition) {
  char buf[20];
  putchar(0x1b);
  putchar('T');
  snprintf(buf, sizeof(buf), "%02x", code);
  basic_io_print(buf);
  for (int i = 0; i < 18; i++) {
    buf[i] = tolower(definition[i]);
  }
  buf[18] = '\0';
  basic_io_print(buf);
}


x86 assembly (clang, -O0):
<console_def_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1b,%edi
call   1030 <putchar@plt>
mov    $0x54,%edi
call   1030 <putchar@plt>
lea    -0x30(%rbp),%rdi
mov    $0x14,%esi
lea    0xe8a(%rip),%rdx
movzbl -0x1(%rbp),%ecx
call   1040 <snprintf@plt>
lea    -0x30(%rbp),%rdi
call   1050 <basic_io_print@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x12,-0x34(%rbp)
jge    11c2 <console_def_char+0x82>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <tolower@plt>
mov    %al,%cl
movslq -0x34(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    118f <console_def_char+0x4f>
movb   $0x0,-0x1e(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <basic_io_print@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<console_def_char>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1b,%edi
call   1030 <putchar@plt>
mov    $0x54,%edi
call   1030 <putchar@plt>
lea    0xe98(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x14,%esi
mov    %ebp,%ecx
call   1040 <snprintf@plt>
mov    %r14,%rdi
call   1050 <basic_io_print@plt>
movsbl (%rbx),%edi
call   1060 <tolower@plt>
mov    %al,(%rsp)
movsbl 0x1(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0x1(%rsp)
movsbl 0x2(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0x2(%rsp)
movsbl 0x3(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0x3(%rsp)
movsbl 0x4(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0x4(%rsp)
movsbl 0x5(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0x5(%rsp)
movsbl 0x6(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0x6(%rsp)
movsbl 0x7(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0x7(%rsp)
movsbl 0x8(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0x8(%rsp)
movsbl 0x9(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0x9(%rsp)
movsbl 0xa(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0xa(%rsp)
movsbl 0xb(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0xb(%rsp)
movsbl 0xc(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0xc(%rsp)
movsbl 0xd(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0xd(%rsp)
movsbl 0xe(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0xe(%rsp)
movsbl 0xf(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0xf(%rsp)
movsbl 0x10(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0x10(%rsp)
movsbl 0x11(%rbx),%edi
call   1060 <tolower@plt>
mov    %al,0x11(%rsp)
movb   $0x0,0x12(%rsp)
mov    %r14,%rdi
call   1050 <basic_io_print@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%02x\00"
define void @console_def_char(i8 zeroext %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = alloca [20 x i8]
%6 = alloca i32
store i8 %0, i8* %3
store i8* %1, i8** %4
%7 = call i32 @putchar(i8 signext 27)
%8 = call i32 @putchar(i8 signext 84)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%10 = load i8, i8* %3
%11 = call i32 @snprintf(i8* %9, i32 20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %10)
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%13 = call i32 @basic_io_print(i8* %12)
store i32 0, i32* %6
br label %14
14: ; preds = %27, %2
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 18
br i1 %16, label %17, label %30
17: ; preds = %14
%18 = load i8*, i8** %4
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = call signext i8 @tolower(i8 signext %22)
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 %25
store i8 %23, i8* %26
br label %27
27: ; preds = %17
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %14
30: ; preds = %14
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 18
store i8 0, i8* %31
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%33 = call i32 @basic_io_print(i8* %32)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
define void @console_def_char(i8 zeroext %0, i8* nocapture %1) {
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @putchar(i8 signext 27)
%6 = tail call i32 @putchar(i8 signext 84)
%7 = call i32 @snprintf(i8* %4, i32 20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %0)
%8 = call i32 @basic_io_print(i8* %4)
%9 = load i8, i8* %1
%10 = call signext i8 @tolower(i8 signext %9)
store i8 %10, i8* %4
%11 = getelementptr inbounds i8, i8* %1, i64 1
%12 = load i8, i8* %11
%13 = call signext i8 @tolower(i8 signext %12)
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 1
store i8 %13, i8* %14
%15 = getelementptr inbounds i8, i8* %1, i64 2
%16 = load i8, i8* %15
%17 = call signext i8 @tolower(i8 signext %16)
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 2
store i8 %17, i8* %18
%19 = getelementptr inbounds i8, i8* %1, i64 3
%20 = load i8, i8* %19
%21 = call signext i8 @tolower(i8 signext %20)
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 3
store i8 %21, i8* %22
%23 = getelementptr inbounds i8, i8* %1, i64 4
%24 = load i8, i8* %23
%25 = call signext i8 @tolower(i8 signext %24)
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 4
store i8 %25, i8* %26
%27 = getelementptr inbounds i8, i8* %1, i64 5
%28 = load i8, i8* %27
%29 = call signext i8 @tolower(i8 signext %28)
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 5
store i8 %29, i8* %30
%31 = getelementptr inbounds i8, i8* %1, i64 6
%32 = load i8, i8* %31
%33 = call signext i8 @tolower(i8 signext %32)
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 6
store i8 %33, i8* %34
%35 = getelementptr inbounds i8, i8* %1, i64 7
%36 = load i8, i8* %35
%37 = call signext i8 @tolower(i8 signext %36)
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 7
store i8 %37, i8* %38
%39 = getelementptr inbounds i8, i8* %1, i64 8
%40 = load i8, i8* %39
%41 = call signext i8 @tolower(i8 signext %40)
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 8
store i8 %41, i8* %42
%43 = getelementptr inbounds i8, i8* %1, i64 9
%44 = load i8, i8* %43
%45 = call signext i8 @tolower(i8 signext %44)
%46 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 9
store i8 %45, i8* %46
%47 = getelementptr inbounds i8, i8* %1, i64 10
%48 = load i8, i8* %47
%49 = call signext i8 @tolower(i8 signext %48)
%50 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 10
store i8 %49, i8* %50
%51 = getelementptr inbounds i8, i8* %1, i64 11
%52 = load i8, i8* %51
%53 = call signext i8 @tolower(i8 signext %52)
%54 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 11
store i8 %53, i8* %54
%55 = getelementptr inbounds i8, i8* %1, i64 12
%56 = load i8, i8* %55
%57 = call signext i8 @tolower(i8 signext %56)
%58 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 12
store i8 %57, i8* %58
%59 = getelementptr inbounds i8, i8* %1, i64 13
%60 = load i8, i8* %59
%61 = call signext i8 @tolower(i8 signext %60)
%62 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 13
store i8 %61, i8* %62
%63 = getelementptr inbounds i8, i8* %1, i64 14
%64 = load i8, i8* %63
%65 = call signext i8 @tolower(i8 signext %64)
%66 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 14
store i8 %65, i8* %66
%67 = getelementptr inbounds i8, i8* %1, i64 15
%68 = load i8, i8* %67
%69 = call signext i8 @tolower(i8 signext %68)
%70 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 15
store i8 %69, i8* %70
%71 = getelementptr inbounds i8, i8* %1, i64 16
%72 = load i8, i8* %71
%73 = call signext i8 @tolower(i8 signext %72)
%74 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 16
store i8 %73, i8* %74
%75 = getelementptr inbounds i8, i8* %1, i64 17
%76 = load i8, i8* %75
%77 = call signext i8 @tolower(i8 signext %76)
%78 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 17
store i8 %77, i8* %78
%79 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 18
store i8 0, i8* %79
%80 = call i32 @basic_io_print(i8* %4)
ret void
}