#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__ render_char_ex(unsigned char *, int, int, unsigned char, int);
int render_string_ex(unsigned char *font, int x, int y, char *str,
                     int contrast) {
  for (; *str; str++) {
    x += render_char_ex(font, x, y, (unsigned char)*str, contrast);
  }
  return x;
}


x86 assembly (clang, -O0):
<render_string_ex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1171 <render_string_ex+0x61>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    -0x1c(%rbp),%r8d
movzbl %al,%ecx
call   1030 <render_char_ex@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112a <render_string_ex+0x1a>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<render_string_ex>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%rbx
mov    %esi,%ebp
mov    (%rcx),%cl
test   %cl,%cl
je     1154 <render_string_ex+0x44>
mov    %r8d,%r14d
mov    %edx,%r15d
mov    %rdi,%r12
add    $0x1,%rbx
movzbl %cl,%ecx
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %r14d,%r8d
call   1030 <render_char_ex@plt>
add    %ebp,%eax
movzbl (%rbx),%ecx
add    $0x1,%rbx
mov    %eax,%ebp
test   %cl,%cl
jne    1130 <render_string_ex+0x20>
jmp    1156 <render_string_ex+0x46>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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