#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 */
scalar_t__ isprint(unsigned char const);
int /*<<< orphan*/ printf(char *, ...);
void appid_hexdump(int n, const void *v, int l) {
  const unsigned char *buffer = v;
  int i;
  for (i = 0; i < l; i += 16) {
    int j;
    printf("%04x:  ", n + i);
    for (j = 0; j < 16; j++) {
      if (i + j < l)
        printf("%02x", buffer[i + j]);
      else
        printf("  ");
      if ((j & 0x03) == 3)
        printf(" ");
    }
    printf("   ");
    for (j = 0; j < 16; j++) {
      char ch = '.';
      if (isprint(buffer[i + j]))
        ch = buffer[i + j];
      if (i + j < l)
        printf("%c", ch);
      else
        printf("  ");
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<appid_hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    129c <appid_hexdump+0x17c>
mov    -0x4(%rbp),%esi
add    -0x24(%rbp),%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x10,-0x28(%rbp)
jge    11e3 <appid_hexdump+0xc3>
mov    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a5 <appid_hexdump+0x85>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b3 <appid_hexdump+0x93>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
and    $0x3,%eax
cmp    $0x3,%eax
jne    11d0 <appid_hexdump+0xb0>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d5 <appid_hexdump+0xb5>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1168 <appid_hexdump+0x48>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x10,-0x28(%rbp)
jge    1280 <appid_hexdump+0x160>
movb   $0x2e,-0x29(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     1239 <appid_hexdump+0x119>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x29(%rbp)
mov    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    125f <appid_hexdump+0x13f>
movsbl -0x29(%rbp),%esi
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126d <appid_hexdump+0x14d>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1272 <appid_hexdump+0x152>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11f8 <appid_hexdump+0xd8>
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x24(%rbp)
jmp    1141 <appid_hexdump+0x21>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<appid_hexdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x10(%rsp)
mov    %edx,0xc(%rsp)
test   %edx,%edx
jle    1281 <appid_hexdump+0x151>
mov    %rsi,%r15
mov    0xc(%rsp),%r13d
lea    0xeaa(%rip),%rbx
xor    %r14d,%r14d
jmp    1190 <appid_hexdump+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%r14
add    $0x10,%r15
cmp    0xc(%rsp),%r14d
mov    %r12,%rbx
jge    1281 <appid_hexdump+0x151>
mov    0x10(%rsp),%rax
lea    (%r14,%rax,1),%esi
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %r12d,%r12d
jmp    11ba <appid_hexdump+0x8a>
nopl   0x0(%rax)
add    $0x1,%r12
cmp    $0x10,%r12
je     1210 <appid_hexdump+0xe0>
lea    (%r14,%r12,1),%rax
cmp    %r13,%rax
jge    11e0 <appid_hexdump+0xb0>
movzbl (%r15,%r12,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ee <appid_hexdump+0xbe>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe27(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12d,%eax
not    %eax
test   $0x3,%al
jne    11b0 <appid_hexdump+0x80>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11b0 <appid_hexdump+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%r12
lea    0xdf3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebp,%ebp
jmp    124c <appid_hexdump+0x11c>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xdd7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    $0x10,%rbp
je     1170 <appid_hexdump+0x40>
lea    (%r14,%rbp,1),%rbx
movzbl (%r15,%rbp,1),%edi
call   1050 <isprint@plt>
test   %rax,%rax
je     1270 <appid_hexdump+0x140>
movzbl (%r15,%rbp,1),%eax
cmp    %r13,%rbx
jge    1230 <appid_hexdump+0x100>
jmp    1277 <appid_hexdump+0x147>
nopl   0x0(%rax,%rax,1)
mov    $0x2e,%al
cmp    %r13,%rbx
jge    1230 <appid_hexdump+0x100>
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    123e <appid_hexdump+0x10e>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"%04x: \00"
@.str.1 = [5 x i8] c"%02x\00"
@.str.2 = [3 x i8] c" \00"
@.str.4 = [4 x i8] c" \00"
define void @appid_hexdump(i32 %0, i8* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %58
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %53
%8 = phi i64 [ 0, %5 ], [ %55, %53 ]
%9 = trunc i64 %8 to i32
%10 = add i32 %9, %0
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %7, %28
%13 = phi i64 [ 0, %7 ], [ %29, %28 ]
%14 = add nuw nsw i64 %13, %8
%15 = icmp slt i64 %14, %6
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %1, i64 %14
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %23
21: ; preds = %12
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %16
%24 = and i64 %13, 3
%25 = icmp eq i64 %24, 3
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 @putchar(i32 32)
br label %28
28: ; preds = %23, %26
%29 = add nuw nsw i64 %13, 1
%30 = icmp eq i64 %29, 16
br i1 %30, label %31, label %12
31: ; preds = %28
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %31, %50
%34 = phi i64 [ 0, %31 ], [ %51, %50 ]
%35 = add nuw nsw i64 %34, %8
%36 = getelementptr inbounds i8, i8* %1, i64 %35
%37 = load i8, i8* %36
%38 = tail call i64 @isprint(i8 zeroext %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %33
%41 = load i8, i8* %36
br label %42
42: ; preds = %40, %33
%43 = phi i8 [ %41, %40 ], [ 46, %33 ]
%44 = icmp slt i64 %35, %6
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = sext i8 %43 to i32
%47 = tail call i32 @putchar(i32 %46)
br label %50
48: ; preds = %42
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %50
50: ; preds = %48, %45
%51 = add nuw nsw i64 %34, 1
%52 = icmp eq i64 %51, 16
br i1 %52, label %53, label %33
53: ; preds = %50
%54 = tail call i32 @putchar(i32 10)
%55 = add nuw i64 %8, 16
%56 = trunc i64 %55 to i32
%57 = icmp slt i32 %56, %2
br i1 %57, label %7, label %58
58: ; preds = %53, %3
ret void
}