#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 */
scalar_t__ oled_fb_writechar(int, int const, char, int const);
void oled_fb_writestring(const int x, const int y, char *text, const int mode) {
  int sx = x;
  for (; *text; text++)
    sx += oled_fb_writechar(sx, y, *text, mode);
}


x86 assembly (clang, -O0):
<oled_fb_writestring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     116d <oled_fb_writestring+0x5d>
mov    -0x18(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    -0x14(%rbp),%ecx
movsbl %al,%edx
call   1030 <oled_fb_writechar@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112b <oled_fb_writestring+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oled_fb_writestring>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    (%rdx),%cl
test   %cl,%cl
je     114f <oled_fb_writestring+0x3f>
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %edi,%ebp
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl %cl,%edx
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r14d,%ecx
call   1030 <oled_fb_writechar@plt>
add    %ebp,%eax
movzbl (%rbx),%ecx
add    $0x1,%rbx
mov    %eax,%ebp
test   %cl,%cl
jne    1130 <oled_fb_writestring+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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