#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stderr;
void print_databuffer(char *marker, void *addr, unsigned char *dp, int bcnt) {
  unsigned long laddr = (unsigned long)addr;
  unsigned long *dlp = (unsigned long *)dp;
  int i, cnt;
  cnt = bcnt - (bcnt & 0x03);
  for (i = 0; i < cnt; i += 4, dlp++) {
    if ((i % 16) == 0) {
      fprintf(stderr, "%s%08lx  %08lx", marker, laddr + i, *dlp);
    } else if ((i % 16) == 12) {
      fprintf(stderr, " %08lx\n", *dlp);
    } else {
      fprintf(stderr, " %08lx", *dlp);
    }
  }
  dp = (unsigned char *)dlp;
  if (bcnt - cnt) {
    if ((i % 16) == 0) {
      fprintf(stderr, "%s%08x ", marker, i);
    }
    switch (bcnt - cnt) {
    case 1:
      fprintf(stderr, " %02x\n", *dp);
      break;
    case 2:
      fprintf(stderr, " %04x\n", *(short *)dp & 0x0000ffff);
      break;
    case 3:
      fprintf(stderr, " %04x%02x\n", *(short *)dp & 0x0000ffff, *(dp + 2));
      break;
    }
  } else if (i % 16) {
    putchar('\n');
  }
}


