#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*/ text(unsigned int, unsigned int, char *, unsigned int);
void number(unsigned x, unsigned y, unsigned n, unsigned color) {
  char s[6];
  int i;
  for (i = 4; i >= 0; --i) {
    s[i] = '0' + n % 10;
    n /= 10;
  }
  s[5] = 0;
  text(x, y, s, color);
}


x86 assembly (clang, -O0):
<number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x4,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     116b <number+0x5b>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
add    $0x30,%edx
mov    %dl,%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x16(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <number+0x1b>
movb   $0x0,-0x11(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x16(%rbp),%rdx
mov    -0x10(%rbp),%ecx
call   1030 <text@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number>:
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r9d
mov    $0xcccccccd,%r8d
imul   $0x51eb851f,%r9,%r10
imul   $0x10624dd3,%r9,%r11
mov    $0xd1b71759,%eax
imul   %r9,%rax
imul   %r8,%r9
shr    $0x23,%r9
lea    (%r9,%r9,1),%ebx
lea    (%rbx,%rbx,4),%ebx
sub    %ebx,%edx
or     $0x30,%dl
mov    %dl,0xe(%rsp)
mov    %r9,%rdx
imul   %r8,%rdx
shr    $0x23,%rdx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%r9d
or     $0x30,%r9b
mov    %r9b,0xd(%rsp)
shr    $0x25,%r10
mov    %r10,%rdx
imul   %r8,%rdx
shr    $0x23,%rdx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%r10d
or     $0x30,%r10b
mov    %r10b,0xc(%rsp)
shr    $0x26,%r11
mov    %r11,%rdx
imul   %r8,%rdx
shr    $0x23,%rdx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%r11d
or     $0x30,%r11b
mov    %r11b,0xb(%rsp)
shr    $0x2d,%rax
mov    %rax,%rdx
imul   %r8,%rdx
shr    $0x23,%rdx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%eax
or     $0x30,%al
mov    %al,0xa(%rsp)
movb   $0x0,0xf(%rsp)
lea    0xa(%rsp),%rdx
call   1030 <text@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @number(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [6 x i8]
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 4, i32* %10
br label %11
11: ; preds = %24, %4
%12 = load i32, i32* %10
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %11
%15 = load i32, i32* %7
%16 = urem i32 %15, 10
%17 = add i32 48, %16
%18 = trunc i32 %17 to i8
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 %20
store i8 %18, i8* %21
%22 = load i32, i32* %7
%23 = udiv i32 %22, 10
store i32 %23, i32* %7
br label %24
24: ; preds = %14
%25 = load i32, i32* %10
%26 = add nsw i32 %25, -1
store i32 %26, i32* %10
br label %11
27: ; preds = %11
%28 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 5
store i8 0, i8* %28
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 0
%32 = load i32, i32* %8
%33 = call i32 @text(i32 %29, i32 %30, i8* %31, i32 %32)
ret void
}

LLVM IR (-O2):
define void @number(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [6 x i8]
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%7 = urem i32 %2, 10
%8 = trunc i32 %7 to i8
%9 = or i8 %8, 48
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 4
store i8 %9, i8* %10
%11 = udiv i32 %2, 10
%12 = urem i32 %11, 10
%13 = trunc i32 %12 to i8
%14 = or i8 %13, 48
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 3
store i8 %14, i8* %15
%16 = udiv i32 %2, 100
%17 = urem i32 %16, 10
%18 = trunc i32 %17 to i8
%19 = or i8 %18, 48
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 2
store i8 %19, i8* %20
%21 = udiv i32 %2, 1000
%22 = urem i32 %21, 10
%23 = trunc i32 %22 to i8
%24 = or i8 %23, 48
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 1
store i8 %24, i8* %25
%26 = udiv i32 %2, 10000
%27 = urem i32 %26, 10
%28 = trunc i32 %27 to i8
%29 = or i8 %28, 48
store i8 %29, i8* %6
%30 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 5
store i8 0, i8* %30
%31 = call i32 @text(i32 %0, i32 %1, i8* %6, i32 %3)
ret void
}