#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*/ pfan_draw_char(int, char, unsigned short *);
void pfan_draw_text(char *text, int lenght, int lspace,
                    unsigned short display[156]) {
  int i = 0;
  if (lenght == 0 || lenght > (156 / (5 + 1))) {
    return;
  }
  pfan_draw_char(0, text[i], display);
  for (i = 1; i < lenght; ++i) {
    pfan_draw_char(i * (5 + lspace), text[i], display);
  }
}


x86 assembly (clang, -O0):
<pfan_draw_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1141 <pfan_draw_text+0x31>
cmpl   $0x1a,-0xc(%rbp)
jle    1146 <pfan_draw_text+0x36>
jmp    11a3 <pfan_draw_text+0x93>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x18(%rbp),%rdx
xor    %edi,%edi
movsbl %al,%esi
call   1030 <pfan_draw_char@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a3 <pfan_draw_text+0x93>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%eax
add    $0x5,%eax
imul   %eax,%edi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x18(%rbp),%rdx
movsbl %al,%esi
call   1030 <pfan_draw_char@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1166 <pfan_draw_text+0x56>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pfan_draw_text>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     117c <pfan_draw_text+0x6c>
mov    %esi,%r15d
cmp    $0x1a,%esi
jg     117c <pfan_draw_text+0x6c>
mov    %rcx,%r14
mov    %edx,%r12d
mov    %rdi,%r13
movsbl (%rdi),%esi
xor    %edi,%edi
mov    %rcx,%rdx
call   1030 <pfan_draw_char@plt>
cmp    $0x2,%r15d
jl     117c <pfan_draw_text+0x6c>
add    $0x5,%r12d
mov    %r15d,%r15d
mov    $0x1,%ebx
mov    %r12d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl 0x0(%r13,%rbx,1),%esi
mov    %ebp,%edi
mov    %r14,%rdx
call   1030 <pfan_draw_char@plt>
add    $0x1,%rbx
add    %r12d,%ebp
cmp    %rbx,%r15
jne    1160 <pfan_draw_text+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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