#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*/ putchar(char const);
void dump(void *p, unsigned int len) {
  const char digits[17] = "0123456789abcdef";
  unsigned char *a = (unsigned char *)p;
  int i;
  for (i = 0; i < len; i++) {
    putchar(' ');
    putchar(digits[a[i] / 16]);
    putchar(digits[a[i] % 16]);
  }
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xed5(%rip),%al
mov    %al,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11b2 <dump+0xa2>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cltq
movsbl -0x20(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movsbl -0x20(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    114d <dump+0x3d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     1168 <dump+0x58>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
lea    0xed5(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
movzbl (%r15,%rbx,1),%eax
shr    $0x4,%rax
movsbl (%rax,%r12,1),%edi
call   1030 <putchar@plt>
movzbl (%r15,%rbx,1),%eax
and    $0xf,%eax
movsbl (%rax,%r12,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1130 <dump+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.dump.digits = [17 x i8] c"0123456789abcdef\00"
define void @dump(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [17 x i8]
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = bitcast [17 x i8]* %5 to i8*
%9 = load i8*, i8** %3
store i8* %9, i8** %6
store i32 0, i32* %7
br label %10
10: ; preds = %38, %2
%11 = load i32, i32* %7
%12 = load i32, i32* %4
%13 = icmp ult i32 %11, %12
br i1 %13, label %14, label %41
14: ; preds = %10
%15 = call i32 @putchar(i8 signext 32)
%16 = load i8*, i8** %6
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = sdiv i32 %21, 16
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [17 x i8], [17 x i8]* %5, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @putchar(i8 signext %25)
%27 = load i8*, i8** %6
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = srem i32 %32, 16
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [17 x i8], [17 x i8]* %5, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = call i32 @putchar(i8 signext %36)
br label %38
38: ; preds = %14
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %10
41: ; preds = %10
ret void
}

LLVM IR (-O2):
@__const.dump.digits = [17 x i8] c"0123456789abcdef\00"
define void @dump(i8* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %24, label %4
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %22, %6 ]
%8 = tail call i32 @putchar(i8 signext 32)
%9 = getelementptr inbounds i8, i8* %0, i64 %7
%10 = load i8, i8* %9
%11 = lshr i8 %10, 4
%12 = zext i8 %11 to i64
%13 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.dump.digits, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = tail call i32 @putchar(i8 signext %14)
%16 = load i8, i8* %9
%17 = and i8 %16, 15
%18 = zext i8 %17 to i64
%19 = getelementptr inbounds [17 x i8], [17 x i8]* @__const.dump.digits, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = tail call i32 @putchar(i8 signext %20)
%22 = add nuw nsw i64 %7, 1
%23 = icmp eq i64 %22, %5
br i1 %23, label %24, label %6
24: ; preds = %6, %2
ret void
}