#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ sprintf(char *, char *, ...);
int /*<<< orphan*/ stderr;
void __xdump(void *x, int length) {
  int i, j;
  int written;
  char buf[256];
  for (i = 0; i < (length / 16) + 1; i++) {
    written = 0;
    written += sprintf(buf + written, "[%04X]: ", (i * 16 & 0x00FFFF));
    for (j = 0; j < 16 && (j + (i * 16) < length); j++) {
      written +=
          sprintf(buf + written, "%02X ", ((char *)x)[j + (i * 16)] & 0x00FF);
    }
    written += sprintf(buf + written, "\n");
    fprintf(stderr, "%s", buf);
    if (j < 16 && (j + i * 16 >= length)) {
      break;
    }
  }
  fflush(stderr);
}


x86 assembly (clang, -O0):
<__xdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x124(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x124(%rbp),%eax
add    $0x1,%ecx
cmp    %ecx,%eax
jge    12bd <__xdump+0x18d>
movl   $0x0,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%edx
shl    $0x4,%edx
and    $0xffff,%edx
lea    0xe68(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x10,-0x14(%rbp)
mov    %al,-0x125(%rbp)
jge    11dc <__xdump+0xac>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x4,%ecx
add    %ecx,%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x125(%rbp)
mov    -0x125(%rbp),%al
test   $0x1,%al
jne    11ef <__xdump+0xbf>
jmp    1242 <__xdump+0x112>
lea    -0x120(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%edx
shl    $0x4,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edx
and    $0xff,%edx
lea    0xde9(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b3 <__xdump+0x83>
lea    -0x120(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
lea    0xdb8(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    -0x120(%rbp),%rdx
lea    0xd8f(%rip),%rsi
call   1030 <fprintf@plt>
cmpl   $0x10,-0x14(%rbp)
jge    12aa <__xdump+0x17a>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x4,%ecx
add    %ecx,%eax
cmp    -0xc(%rbp),%eax
jl     12aa <__xdump+0x17a>
jmp    12bd <__xdump+0x18d>
jmp    12af <__xdump+0x17f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1149 <__xdump+0x19>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__xdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
cmp    $0xfffffff1,%esi
jl     1251 <__xdump+0x121>
mov    %rdi,%rbx
lea    0xf(%rsi),%eax
test   %esi,%esi
cmovns %esi,%eax
sar    $0x4,%eax
movslq %esi,%rbp
add    $0x1,%eax
mov    %rax,(%rsp)
lea    0xe97(%rip),%rsi
lea    0x10(%rsp),%r15
lea    0xe94(%rip),%r12
xor    %r14d,%r14d
xor    %eax,%eax
mov    %rax,0x8(%rsp)
shl    $0x4,%eax
movzwl %ax,%edx
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%r14,%r13,1),%rcx
movslq %eax,%r15
lea    (%rsp,%r15,1),%rdi
add    $0x10,%rdi
cmp    %rbp,%rcx
jge    1229 <__xdump+0xf9>
movzbl (%rbx,%r13,1),%edx
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <sprintf@plt>
add    %r15,%rax
add    $0x1,%r13
cmp    $0x10,%r13
jne    11a0 <__xdump+0x70>
cltq
lea    (%rsp,%rax,1),%rdi
add    $0x10,%rdi
lea    0xe2e(%rip),%rsi
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
lea    0x10(%rsp),%r15
mov    %r15,%rdx
call   1030 <fprintf@plt>
mov    0x8(%rsp),%rax
add    $0x1,%rax
add    $0x10,%rbx
add    $0x10,%r14
cmp    (%rsp),%rax
lea    0xddf(%rip),%rsi
jne    117a <__xdump+0x4a>
jmp    1251 <__xdump+0x121>
lea    0xddf(%rip),%rsi
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
lea    0x10(%rsp),%rdx
call   1030 <fprintf@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"[%04X]: \00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [2 x i8] c"\0A\00"
@stderr = global i32 0
@.str.3 = [3 x i8] c"%s\00"
define void @__xdump(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [256 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %9
9: ; preds = %87, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = sdiv i32 %11, 16
%13 = add nsw i32 %12, 1
%14 = icmp slt i32 %10, %13
br i1 %14, label %15, label %90
15: ; preds = %9
store i32 0, i32* %7
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i32, i32* %5
%21 = mul nsw i32 %20, 16
%22 = and i32 %21, 65535
%23 = call i64 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = add nsw i64 %25, %23
%27 = trunc i64 %26 to i32
store i32 %27, i32* %7
store i32 0, i32* %6
br label %28
28: ; preds = %60, %15
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 16
br i1 %30, label %31, label %38
31: ; preds = %28
%32 = load i32, i32* %6
%33 = load i32, i32* %5
%34 = mul nsw i32 %33, 16
%35 = add nsw i32 %32, %34
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br label %38
38: ; preds = %31, %28
%39 = phi i1 [ false, %28 ], [ %37, %31 ]
br i1 %39, label %40, label %63
40: ; preds = %38
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8*, i8** %3
%46 = load i32, i32* %6
%47 = load i32, i32* %5
%48 = mul nsw i32 %47, 16
%49 = add nsw i32 %46, %48
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %45, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = and i32 %53, 255
%55 = call i64 (i8*, i8*, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = add nsw i64 %57, %55
%59 = trunc i64 %58 to i32
store i32 %59, i32* %7
br label %60
60: ; preds = %40
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
store i32 %62, i32* %6
br label %28
63: ; preds = %38
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%65 = load i32, i32* %7
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %64, i64 %66
%68 = call i64 (i8*, i8*, ...) @sprintf(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%69 = load i32, i32* %7
%70 = sext i32 %69 to i64
%71 = add nsw i64 %70, %68
%72 = trunc i64 %71 to i32
store i32 %72, i32* %7
%73 = load i32, i32* @stderr
%74 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%75 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %74)
%76 = load i32, i32* %6
%77 = icmp slt i32 %76, 16
br i1 %77, label %78, label %86
78: ; preds = %63
%79 = load i32, i32* %6
%80 = load i32, i32* %5
%81 = mul nsw i32 %80, 16
%82 = add nsw i32 %79, %81
%83 = load i32, i32* %4
%84 = icmp sge i32 %82, %83
br i1 %84, label %85, label %86
85: ; preds = %78
br label %90
86: ; preds = %78, %63
br label %87
87: ; preds = %86
%88 = load i32, i32* %5
%89 = add nsw i32 %88, 1
store i32 %89, i32* %5
br label %9
90: ; preds = %85, %9
%91 = load i32, i32* @stderr
%92 = call i32 @fflush(i32 %91)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"[%04X]: \00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [2 x i8] c"\0A\00"
@stderr = global i32 0
@.str.3 = [3 x i8] c"%s\00"
define void @__xdump(i8* nocapture %0, i32 %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %1, -15
br i1 %5, label %46, label %6
6: ; preds = %2
%7 = sdiv i32 %1, 16
%8 = sext i32 %1 to i64
%9 = add nuw nsw i32 %7, 1
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %6, %37
%12 = phi i64 [ 0, %6 ], [ %44, %37 ]
%13 = shl nsw i64 %12, 4
%14 = trunc i64 %13 to i32
%15 = and i32 %14, 65520
%16 = call i64 (i8*, i8*, ...) @sprintf(i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %11, %25
%18 = phi i64 [ 0, %11 ], [ %31, %25 ]
%19 = phi i64 [ %16, %11 ], [ %30, %25 ]
%20 = add nuw nsw i64 %18, %13
%21 = icmp slt i64 %20, %8
%22 = shl i64 %19, 32
%23 = ashr exact i64 %22, 32
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %23
br i1 %21, label %25, label %33
25: ; preds = %17
%26 = getelementptr inbounds i8, i8* %0, i64 %20
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = call i64 (i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = add nsw i64 %29, %23
%31 = add nuw nsw i64 %18, 1
%32 = icmp eq i64 %31, 16
br i1 %32, label %37, label %17
33: ; preds = %17
%34 = call i64 (i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %46
37: ; preds = %25
%38 = shl i64 %30, 32
%39 = ashr exact i64 %38, 32
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %39
%41 = call i64 (i8*, i8*, ...) @sprintf(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%44 = add nuw nsw i64 %12, 1
%45 = icmp eq i64 %44, %10
br i1 %45, label %46, label %11
46: ; preds = %37, %2, %33
%47 = load i32, i32* @stderr
%48 = call i32 @fflush(i32 %47)
ret void
}