#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*/ avrdude_message(int const, char *, ...);
void dump_mem(const int msglvl, const unsigned char *buf, size_t len) {
  size_t i;
  for (i = 0; i < len; i++) {
    if (i % 8 == 0)
      avrdude_message(msglvl, "\t");
    avrdude_message(msglvl, "0x%02x ", buf[i]);
    if (i % 8 == 3)
      avrdude_message(msglvl, "  ");
    else if (i % 8 == 7)
      avrdude_message(msglvl, "\n");
  }
  if (i % 8 != 7)
    avrdude_message(msglvl, "\n");
}


x86 assembly (clang, -O0):
<dump_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11df <dump_mem+0xcf>
mov    -0x20(%rbp),%rax
and    $0x7,%rax
cmp    $0x0,%rax
jne    115c <dump_mem+0x4c>
mov    -0x4(%rbp),%edi
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1030 <avrdude_message@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1030 <avrdude_message@plt>
mov    -0x20(%rbp),%rax
and    $0x7,%rax
cmp    $0x3,%rax
jne    11a1 <dump_mem+0x91>
mov    -0x4(%rbp),%edi
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1030 <avrdude_message@plt>
jmp    11c9 <dump_mem+0xb9>
mov    -0x20(%rbp),%rax
and    $0x7,%rax
cmp    $0x7,%rax
jne    11c4 <dump_mem+0xb4>
mov    -0x4(%rbp),%edi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1030 <avrdude_message@plt>
jmp    11c9 <dump_mem+0xb9>
jmp    11ce <dump_mem+0xbe>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112b <dump_mem+0x1b>
mov    -0x20(%rbp),%rax
and    $0x7,%rax
cmp    $0x7,%rax
je     1202 <dump_mem+0xf2>
mov    -0x4(%rbp),%edi
lea    0xe12(%rip),%rsi
mov    $0x0,%al
call   1030 <avrdude_message@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_mem>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
test   %rdx,%rdx
je     11ca <dump_mem+0xba>
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xecf(%rip),%r13
xor    %ebp,%ebp
jmp    116a <dump_mem+0x5a>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
lea    0xeb7(%rip),%rsi
xor    %eax,%eax
call   1030 <avrdude_message@plt>
movzbl (%r15,%rbp,1),%edx
mov    %ebx,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <avrdude_message@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
je     11b2 <dump_mem+0xa2>
mov    %rbp,%r12
and    $0x7,%r12
je     1140 <dump_mem+0x30>
movzbl (%r15,%rbp,1),%edx
mov    %ebx,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <avrdude_message@plt>
cmp    $0x7,%r12
je     11a0 <dump_mem+0x90>
cmp    $0x3,%r12
jne    1161 <dump_mem+0x51>
mov    %ebx,%edi
lea    0xe71(%rip),%rsi
jmp    11a9 <dump_mem+0x99>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
lea    0xe64(%rip),%rsi
xor    %eax,%eax
call   1030 <avrdude_message@plt>
jmp    1161 <dump_mem+0x51>
not    %r14d
test   $0x7,%r14b
jne    11ca <dump_mem+0xba>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe3c(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <avrdude_message@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"\09\00"
@.str.1 = [8 x i8] c"0x%02x \00"
@.str.2 = [3 x i8] c" \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @dump_mem(i32 %0, i8* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %30, label %5
5: ; preds = %3, %24
%6 = phi i64 [ %25, %24 ], [ 0, %3 ]
%7 = and i64 %6, 7
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = tail call i32 (i32, i8*, ...) @avrdude_message(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds i8, i8* %1, i64 %6
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = tail call i32 (i32, i8*, ...) @avrdude_message(i32 %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %24
15: ; preds = %5
%16 = getelementptr inbounds i8, i8* %1, i64 %6
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = tail call i32 (i32, i8*, ...) @avrdude_message(i32 %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %18)
switch i64 %7, label %24 [
i64 3, label %20
i64 7, label %22
]
20: ; preds = %15
%21 = tail call i32 (i32, i8*, ...) @avrdude_message(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %24
22: ; preds = %15
%23 = tail call i32 (i32, i8*, ...) @avrdude_message(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %9, %15, %20, %22
%25 = add nuw i64 %6, 1
%26 = icmp eq i64 %25, %2
br i1 %26, label %27, label %5
27: ; preds = %24
%28 = and i64 %2, 7
%29 = icmp eq i64 %28, 7
br i1 %29, label %32, label %30
30: ; preds = %3, %27
%31 = tail call i32 (i32, i8*, ...) @avrdude_message(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
ret void
}