#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*/ va_list;

/* Variables and functions */
int /*<<< orphan*/ Lcd_PutASCII(unsigned int, unsigned int, unsigned char,
                                unsigned int, unsigned int, unsigned int);
int /*<<< orphan*/ Lcd_PutHZ(unsigned int, unsigned int, unsigned char,
                             unsigned int, unsigned int, unsigned int);
int /*<<< orphan*/ xsprintf(char *, char *);
void Lcd_Printf(unsigned int x, unsigned int y, unsigned int c,
                unsigned int bk_c, unsigned int st, char *fmt, ...) {
  char __LCD_Printf_Buf[256];
  va_list ap;
  unsigned char *pStr = (unsigned char *)__LCD_Printf_Buf;
  unsigned int i = 0;
  xsprintf(__LCD_Printf_Buf, fmt);
  while (*pStr != 0) {
    switch (*pStr) {
    case '\n': {
      break;
    }
    default: {
      if (*pStr > 0xA0 & *(pStr + 1) > 0xA0) {
        Lcd_PutHZ(x, y, (*pStr - 0xA0) * 0x0100 + *(pStr + 1) - 0xA0, c, bk_c,
                  st);
        pStr++;
        i++;
        y += 16;
      } else {
        Lcd_PutASCII(x, y, *pStr, c, bk_c, st);
        y += 8;
      }
      break;
    }
    }
    pStr++;
    i++;
    if (i > 256)
      break;
  }
}


