#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*/ draw_Char(unsigned char);
int /*<<< orphan*/ sendCommand(int);
int /*<<< orphan*/ sprintf(char, char *, char);
int /*<<< orphan*/ sscanf(char, char *, int *);
int strlen(char *);
void draw_Text(char *printtext) {
  sendCommand(0b10110000);
  for (int j = 0; j <= strlen(printtext); j++) {
    char chartodraw;
    int chart;
    unsigned char ctd;
    sprintf(chartodraw, "%02X", printtext[j]);
    sscanf(chartodraw, "%x", &chart);
    ctd = chart & 0xFF;
    draw_Char(ctd);
  }
}


x86 assembly (clang, -O0):
<draw_Text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0xb0,%edi
call   1030 <sendCommand@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jg     11dd <draw_Text+0x8d>
mov    -0xd(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xe65(%rip),%rsi
movsbl %dl,%edi
movsbl (%rax,%rcx,1),%edx
call   1060 <sprintf@plt>
lea    0xe57(%rip),%rsi
lea    -0x14(%rbp),%rdx
movsbl -0xd(%rbp),%edi
call   1050 <sscanf@plt>
mov    -0x14(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x15(%rbp)
movzbl -0x15(%rbp),%edi
call   1070 <draw_Char@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116d <draw_Text+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_Text>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r13
mov    $0xb0,%edi
call   1030 <sendCommand@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
js     11ca <draw_Text+0x7a>
mov    $0xffffffffffffffff,%rbx
lea    0xe7c(%rip),%r14
lea    0xe7a(%rip),%r15
lea    0xc(%rsp),%r12
movsbl 0x1(%r13,%rbx,1),%edx
xor    %edi,%edi
mov    %r14,%rsi
call   1060 <sprintf@plt>
xor    %edi,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <sscanf@plt>
movzbl 0xc(%rsp),%edi
call   1070 <draw_Char@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
add    $0x1,%rbx
cmp    %rax,%rbx
jl     1190 <draw_Text+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%02X\00"
@.str.1 = [3 x i8] c"%x\00"
define void @draw_Text(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
%6 = alloca i8
store i8* %0, i8** %2
%7 = call i32 @sendCommand(i32 176)
store i32 0, i32* %3
br label %8
8: ; preds = %28, %1
%9 = load i32, i32* %3
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
%12 = icmp sle i32 %9, %11
br i1 %12, label %13, label %31
13: ; preds = %8
%14 = load i8, i8* %4
%15 = load i8*, i8** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = call i32 @sprintf(i8 signext %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %19)
%21 = load i8, i8* %4
%22 = call i32 @sscanf(i8 signext %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%23 = load i32, i32* %5
%24 = and i32 %23, 255
%25 = trunc i32 %24 to i8
store i8 %25, i8* %6
%26 = load i8, i8* %6
%27 = call i32 @draw_Char(i8 zeroext %26)
br label %28
28: ; preds = %13
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %8
31: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02X\00"
@.str.1 = [3 x i8] c"%x\00"
define void @draw_Text(i8* %0) {
%2 = alloca i32
%3 = tail call i32 @sendCommand(i32 176)
%4 = call i32 @strlen(i8* %0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = bitcast i32* %2 to i8*
br label %9
8: ; preds = %9, %1
ret void
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %18, %9 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = call i32 @sprintf(i8 signext undef, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %12)
%14 = call i32 @sscanf(i8 signext undef, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = trunc i32 %15 to i8
%17 = call i32 @draw_Char(i8 zeroext %16)
%18 = add nuw nsw i64 %10, 1
%19 = call i32 @strlen(i8* %0)
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %10, %20
br i1 %21, label %9, label %8
}