x86 assembly (clang, -O0):
<print_databuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
and    $0x3,%ecx
sub    %ecx,%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1227 <print_databuffer+0x107>
mov    -0x34(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ae <print_databuffer+0x8e>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x28(%rbp),%rcx
movslq -0x34(%rbp),%rax
add    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    (%rax),%r8
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1208 <print_databuffer+0xe8>
mov    -0x34(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xc,%edx
jne    11e5 <print_databuffer+0xc5>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rax
mov    (%rax),%rdx
lea    0xe36(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1203 <print_databuffer+0xe3>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rax
mov    (%rax),%rdx
lea    0xe0c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1208 <print_databuffer+0xe8>
jmp    120d <print_databuffer+0xed>
mov    -0x34(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
jmp    115c <print_databuffer+0x3c>
mov    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x38(%rbp),%eax
cmp    $0x0,%eax
je     1328 <print_databuffer+0x208>
mov    -0x34(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1270 <print_databuffer+0x150>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x34(%rbp),%ecx
lea    0xdae(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
mov    -0x38(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x3c(%rbp)
sub    $0x1,%eax
je     12ab <print_databuffer+0x18b>
jmp    1289 <print_databuffer+0x169>
mov    -0x3c(%rbp),%eax
sub    $0x2,%eax
je     12ce <print_databuffer+0x1ae>
jmp    129a <print_databuffer+0x17a>
mov    -0x3c(%rbp),%eax
sub    $0x3,%eax
je     12f7 <print_databuffer+0x1d7>
jmp    1323 <print_databuffer+0x203>
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
movzbl (%rax),%edx
lea    0xd5d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1323 <print_databuffer+0x203>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
movswl (%rax),%edx
and    $0xffff,%edx
lea    0xd3b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1323 <print_databuffer+0x203>
mov    0x2ce2(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
movswl (%rax),%edx
and    $0xffff,%edx
mov    -0x18(%rbp),%rax
movzbl 0x2(%rax),%ecx
lea    0xd11(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    134b <print_databuffer+0x22b>
mov    -0x34(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1346 <print_databuffer+0x226>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    134b <print_databuffer+0x22b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_databuffer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rdi,%r14
mov    %ecx,%ebp
and    $0x3,%ebp
and    $0xfffffffc,%ecx
jle    11f9 <print_databuffer+0xd9>
mov    %rsi,%r12
mov    %ebp,0x4(%rsp)
mov    %ecx,%ebp
mov    0x2e91(%rip),%r13
xor    %ebx,%ebx
jmp    1182 <print_databuffer+0x62>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13),%edi
mov    (%r15),%rdx
lea    0xe9a(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x4,%rbx
add    $0x8,%r15
cmp    %rbp,%rbx
jae    11c0 <print_databuffer+0xa0>
mov    %ebx,%eax
and    $0xc,%eax
cmp    $0xc,%eax
je     11b0 <print_databuffer+0x90>
test   %eax,%eax
jne    1160 <print_databuffer+0x40>
mov    0x0(%r13),%edi
lea    (%r12,%rbx,1),%rcx
mov    (%r15),%r8
lea    0xe5e(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1175 <print_databuffer+0x55>
xchg   %ax,%ax
mov    0x0(%r13),%edi
mov    (%r15),%rdx
lea    0xe51(%rip),%rsi
jmp    116e <print_databuffer+0x4e>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
je     11ff <print_databuffer+0xdf>
test   $0xc,%bl
je     122b <print_databuffer+0x10b>
cmp    $0x3,%ebp
je     124c <print_databuffer+0x12c>
cmp    $0x2,%ebp
je     127a <print_databuffer+0x15a>
cmp    $0x1,%ebp
jne    121c <print_databuffer+0xfc>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
movzbl (%r15),%edx
lea    0xe2b(%rip),%rsi
jmp    128e <print_databuffer+0x16e>
xor    %ebx,%ebx
test   %ebp,%ebp
jne    11c8 <print_databuffer+0xa8>
test   $0xc,%bl
je     121c <print_databuffer+0xfc>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
mov    %r14,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x3,%ebp
jne    11d2 <print_databuffer+0xb2>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
movzwl (%r15),%edx
movzbl 0x2(%r15),%ecx
lea    0xdc8(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
movzwl (%r15),%edx
lea    0xd98(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"%s%08lx %08lx\00"
@.str.1 = [8 x i8] c" %08lx\0A\00"
@.str.2 = [7 x i8] c" %08lx\00"
@.str.3 = [8 x i8] c"%s%08x \00"
@.str.4 = [7 x i8] c" %02x\0A\00"
@.str.5 = [7 x i8] c" %04x\0A\00"
@.str.6 = [11 x i8] c" %04x%02x\0A\00"
define void @print_databuffer(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64*
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%13 = load i8*, i8** %6
%14 = ptrtoint i8* %13 to i64
store i64 %14, i64* %9
%15 = load i8*, i8** %7
%16 = bitcast i8* %15 to i64*
store i64* %16, i64** %10
%17 = load i32, i32* %8
%18 = load i32, i32* %8
%19 = and i32 %18, 3
%20 = sub nsw i32 %17, %19
store i32 %20, i32* %12
store i32 0, i32* %11
br label %21
21: ; preds = %55, %4
%22 = load i32, i32* %11
%23 = load i32, i32* %12
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %60
25: ; preds = %21
%26 = load i32, i32* %11
%27 = srem i32 %26, 16
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %5
%32 = load i64, i64* %9
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = add i64 %32, %34
%36 = load i64*, i64** %10
%37 = load i64, i64* %36
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %31, i64 %35, i64 %37)
br label %54
39: ; preds = %25
%40 = load i32, i32* %11
%41 = srem i32 %40, 16
%42 = icmp eq i32 %41, 12
br i1 %42, label %43, label %48
43: ; preds = %39
%44 = load i32, i32* @stderr
%45 = load i64*, i64** %10
%46 = load i64, i64* %45
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %46)
br label %53
48: ; preds = %39
%49 = load i32, i32* @stderr
%50 = load i64*, i64** %10
%51 = load i64, i64* %50
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %51)
br label %53
53: ; preds = %48, %43
br label %54
54: ; preds = %53, %29
br label %55
55: ; preds = %54
%56 = load i32, i32* %11
%57 = add nsw i32 %56, 4
store i32 %57, i32* %11
%58 = load i64*, i64** %10
%59 = getelementptr inbounds i64, i64* %58, i32 1
store i64* %59, i64** %10
br label %21
60: ; preds = %21
%61 = load i64*, i64** %10
%62 = bitcast i64* %61 to i8*
store i8* %62, i8** %7
%63 = load i32, i32* %8
%64 = load i32, i32* %12
%65 = sub nsw i32 %63, %64
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %107
67: ; preds = %60
%68 = load i32, i32* %11
%69 = srem i32 %68, 16
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %76
71: ; preds = %67
%72 = load i32, i32* @stderr
%73 = load i8*, i8** %5
%74 = load i32, i32* %11
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %73, i32 %74)
br label %76
76: ; preds = %71, %67
%77 = load i32, i32* %8
%78 = load i32, i32* %12
%79 = sub nsw i32 %77, %78
switch i32 %79, label %106 [
i32 1, label %80
i32 2, label %86
i32 3, label %94
]
80: ; preds = %76
%81 = load i32, i32* @stderr
%82 = load i8*, i8** %7
%83 = load i8, i8* %82
%84 = zext i8 %83 to i32
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %84)
br label %106
86: ; preds = %76
%87 = load i32, i32* @stderr
%88 = load i8*, i8** %7
%89 = bitcast i8* %88 to i16*
%90 = load i16, i16* %89
%91 = sext i16 %90 to i32
%92 = and i32 %91, 65535
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %92)
br label %106
94: ; preds = %76
%95 = load i32, i32* @stderr
%96 = load i8*, i8** %7
%97 = bitcast i8* %96 to i16*
%98 = load i16, i16* %97
%99 = sext i16 %98 to i32
%100 = and i32 %99, 65535
%101 = load i8*, i8** %7
%102 = getelementptr inbounds i8, i8* %101, i64 2
%103 = load i8, i8* %102
%104 = zext i8 %103 to i32
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %100, i32 %104)
br label %106
106: ; preds = %76, %94, %86, %80
br label %114
107: ; preds = %60
%108 = load i32, i32* %11
%109 = srem i32 %108, 16
%110 = icmp ne i32 %109, 0
br i1 %110, label %111, label %113
111: ; preds = %107
%112 = call i32 @putchar(i8 signext 10)
br label %113
113: ; preds = %111, %107
br label %114
114: ; preds = %113, %106
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"%s%08lx %08lx\00"
@.str.1 = [8 x i8] c" %08lx\0A\00"
@.str.2 = [7 x i8] c" %08lx\00"
@.str.3 = [8 x i8] c"%s%08x \00"
@.str.4 = [7 x i8] c" %02x\0A\00"
@.str.5 = [7 x i8] c" %04x\0A\00"
@.str.6 = [11 x i8] c" %04x%02x\0A\00"
define void @print_databuffer(i8* %0, i8* %1, i8* nocapture %2, i32 %3) {
%5 = ptrtoint i8* %1 to i64
%6 = bitcast i8* %2 to i64*
%7 = and i32 %3, 3
%8 = and i32 %3, -4
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %36
10: ; preds = %4
%11 = zext i32 %8 to i64
br label %12
12: ; preds = %10, %30
%13 = phi i64 [ 0, %10 ], [ %31, %30 ]
%14 = phi i64* [ %6, %10 ], [ %32, %30 ]
%15 = trunc i64 %13 to i32
%16 = and i32 %15, 12
switch i32 %16, label %26 [
i32 0, label %17
i32 12, label %22
]
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = add i64 %13, %5
%20 = load i64, i64* %14
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %19, i64 %20)
br label %30
22: ; preds = %12
%23 = load i32, i32* @stderr
%24 = load i64, i64* %14
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %24)
br label %30
26: ; preds = %12
%27 = load i32, i32* @stderr
%28 = load i64, i64* %14
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %28)
br label %30
30: ; preds = %17, %26, %22
%31 = add nuw nsw i64 %13, 4
%32 = getelementptr inbounds i64, i64* %14, i64 1
%33 = icmp ult i64 %31, %11
br i1 %33, label %12, label %34
34: ; preds = %30
%35 = trunc i64 %31 to i32
br label %36
36: ; preds = %34, %4
%37 = phi i64* [ %6, %4 ], [ %32, %34 ]
%38 = phi i32 [ 0, %4 ], [ %35, %34 ]
%39 = bitcast i64* %37 to i8*
%40 = icmp eq i32 %7, 0
%41 = and i32 %38, 12
%42 = icmp eq i32 %41, 0
br i1 %40, label %68, label %43
43: ; preds = %36
br i1 %42, label %44, label %47
44: ; preds = %43
%45 = load i32, i32* @stderr
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 %38)
br label %47
47: ; preds = %44, %43
switch i32 %7, label %71 [
i32 1, label %48
i32 2, label %53
i32 3, label %59
]
48: ; preds = %47
%49 = load i32, i32* @stderr
%50 = load i8, i8* %39
%51 = zext i8 %50 to i32
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %51)
br label %71
53: ; preds = %47
%54 = load i32, i32* @stderr
%55 = bitcast i64* %37 to i16*
%56 = load i16, i16* %55
%57 = zext i16 %56 to i32
%58 = tail call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %57)
br label %71
59: ; preds = %47
%60 = load i32, i32* @stderr
%61 = bitcast i64* %37 to i16*
%62 = load i16, i16* %61
%63 = zext i16 %62 to i32
%64 = getelementptr inbounds i8, i8* %39, i64 2
%65 = load i8, i8* %64
%66 = zext i8 %65 to i32
%67 = tail call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %63, i32 %66)
br label %71
68: ; preds = %36
br i1 %42, label %71, label %69
69: ; preds = %68
%70 = tail call i32 @putchar(i8 signext 10)
br label %71
71: ; preds = %68, %69, %48, %53, %59, %47
ret void
}