#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*/ fb_write_cell(unsigned int, char const, unsigned char,
                                 unsigned char);
void fb_write_cell_data(const unsigned int cell, const char *data,
                        const unsigned int len, unsigned char fg,
                        unsigned char bg) {
  unsigned int i = cell;
  const char *dataEnd = data + len;
  while (data < dataEnd) {
    fb_write_cell(i, *data, fg, bg);
    i += 2;
    ++data;
  }
}


x86 assembly (clang, -O0):
<fb_write_cell_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8b,%al
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %cl,-0x15(%rbp)
mov    %al,-0x16(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1182 <fb_write_cell_data+0x72>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x15(%rbp),%al
movsbl %cl,%esi
movzbl %al,%edx
movzbl -0x16(%rbp),%ecx
call   1030 <fb_write_cell@plt>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113f <fb_write_cell_data+0x2f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fb_write_cell_data>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
je     114c <fb_write_cell_data+0x3c>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %edx,%r12d
add    %rsi,%r12
movzbl %cl,%r14d
movzbl %r8b,%r15d
nop
movsbl (%rbx),%esi
mov    %ebp,%edi
mov    %r14d,%edx
mov    %r15d,%ecx
call   1030 <fb_write_cell@plt>
add    $0x2,%ebp
add    $0x1,%rbx
cmp    %r12,%rbx
jb     1130 <fb_write_cell_data+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @fb_write_cell_data(i32 %0, i8* %1, i32 %2, i8 zeroext %3, i8 zeroext %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8
%10 = alloca i8
%11 = alloca i32
%12 = alloca i8*
store i32 %0, i32* %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8 %3, i8* %9
store i8 %4, i8* %10
%13 = load i32, i32* %6
store i32 %13, i32* %11
%14 = load i8*, i8** %7
%15 = load i32, i32* %8
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
store i8* %17, i8** %12
br label %18
18: ; preds = %22, %5
%19 = load i8*, i8** %7
%20 = load i8*, i8** %12
%21 = icmp ult i8* %19, %20
br i1 %21, label %22, label %33
22: ; preds = %18
%23 = load i32, i32* %11
%24 = load i8*, i8** %7
%25 = load i8, i8* %24
%26 = load i8, i8* %9
%27 = load i8, i8* %10
%28 = call i32 @fb_write_cell(i32 %23, i8 signext %25, i8 zeroext %26, i8 zeroext %27)
%29 = load i32, i32* %11
%30 = add i32 %29, 2
store i32 %30, i32* %11
%31 = load i8*, i8** %7
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %7
br label %18
33: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @fb_write_cell_data(i32 %0, i8* %1, i32 %2, i8 zeroext %3, i8 zeroext %4) {
%6 = zext i32 %2 to i64
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = icmp eq i32 %2, 0
br i1 %8, label %17, label %9
9: ; preds = %5, %9
%10 = phi i8* [ %15, %9 ], [ %1, %5 ]
%11 = phi i32 [ %14, %9 ], [ %0, %5 ]
%12 = load i8, i8* %10
%13 = tail call i32 @fb_write_cell(i32 %11, i8 signext %12, i8 zeroext %3, i8 zeroext %4)
%14 = add i32 %11, 2
%15 = getelementptr inbounds i8, i8* %10, i64 1
%16 = icmp ult i8* %15, %7
br i1 %16, label %9, label %17
17: ; preds = %9, %5
ret void
}