#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 *, ...);
void showhdr(unsigned char *hdr) {
  int i, j;
  for (j = 0; j < 5; j++) {
    for (i = 0; i < 16; i++) {
      printf("%02x ", (unsigned int)(hdr[j * 16 + i]));
    }
    printf("   ");
    for (i = 0; i < 16; i++) {
      unsigned char d = hdr[j * 16 + i];
      printf("%c", (d >= ' ' && d < 127) ? d : '.');
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<showhdr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x5,-0x10(%rbp)
jge    1211 <showhdr+0x101>
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    116e <showhdr+0x5e>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x4,%ecx
add    -0xc(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1134 <showhdr+0x24>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    11f5 <showhdr+0xe5>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x4,%ecx
add    -0xc(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x20,%eax
jl     11c9 <showhdr+0xb9>
movzbl -0x11(%rbp),%eax
cmp    $0x7f,%eax
jge    11c9 <showhdr+0xb9>
movzbl -0x11(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11d6 <showhdr+0xc6>
mov    $0x2e,%eax
mov    %eax,-0x18(%rbp)
jmp    11d6 <showhdr+0xc6>
mov    -0x18(%rbp),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1183 <showhdr+0x73>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1123 <showhdr+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showhdr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
mov    $0xf,%ebx
lea    0xec9(%rip),%r14
lea    0xec8(%rip),%r15
mov    $0x2e,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl -0xf(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0xe(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0xd(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0xc(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0xb(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0xa(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0x9(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0x8(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0x7(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0x6(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0x5(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0x4(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0x3(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0x2(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0x1(%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0xf(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0xe(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0xd(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0xc(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0xb(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0xa(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0x9(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0x8(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0x7(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0x6(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0x5(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0x4(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0x3(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0x2(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl -0x1(%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl (%r12,%rbx,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rbx
cmp    $0x5f,%rbx
jne    1150 <showhdr+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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