#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 int /*<<< orphan*/ result;

/* Variables and functions */
int /*<<< orphan*/ lcd_display_char(char);
void lcd_display_number_w_decimal(int number, int decimal_place) {
  char result[12];
  int i = 0;
  do {
    result[i++] = '0' + (number % 10);
  } while ((number /= 10) > 0 && i < sizeof(result));
  i--;
  while (i >= 0) {
    lcd_display_char(result[i]);
    if (decimal_place > 0 && i == decimal_place)
      lcd_display_char('.');
    i--;
  }
}


x86 assembly (clang, -O0):
<lcd_display_number_w_decimal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x18(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
cltq
mov    %cl,-0x14(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    %ecx,-0x4(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
jle    1172 <lcd_display_number_w_decimal+0x62>
movslq -0x18(%rbp),%rax
cmp    $0xc,%rax
setb   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1125 <lcd_display_number_w_decimal+0x15>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     11cc <lcd_display_number_w_decimal+0xbc>
movslq -0x18(%rbp),%rax
movsbl -0x14(%rbp,%rax,1),%edi
call   1030 <lcd_display_char@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11be <lcd_display_number_w_decimal+0xae>
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11be <lcd_display_number_w_decimal+0xae>
mov    $0x2e,%edi
call   1030 <lcd_display_char@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1186 <lcd_display_number_w_decimal+0x76>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_display_number_w_decimal>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
xor    %eax,%eax
nopl   (%rax)
movslq %edi,%rdx
imul   $0x66666667,%rdx,%rdi
mov    %rdi,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rdi
add    %ecx,%edi
lea    (%rdi,%rdi,1),%ecx
lea    (%rcx,%rcx,4),%esi
mov    %edx,%ecx
sub    %esi,%ecx
add    $0x30,%cl
lea    0x1(%rax),%rbx
mov    %cl,0x4(%rsp,%rax,1)
cmp    $0xa,%edx
jl     115a <lcd_display_number_w_decimal+0x4a>
cmp    $0xb,%rax
mov    %rbx,%rax
jb     1120 <lcd_display_number_w_decimal+0x10>
mov    %r14d,%ebp
nopl   (%rax)
add    $0xffffffffffffffff,%rbx
movsbl %cl,%edi
call   1030 <lcd_display_char@plt>
test   %r14d,%r14d
jle    1180 <lcd_display_number_w_decimal+0x70>
cmp    %rbx,%rbp
jne    1180 <lcd_display_number_w_decimal+0x70>
mov    $0x2e,%edi
call   1030 <lcd_display_char@plt>
test   %rbx,%rbx
jle    118c <lcd_display_number_w_decimal+0x7c>
movzbl 0x3(%rsp,%rbx,1),%ecx
jmp    1160 <lcd_display_number_w_decimal+0x50>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @lcd_display_number_w_decimal(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [12 x i8]
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %6
br label %7
7: ; preds = %24, %2
%8 = load i32, i32* %3
%9 = srem i32 %8, 10
%10 = add nsw i32 48, %9
%11 = trunc i32 %10 to i8
%12 = load i32, i32* %6
%13 = add nsw i32 %12, 1
store i32 %13, i32* %6
%14 = sext i32 %12 to i64
%15 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 %14
store i8 %11, i8* %15
br label %16
16: ; preds = %7
%17 = load i32, i32* %3
%18 = sdiv i32 %17, 10
store i32 %18, i32* %3
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = icmp ult i64 %22, 12
br label %24
24: ; preds = %20, %16
%25 = phi i1 [ false, %16 ], [ %23, %20 ]
br i1 %25, label %7, label %26
26: ; preds = %24
%27 = load i32, i32* %6
%28 = add nsw i32 %27, -1
store i32 %28, i32* %6
br label %29
29: ; preds = %46, %26
%30 = load i32, i32* %6
%31 = icmp sge i32 %30, 0
br i1 %31, label %32, label %49
32: ; preds = %29
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = call i32 @lcd_display_char(i8 signext %36)
%38 = load i32, i32* %4
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %32
%41 = load i32, i32* %6
%42 = load i32, i32* %4
%43 = icmp eq i32 %41, %42
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 @lcd_display_char(i8 signext 46)
br label %46
46: ; preds = %44, %40, %32
%47 = load i32, i32* %6
%48 = add nsw i32 %47, -1
store i32 %48, i32* %6
br label %29
49: ; preds = %29
ret void
}

LLVM IR (-O2):
define void @lcd_display_number_w_decimal(i32 %0, i32 %1) {
%3 = alloca [12 x i8]
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %5, %2
%6 = phi i64 [ %11, %5 ], [ 0, %2 ]
%7 = phi i32 [ %13, %5 ], [ %0, %2 ]
%8 = srem i32 %7, 10
%9 = trunc i32 %8 to i8
%10 = add nsw i8 %9, 48
%11 = add nuw nsw i64 %6, 1
%12 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 %6
store i8 %10, i8* %12
%13 = sdiv i32 %7, 10
%14 = icmp sgt i32 %7, 9
%15 = icmp ult i64 %6, 11
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %5, label %17
17: ; preds = %5
%18 = icmp sgt i32 %1, 0
%19 = zext i32 %1 to i64
br label %20
20: ; preds = %31, %17
%21 = phi i8 [ %10, %17 ], [ %33, %31 ]
%22 = phi i64 [ %6, %17 ], [ %29, %31 ]
%23 = tail call i32 @lcd_display_char(i8 signext %21)
%24 = icmp eq i64 %22, %19
%25 = select i1 %18, i1 %24, i1 false
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = tail call i32 @lcd_display_char(i8 signext 46)
br label %28
28: ; preds = %26, %20
%29 = add nsw i64 %22, -1
%30 = icmp sgt i64 %22, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 %29
%33 = load i8, i8* %32
br label %20
34: ; preds = %28
ret void
}