#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*/ vram_adr(unsigned int);
int /*<<< orphan*/ vram_put(int);
void put_num(unsigned int adr, unsigned int num, unsigned char len) {
  vram_adr(adr);
  if (len > 2)
    vram_put(0x10 + num / 100);
  if (len > 1)
    vram_put(0x10 + num / 10 % 10);
  vram_put(0x10 + num % 10);
}


x86 assembly (clang, -O0):
<put_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <vram_adr@plt>
movzbl -0x9(%rbp),%eax
cmp    $0x2,%eax
jle    115e <put_num+0x3e>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%edi
add    $0x10,%edi
call   1030 <vram_put@plt>
movzbl -0x9(%rbp),%eax
cmp    $0x1,%eax
jle    118a <put_num+0x6a>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%edi
add    $0x10,%edi
call   1030 <vram_put@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%edi
add    $0x10,%edi
call   1030 <vram_put@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_num>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%ebx
call   1040 <vram_adr@plt>
mov    %ebx,%r14d
cmp    $0x3,%bpl
jb     114b <put_num+0x2b>
imul   $0x51eb851f,%r14,%rdi
shr    $0x25,%rdi
add    $0x10,%edi
call   1030 <vram_put@plt>
jmp    1151 <put_num+0x31>
cmp    $0x2,%bpl
jne    117b <put_num+0x5b>
mov    $0xcccccccd,%eax
mov    %r14,%rdi
imul   %rax,%rdi
shr    $0x23,%rdi
mov    %rdi,%rcx
imul   %rax,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%eax
sub    %eax,%edi
or     $0x10,%edi
call   1030 <vram_put@plt>
mov    $0xcccccccd,%eax
imul   %r14,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
or     $0x10,%ebx
mov    %ebx,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <vram_put@plt>

LLVM IR (-O0):
define void @put_num(i32 %0, i32 %1, i8 zeroext %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8 %2, i8* %6
%7 = load i32, i32* %4
%8 = call i32 @vram_adr(i32 %7)
%9 = load i8, i8* %6
%10 = zext i8 %9 to i32
%11 = icmp sgt i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %3
%13 = load i32, i32* %5
%14 = udiv i32 %13, 100
%15 = add i32 16, %14
%16 = call i32 @vram_put(i32 %15)
br label %17
17: ; preds = %12, %3
%18 = load i8, i8* %6
%19 = zext i8 %18 to i32
%20 = icmp sgt i32 %19, 1
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i32, i32* %5
%23 = udiv i32 %22, 10
%24 = urem i32 %23, 10
%25 = add i32 16, %24
%26 = call i32 @vram_put(i32 %25)
br label %27
27: ; preds = %21, %17
%28 = load i32, i32* %5
%29 = urem i32 %28, 10
%30 = add i32 16, %29
%31 = call i32 @vram_put(i32 %30)
ret void
}

LLVM IR (-O2):
define void @put_num(i32 %0, i32 %1, i8 zeroext %2) {
%4 = tail call i32 @vram_adr(i32 %0)
%5 = icmp ugt i8 %2, 2
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = udiv i32 %1, 100
%8 = add nuw nsw i32 %7, 16
%9 = tail call i32 @vram_put(i32 %8)
br label %12
10: ; preds = %3
%11 = icmp eq i8 %2, 2
br i1 %11, label %12, label %17
12: ; preds = %6, %10
%13 = udiv i32 %1, 10
%14 = urem i32 %13, 10
%15 = or i32 %14, 16
%16 = tail call i32 @vram_put(i32 %15)
br label %17
17: ; preds = %12, %10
%18 = urem i32 %1, 10
%19 = or i32 %18, 16
%20 = tail call i32 @vram_put(i32 %19)
ret void
}