#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*/ ST7735_DrawCharS(unsigned short, unsigned short,
                                    unsigned char, short, int, int);
unsigned long ST7735_OutString(unsigned short x, unsigned short y,
                               unsigned char *pt, short textColor) {
  unsigned long count = 0;
  if (y > 15)
    return 0;
  while (*pt) {
    ST7735_DrawCharS(x * 6, y * 10, *pt, textColor, 0x0000, 1);
    pt++;
    x = x + 1;
    if (x > 20)
      return count;
    count++;
  }
  return count;
}


x86 assembly (clang, -O0):
<ST7735_OutString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cx,%ax
mov    %si,%cx
mov    %di,%si
mov    %si,-0xa(%rbp)
mov    %cx,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ax,-0x1a(%rbp)
movq   $0x0,-0x28(%rbp)
movzwl -0xc(%rbp),%eax
cmp    $0xf,%eax
jle    1153 <ST7735_OutString+0x43>
movq   $0x0,-0x8(%rbp)
jmp    11e4 <ST7735_OutString+0xd4>
jmp    1158 <ST7735_OutString+0x48>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11dc <ST7735_OutString+0xcc>
movzwl -0xa(%rbp),%eax
imul   $0x6,%eax,%eax
mov    %ax,%dx
movzwl -0xc(%rbp),%eax
imul   $0xa,%eax,%eax
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    (%rax),%al
xor    %r8d,%r8d
mov    $0x1,%r9d
movzwl %dx,%edi
movzwl %cx,%esi
movzbl %al,%edx
movswl -0x1a(%rbp),%ecx
call   1030 <ST7735_DrawCharS@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
movzwl -0xa(%rbp),%eax
add    $0x1,%eax
mov    %ax,-0xa(%rbp)
movzwl -0xa(%rbp),%eax
cmp    $0x14,%eax
jle    11cb <ST7735_OutString+0xbb>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11e4 <ST7735_OutString+0xd4>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1158 <ST7735_OutString+0x48>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ST7735_OutString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0xf,%si
ja     1187 <ST7735_OutString+0x77>
mov    %rdx,%r14
mov    (%rdx),%al
test   %al,%al
je     1187 <ST7735_OutString+0x77>
add    %esi,%esi
lea    (%rsi,%rsi,4),%edx
lea    (%rdi,%rdi,1),%esi
lea    (%rsi,%rsi,2),%ebp
add    $0x1,%edi
movzwl %di,%r13d
xor    %ebx,%ebx
movzwl %dx,%r15d
movswl %cx,%r12d
cs nopw 0x0(%rax,%rax,1)
movzwl %bp,%edi
movzbl %al,%edx
mov    %r15d,%esi
mov    %r12d,%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1030 <ST7735_DrawCharS@plt>
lea    (%rbx,%r13,1),%eax
cmp    $0x14,%ax
ja     1189 <ST7735_OutString+0x79>
movzbl 0x1(%r14,%rbx,1),%eax
add    $0x1,%rbx
add    $0x6,%ebp
test   %al,%al
jne    1150 <ST7735_OutString+0x40>
jmp    1189 <ST7735_OutString+0x79>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @ST7735_OutString(i16 zeroext %0, i16 zeroext %1, i8* %2, i16 signext %3) {
%5 = alloca i64
%6 = alloca i16
%7 = alloca i16
%8 = alloca i8*
%9 = alloca i16
%10 = alloca i64
store i16 %0, i16* %6
store i16 %1, i16* %7
store i8* %2, i8** %8
store i16 %3, i16* %9
store i64 0, i64* %10
%11 = load i16, i16* %7
%12 = zext i16 %11 to i32
%13 = icmp sgt i32 %12, 15
br i1 %13, label %14, label %15
14: ; preds = %4
store i64 0, i64* %5
br label %49
15: ; preds = %4
br label %16
16: ; preds = %44, %15
%17 = load i8*, i8** %8
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %47
20: ; preds = %16
%21 = load i16, i16* %6
%22 = zext i16 %21 to i32
%23 = mul nsw i32 %22, 6
%24 = trunc i32 %23 to i16
%25 = load i16, i16* %7
%26 = zext i16 %25 to i32
%27 = mul nsw i32 %26, 10
%28 = trunc i32 %27 to i16
%29 = load i8*, i8** %8
%30 = load i8, i8* %29
%31 = load i16, i16* %9
%32 = call i32 @ST7735_DrawCharS(i16 zeroext %24, i16 zeroext %28, i8 zeroext %30, i16 signext %31, i32 0, i32 1)
%33 = load i8*, i8** %8
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %8
%35 = load i16, i16* %6
%36 = zext i16 %35 to i32
%37 = add nsw i32 %36, 1
%38 = trunc i32 %37 to i16
store i16 %38, i16* %6
%39 = load i16, i16* %6
%40 = zext i16 %39 to i32
%41 = icmp sgt i32 %40, 20
br i1 %41, label %42, label %44
42: ; preds = %20
%43 = load i64, i64* %10
store i64 %43, i64* %5
br label %49
44: ; preds = %20
%45 = load i64, i64* %10
%46 = add i64 %45, 1
store i64 %46, i64* %10
br label %16
47: ; preds = %16
%48 = load i64, i64* %10
store i64 %48, i64* %5
br label %49
49: ; preds = %47, %42, %14
%50 = load i64, i64* %5
ret i64 %50
}

LLVM IR (-O2):
define i64 @ST7735_OutString(i16 zeroext %0, i16 zeroext %1, i8* nocapture %2, i16 signext %3) {
%5 = icmp ugt i16 %1, 15
br i1 %5, label %25, label %6
6: ; preds = %4
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
br i1 %8, label %25, label %9
9: ; preds = %6
%10 = mul nuw nsw i16 %1, 10
br label %11
11: ; preds = %9, %20
%12 = phi i8 [ %7, %9 ], [ %23, %20 ]
%13 = phi i64 [ 0, %9 ], [ %22, %20 ]
%14 = phi i8* [ %2, %9 ], [ %21, %20 ]
%15 = phi i16 [ %0, %9 ], [ %18, %20 ]
%16 = mul i16 %15, 6
%17 = tail call i32 @ST7735_DrawCharS(i16 zeroext %16, i16 zeroext %10, i8 zeroext %12, i16 signext %3, i32 0, i32 1)
%18 = add i16 %15, 1
%19 = icmp ugt i16 %18, 20
br i1 %19, label %25, label %20
20: ; preds = %11
%21 = getelementptr inbounds i8, i8* %14, i64 1
%22 = add nuw nsw i64 %13, 1
%23 = load i8, i8* %21
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %11
25: ; preds = %11, %20, %6, %4
%26 = phi i64 [ 0, %4 ], [ 0, %6 ], [ %13, %11 ], [ %22, %20 ]
ret i64 %26
}