#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*/ console_Output1Line(char *, int);
int console_findLineEnd(char *);
char *console_processCodes(char *);
int /*<<< orphan*/ console_update();
int strlen(char *);
void CONSOLE_Output(char *str) {
  int len;
  int len_total;
  char *str_work;
  len_total = strlen(str);
  str_work = str;
  while (str_work < str + len_total) {
    len = console_findLineEnd(str_work);
    if (len > 0) {
      console_Output1Line(str_work, len);
      str_work += len;
    }
    str_work = console_processCodes(str_work);
  }
  console_update();
}


x86 assembly (clang, -O0):
<CONSOLE_Output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    11cd <CONSOLE_Output+0x7d>
mov    -0x18(%rbp),%rdi
call   1060 <console_findLineEnd@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11bb <CONSOLE_Output+0x6b>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <console_Output1Line@plt>
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <console_processCodes@plt>
mov    %rax,-0x18(%rbp)
jmp    1170 <CONSOLE_Output+0x20>
mov    $0x0,%al
call   1040 <console_update@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CONSOLE_Output>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1050 <strlen@plt>
test   %eax,%eax
jle    119f <CONSOLE_Output+0x4f>
movslq %eax,%r14
add    %rbx,%r14
jmp    1180 <CONSOLE_Output+0x30>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <console_processCodes@plt>
mov    %rax,%rbx
cmp    %r14,%rax
jae    119f <CONSOLE_Output+0x4f>
mov    %rbx,%rdi
call   1060 <console_findLineEnd@plt>
test   %eax,%eax
jle    1170 <CONSOLE_Output+0x20>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <console_Output1Line@plt>
mov    %ebp,%eax
add    %rax,%rbx
jmp    1170 <CONSOLE_Output+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <console_update@plt>

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

LLVM IR (-O2):
define void @CONSOLE_Output(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %18
6: ; preds = %1, %14
%7 = phi i8* [ %16, %14 ], [ %0, %1 ]
%8 = tail call i32 @console_findLineEnd(i8* %7)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = tail call i32 @console_Output1Line(i8* %7, i32 %8)
%12 = zext i32 %8 to i64
%13 = getelementptr inbounds i8, i8* %7, i64 %12
br label %14
14: ; preds = %10, %6
%15 = phi i8* [ %13, %10 ], [ %7, %6 ]
%16 = tail call i8* @console_processCodes(i8* %15)
%17 = icmp ult i8* %16, %4
br i1 %17, label %6, label %18
18: ; preds = %14, %1
%19 = tail call i32 (...) @console_update()
ret void
}