#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 */
scalar_t__ put(char **, char **, int *, char *, ...);
int dump(char **pos, char **end, int *length, const unsigned char *start,
         int size) {
  int i;
  if (!size)
    return -1;
  put(pos, end, length, "0x");
  for (i = 0; i < size; i++)
    if (put(pos, end, length, "%02X", start[i]) < 0)
      return -1;
  return 0;
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1142 <dump+0x32>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <dump+0xb6>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xeab(%rip),%rcx
mov    $0x0,%al
call   1030 <put@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11bf <dump+0xaf>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movzbl (%rax,%rcx,1),%r8d
lea    0xe74(%rip),%rcx
mov    $0x0,%al
call   1030 <put@plt>
cmp    $0x0,%rax
jge    11ac <dump+0x9c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <dump+0xb6>
jmp    11b1 <dump+0xa1>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1163 <dump+0x53>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
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
test   %r8d,%r8d
je     117f <dump+0x6f>
mov    %r8d,%ebp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0xeca(%rip),%rcx
xor    %r13d,%r13d
xor    %eax,%eax
call   1030 <put@plt>
test   %ebp,%ebp
jle    1185 <dump+0x75>
mov    %ebp,%ebp
xor    %r13d,%r13d
nopl   0x0(%rax)
movzbl (%r14,%r13,1),%r8d
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
lea    0xe9e(%rip),%rcx
xor    %eax,%eax
call   1030 <put@plt>
test   %rax,%rax
js     117f <dump+0x6f>
add    $0x1,%r13
cmp    %r13,%rbp
jne    1150 <dump+0x40>
xor    %r13d,%r13d
jmp    1185 <dump+0x75>
mov    $0xffffffff,%r13d
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"0x\00"
@.str.1 = [5 x i8] c"%02X\00"
define i32 @dump(i8** %0, i8** %1, i32* %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
store i8** %0, i8*** %7
store i8** %1, i8*** %8
store i32* %2, i32** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%13 = load i32, i32* %11
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %5
store i32 -1, i32* %6
br label %43
16: ; preds = %5
%17 = load i8**, i8*** %7
%18 = load i8**, i8*** %8
%19 = load i32*, i32** %9
%20 = call i64 (i8**, i8**, i32*, i8*, ...) @put(i8** %17, i8** %18, i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %12
br label %21
21: ; preds = %39, %16
%22 = load i32, i32* %12
%23 = load i32, i32* %11
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %42
25: ; preds = %21
%26 = load i8**, i8*** %7
%27 = load i8**, i8*** %8
%28 = load i32*, i32** %9
%29 = load i8*, i8** %10
%30 = load i32, i32* %12
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = call i64 (i8**, i8**, i32*, i8*, ...) @put(i8** %26, i8** %27, i32* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %25
store i32 -1, i32* %6
br label %43
38: ; preds = %25
br label %39
39: ; preds = %38
%40 = load i32, i32* %12
%41 = add nsw i32 %40, 1
store i32 %41, i32* %12
br label %21
42: ; preds = %21
store i32 0, i32* %6
br label %43
43: ; preds = %42, %37, %15
%44 = load i32, i32* %6
ret i32 %44
}

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