#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 dump(char *s, unsigned char *buf, size_t sz) {
  size_t i;
  printf("%s\n\t", s);
  for (i = 0; i < sz; i++)
    printf("%02x%s", buf[i], ((i % 16 == 15) && (i < sz - 1)) ? "\n\t" : " ");
  printf("\n");
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11c1 <dump+0xb1>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rcx
and    $0xf,%rcx
xor    %eax,%eax
cmp    $0xf,%rcx
mov    %al,-0x21(%rbp)
jne    1187 <dump+0x77>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
setb   %al
mov    %al,-0x21(%rbp)
mov    -0x28(%rbp),%esi
mov    -0x21(%rbp),%cl
lea    0xe78(%rip),%rdx
lea    0xe67(%rip),%rax
test   $0x1,%cl
cmovne %rax,%rdx
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113e <dump+0x2e>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%rsi
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12,%r12
je     1194 <dump+0x74>
lea    -0x1(%r12),%rbx
lea    0xeb9(%rip),%rbp
lea    0xeab(%rip),%r15
xor    %r13d,%r13d
nopl   (%rax)
mov    %r13d,%eax
not    %eax
test   $0xf,%al
mov    %rbp,%rdx
lea    0xe91(%rip),%rax
cmove  %rax,%rdx
movzbl (%r14,%r13,1),%esi
cmp    %rbx,%r13
cmovae %rbp,%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r13
cmp    %r13,%r12
jne    1160 <dump+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%s\0A\09\00"
@.str.1 = [7 x i8] c"%02x%s\00"
@.str.2 = [3 x i8] c"\0A\09\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [2 x i8] c"\0A\00"
define void @dump(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i8*, i8** %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %8)
store i64 0, i64* %7
br label %10
10: ; preds = %33, %3
%11 = load i64, i64* %7
%12 = load i64, i64* %6
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %36
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = load i64, i64* %7
%17 = getelementptr inbounds i8, i8* %15, i64 %16
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = load i64, i64* %7
%21 = urem i64 %20, 16
%22 = icmp eq i64 %21, 15
br i1 %22, label %23, label %28
23: ; preds = %14
%24 = load i64, i64* %7
%25 = load i64, i64* %6
%26 = sub i64 %25, 1
%27 = icmp ult i64 %24, %26
br label %28
28: ; preds = %23, %14
%29 = phi i1 [ false, %14 ], [ %27, %23 ]
%30 = zext i1 %29 to i64
%31 = select i1 %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %19, i8* %31)
br label %33
33: ; preds = %28
%34 = load i64, i64* %7
%35 = add i64 %34, 1
store i64 %35, i64* %7
br label %10
36: ; preds = %10
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

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