#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*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ put_char_there(char, int, int, int /*<<< orphan*/,
                                  int /*<<< orphan*/);
int strlen(char *);
void put_string_on_line(char *c, int row, int offset, uint16_t color,
                        uint16_t background_color) {
  int len = strlen(c);
  for (int i = 0; i < len; i++)
    put_char_there(c[i], row, offset + i, color, background_color);
}


x86 assembly (clang, -O0):
<put_string_on_line>:
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    %r8d,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1189 <put_string_on_line+0x69>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    -0x20(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
movsbl %al,%edi
call   1030 <put_char_there@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114c <put_string_on_line+0x2c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_string_on_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,0x4(%rsp)
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %esi,%r13d
mov    %rdi,%r12
call   1040 <strlen@plt>
test   %eax,%eax
jle    1172 <put_string_on_line+0x52>
mov    %eax,%ebx
mov    %ebp,%ebp
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
movsbl (%r12,%r14,1),%edi
lea    (%r14,%rbp,1),%edx
mov    %r13d,%esi
mov    %r15d,%ecx
mov    0x4(%rsp),%r8d
call   1030 <put_char_there@plt>
add    $0x1,%r14
cmp    %r14,%rbx
jne    1150 <put_string_on_line+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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