#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*/ lcd_data(int);
void num(unsigned int p) {
  int k, w, b = 1;
  k = p;
  if (p < 1000)
    lcd_data(48);
  while (k >= 10) {
    b = b * 10;
    k = k / 10;
  }
  while (b >= 1) {
    w = p / b;
    p = p % b;
    b = b / 10;
    lcd_data(w + 48);
  }
}


x86 assembly (clang, -O0):
<num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jae    113f <num+0x2f>
mov    $0x30,%edi
call   1030 <lcd_data@plt>
jmp    1144 <num+0x34>
cmpl   $0xa,-0x8(%rbp)
jl     1168 <num+0x58>
imul   $0xa,-0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1144 <num+0x34>
jmp    116d <num+0x5d>
cmpl   $0x1,-0x10(%rbp)
jl     11ab <num+0x9b>
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0x10(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0x10(%rbp)
mov    %edx,-0x4(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
add    $0x30,%edi
call   1030 <lcd_data@plt>
jmp    116d <num+0x5d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
cmp    $0x3e7,%edi
ja     112c <num+0x1c>
mov    $0x30,%edi
call   1030 <lcd_data@plt>
mov    $0x1,%ebp
cmp    $0xa,%r15d
jl     1167 <num+0x57>
mov    $0x1,%ebp
mov    $0xcccccccd,%eax
mov    %r15d,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %ebp,%ebp
lea    0x0(%rbp,%rbp,4),%ebp
mov    %ecx,%edx
imul   %rax,%rdx
shr    $0x23,%rdx
cmp    $0x63,%ecx
mov    %edx,%ecx
ja     1150 <num+0x40>
mov    $0xcccccccd,%r14d
nopl   (%rax)
mov    %r15d,%eax
xor    %edx,%edx
div    %ebp
mov    %ebp,%ebx
imul   %r14,%rbx
shr    $0x23,%rbx
lea    0x30(%rax),%edi
mov    %edx,%r15d
call   1030 <lcd_data@plt>
cmp    $0x9,%ebp
mov    %ebx,%ebp
ja     1170 <num+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @num(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %5
%6 = load i32, i32* %2
store i32 %6, i32* %3
%7 = load i32, i32* %2
%8 = icmp ult i32 %7, 1000
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @lcd_data(i32 48)
br label %11
11: ; preds = %9, %1
br label %12
12: ; preds = %15, %11
%13 = load i32, i32* %3
%14 = icmp sge i32 %13, 10
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i32, i32* %5
%17 = mul nsw i32 %16, 10
store i32 %17, i32* %5
%18 = load i32, i32* %3
%19 = sdiv i32 %18, 10
store i32 %19, i32* %3
br label %12
20: ; preds = %12
br label %21
21: ; preds = %24, %20
%22 = load i32, i32* %5
%23 = icmp sge i32 %22, 1
br i1 %23, label %24, label %36
24: ; preds = %21
%25 = load i32, i32* %2
%26 = load i32, i32* %5
%27 = udiv i32 %25, %26
store i32 %27, i32* %4
%28 = load i32, i32* %2
%29 = load i32, i32* %5
%30 = urem i32 %28, %29
store i32 %30, i32* %2
%31 = load i32, i32* %5
%32 = sdiv i32 %31, 10
store i32 %32, i32* %5
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 48
%35 = call i32 @lcd_data(i32 %34)
br label %21
36: ; preds = %21
ret void
}

LLVM IR (-O2):
define void @num(i32 %0) {
%2 = icmp ult i32 %0, 1000
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @lcd_data(i32 48)
br label %5
5: ; preds = %3, %1
%6 = icmp sgt i32 %0, 9
br i1 %6, label %7, label %13
7: ; preds = %5, %7
%8 = phi i32 [ %10, %7 ], [ 1, %5 ]
%9 = phi i32 [ %11, %7 ], [ %0, %5 ]
%10 = mul nsw i32 %8, 10
%11 = udiv i32 %9, 10
%12 = icmp ugt i32 %9, 99
br i1 %12, label %7, label %13
13: ; preds = %7, %5
%14 = phi i32 [ 1, %5 ], [ %10, %7 ]
br label %15
15: ; preds = %13, %15
%16 = phi i32 [ %20, %15 ], [ %14, %13 ]
%17 = phi i32 [ %19, %15 ], [ %0, %13 ]
%18 = udiv i32 %17, %16
%19 = urem i32 %17, %16
%20 = udiv i32 %16, 10
%21 = add nsw i32 %18, 48
%22 = tail call i32 @lcd_data(i32 %21)
%23 = icmp ult i32 %16, 10
br i1 %23, label %24, label %15
24: ; preds = %15
ret void
}