#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 */
typedef int /*<<< orphan*/ txt;

/* Variables and functions */
int /*<<< orphan*/ I_OutputMsg(char *, char *);
int /*<<< orphan*/ memset(char *, char, int);
void CON_LogMessage(const char *msg) {
  char txt[8192], *t;
  const char *p = msg, *e = txt + sizeof(txt) - 2;
  for (t = txt; *p != '\0'; p++) {
    if (*p == '\n' || *p >= ' ')
      *t++ = *p;
    if (t >= e) {
      *t = '\0';
      I_OutputMsg("%s", txt);
      t = txt;
      memset(txt, '\0', sizeof(txt));
    }
  }
  *t = '\0';
  I_OutputMsg("%s", txt);
}


x86 assembly (clang, -O0):
<CON_LogMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x2020(%rbp)
lea    -0x2010(%rbp),%rax
add    $0x2000,%rax
add    $0xfffffffffffffffe,%rax
mov    %rax,-0x2028(%rbp)
lea    -0x2010(%rbp),%rax
mov    %rax,-0x2018(%rbp)
mov    -0x2020(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1227 <CON_LogMessage+0x107>
mov    -0x2020(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     1199 <CON_LogMessage+0x79>
mov    -0x2020(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jl     11b9 <CON_LogMessage+0x99>
mov    -0x2020(%rbp),%rax
mov    (%rax),%cl
mov    -0x2018(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x2018(%rbp)
mov    %cl,(%rax)
mov    -0x2018(%rbp),%rax
cmp    -0x2028(%rbp),%rax
jb     120b <CON_LogMessage+0xeb>
mov    -0x2018(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x2010(%rbp),%rsi
lea    0xe1b(%rip),%rdi
call   1040 <I_OutputMsg@plt>
lea    -0x2010(%rbp),%rax
mov    %rax,-0x2018(%rbp)
lea    -0x2010(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1030 <memset@plt>
jmp    1210 <CON_LogMessage+0xf0>
mov    -0x2020(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2020(%rbp)
jmp    1160 <CON_LogMessage+0x40>
mov    -0x2018(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x2010(%rbp),%rsi
lea    0xdc1(%rip),%rdi
call   1040 <I_OutputMsg@plt>
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CON_LogMessage>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2008,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
lea    0x1ffe(%rsp),%r12
lea    0xebd(%rip),%r15
mov    %r14,%rax
jmp    1154 <CON_LogMessage+0x34>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
movzbl (%rbx),%ecx
cmp    $0xa,%cl
je     1165 <CON_LogMessage+0x45>
test   %cl,%cl
je     1192 <CON_LogMessage+0x72>
cmp    $0x20,%cl
jl     116b <CON_LogMessage+0x4b>
mov    %cl,(%rax)
add    $0x1,%rax
cmp    %r12,%rax
jb     1150 <CON_LogMessage+0x30>
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <I_OutputMsg@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1030 <memset@plt>
mov    %r14,%rax
jmp    1150 <CON_LogMessage+0x30>
movb   $0x0,(%rax)
lea    0xe64(%rip),%rdi
mov    %rsp,%rsi
call   1040 <I_OutputMsg@plt>
add    $0x2008,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @CON_LogMessage(i8* %0) {
%2 = alloca i8*
%3 = alloca [8192 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %2
%7 = load i8*, i8** %2
store i8* %7, i8** %5
%8 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds i8, i8* %8, i64 8192
%10 = getelementptr inbounds i8, i8* %9, i64 -2
store i8* %10, i8** %6
%11 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
store i8* %11, i8** %4
br label %12
12: ; preds = %44, %1
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %47
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 10
br i1 %21, label %27, label %22
22: ; preds = %17
%23 = load i8*, i8** %5
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp sge i32 %25, 32
br i1 %26, label %27, label %32
27: ; preds = %22, %17
%28 = load i8*, i8** %5
%29 = load i8, i8* %28
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %4
store i8 %29, i8* %30
br label %32
32: ; preds = %27, %22
%33 = load i8*, i8** %4
%34 = load i8*, i8** %6
%35 = icmp uge i8* %33, %34
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i8*, i8** %4
store i8 0, i8* %37
%38 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%39 = call i32 @I_OutputMsg(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %38)
%40 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
store i8* %40, i8** %4
%41 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%42 = call i32 @memset(i8* %41, i8 signext 0, i32 8192)
br label %43
43: ; preds = %36, %32
br label %44
44: ; preds = %43
%45 = load i8*, i8** %5
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %5
br label %12
47: ; preds = %12
%48 = load i8*, i8** %4
store i8 0, i8* %48
%49 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%50 = call i32 @I_OutputMsg(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %49)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @CON_LogMessage(i8* nocapture %0) {
%2 = alloca [8192 x i8]
%3 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 8190
br label %5
5: ; preds = %19, %1
%6 = phi i8* [ %0, %1 ], [ %21, %19 ]
%7 = phi i8* [ %3, %1 ], [ %20, %19 ]
%8 = load i8, i8* %6
switch i8 %8, label %9 [
i8 0, label %22
i8 10, label %11
]
9: ; preds = %5
%10 = icmp sgt i8 %8, 31
br i1 %10, label %11, label %13
11: ; preds = %5, %9
%12 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %8, i8* %7
br label %13
13: ; preds = %11, %9
%14 = phi i8* [ %12, %11 ], [ %7, %9 ]
%15 = icmp ult i8* %14, %4
br i1 %15, label %19, label %16
16: ; preds = %13
store i8 0, i8* %14
%17 = call i32 @I_OutputMsg(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%18 = call i32 @memset(i8* %3, i8 signext 0, i32 8192)
br label %19
19: ; preds = %13, %16
%20 = phi i8* [ %3, %16 ], [ %14, %13 ]
%21 = getelementptr inbounds i8, i8* %6, i64 1
br label %5
22: ; preds = %5
store i8 0, i8* %7
%23 = call i32 @I_OutputMsg(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
ret void
}