#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*/ nokia_lcd_out_char(char);
void nokia_lcd_out_unsigned_int(unsigned int num) {
  char numCache[6];
  unsigned int num_mod;
  unsigned int num_div;
  char digit_index = 0;
  num_div = num;
  do {
    num_mod = num_div % 10;
    num_div = num_div / 10;
    numCache[digit_index] = num_mod + 48;
    digit_index++;
  } while (num_div > 0);
  while (digit_index > 0) {
    digit_index--;
    nokia_lcd_out_char(numCache[digit_index]);
  }
}


x86 assembly (clang, -O0):
<nokia_lcd_out_unsigned_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,-0x15(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
movsbq -0x15(%rbp),%rax
mov    %cl,-0xa(%rbp,%rax,1)
mov    -0x15(%rbp),%al
add    $0x1,%al
mov    %al,-0x15(%rbp)
cmpl   $0x0,-0x14(%rbp)
ja     1125 <nokia_lcd_out_unsigned_int+0x15>
jmp    116b <nokia_lcd_out_unsigned_int+0x5b>
movsbl -0x15(%rbp),%eax
cmp    $0x0,%eax
jle    1194 <nokia_lcd_out_unsigned_int+0x84>
mov    -0x15(%rbp),%al
add    $0xff,%al
mov    %al,-0x15(%rbp)
movsbq -0x15(%rbp),%rax
movsbl -0xa(%rbp,%rax,1),%edi
call   1030 <nokia_lcd_out_char@plt>
jmp    116b <nokia_lcd_out_unsigned_int+0x5b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nokia_lcd_out_unsigned_int>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
mov    $0xcccccccd,%eax
nopl   0x0(%rax,%rax,1)
mov    %edi,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %edi,%esi
sub    %edx,%esi
or     $0x30,%sil
movsbq %bl,%rbx
mov    %sil,0x2(%rsp,%rbx,1)
add    $0x1,%bl
cmp    $0x9,%edi
mov    %ecx,%edi
ja     1120 <nokia_lcd_out_unsigned_int+0x10>
lea    -0x1(%rbx),%eax
cmp    $0x7e,%al
ja     117a <nokia_lcd_out_unsigned_int+0x6a>
movzbl %bl,%r14d
add    $0x1,%bl
add    $0xffffffffffffffff,%r14
nopl   (%rax)
movzbl %r14b,%eax
movsbl 0x2(%rsp,%rax,1),%edi
call   1030 <nokia_lcd_out_char@plt>
add    $0xff,%bl
add    $0xffffffffffffffff,%r14
cmp    $0x1,%bl
jg     1160 <nokia_lcd_out_unsigned_int+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @nokia_lcd_out_unsigned_int(i32 %0) {
%2 = alloca [6 x i8]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %4, %1
%5 = phi i32 [ %0, %1 ], [ %8, %4 ]
%6 = phi i8 [ 0, %1 ], [ %13, %4 ]
%7 = urem i32 %5, 10
%8 = udiv i32 %5, 10
%9 = trunc i32 %7 to i8
%10 = or i8 %9, 48
%11 = sext i8 %6 to i64
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 %11
store i8 %10, i8* %12
%13 = add i8 %6, 1
%14 = icmp ult i32 %5, 10
br i1 %14, label %15, label %4
15: ; preds = %4
%16 = icmp ult i8 %6, 127
br i1 %16, label %17, label %28
17: ; preds = %15
%18 = zext i8 %13 to i64
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ %18, %17 ], [ %21, %19 ]
%21 = add nsw i64 %20, -1
%22 = and i64 %21, 255
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = tail call i32 @nokia_lcd_out_char(i8 signext %24)
%26 = trunc i64 %20 to i8
%27 = icmp sgt i8 %26, 1
br i1 %27, label %19, label %28
28: ; preds = %19, %15
ret void
}