#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
void hexlify(const char *tag, const void *sp, size_t count) {
  const uint8_t *u8p = (const uint8_t *)sp;
  const uint8_t *const u8pe = u8p + count;
  printf("%s: ", tag);
  while (u8p < u8pe) {
    printf("%02x", *u8p);
    ++u8p;
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<hexlify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1194 <hexlify+0x74>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    1161 <hexlify+0x41>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexlify>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    (%rbx,%rdx,4),%r15
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %rbx,%r15
jbe    1165 <hexlify+0x45>
lea    0xebc(%rip),%r14
nopl   0x0(%rax)
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x4,%rbx
cmp    %r15,%rbx
jb     1150 <hexlify+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [5 x i8] c"%s: \00"
@.str.1 = [5 x i8] c"%02x\00"
define void @hexlify(i8* %0, i8* %1, i64 %2) {
%4 = bitcast i8* %1 to i32*
%5 = getelementptr inbounds i32, i32* %4, i64 %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = icmp ugt i32* %5, %4
br i1 %7, label %8, label %14
8: ; preds = %3, %8
%9 = phi i32* [ %12, %8 ], [ %4, %3 ]
%10 = load i32, i32* %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds i32, i32* %9, i64 1
%13 = icmp ult i32* %12, %5
br i1 %13, label %8, label %14
14: ; preds = %8, %3
%15 = tail call i32 @putchar(i8 signext 10)
ret void
}