#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 */
char *realloc(char *, size_t);
int /*<<< orphan*/ sprintf(char *, char *, char);
char *aux_dbg_hexprint(char *data, size_t size) {
  static char *output;
  static size_t outsize;
  if (outsize < size * 3) {
    outsize = size * 3;
    output = realloc(output, outsize);
  }
  int ichar;
  for (ichar = 0; ichar < size; ichar++) {
    sprintf(&output[ichar * 3], "%02X ", data[ichar] & 0xff);
  }
  output[ichar * 3 + 2] = '\0';
  return output;
}


x86 assembly (clang, -O0):
<aux_dbg_hexprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2f09(%rip),%rax
imul   $0x3,-0x10(%rbp),%rcx
cmp    %rcx,%rax
jae    116b <aux_dbg_hexprint+0x4b>
imul   $0x3,-0x10(%rbp),%rax
mov    %rax,0x2eef(%rip)
mov    0x2ee0(%rip),%rdi
mov    0x2ee1(%rip),%rsi
call   1030 <realloc@plt>
mov    %rax,0x2ecd(%rip)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11be <aux_dbg_hexprint+0x9e>
mov    0x2eb1(%rip),%rdi
imul   $0x3,-0x14(%rbp),%eax
cltq
add    %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0xff,%eax
lea    0xe58(%rip),%rsi
movsbl %al,%edx
call   1040 <sprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1172 <aux_dbg_hexprint+0x52>
mov    0x2e73(%rip),%rax
imul   $0x3,-0x14(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    0x2e5e(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aux_dbg_hexprint>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r14
lea    (%rsi,%rsi,2),%rsi
cmp    %rsi,0x2f06(%rip)
jae    1156 <aux_dbg_hexprint+0x36>
mov    %rsi,0x2efd(%rip)
mov    0x2eee(%rip),%rdi
call   1030 <realloc@plt>
mov    %rax,0x2ee2(%rip)
test   %r12,%r12
je     119d <aux_dbg_hexprint+0x7d>
xor    %r13d,%r13d
lea    0xe9b(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    0x2ec1(%rip),%rdi
add    %r13,%rdi
movsbl (%r14,%rbx,1),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
add    $0x1,%rbx
add    $0x3,%r13
cmp    %rbx,%r12
jne    1170 <aux_dbg_hexprint+0x50>
lea    (%r12,%r12,2),%ecx
add    $0x2,%ecx
jmp    11a2 <aux_dbg_hexprint+0x82>
mov    $0x2,%ecx
mov    0x2e8f(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@aux_dbg_hexprint.output = internal unnamed_addr global i8* null
@aux_dbg_hexprint.outsize = internal unnamed_addr global i64 0
@.str = [6 x i8] c"%02X \00"
define i8* @aux_dbg_hexprint(i8* nocapture %0, i64 %1) {
%3 = load i64, i64* @aux_dbg_hexprint.outsize
%4 = mul i64 %1, 3
%5 = icmp ult i64 %3, %4
br i1 %5, label %6, label %9
6: ; preds = %2
store i64 %4, i64* @aux_dbg_hexprint.outsize
%7 = load i8*, i8** @aux_dbg_hexprint.output
%8 = tail call i8* @realloc(i8* %7, i64 %4)
store i8* %8, i8** @aux_dbg_hexprint.output
br label %9
9: ; preds = %6, %2
%10 = icmp eq i64 %1, 0
br i1 %10, label %25, label %11
11: ; preds = %9, %11
%12 = phi i64 [ %19, %11 ], [ 0, %9 ]
%13 = load i8*, i8** @aux_dbg_hexprint.output
%14 = mul nuw nsw i64 %12, 3
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = getelementptr inbounds i8, i8* %0, i64 %12
%17 = load i8, i8* %16
%18 = tail call i32 @sprintf(i8* dereferenceable(1) %15, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 signext %17)
%19 = add nuw i64 %12, 1
%20 = icmp eq i64 %19, %1
br i1 %20, label %21, label %11
21: ; preds = %11
%22 = mul i64 %1, 3
%23 = add i64 %22, 2
%24 = and i64 %23, 4294967295
br label %25
25: ; preds = %21, %9
%26 = phi i64 [ 2, %9 ], [ %24, %21 ]
%27 = load i8*, i8** @aux_dbg_hexprint.output
%28 = getelementptr inbounds i8, i8* %27, i64 %26
store i8 0, i8* %28
ret i8* %27
}