#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 scalar_t__ uint32_t;
typedef int uint16_t;
typedef int /*<<< orphan*/ int16_t;

/* Variables and functions */
int /*<<< orphan*/ BSP_LCD_DrawChar(int, int, char, int /*<<< orphan*/, int,
                                    int);
uint32_t BSP_LCD_DrawString(uint16_t x, uint16_t y, char *pt,
                            int16_t textColor) {
  uint32_t count = 0;
  if (y > 12)
    return 0;
  while (*pt) {
    BSP_LCD_DrawChar(x * 6, y * 10, *pt, textColor, 0x0000, 1);
    pt++;
    x = x + 1;
    if (x > 20)
      return count;
    count++;
  }
  return count;
}


x86 assembly (clang, -O0):
<BSP_LCD_DrawString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
cmpl   $0xc,-0x10(%rbp)
jle    1144 <BSP_LCD_DrawString+0x34>
movq   $0x0,-0x8(%rbp)
jmp    11bd <BSP_LCD_DrawString+0xad>
jmp    1149 <BSP_LCD_DrawString+0x39>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b5 <BSP_LCD_DrawString+0xa5>
imul   $0x6,-0xc(%rbp),%edi
imul   $0xa,-0x10(%rbp),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    -0x1c(%rbp),%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
movsbl %al,%edx
call   1030 <BSP_LCD_DrawChar@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x14,-0xc(%rbp)
jle    11a4 <BSP_LCD_DrawString+0x94>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11bd <BSP_LCD_DrawString+0xad>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1149 <BSP_LCD_DrawString+0x39>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BSP_LCD_DrawString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0xc,%esi
jg     1181 <BSP_LCD_DrawString+0x71>
mov    %rdx,%r12
mov    (%rdx),%al
test   %al,%al
je     1181 <BSP_LCD_DrawString+0x71>
mov    %ecx,%r14d
add    %esi,%esi
lea    (%rsi,%rsi,4),%r15d
cmp    $0x15,%edi
mov    $0x14,%r13d
cmovge %edi,%r13d
sub    %edi,%r13d
add    %edi,%edi
lea    (%rdi,%rdi,2),%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
movsbl %al,%edx
mov    %ebx,%edi
mov    %r15d,%esi
mov    %r14d,%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1030 <BSP_LCD_DrawChar@plt>
cmp    %rbp,%r13
je     1185 <BSP_LCD_DrawString+0x75>
movzbl 0x1(%r12,%rbp,1),%eax
add    $0x1,%rbp
add    $0x6,%ebx
test   %al,%al
jne    1150 <BSP_LCD_DrawString+0x40>
jmp    1188 <BSP_LCD_DrawString+0x78>
xor    %ebp,%ebp
jmp    1188 <BSP_LCD_DrawString+0x78>
mov    %r13,%rbp
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i64 @BSP_LCD_DrawString(i32 %0, i32 %1, i8* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %1, 12
br i1 %5, label %28, label %6
6: ; preds = %4
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
br i1 %8, label %28, label %9
9: ; preds = %6
%10 = mul nsw i32 %1, 10
%11 = call i32 @llvm.smax.i32(i32 %0, i32 20)
%12 = sub i32 %11, %0
%13 = zext i32 %12 to i64
br label %14
14: ; preds = %9, %22
%15 = phi i8 [ %7, %9 ], [ %26, %22 ]
%16 = phi i64 [ 0, %9 ], [ %25, %22 ]
%17 = phi i8* [ %2, %9 ], [ %24, %22 ]
%18 = phi i32 [ %0, %9 ], [ %23, %22 ]
%19 = mul nsw i32 %18, 6
%20 = tail call i32 @BSP_LCD_DrawChar(i32 %19, i32 %10, i8 signext %15, i32 %3, i32 0, i32 1)
%21 = icmp eq i64 %16, %13
br i1 %21, label %28, label %22
22: ; preds = %14
%23 = add nsw i32 %18, 1
%24 = getelementptr inbounds i8, i8* %17, i64 1
%25 = add nuw nsw i64 %16, 1
%26 = load i8, i8* %24
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %14
28: ; preds = %14, %22, %6, %4
%29 = phi i64 [ 0, %4 ], [ 0, %6 ], [ %13, %14 ], [ %25, %22 ]
ret i64 %29
}