#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*/ itochar(int, char *);
void ToLCDString(char *dest, char *fmt, int number, unsigned char dp) {
  do {
    if (*fmt == '%') {
      if (dp == 0) {
        dest += itochar(number, dest);
      } else {
        dest += itochar(number / 10, dest);
        *dest = '.';
        dest++;
        dest += itochar(number % 10, dest);
      }
    } else {
      *dest = *fmt;
      dest++;
    }
  } while (*(fmt++) != '\0');
  *dest = '\0';
}


x86 assembly (clang, -O0):
<ToLCDString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %al,-0x15(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    11ca <ToLCDString+0xba>
movzbl -0x15(%rbp),%eax
cmp    $0x0,%eax
jne    1166 <ToLCDString+0x56>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <itochar@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    11c5 <ToLCDString+0xb5>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <itochar@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x2e,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
mov    -0x8(%rbp),%rsi
call   1030 <itochar@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    11e2 <ToLCDString+0xd2>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11e7 <ToLCDString+0xd7>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1128 <ToLCDString+0x18>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ToLCDString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %edx,0x4(%rsp)
movslq %edx,%r15
imul   $0x66666667,%r15,%r13
mov    %r13,%rax
shr    $0x3f,%rax
sar    $0x22,%r13
add    %eax,%r13d
lea    0x0(%r13,%r13,1),%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%r15d
jmp    1160 <ToLCDString+0x50>
nopl   (%rax)
mov    %al,(%rbx)
add    $0x1,%rbx
cmpb   $0x0,0x0(%rbp)
lea    0x1(%rbp),%rbp
je     11b1 <ToLCDString+0xa1>
movzbl 0x0(%rbp),%eax
cmp    $0x25,%al
jne    1150 <ToLCDString+0x40>
test   %r12b,%r12b
je     119e <ToLCDString+0x8e>
mov    %r13d,%edi
mov    %rbx,%rsi
call   1030 <itochar@plt>
cltq
lea    (%rbx,%rax,1),%r14
movb   $0x2e,(%rbx,%rax,1)
lea    (%rbx,%rax,1),%rsi
add    $0x1,%rsi
mov    %r15d,%edi
call   1030 <itochar@plt>
cltq
lea    (%rax,%r14,1),%rbx
add    $0x1,%rbx
jmp    1156 <ToLCDString+0x46>
mov    0x4(%rsp),%edi
mov    %rbx,%rsi
call   1030 <itochar@plt>
cltq
add    %rax,%rbx
jmp    1156 <ToLCDString+0x46>
movb   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ToLCDString(i8* %0, i8* %1, i32 %2, i8 zeroext %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8 %3, i8* %8
br label %9
9: ; preds = %51, %4
%10 = load i8*, i8** %6
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 37
br i1 %13, label %14, label %44
14: ; preds = %9
%15 = load i8, i8* %8
%16 = zext i8 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i32, i32* %7
%20 = load i8*, i8** %5
%21 = call i32 @itochar(i32 %19, i8* %20)
%22 = load i8*, i8** %5
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds i8, i8* %22, i64 %23
store i8* %24, i8** %5
br label %43
25: ; preds = %14
%26 = load i32, i32* %7
%27 = sdiv i32 %26, 10
%28 = load i8*, i8** %5
%29 = call i32 @itochar(i32 %27, i8* %28)
%30 = load i8*, i8** %5
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %30, i64 %31
store i8* %32, i8** %5
%33 = load i8*, i8** %5
store i8 46, i8* %33
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %5
%36 = load i32, i32* %7
%37 = srem i32 %36, 10
%38 = load i8*, i8** %5
%39 = call i32 @itochar(i32 %37, i8* %38)
%40 = load i8*, i8** %5
%41 = sext i32 %39 to i64
%42 = getelementptr inbounds i8, i8* %40, i64 %41
store i8* %42, i8** %5
br label %43
43: ; preds = %25, %18
br label %50
44: ; preds = %9
%45 = load i8*, i8** %6
%46 = load i8, i8* %45
%47 = load i8*, i8** %5
store i8 %46, i8* %47
%48 = load i8*, i8** %5
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %5
br label %50
50: ; preds = %44, %43
br label %51
51: ; preds = %50
%52 = load i8*, i8** %6
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %6
%54 = load i8, i8* %52
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %55, 0
br i1 %56, label %9, label %57
57: ; preds = %51
%58 = load i8*, i8** %5
store i8 0, i8* %58
ret void
}

LLVM IR (-O2):
define void @ToLCDString(i8* %0, i8* nocapture %1, i32 %2, i8 zeroext %3) {
%5 = icmp eq i8 %3, 0
%6 = sdiv i32 %2, 10
%7 = srem i32 %2, 10
br label %8
8: ; preds = %28, %4
%9 = phi i8* [ %1, %4 ], [ %30, %28 ]
%10 = phi i8* [ %0, %4 ], [ %29, %28 ]
%11 = load i8, i8* %9
%12 = icmp eq i8 %11, 37
br i1 %12, label %13, label %26
13: ; preds = %8
br i1 %5, label %14, label %18
14: ; preds = %13
%15 = tail call i32 @itochar(i32 %2, i8* %10)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %10, i64 %16
br label %28
18: ; preds = %13
%19 = tail call i32 @itochar(i32 %6, i8* %10)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %10, i64 %20
store i8 46, i8* %21
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = tail call i32 @itochar(i32 %7, i8* %22)
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
br label %28
26: ; preds = %8
store i8 %11, i8* %10
%27 = getelementptr inbounds i8, i8* %10, i64 1
br label %28
28: ; preds = %26, %18, %14
%29 = phi i8* [ %17, %14 ], [ %25, %18 ], [ %27, %26 ]
%30 = getelementptr inbounds i8, i8* %9, i64 1
%31 = load i8, i8* %9
%32 = icmp eq i8 %31, 0
br i1 %32, label %33, label %8
33: ; preds = %28
store i8 0, i8* %29
ret void
}