x86 assembly (clang, -O0):
<Lcd_Printf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9,-0x20(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x130(%rbp)
movl   $0x0,-0x134(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <xsprintf@plt>
mov    -0x130(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
je     12b8 <Lcd_Printf+0x188>
mov    -0x130(%rbp),%rax
mov    (%rax),%al
sub    $0xa,%al
jne    11a5 <Lcd_Printf+0x75>
jmp    11a0 <Lcd_Printf+0x70>
jmp    127d <Lcd_Printf+0x14d>
mov    -0x130(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xa0,%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    -0x130(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
cmp    $0xa0,%ecx
setg   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     124d <Lcd_Printf+0x11d>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x130(%rbp),%rax
movzbl (%rax),%eax
sub    $0xa0,%eax
shl    $0x8,%eax
mov    -0x130(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
add    %ecx,%eax
sub    $0xa0,%eax
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
movzbl %al,%edx
call   1050 <Lcd_PutHZ@plt>
mov    -0x130(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x130(%rbp)
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x8(%rbp)
jmp    1278 <Lcd_Printf+0x148>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x130(%rbp),%rax
mov    (%rax),%al
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
movzbl %al,%edx
call   1040 <Lcd_PutASCII@plt>
mov    -0x8(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x8(%rbp)
jmp    127d <Lcd_Printf+0x14d>
mov    -0x130(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x130(%rbp)
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
cmpl   $0x100,-0x134(%rbp)
jbe    12b3 <Lcd_Printf+0x183>
jmp    12b8 <Lcd_Printf+0x188>
jmp    1177 <Lcd_Printf+0x47>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Lcd_Printf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %r8d,0xc(%rsp)
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%ebp
mov    %edi,%r13d
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r9,%rsi
call   1030 <xsprintf@plt>
xor    %r14d,%r14d
jmp    119c <Lcd_Printf+0x6c>
cs nopw 0x0(%rax,%rax,1)
movzbl %al,%edx
mov    %r13d,%edi
mov    %ebp,%esi
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    0xc(%rsp),%r9d
call   1040 <Lcd_PutASCII@plt>
add    $0x8,%ebp
add    $0x1,%rbx
add    $0x1,%r14d
cmp    $0x101,%r14d
jae    11dc <Lcd_Printf+0xac>
movzbl (%rbx),%eax
cmp    $0xa,%al
je     118b <Lcd_Printf+0x5b>
test   %al,%al
je     11dc <Lcd_Printf+0xac>
cmp    $0xa1,%al
jb     1170 <Lcd_Printf+0x40>
movzbl 0x1(%rbx),%ecx
cmp    $0xa1,%cl
jb     1170 <Lcd_Printf+0x40>
add    $0x1,%rbx
add    $0x60,%cl
movzbl %cl,%edx
mov    %r13d,%edi
mov    %ebp,%esi
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    0xc(%rsp),%r9d
call   1050 <Lcd_PutHZ@plt>
add    $0x1,%r14d
add    $0x10,%ebp
jmp    118b <Lcd_Printf+0x5b>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @Lcd_Printf(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* %5, ...) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca [256 x i8]
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i8* %5, i8** %12
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
store i8* %17, i8** %15
store i32 0, i32* %16
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%19 = load i8*, i8** %12
%20 = call i32 @xsprintf(i8* %18, i8* %19)
br label %21
21: ; preds = %90, %6
%22 = load i8*, i8** %15
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %91
26: ; preds = %21
%27 = load i8*, i8** %15
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
switch i32 %29, label %31 [
i32 10, label %30
]
30: ; preds = %26
br label %82
31: ; preds = %26
%32 = load i8*, i8** %15
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = icmp sgt i32 %34, 160
%36 = zext i1 %35 to i32
%37 = load i8*, i8** %15
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = icmp sgt i32 %40, 160
%42 = zext i1 %41 to i32
%43 = and i32 %36, %42
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %70
45: ; preds = %31
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = load i8*, i8** %15
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = sub nsw i32 %50, 160
%52 = mul nsw i32 %51, 256
%53 = load i8*, i8** %15
%54 = getelementptr inbounds i8, i8* %53, i64 1
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = add nsw i32 %52, %56
%58 = sub nsw i32 %57, 160
%59 = trunc i32 %58 to i8
%60 = load i32, i32* %9
%61 = load i32, i32* %10
%62 = load i32, i32* %11
%63 = call i32 @Lcd_PutHZ(i32 %46, i32 %47, i8 zeroext %59, i32 %60, i32 %61, i32 %62)
%64 = load i8*, i8** %15
%65 = getelementptr inbounds i8, i8* %64, i32 1
store i8* %65, i8** %15
%66 = load i32, i32* %16
%67 = add i32 %66, 1
store i32 %67, i32* %16
%68 = load i32, i32* %8
%69 = add i32 %68, 16
store i32 %69, i32* %8
br label %81
70: ; preds = %31
%71 = load i32, i32* %7
%72 = load i32, i32* %8
%73 = load i8*, i8** %15
%74 = load i8, i8* %73
%75 = load i32, i32* %9
%76 = load i32, i32* %10
%77 = load i32, i32* %11
%78 = call i32 @Lcd_PutASCII(i32 %71, i32 %72, i8 zeroext %74, i32 %75, i32 %76, i32 %77)
%79 = load i32, i32* %8
%80 = add i32 %79, 8
store i32 %80, i32* %8
br label %81
81: ; preds = %70, %45
br label %82
82: ; preds = %81, %30
%83 = load i8*, i8** %15
%84 = getelementptr inbounds i8, i8* %83, i32 1
store i8* %84, i8** %15
%85 = load i32, i32* %16
%86 = add i32 %85, 1
store i32 %86, i32* %16
%87 = load i32, i32* %16
%88 = icmp ugt i32 %87, 256
br i1 %88, label %89, label %90
89: ; preds = %82
br label %91
90: ; preds = %82
br label %21
91: ; preds = %89, %21
ret void
}

LLVM IR (-O2):
define void @Lcd_Printf(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* %5, ...) {
%7 = alloca [256 x i8]
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%9 = call i32 @xsprintf(i8* %8, i8* %5)
br label %10
10: ; preds = %29, %6
%11 = phi i32 [ %1, %6 ], [ %30, %29 ]
%12 = phi i8* [ %8, %6 ], [ %33, %29 ]
%13 = phi i32 [ 0, %6 ], [ %34, %29 ]
%14 = load i8, i8* %12
switch i8 %14, label %15 [
i8 0, label %36
i8 10, label %29
]
15: ; preds = %10
%16 = icmp ugt i8 %14, -96
%17 = getelementptr inbounds i8, i8* %12, i64 1
%18 = load i8, i8* %17
%19 = icmp ugt i8 %18, -96
%20 = and i1 %16, %19
br i1 %20, label %21, label %26
21: ; preds = %15
%22 = add nsw i8 %18, 96
%23 = call i32 @Lcd_PutHZ(i32 %0, i32 %11, i8 zeroext %22, i32 %2, i32 %3, i32 %4)
%24 = add nuw nsw i32 %13, 1
%25 = add i32 %11, 16
br label %29
26: ; preds = %15
%27 = call i32 @Lcd_PutASCII(i32 %0, i32 %11, i8 zeroext %14, i32 %2, i32 %3, i32 %4)
%28 = add i32 %11, 8
br label %29
29: ; preds = %10, %21, %26
%30 = phi i32 [ %25, %21 ], [ %28, %26 ], [ %11, %10 ]
%31 = phi i8* [ %17, %21 ], [ %12, %26 ], [ %12, %10 ]
%32 = phi i32 [ %24, %21 ], [ %13, %26 ], [ %13, %10 ]
%33 = getelementptr inbounds i8, i8* %31, i64 1
%34 = add i32 %32, 1
%35 = icmp ugt i32 %34, 256
br i1 %35, label %36, label %10
36: ; preds = %10, %29
ret void
}