#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*/ VHB_DrawTile8(int, int, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char *);
void CK_DrawLongRight(int x, int y, int digits, int zerotile, int value) {
  char s[20];
  int len, i;
  sprintf(s, "%d", value);
  len = strlen(s);
  for (i = digits; i > len; i--) {
    VHB_DrawTile8(x, y, zerotile);
    x += 8;
  }
  while (i > 0) {
    VHB_DrawTile8(x, y, zerotile + s[len - i] - 47);
    i--;
    x += 8;
  }
}


x86 assembly (clang, -O0):
<CK_DrawLongRight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xeaa(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jle    119e <CK_DrawLongRight+0x6e>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <VHB_DrawTile8@plt>
mov    -0x4(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
jmp    116d <CK_DrawLongRight+0x3d>
jmp    11a3 <CK_DrawLongRight+0x73>
cmpl   $0x0,-0x38(%rbp)
jle    11e4 <CK_DrawLongRight+0xb4>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x34(%rbp),%eax
sub    -0x38(%rbp),%eax
cltq
movsbl -0x30(%rbp,%rax,1),%eax
add    %eax,%edx
sub    $0x2f,%edx
call   1040 <VHB_DrawTile8@plt>
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
mov    -0x4(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x4(%rbp)
jmp    11a3 <CK_DrawLongRight+0x73>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CK_DrawLongRight>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r15d
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%r13d
lea    0xeb0(%rip),%rsi
mov    %rsp,%r12
mov    %r12,%rdi
mov    %r8d,%edx
call   1050 <sprintf@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
cmp    %ebx,%eax
jge    118d <CK_DrawLongRight+0x5d>
nopl   (%rax)
mov    %r13d,%edi
mov    %r14d,%esi
mov    %r15d,%edx
call   1040 <VHB_DrawTile8@plt>
add    $0x8,%r13d
add    $0xffffffff,%ebx
cmp    %r12d,%ebx
jg     1170 <CK_DrawLongRight+0x40>
mov    %r12d,%ebx
test   %ebx,%ebx
jle    11d4 <CK_DrawLongRight+0xa4>
add    $0xffffffd1,%r15d
mov    %ebx,%ebx
movslq %r12d,%rax
sub    %rbx,%rax
add    $0x1,%rbx
lea    (%rsp,%rax,1),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
movsbl 0x0(%rbp),%edx
add    %r15d,%edx
mov    %r13d,%edi
mov    %r14d,%esi
call   1040 <VHB_DrawTile8@plt>
add    $0x8,%r13d
add    $0xffffffffffffffff,%rbx
add    $0x1,%rbp
cmp    $0x1,%rbx
ja     11b0 <CK_DrawLongRight+0x80>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @CK_DrawLongRight(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [20 x i8]
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%15 = load i32, i32* %10
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %12
%19 = load i32, i32* %8
store i32 %19, i32* %13
br label %20
20: ; preds = %31, %5
%21 = load i32, i32* %13
%22 = load i32, i32* %12
%23 = icmp sgt i32 %21, %22
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = load i32, i32* %9
%28 = call i32 @VHB_DrawTile8(i32 %25, i32 %26, i32 %27)
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 8
store i32 %30, i32* %6
br label %31
31: ; preds = %24
%32 = load i32, i32* %13
%33 = add nsw i32 %32, -1
store i32 %33, i32* %13
br label %20
34: ; preds = %20
br label %35
35: ; preds = %38, %34
%36 = load i32, i32* %13
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %56
38: ; preds = %35
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = load i32, i32* %9
%42 = load i32, i32* %12
%43 = load i32, i32* %13
%44 = sub nsw i32 %42, %43
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = add nsw i32 %41, %48
%50 = sub nsw i32 %49, 47
%51 = call i32 @VHB_DrawTile8(i32 %39, i32 %40, i32 %50)
%52 = load i32, i32* %13
%53 = add nsw i32 %52, -1
store i32 %53, i32* %13
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 8
store i32 %55, i32* %6
br label %35
56: ; preds = %35
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @CK_DrawLongRight(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [20 x i8]
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%8 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %4)
%9 = call i32 @strlen(i8* %7)
%10 = icmp slt i32 %9, %2
br i1 %10, label %19, label %11
11: ; preds = %19, %5
%12 = phi i32 [ %0, %5 ], [ %23, %19 ]
%13 = phi i32 [ %2, %5 ], [ %9, %19 ]
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %38
15: ; preds = %11
%16 = add i32 %3, -47
%17 = zext i32 %13 to i64
%18 = sext i32 %9 to i64
br label %26
19: ; preds = %5, %19
%20 = phi i32 [ %24, %19 ], [ %2, %5 ]
%21 = phi i32 [ %23, %19 ], [ %0, %5 ]
%22 = call i32 @VHB_DrawTile8(i32 %21, i32 %1, i32 %3)
%23 = add nsw i32 %21, 8
%24 = add nsw i32 %20, -1
%25 = icmp sgt i32 %24, %9
br i1 %25, label %19, label %11
26: ; preds = %15, %26
%27 = phi i64 [ %17, %15 ], [ %35, %26 ]
%28 = phi i32 [ %12, %15 ], [ %36, %26 ]
%29 = sub nsw i64 %18, %27
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = add i32 %16, %32
%34 = call i32 @VHB_DrawTile8(i32 %28, i32 %1, i32 %33)
%35 = add nsw i64 %27, -1
%36 = add nsw i32 %28, 8
%37 = icmp ugt i64 %27, 1
br i1 %37, label %26, label %38
38: ; preds = %26, %11
ret void
}