#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_Write_Char(unsigned char);
int /*<<< orphan*/ LCD_Write_String(char *);
void LCD_Write_Int1(char v, long num) {
  if (num < 0) {
    LCD_Write_String("-");
    num *= -1;
  }
  unsigned char number[10];
  unsigned char num_count = 0;
  do {
    number[num_count] = num % 10;
    num_count++;
    num /= 10;
  } while (num > 0);
  for (int i = v - 1; i >= 0; i--) {
    if (num_count <= i) {
      LCD_Write_Char('0');
    } else {
      LCD_Write_Char(number[i] + 0b00110000);
    }
  }
}


x86 assembly (clang, -O0):
<LCD_Write_Int1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    1152 <LCD_Write_Int1+0x32>
lea    0xebc(%rip),%rdi
call   1040 <LCD_Write_String@plt>
imul   $0xffffffffffffffff,-0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
movb   $0x0,-0x1b(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %dl,%cl
movzbl -0x1b(%rbp),%eax
mov    %cl,-0x1a(%rbp,%rax,1)
mov    -0x1b(%rbp),%al
add    $0x1,%al
mov    %al,-0x1b(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jg     1156 <LCD_Write_Int1+0x36>
movsbl -0x1(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     11ea <LCD_Write_Int1+0xca>
movzbl -0x1b(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     11c3 <LCD_Write_Int1+0xa3>
mov    $0x30,%edi
call   1030 <LCD_Write_Char@plt>
jmp    11d7 <LCD_Write_Int1+0xb7>
movslq -0x20(%rbp),%rax
movzbl -0x1a(%rbp,%rax,1),%eax
add    $0x30,%eax
movzbl %al,%edi
call   1030 <LCD_Write_Char@plt>
jmp    11dc <LCD_Write_Int1+0xbc>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    119d <LCD_Write_Int1+0x7d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LCD_Write_Int1>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
test   %rsi,%rsi
jns    113f <LCD_Write_Int1+0x1f>
lea    0xec9(%rip),%rdi
call   1040 <LCD_Write_String@plt>
neg    %rbx
xor    %ecx,%ecx
movabs $0x6666666666666667,%rsi
66 66 66
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rax
imul   %rsi
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
lea    (%rdx,%rdx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ebx,%edi
sub    %eax,%edi
movzbl %cl,%ecx
mov    %dil,0xe(%rsp,%rcx,1)
add    $0x1,%cl
cmp    $0x9,%rbx
mov    %rdx,%rbx
jg     1150 <LCD_Write_Int1+0x30>
test   %bpl,%bpl
jle    11bf <LCD_Write_Int1+0x9f>
movzbl %bpl,%eax
movzbl %cl,%ebx
jmp    11a8 <LCD_Write_Int1+0x88>
movzbl %cl,%edi
call   1030 <LCD_Write_Char@plt>
mov    %rbp,%rcx
add    $0x1,%rcx
mov    %rbp,%rax
cmp    $0x1,%rcx
jbe    11bf <LCD_Write_Int1+0x9f>
lea    -0x1(%rax),%rbp
mov    $0x30,%cl
cmp    %rbx,%rax
ja     1190 <LCD_Write_Int1+0x70>
mov    %ebp,%eax
movzbl 0xe(%rsp,%rax,1),%ecx
add    $0x30,%cl
jmp    1190 <LCD_Write_Int1+0x70>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
define void @LCD_Write_Int1(i8 signext %0, i64 %1) {
%3 = alloca i8
%4 = alloca i64
%5 = alloca [10 x i8]
%6 = alloca i8
%7 = alloca i32
store i8 %0, i8* %3
store i64 %1, i64* %4
%8 = load i64, i64* %4
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = call i32 @LCD_Write_String(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = load i64, i64* %4
%13 = mul nsw i64 %12, -1
store i64 %13, i64* %4
br label %14
14: ; preds = %10, %2
store i8 0, i8* %6
br label %15
15: ; preds = %26, %14
%16 = load i64, i64* %4
%17 = srem i64 %16, 10
%18 = trunc i64 %17 to i8
%19 = load i8, i8* %6
%20 = zext i8 %19 to i64
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 %20
store i8 %18, i8* %21
%22 = load i8, i8* %6
%23 = add i8 %22, 1
store i8 %23, i8* %6
%24 = load i64, i64* %4
%25 = sdiv i64 %24, 10
store i64 %25, i64* %4
br label %26
26: ; preds = %15
%27 = load i64, i64* %4
%28 = icmp sgt i64 %27, 0
br i1 %28, label %15, label %29
29: ; preds = %26
%30 = load i8, i8* %3
%31 = sext i8 %30 to i32
%32 = sub nsw i32 %31, 1
store i32 %32, i32* %7
br label %33
33: ; preds = %53, %29
%34 = load i32, i32* %7
%35 = icmp sge i32 %34, 0
br i1 %35, label %36, label %56
36: ; preds = %33
%37 = load i8, i8* %6
%38 = zext i8 %37 to i32
%39 = load i32, i32* %7
%40 = icmp sle i32 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 @LCD_Write_Char(i8 zeroext 48)
br label %52
43: ; preds = %36
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = add nsw i32 %48, 48
%50 = trunc i32 %49 to i8
%51 = call i32 @LCD_Write_Char(i8 zeroext %50)
br label %52
52: ; preds = %43, %41
br label %53
53: ; preds = %52
%54 = load i32, i32* %7
%55 = add nsw i32 %54, -1
store i32 %55, i32* %7
br label %33
56: ; preds = %33
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
define void @LCD_Write_Int1(i8 signext %0, i64 %1) {
%3 = alloca [10 x i8]
%4 = icmp slt i64 %1, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @LCD_Write_String(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = sub nsw i64 0, %1
br label %8
8: ; preds = %5, %2
%9 = phi i64 [ %7, %5 ], [ %1, %2 ]
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
br label %11
11: ; preds = %11, %8
%12 = phi i64 [ %9, %8 ], [ %19, %11 ]
%13 = phi i8 [ 0, %8 ], [ %18, %11 ]
%14 = srem i64 %12, 10
%15 = trunc i64 %14 to i8
%16 = zext i8 %13 to i64
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %16
store i8 %15, i8* %17
%18 = add i8 %13, 1
%19 = sdiv i64 %12, 10
%20 = icmp sgt i64 %12, 9
br i1 %20, label %11, label %21
21: ; preds = %11
%22 = icmp sgt i8 %0, 0
br i1 %22, label %23, label %26
23: ; preds = %21
%24 = zext i8 %0 to i64
%25 = zext i8 %18 to i64
br label %27
26: ; preds = %36, %21
ret void
27: ; preds = %23, %36
%28 = phi i64 [ %24, %23 ], [ %29, %36 ]
%29 = add nsw i64 %28, -1
%30 = icmp ugt i64 %28, %25
br i1 %30, label %36, label %31
31: ; preds = %27
%32 = and i64 %29, 4294967295
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = add i8 %34, 48
br label %36
36: ; preds = %27, %31
%37 = phi i8 [ %35, %31 ], [ 48, %27 ]
%38 = tail call i32 @LCD_Write_Char(i8 zeroext %37)
%39 = icmp ugt i64 %28, 1
br i1 %39, label %27, label %26
}