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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
void dump_raw_message(char updown, uint8_t *data, int len, int rs_errors) {
  int i;
  fprintf(stdout, "%c", updown);
  for (i = 0; i < len; ++i) {
    fprintf(stdout, "%02x", data[i]);
  }
  if (rs_errors)
    fprintf(stdout, ";rs=%d", rs_errors);
  fprintf(stdout, ";\n");
}


x86 assembly (clang, -O0):
<dump_raw_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
movsbl -0x1(%rbp),%edx
lea    0xec4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1186 <dump_raw_message+0x76>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <dump_raw_message+0x3a>
cmpl   $0x0,-0x18(%rbp)
je     11aa <dump_raw_message+0x9a>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_raw_message>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%r13
mov    %edi,%edx
mov    0x2eb4(%rip),%r15
mov    (%r15),%edi
lea    0xeca(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %ebp,%ebp
jle    116b <dump_raw_message+0x5b>
mov    %ebp,%ebp
lea    0xeb9(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r15),%edi
mov    0x0(%r13,%rbx,4),%edx
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <dump_raw_message+0x40>
test   %r14d,%r14d
je     1184 <dump_raw_message+0x74>
mov    (%r15),%edi
lea    0xe8e(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xe81(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [3 x i8] c"%c\00"
@.str.1 = [5 x i8] c"%02x\00"
@.str.2 = [7 x i8] c";rs=%d\00"
@.str.3 = [3 x i8] c";\0A\00"
define void @dump_raw_message(i8 signext %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i8
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8 %0, i8* %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* @stdout
%11 = load i8, i8* %5
%12 = sext i8 %11 to i32
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
store i32 0, i32* %9
br label %14
14: ; preds = %26, %4
%15 = load i32, i32* %9
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = load i32, i32* @stdout
%20 = load i32*, i32** %6
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* %23
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
br label %14
29: ; preds = %14
%30 = load i32, i32* %8
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load i32, i32* @stdout
%34 = load i32, i32* %8
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %32, %29
%37 = load i32, i32* @stdout
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [3 x i8] c"%c\00"
@.str.1 = [5 x i8] c"%02x\00"
@.str.2 = [7 x i8] c";rs=%d\00"
@.str.3 = [3 x i8] c";\0A\00"
define void @dump_raw_message(i8 signext %0, i32* nocapture %1, i32 %2, i32 %3) {
%5 = load i32, i32* @stdout
%6 = sext i8 %0 to i32
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %19
9: ; preds = %4
%10 = zext i32 %2 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %17, %11 ]
%13 = load i32, i32* @stdout
%14 = getelementptr inbounds i32, i32* %1, i64 %12
%15 = load i32, i32* %14
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, %10
br i1 %18, label %19, label %11
19: ; preds = %11, %4
%20 = icmp eq i32 %3, 0
br i1 %20, label %24, label %21
21: ; preds = %19
%22 = load i32, i32* @stdout
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %3)
br label %24
24: ; preds = %21, %19
%25 = load i32, i32* @stdout
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret void
}