#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 strleng(char *);
int /*<<< orphan*/ sysWriteChar(char, int, int, int);
void sysPrintString(char *string, int B, int G, int R) {
  int len = strleng(string);
  int i;
  for (i = 0; i < len; i++) {
    sysWriteChar(string[i], B, G, R);
  }
}


x86 assembly (clang, -O0):
<sysPrintString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strleng@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    117e <sysPrintString+0x5e>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
movsbl %al,%edi
call   1040 <sysWriteChar@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1148 <sysPrintString+0x28>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sysPrintString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%r13
call   1030 <strleng@plt>
test   %eax,%eax
jle    116d <sysPrintString+0x4d>
mov    %eax,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl 0x0(%r13,%rbp,1),%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1040 <sysWriteChar@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1150 <sysPrintString+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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