#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*/ putfont8(char *, int, int, int, char, char *);
void putHex(char *vram, int xsize, int x, int y, char c, unsigned char *s) {
  extern char ascii[4096];
  if ((*s) / 16 < 10) {
    putfont8(vram, xsize, x, y, c, ascii + '0' * 16 + (*s) / 16 * 16);
  } else {
    putfont8(vram, xsize, x, y, c, ascii + ('A' - 10) * 16 + (*s) / 16 * 16);
  }
  x += 8;
  if ((*s) % 16 < 10) {
    putfont8(vram, xsize, x, y, c, ascii + '0' * 16 + (*s) % 16 * 16);
  } else {
    putfont8(vram, xsize, x, y, c, ascii + ('A' - 10) * 16 + (*s++) % 16 * 16);
  }
}


x86 assembly (clang, -O0):
<putHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %r8b,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %al,-0x15(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xa,%eax
jge    119d <putHex+0x8d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x15(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
mov    $0x10,%r8d
cltd
idiv   %r8d
mov    -0x28(%rbp),%edx
mov    %eax,%r8d
mov    -0x21(%rbp),%al
shl    $0x4,%r8d
movslq %r8d,%r8
mov    0x2e5b(%rip),%r9
add    $0x300,%r9
add    %r8,%r9
movsbl %al,%r8d
call   1030 <putfont8@plt>
jmp    11ee <putHex+0xde>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x15(%rbp),%al
mov    %al,-0x29(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
mov    $0x10,%r8d
cltd
idiv   %r8d
mov    -0x30(%rbp),%edx
mov    %eax,%r8d
mov    -0x29(%rbp),%al
shl    $0x4,%r8d
movslq %r8d,%r8
mov    0x2e05(%rip),%r9
add    $0x370,%r9
add    %r8,%r9
movsbl %al,%r8d
call   1030 <putfont8@plt>
mov    -0x10(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xa,%edx
jge    1265 <putHex+0x155>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x15(%rbp),%al
mov    %al,-0x35(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
mov    $0x10,%r8d
cltd
idiv   %r8d
mov    -0x35(%rbp),%al
mov    %edx,%r8d
mov    -0x34(%rbp),%edx
shl    $0x4,%r8d
movslq %r8d,%r8
mov    0x2d93(%rip),%r9
add    $0x300,%r9
add    %r8,%r9
movsbl %al,%r8d
call   1030 <putfont8@plt>
jmp    12c1 <putHex+0x1b1>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x15(%rbp),%al
mov    %al,-0x3d(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
movzbl (%rax),%eax
mov    $0x10,%r8d
cltd
idiv   %r8d
mov    -0x3d(%rbp),%al
mov    %edx,%r8d
mov    -0x3c(%rbp),%edx
shl    $0x4,%r8d
movslq %r8d,%r8
mov    0x2d32(%rip),%r9
add    $0x370,%r9
add    %r8,%r9
movsbl %al,%r8d
call   1030 <putfont8@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putHex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%rbx
mov    %r8d,%r12d
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%r13
movzbl (%r9),%eax
mov    %eax,%ecx
and    $0xfffffff0,%ecx
mov    0x2ea4(%rip),%rdx
lea    0x370(%rdx),%r9
add    $0x300,%rdx
cmp    $0xa0,%al
cmovb  %rdx,%r9
add    %rcx,%r9
mov    %ebp,%edx
mov    %r14d,%ecx
call   1030 <putfont8@plt>
add    $0x8,%ebp
mov    (%rbx),%al
mov    %eax,%ecx
and    $0xe,%cl
shl    $0x4,%al
movzbl %al,%eax
cmp    $0x9,%cl
ja     1186 <putHex+0x76>
mov    0x2e67(%rip),%rcx
lea    (%rcx,%rax,1),%r9
add    $0x300,%r9
jmp    1198 <putHex+0x88>
mov    0x2e53(%rip),%rcx
lea    (%rcx,%rax,1),%r9
add    $0x370,%r9
movsbl %r12b,%r8d
mov    %r13,%rdi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putfont8@plt>

LLVM IR (-O0):
@ascii = external global [4096 x i8]
define void @putHex(i8* %0, i32 %1, i32 %2, i32 %3, i8 signext %4, i8* %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
%12 = alloca i8*
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i8 %4, i8* %11
store i8* %5, i8** %12
%13 = load i8*, i8** %12
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = sdiv i32 %15, 16
%17 = icmp slt i32 %16, 10
br i1 %17, label %18, label %32
18: ; preds = %6
%19 = load i8*, i8** %7
%20 = load i32, i32* %8
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = load i8, i8* %11
%24 = load i8*, i8** %12
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = sdiv i32 %26, 16
%28 = mul nsw i32 %27, 16
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @ascii, i64 0, i64 768), i64 %29
%31 = call i32 @putfont8(i8* %19, i32 %20, i32 %21, i32 %22, i8 signext %23, i8* %30)
br label %46
32: ; preds = %6
%33 = load i8*, i8** %7
%34 = load i32, i32* %8
%35 = load i32, i32* %9
%36 = load i32, i32* %10
%37 = load i8, i8* %11
%38 = load i8*, i8** %12
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = sdiv i32 %40, 16
%42 = mul nsw i32 %41, 16
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @ascii, i64 0, i64 880), i64 %43
%45 = call i32 @putfont8(i8* %33, i32 %34, i32 %35, i32 %36, i8 signext %37, i8* %44)
br label %46
46: ; preds = %32, %18
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 8
store i32 %48, i32* %9
%49 = load i8*, i8** %12
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = srem i32 %51, 16
%53 = icmp slt i32 %52, 10
br i1 %53, label %54, label %68
54: ; preds = %46
%55 = load i8*, i8** %7
%56 = load i32, i32* %8
%57 = load i32, i32* %9
%58 = load i32, i32* %10
%59 = load i8, i8* %11
%60 = load i8*, i8** %12
%61 = load i8, i8* %60
%62 = zext i8 %61 to i32
%63 = srem i32 %62, 16
%64 = mul nsw i32 %63, 16
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @ascii, i64 0, i64 768), i64 %65
%67 = call i32 @putfont8(i8* %55, i32 %56, i32 %57, i32 %58, i8 signext %59, i8* %66)
br label %83
68: ; preds = %46
%69 = load i8*, i8** %7
%70 = load i32, i32* %8
%71 = load i32, i32* %9
%72 = load i32, i32* %10
%73 = load i8, i8* %11
%74 = load i8*, i8** %12
%75 = getelementptr inbounds i8, i8* %74, i32 1
store i8* %75, i8** %12
%76 = load i8, i8* %74
%77 = zext i8 %76 to i32
%78 = srem i32 %77, 16
%79 = mul nsw i32 %78, 16
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @ascii, i64 0, i64 880), i64 %80
%82 = call i32 @putfont8(i8* %69, i32 %70, i32 %71, i32 %72, i8 signext %73, i8* %81)
br label %83
83: ; preds = %68, %54
ret void
}

LLVM IR (-O2):
@ascii = external global [4096 x i8]
define void @putHex(i8* %0, i32 %1, i32 %2, i32 %3, i8 signext %4, i8* nocapture %5) {
%7 = load i8, i8* %5
%8 = and i8 %7, -16
%9 = icmp ult i8 %7, -96
%10 = zext i8 %8 to i64
%11 = select i1 %9, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @ascii, i64 0, i64 768), i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @ascii, i64 0, i64 880)
%12 = getelementptr inbounds i8, i8* %11, i64 %10
%13 = tail call i32 @putfont8(i8* %0, i32 %1, i32 %2, i32 %3, i8 signext %4, i8* %12)
%14 = add nsw i32 %2, 8
%15 = load i8, i8* %5
%16 = and i8 %15, 14
%17 = icmp ult i8 %16, 10
%18 = shl i8 %15, 4
%19 = zext i8 %18 to i64
br i1 %17, label %20, label %23
20: ; preds = %6
%21 = getelementptr inbounds i8, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @ascii, i64 0, i64 768), i64 %19
%22 = tail call i32 @putfont8(i8* %0, i32 %1, i32 %14, i32 %3, i8 signext %4, i8* %21)
br label %26
23: ; preds = %6
%24 = getelementptr inbounds i8, i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @ascii, i64 0, i64 880), i64 %19
%25 = tail call i32 @putfont8(i8* %0, i32 %1, i32 %14, i32 %3, i8 signext %4, i8* %24)
br label %26
26: ; preds = %23, %20
ret void
}