#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 int /*<<< orphan*/ uint8_t;

/* Variables and functions */
size_t strLen(char *);
int /*<<< orphan*/ vga_setChar(char, int /*<<< orphan*/, size_t, size_t);
void vga_setString(char *string, uint8_t color, size_t x, size_t y) {
  size_t stringLength = strLen(string);
  for (size_t i = 0; i < stringLength; i++) {
    vga_setChar(string[i], color, x + i, y);
  }
}


x86 assembly (clang, -O0):
<vga_setString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strLen@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    118d <vga_setString+0x6d>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
add    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rcx
movsbl %al,%edi
call   1040 <vga_setChar@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    114c <vga_setString+0x2c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vga_setString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%r12d
mov    %rdi,%r13
call   1030 <strLen@plt>
test   %rax,%rax
je     116e <vga_setString+0x4e>
mov    %rax,%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movsbl 0x0(%r13,%rbx,1),%edi
lea    (%r15,%rbx,1),%rdx
mov    %r12d,%esi
mov    %r14,%rcx
call   1040 <vga_setChar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <vga_setString+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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