#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 hexprint(const char *s, unsigned char *p, int n) {
  printf("%14s:", s);
  while (--n >= 0) {
    if (n % 20 == 19)
      printf("\n%14s ", "");
    printf(" %02x", *p++);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<hexprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     1195 <hexprint+0x85>
mov    -0x14(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
cmp    $0x13,%edx
jne    1170 <hexprint+0x60>
lea    0xea4(%rip),%rdi
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1135 <hexprint+0x25>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexprint>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%rsi
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    11b9 <hexprint+0x99>
lea    0x1(%rbx),%ebp
add    $0xffffffff,%ebx
mov    $0xcccccccd,%r15d
lea    0xeb4(%rip),%r12
lea    0xeae(%rip),%r13
jmp    118d <hexprint+0x6d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%r14),%esi
add    $0x1,%r14
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebp
add    $0xffffffff,%ebx
cmp    $0x1,%ebp
jbe    11b9 <hexprint+0x99>
mov    %ebx,%eax
imul   %r15,%rax
shr    $0x24,%rax
shl    $0x2,%eax
lea    (%rax,%rax,4),%eax
mov    %ebp,%ecx
sub    %eax,%ecx
cmp    $0x15,%ecx
jne    1170 <hexprint+0x50>
lea    0xe59(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <hexprint+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%14s:\00"
@.str.1 = [7 x i8] c"\0A%14s \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [6 x i8] c" %02x\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @hexprint(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %19, %3
%10 = load i32, i32* %6
%11 = add nsw i32 %10, -1
store i32 %11, i32* %6
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = load i32, i32* %6
%15 = srem i32 %14, 20
%16 = icmp eq i32 %15, 19
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %5
%22 = load i8, i8* %20
%23 = zext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %9
25: ; preds = %9
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%14s:\00"
@.str.1 = [7 x i8] c"\0A%14s \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [6 x i8] c" %02x\00"
define i32 @hexprint(i8* %0, i8* nocapture %1, i32 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %20
6: ; preds = %3, %14
%7 = phi i32 [ %9, %14 ], [ %2, %3 ]
%8 = phi i8* [ %15, %14 ], [ %1, %3 ]
%9 = add nsw i32 %7, -1
%10 = urem i32 %9, 20
%11 = icmp eq i32 %10, 19
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %6
%15 = getelementptr inbounds i8, i8* %8, i64 1
%16 = load i8, i8* %8
%17 = zext i8 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = icmp ugt i32 %7, 1
br i1 %19, label %6, label %20
20: ; preds = %14, %3
%21 = tail call i32 @putchar(i32 10)
ret i32 0
}