#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 */
struct fb_info {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fb_clear_area(struct fb_info *, int, int, int, int);
int /*<<< orphan*/ fb_put_char(struct fb_info *, int, int, char, int);
int strlen(char *);
int fb_put_string(struct fb_info *fb_info, int x, int y, char *s, int maxlen,
                  int color, int clear, int clearlen) {
  int i;
  int w = 0;
  if (clear)
    fb_clear_area(fb_info, x, y, clearlen * 8, 8);
  for (i = 0; i < strlen(s) && i < maxlen; i++) {
    fb_put_char(fb_info, (x + 8 * i), y, s[i], color);
    w += 8;
  }
  return w;
}


x86 assembly (clang, -O0):
<fb_put_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x0,0x10(%rbp)
je     1180 <fb_put_string+0x50>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    0x18(%rbp),%ecx
shl    $0x3,%ecx
mov    $0x8,%r8d
call   1040 <fb_clear_area@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%ecx
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x29(%rbp)
jge    11b4 <fb_put_string+0x84>
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
setl   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11c4 <fb_put_string+0x94>
jmp    1204 <fb_put_string+0xd4>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x24(%rbp),%eax
shl    $0x3,%eax
add    %eax,%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x20(%rbp),%r8d
movsbl %al,%ecx
call   1050 <fb_put_char@plt>
mov    -0x28(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1187 <fb_put_string+0x57>
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fb_put_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0xc(%rsp)
mov    %r8d,%r15d
mov    %rcx,%rbx
mov    %edx,%r12d
mov    %esi,%r14d
mov    %rdi,%r13
cmpl   $0x0,0x50(%rsp)
je     1174 <fb_put_string+0x44>
mov    0x58(%rsp),%ecx
shl    $0x3,%ecx
mov    %r13,%rdi
mov    %r14d,%esi
mov    %r12d,%edx
mov    $0x8,%r8d
call   1040 <fb_clear_area@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
xor    %ebp,%ebp
test   %r15d,%r15d
jle    11dc <fb_put_string+0xac>
mov    %r14,0x10(%rsp)
test   %eax,%eax
jle    11dc <fb_put_string+0xac>
mov    %r15d,%r14d
xor    %ebp,%ebp
mov    $0x1,%r15d
nopw   0x0(%rax,%rax,1)
movsbl -0x1(%rbx,%r15,1),%ecx
mov    0x10(%rsp),%rax
lea    (%rax,%rbp,1),%esi
mov    %r13,%rdi
mov    %r12d,%edx
mov    0xc(%rsp),%r8d
call   1050 <fb_put_char@plt>
add    $0x8,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %r14,%r15
jae    11dc <fb_put_string+0xac>
cltq
lea    0x1(%r15),%rcx
cmp    %rax,%r15
mov    %rcx,%r15
jl     11a0 <fb_put_string+0x70>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.fb_info = type { i32 }
define i32 @fb_put_string(%struct.fb_info* %0, i32 %1, i32 %2, i8* %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca %struct.fb_info*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store %struct.fb_info* %0, %struct.fb_info** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i8* %3, i8** %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
store i32 %7, i32* %16
store i32 0, i32* %18
%19 = load i32, i32* %15
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %8
%22 = load %struct.fb_info*, %struct.fb_info** %9
%23 = load i32, i32* %10
%24 = load i32, i32* %11
%25 = load i32, i32* %16
%26 = mul nsw i32 %25, 8
%27 = call i32 @fb_clear_area(%struct.fb_info* %22, i32 %23, i32 %24, i32 %26, i32 8)
br label %28
28: ; preds = %21, %8
store i32 0, i32* %17
br label %29
29: ; preds = %56, %28
%30 = load i32, i32* %17
%31 = load i8*, i8** %12
%32 = call i32 @strlen(i8* %31)
%33 = icmp slt i32 %30, %32
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i32, i32* %17
%36 = load i32, i32* %13
%37 = icmp slt i32 %35, %36
br label %38
38: ; preds = %34, %29
%39 = phi i1 [ false, %29 ], [ %37, %34 ]
br i1 %39, label %40, label %59
40: ; preds = %38
%41 = load %struct.fb_info*, %struct.fb_info** %9
%42 = load i32, i32* %10
%43 = load i32, i32* %17
%44 = mul nsw i32 8, %43
%45 = add nsw i32 %42, %44
%46 = load i32, i32* %11
%47 = load i8*, i8** %12
%48 = load i32, i32* %17
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = load i8, i8* %50
%52 = load i32, i32* %14
%53 = call i32 @fb_put_char(%struct.fb_info* %41, i32 %45, i32 %46, i8 signext %51, i32 %52)
%54 = load i32, i32* %18
%55 = add nsw i32 %54, 8
store i32 %55, i32* %18
br label %56
56: ; preds = %40
%57 = load i32, i32* %17
%58 = add nsw i32 %57, 1
store i32 %58, i32* %17
br label %29
59: ; preds = %38
%60 = load i32, i32* %18
ret i32 %60
}

LLVM IR (-O2):
%struct.fb_info = type { i32 }
define i32 @fb_put_string(%struct.fb_info* %0, i32 %1, i32 %2, i8* %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = icmp eq i32 %6, 0
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = shl nsw i32 %7, 3
%12 = tail call i32 @fb_clear_area(%struct.fb_info* %0, i32 %1, i32 %2, i32 %11, i32 8)
br label %13
13: ; preds = %10, %8
%14 = tail call i32 @strlen(i8* %3)
%15 = icmp sgt i32 %14, 0
%16 = icmp sgt i32 %4, 0
%17 = and i1 %16, %15
br i1 %17, label %18, label %36
18: ; preds = %13
%19 = zext i32 %4 to i64
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ 0, %18 ], [ %30, %20 ]
%22 = phi i32 [ 0, %18 ], [ %29, %20 ]
%23 = getelementptr inbounds i8, i8* %3, i64 %21
%24 = load i8, i8* %23
%25 = trunc i64 %21 to i32
%26 = shl i32 %25, 3
%27 = add i32 %26, %1
%28 = tail call i32 @fb_put_char(%struct.fb_info* %0, i32 %27, i32 %2, i8 signext %24, i32 %5)
%29 = add nuw nsw i32 %22, 8
%30 = add nuw nsw i64 %21, 1
%31 = tail call i32 @strlen(i8* %3)
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
%34 = icmp ult i64 %30, %19
%35 = and i1 %34, %33
br i1 %35, label %20, label %36
36: ; preds = %20, %13
%37 = phi i32 [ 0, %13 ], [ %29, %20 ]
ret i32 %37
}