#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*/ font_draw_char(unsigned char, long, long, long);
char _draw_number(long long num, long x, long y, long color) {
  long long copy = num;
  char counter = 0;
  char length = 0;
  while (copy != 0) {
    copy /= 10;
    counter++;
  }
  copy = num;
  length = counter;
  while (copy != 0) {
    counter--;
    font_draw_char((unsigned char)(copy % 10) + 48, x + counter * 8, y, color);
    copy /= 10;
  }
  return length;
}


x86 assembly (clang, -O0):
<_draw_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movb   $0x0,-0x29(%rbp)
movb   $0x0,-0x2a(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1162 <_draw_number+0x52>
mov    -0x28(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    -0x29(%rbp),%al
add    $0x1,%al
mov    %al,-0x29(%rbp)
jmp    1138 <_draw_number+0x28>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x29(%rbp),%al
mov    %al,-0x2a(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11d1 <_draw_number+0xc1>
mov    -0x29(%rbp),%al
add    $0xff,%al
mov    %al,-0x29(%rbp)
mov    -0x28(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %dl,%al
movzbl %al,%eax
add    $0x30,%eax
mov    -0x10(%rbp),%rsi
movsbl -0x29(%rbp),%ecx
shl    $0x3,%ecx
movslq %ecx,%rcx
add    %rcx,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
movzbl %al,%edi
call   1030 <font_draw_char@plt>
mov    -0x28(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
jmp    1170 <_draw_number+0x60>
movsbl -0x2a(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_draw_number>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11e5 <_draw_number+0xd5>
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%rbp
mov    $0xff,%r13b
movabs $0x6666666666666667,%rdi
66 66 66
mov    %rbp,%rsi
mov    %rsi,%rax
imul   %rdi
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
add    $0x9,%rsi
add    $0x1,%r13b
cmp    $0x13,%rsi
mov    %rdx,%rsi
jae    1140 <_draw_number+0x30>
lea    0x1(%r13),%eax
test   %rbp,%rbp
je     11e7 <_draw_number+0xd7>
mov    %eax,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rax
imul   %rdi
mov    %rdx,%rbx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rbx
add    %rax,%rbx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ebp,%edx
sub    %eax,%edx
add    $0x30,%dl
movsbl %r13b,%r13d
lea    0x0(,%r13,8),%eax
movslq %eax,%rsi
add    %r14,%rsi
movzbl %dl,%edi
mov    %r12,%rdx
mov    %r15,%rcx
call   1030 <font_draw_char@plt>
movabs $0x6666666666666667,%rdi
66 66 66
add    $0x9,%rbp
add    $0xff,%r13b
cmp    $0x12,%rbp
mov    %rbx,%rbp
ja     1180 <_draw_number+0x70>
mov    0x4(%rsp),%eax
jmp    11e7 <_draw_number+0xd7>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @_draw_number(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8
%11 = alloca i8
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%12 = load i64, i64* %5
store i64 %12, i64* %9
store i8 0, i8* %10
store i8 0, i8* %11
br label %13
13: ; preds = %16, %4
%14 = load i64, i64* %9
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i64, i64* %9
%18 = sdiv i64 %17, 10
store i64 %18, i64* %9
%19 = load i8, i8* %10
%20 = add i8 %19, 1
store i8 %20, i8* %10
br label %13
21: ; preds = %13
%22 = load i64, i64* %5
store i64 %22, i64* %9
%23 = load i8, i8* %10
store i8 %23, i8* %11
br label %24
24: ; preds = %27, %21
%25 = load i64, i64* %9
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %47
27: ; preds = %24
%28 = load i8, i8* %10
%29 = add i8 %28, -1
store i8 %29, i8* %10
%30 = load i64, i64* %9
%31 = srem i64 %30, 10
%32 = trunc i64 %31 to i8
%33 = zext i8 %32 to i32
%34 = add nsw i32 %33, 48
%35 = trunc i32 %34 to i8
%36 = load i64, i64* %6
%37 = load i8, i8* %10
%38 = sext i8 %37 to i32
%39 = mul nsw i32 %38, 8
%40 = sext i32 %39 to i64
%41 = add nsw i64 %36, %40
%42 = load i64, i64* %7
%43 = load i64, i64* %8
%44 = call i32 @font_draw_char(i8 zeroext %35, i64 %41, i64 %42, i64 %43)
%45 = load i64, i64* %9
%46 = sdiv i64 %45, 10
store i64 %46, i64* %9
br label %24
47: ; preds = %24
%48 = load i8, i8* %11
ret i8 %48
}

LLVM IR (-O2):
define signext i8 @_draw_number(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = icmp eq i64 %0, 0
br i1 %5, label %29, label %7
6: ; preds = %7
br i1 %5, label %29, label %14
7: ; preds = %4, %7
%8 = phi i8 [ %11, %7 ], [ 0, %4 ]
%9 = phi i64 [ %10, %7 ], [ %0, %4 ]
%10 = sdiv i64 %9, 10
%11 = add i8 %8, 1
%12 = add i64 %9, 9
%13 = icmp ult i64 %12, 19
br i1 %13, label %6, label %7
14: ; preds = %6, %14
%15 = phi i8 [ %17, %14 ], [ %11, %6 ]
%16 = phi i64 [ %26, %14 ], [ %0, %6 ]
%17 = add i8 %15, -1
%18 = srem i64 %16, 10
%19 = trunc i64 %18 to i8
%20 = add nsw i8 %19, 48
%21 = sext i8 %17 to i32
%22 = shl nsw i32 %21, 3
%23 = sext i32 %22 to i64
%24 = add nsw i64 %23, %1
%25 = tail call i32 @font_draw_char(i8 zeroext %20, i64 %24, i64 %2, i64 %3)
%26 = sdiv i64 %16, 10
%27 = add i64 %16, 9
%28 = icmp ult i64 %27, 19
br i1 %28, label %29, label %14
29: ; preds = %14, %4, %6
%30 = phi i8 [ %11, %6 ], [ 0, %4 ], [ %11, %14 ]
ret i8 %30
}