#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_string(const unsigned int cell, const char *str,
                          unsigned char fg, unsigned char bg) {
  unsigned int i = cell;
  while (*str != '\0') {
    fb_write_cell(i, *str, fg, bg);
    i += 2;
    ++str;
  }
}


x86 assembly (clang, -O0):
<fb_write_cell_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1174 <fb_write_cell_string+0x64>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x11(%rbp),%al
movsbl %cl,%esi
movzbl %al,%edx
movzbl -0x12(%rbp),%ecx
call   1030 <fb_write_cell@plt>
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112f <fb_write_cell_string+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fb_write_cell_string>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rsi),%al
test   %al,%al
je     114e <fb_write_cell_string+0x3e>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0x1,%rbx
movzbl %dl,%r14d
movzbl %cl,%r15d
xchg   %ax,%ax
movsbl %al,%esi
mov    %ebp,%edi
mov    %r14d,%edx
mov    %r15d,%ecx
call   1030 <fb_write_cell@plt>
add    $0x2,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <fb_write_cell_string+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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