#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*/ put_char(char, int, int, int, int /*<<< orphan*/,
                            int /*<<< orphan*/, int, unsigned char *);
int strlen(char *);
int print_string(char *string, int x, int y, int color, int which_font,
                 unsigned char *buffer) {
  int i;
  for (i = 0; i < strlen(string); i++) {
    put_char(string[i], x + (i * 8), y, color, 0, 0, which_font, buffer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<print_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11ab <print_string+0x8b>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%dil
mov    -0xc(%rbp),%esi
mov    -0x24(%rbp),%eax
shl    $0x3,%eax
add    %eax,%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r10d
mov    -0x20(%rbp),%rax
xor    %r9d,%r9d
movsbl %dil,%edi
mov    %r9d,%r8d
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <put_char@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1144 <print_string+0x24>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,(%rsp)
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    1187 <print_string+0x67>
xor    %r14d,%r14d
nopl   0x0(%rax)
movsbl (%rbx,%r14,1),%edi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   (%rsp)
push   %r15
call   1040 <put_char@plt>
add    $0x10,%rsp
add    $0x1,%r14
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
add    $0x8,%ebp
cmp    %rax,%r14
jl     1150 <print_string+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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