#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 char uint8_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fwrite(char *, int, unsigned int, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void txt_msg(uint8_t *data, unsigned int len, void *state) {
  if (len == 0 || (data[0] != '-' && data[0] != '='))
    fprintf(stdout, "--0000-- ");
  fwrite(data, 1, len, stdout);
  fprintf(stdout, "\n");
}


x86 assembly (clang, -O0):
<txt_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     115d <txt_msg+0x3d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1172 <txt_msg+0x52>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
je     1172 <txt_msg+0x52>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    0x2e60(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1040 <fwrite@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<txt_msg>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
test   %esi,%esi
je     1137 <txt_msg+0x17>
mov    (%r14),%al
or     $0x10,%al
cmp    $0x3d,%al
je     114c <txt_msg+0x2c>
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    0xeb9(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e8d(%rip),%r15
mov    (%r15),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   1040 <fwrite@plt>
mov    (%r15),%edi
lea    0xe9b(%rip),%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [10 x i8] c"--0000-- \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @txt_msg(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %21, label %9
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 45
br i1 %14, label %15, label %24
15: ; preds = %9
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 61
br i1 %20, label %21, label %24
21: ; preds = %15, %3
%22 = load i32, i32* @stdout
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %21, %15, %9
%25 = load i8*, i8** %4
%26 = load i32, i32* %5
%27 = load i32, i32* @stdout
%28 = call i32 @fwrite(i8* %25, i32 1, i32 %26, i32 %27)
%29 = load i32, i32* @stdout
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [10 x i8] c"--0000-- \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @txt_msg(i8* %0, i32 %1, i8* nocapture readnone %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = load i8, i8* %0
switch i8 %6, label %7 [
i8 45, label %10
i8 61, label %10
]
7: ; preds = %5, %3
%8 = load i32, i32* @stdout
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %5, %5, %7
%11 = load i32, i32* @stdout
%12 = tail call i32 @fwrite(i8* %0, i32 1, i32 %1, i32 %11)
%13 = load i32, i32* @stdout
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}