#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*/ printf(char *, ...);
int /*<<< orphan*/ putchar(unsigned char const);
void printhex(const unsigned char *p, int n) {
  int i;
  while (n > 0) {
    for (i = 0; i < 16; i++)
      printf("%02x ", p[i]);
    printf("| ");
    for (i = 0; i < 16; i++) {
      putchar((p[i] >= 32 && p[i] < 127) ? p[i] : '.');
    }
    printf("\n");
    p += 16;
    n -= 16;
  }
}


x86 assembly (clang, -O0):
<printhex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    121d <printhex+0xfd>
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0x10(%rbp)
jge    1172 <printhex+0x52>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1140 <printhex+0x20>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0x10(%rbp)
jge    11f5 <printhex+0xd5>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     11cf <printhex+0xaf>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7f,%eax
jge    11cf <printhex+0xaf>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x14(%rbp)
jmp    11dc <printhex+0xbc>
mov    $0x2e,%eax
mov    %eax,-0x14(%rbp)
jmp    11dc <printhex+0xbc>
mov    -0x14(%rbp),%eax
movzbl %al,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1187 <printhex+0x67>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x10,%eax
mov    %eax,-0xc(%rbp)
jmp    112f <printhex+0xf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printhex>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    13b4 <printhex+0x294>
mov    %esi,%r14d
mov    %rdi,%rbx
add    $0x10,%r14d
lea    0xebf(%rip),%rbp
lea    0xebe(%rip),%r15
mov    $0x2e,%r12d
xchg   %ax,%ax
movzbl (%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x1(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x2(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x3(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x4(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x5(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x6(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x7(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x8(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x9(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xa(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xb(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xc(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xd(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xe(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xf(%rbx),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x1(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x2(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x3(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x4(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x5(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x6(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x7(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x8(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x9(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0xa(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0xb(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0xc(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0xd(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0xe(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0xf(%rbx),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r12d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xfffffff0,%r14d
add    $0x10,%rbx
cmp    $0x10,%r14d
ja     1150 <printhex+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%02x \00"
@.str.1 = [3 x i8] c"| \00"
define void @printhex(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %155
4: ; preds = %2, %4
%5 = phi i32 [ %153, %4 ], [ %1, %2 ]
%6 = phi i8* [ %152, %4 ], [ %0, %2 ]
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds i8, i8* %6, i64 2
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds i8, i8* %6, i64 3
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds i8, i8* %6, i64 4
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds i8, i8* %6, i64 5
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds i8, i8* %6, i64 6
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds i8, i8* %6, i64 7
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds i8, i8* %6, i64 8
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds i8, i8* %6, i64 9
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds i8, i8* %6, i64 10
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %48)
%50 = getelementptr inbounds i8, i8* %6, i64 11
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %52)
%54 = getelementptr inbounds i8, i8* %6, i64 12
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %56)
%58 = getelementptr inbounds i8, i8* %6, i64 13
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %60)
%62 = getelementptr inbounds i8, i8* %6, i64 14
%63 = load i8, i8* %62
%64 = zext i8 %63 to i32
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %64)
%66 = getelementptr inbounds i8, i8* %6, i64 15
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %68)
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%71 = load i8, i8* %6
%72 = add i8 %71, -32
%73 = icmp ult i8 %72, 95
%74 = select i1 %73, i8 %71, i8 46
%75 = tail call i32 @putchar(i8 zeroext %74)
%76 = load i8, i8* %10
%77 = add i8 %76, -32
%78 = icmp ult i8 %77, 95
%79 = select i1 %78, i8 %76, i8 46
%80 = tail call i32 @putchar(i8 zeroext %79)
%81 = load i8, i8* %14
%82 = add i8 %81, -32
%83 = icmp ult i8 %82, 95
%84 = select i1 %83, i8 %81, i8 46
%85 = tail call i32 @putchar(i8 zeroext %84)
%86 = load i8, i8* %18
%87 = add i8 %86, -32
%88 = icmp ult i8 %87, 95
%89 = select i1 %88, i8 %86, i8 46
%90 = tail call i32 @putchar(i8 zeroext %89)
%91 = load i8, i8* %22
%92 = add i8 %91, -32
%93 = icmp ult i8 %92, 95
%94 = select i1 %93, i8 %91, i8 46
%95 = tail call i32 @putchar(i8 zeroext %94)
%96 = load i8, i8* %26
%97 = add i8 %96, -32
%98 = icmp ult i8 %97, 95
%99 = select i1 %98, i8 %96, i8 46
%100 = tail call i32 @putchar(i8 zeroext %99)
%101 = load i8, i8* %30
%102 = add i8 %101, -32
%103 = icmp ult i8 %102, 95
%104 = select i1 %103, i8 %101, i8 46
%105 = tail call i32 @putchar(i8 zeroext %104)
%106 = load i8, i8* %34
%107 = add i8 %106, -32
%108 = icmp ult i8 %107, 95
%109 = select i1 %108, i8 %106, i8 46
%110 = tail call i32 @putchar(i8 zeroext %109)
%111 = load i8, i8* %38
%112 = add i8 %111, -32
%113 = icmp ult i8 %112, 95
%114 = select i1 %113, i8 %111, i8 46
%115 = tail call i32 @putchar(i8 zeroext %114)
%116 = load i8, i8* %42
%117 = add i8 %116, -32
%118 = icmp ult i8 %117, 95
%119 = select i1 %118, i8 %116, i8 46
%120 = tail call i32 @putchar(i8 zeroext %119)
%121 = load i8, i8* %46
%122 = add i8 %121, -32
%123 = icmp ult i8 %122, 95
%124 = select i1 %123, i8 %121, i8 46
%125 = tail call i32 @putchar(i8 zeroext %124)
%126 = load i8, i8* %50
%127 = add i8 %126, -32
%128 = icmp ult i8 %127, 95
%129 = select i1 %128, i8 %126, i8 46
%130 = tail call i32 @putchar(i8 zeroext %129)
%131 = load i8, i8* %54
%132 = add i8 %131, -32
%133 = icmp ult i8 %132, 95
%134 = select i1 %133, i8 %131, i8 46
%135 = tail call i32 @putchar(i8 zeroext %134)
%136 = load i8, i8* %58
%137 = add i8 %136, -32
%138 = icmp ult i8 %137, 95
%139 = select i1 %138, i8 %136, i8 46
%140 = tail call i32 @putchar(i8 zeroext %139)
%141 = load i8, i8* %62
%142 = add i8 %141, -32
%143 = icmp ult i8 %142, 95
%144 = select i1 %143, i8 %141, i8 46
%145 = tail call i32 @putchar(i8 zeroext %144)
%146 = load i8, i8* %66
%147 = add i8 %146, -32
%148 = icmp ult i8 %147, 95
%149 = select i1 %148, i8 %146, i8 46
%150 = tail call i32 @putchar(i8 zeroext %149)
%151 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
%152 = getelementptr inbounds i8, i8* %6, i64 16
%153 = add nsw i32 %5, -16
%154 = icmp ugt i32 %5, 16
br i1 %154, label %4, label %155
155: ; preds = %4, %2
ret void
}