#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 */
typedef unsigned int uint8_t;
typedef unsigned int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ display_write_char(unsigned int);
void display_write_number(uint16_t number, bool leading_zeros) {
  bool not_zero = false;
  uint8_t tmp;
  uint16_t i = 10000U;
  do {
    tmp = (number / i) % 10U;
    if ((leading_zeros == true) || (tmp != 0U) || (i == 1U))
      not_zero = true;
    if (not_zero == true)
      display_write_char('0' + tmp);
    i /= 10U;
  } while (i != 0U);
}


x86 assembly (clang, -O0):
<display_write_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x2710,-0x14(%rbp)
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0x14(%rbp)
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     115e <display_write_number+0x4e>
cmpl   $0x0,-0x10(%rbp)
jne    115e <display_write_number+0x4e>
cmpl   $0x1,-0x14(%rbp)
jne    1165 <display_write_number+0x55>
movl   $0x1,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    117a <display_write_number+0x6a>
mov    -0x10(%rbp),%edi
add    $0x30,%edi
call   1030 <display_write_char@plt>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    112c <display_write_number+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_write_number>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%r15d
mov    %edi,%r14d
mov    $0xd1b71759,%ebx
imul   %r14,%rbx
shr    $0x2d,%rbx
mov    $0xcccccccd,%eax
imul   %rbx,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
cmp    $0x1,%esi
je     1149 <display_write_number+0x39>
test   %ebx,%ebx
je     1153 <display_write_number+0x43>
mov    %ebx,%edi
or     $0x30,%edi
call   1030 <display_write_char@plt>
cmp    $0x1,%ebp
sete   %cl
imul   $0x10624dd3,%r14,%rdi
shr    $0x26,%rdi
mov    $0xcccccccd,%ebp
mov    %rdi,%rax
imul   %rbp,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
or     %edi,%ebx
setne  %al
or     %cl,%al
cmp    $0x1,%al
jne    11ad <display_write_number+0x9d>
or     $0x30,%edi
call   1030 <display_write_char@plt>
imul   $0x51eb851f,%r14,%rdi
shr    $0x25,%rdi
mov    %rdi,%rax
imul   %rbp,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
jmp    11d3 <display_write_number+0xc3>
imul   $0x51eb851f,%r14,%rdi
shr    $0x25,%rdi
mov    %rdi,%rcx
imul   %rbp,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%edi
sete   %cl
not    %al
test   %cl,%al
jne    1230 <display_write_number+0x120>
or     $0x30,%edi
call   1030 <display_write_char@plt>
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     $0x30,%edi
call   1030 <display_write_char@plt>
mov    $0xcccccccd,%eax
imul   %r14,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%r15d
or     $0x30,%r15d
mov    %r15d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <display_write_char@plt>
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
jne    11fd <display_write_number+0xed>
jmp    1205 <display_write_number+0xf5>

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

LLVM IR (-O2):
define void @display_write_number(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 1
%4 = udiv i32 %0, 10000
%5 = urem i32 %4, 10
%6 = icmp ne i32 %5, 0
%7 = or i1 %3, %6
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = or i32 %5, 48
%10 = tail call i32 @display_write_char(i32 %9)
br label %11
11: ; preds = %8, %2
%12 = udiv i32 %0, 1000
%13 = urem i32 %12, 10
%14 = or i32 %13, %5
%15 = icmp ne i32 %14, 0
%16 = or i1 %15, %3
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = or i32 %13, 48
%19 = tail call i32 @display_write_char(i32 %18)
%20 = udiv i32 %0, 100
%21 = urem i32 %20, 10
br label %27
22: ; preds = %11
%23 = udiv i32 %0, 100
%24 = urem i32 %23, 10
%25 = icmp ne i32 %24, 0
%26 = or i1 %16, %25
br i1 %26, label %27, label %33
27: ; preds = %22, %17
%28 = phi i32 [ %21, %17 ], [ %24, %22 ]
%29 = or i32 %28, 48
%30 = tail call i32 @display_write_char(i32 %29)
%31 = udiv i32 %0, 10
%32 = urem i32 %31, 10
br label %37
33: ; preds = %22
%34 = udiv i32 %0, 10
%35 = urem i32 %34, 10
%36 = icmp eq i32 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %27, %33
%38 = phi i32 [ %32, %27 ], [ %35, %33 ]
%39 = or i32 %38, 48
%40 = tail call i32 @display_write_char(i32 %39)
br label %41
41: ; preds = %37, %33
%42 = urem i32 %0, 10
%43 = or i32 %42, 48
%44 = tail call i32 @display_write_char(i32 %43)
ret void
}