#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 /*<<< orphan*/ str_format_line;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char const *);
char *string_hex_dump(const char *data, int data_size, int bytes_per_line,
                      const char *prefix, const char *suffix) {
  char *buf, *str_hexa, *str_ascii, str_format_line[64], *str_line;
  int length_hexa, length_ascii, length_prefix, length_suffix, length_line;
  int hexa_pos, ascii_pos, i;
  if (!data || (data_size < 1) || (bytes_per_line < 1))
    return NULL;
  str_hexa = NULL;
  str_ascii = NULL;
  str_line = NULL;
  buf = NULL;
  length_hexa = bytes_per_line * 3;
  str_hexa = malloc(length_hexa + 1);
  if (!str_hexa)
    goto end;
  length_ascii = bytes_per_line * 2;
  str_ascii = malloc(length_ascii + 1);
  if (!str_ascii)
    goto end;
  length_prefix = (prefix) ? strlen(prefix) : 0;
  length_suffix = (suffix) ? strlen(suffix) : 0;
  length_line =
      length_prefix + (bytes_per_line * 3) + 2 + length_ascii + length_suffix;
  str_line = malloc(length_line + 1);
  if (!str_line)
    goto end;
  buf = malloc((((data_size / bytes_per_line) + 1) * (length_line + 1)) + 1);
  if (!buf)
    goto end;
  buf[0] = '\0';
  snprintf(str_format_line, sizeof(str_format_line), "%%s%%-%ds  %%-%ds%%s",
           length_hexa, length_ascii);
  hexa_pos = 0;
  ascii_pos = 0;
  for (i = 0; i < data_size; i++) {
    snprintf(str_hexa + hexa_pos, 4, "%02X ", (unsigned char)(data[i]));
    hexa_pos += 3;
    snprintf(
        str_ascii + ascii_pos, 3, "%c ",
        ((((unsigned char)data[i]) < 32) || (((unsigned char)data[i]) > 127))
            ? '.'
            : (unsigned char)(data[i]));
    ascii_pos += 2;
    if (ascii_pos == bytes_per_line * 2) {
      if (buf[0])
        strcat(buf, "\n");
      str_ascii[ascii_pos - 1] = '\0';
      snprintf(str_line, length_line + 1, str_format_line,
               (prefix) ? prefix : "", str_hexa, str_ascii,
               (suffix) ? suffix : "");
      strcat(buf, str_line);
      hexa_pos = 0;
      ascii_pos = 0;
    }
  }
  if (ascii_pos > 0) {
    if (buf[0])
      strcat(buf, "\n");
    str_ascii[ascii_pos - 1] = '\0';
    str_ascii[ascii_pos] = '\0';
    snprintf(str_line, length_line + 1, str_format_line, (prefix) ? prefix : "",
             str_hexa, str_ascii, (suffix) ? suffix : "");
    strcat(buf, str_line);
  }
end:
  if (str_hexa)
    free(str_hexa);
  if (str_ascii)
    free(str_ascii);
  if (str_line)
    free(str_line);
  return buf;
}


x86 assembly (clang, -O0):
<string_hex_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118c <string_hex_dump+0x3c>
cmpl   $0x1,-0x14(%rbp)
jl     118c <string_hex_dump+0x3c>
cmpl   $0x1,-0x18(%rbp)
jge    1199 <string_hex_dump+0x49>
movq   $0x0,-0x8(%rbp)
jmp    1727 <string_hex_dump+0x5d7>
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x88(%rbp)
movq   $0x0,-0x30(%rbp)
imul   $0x3,-0x18(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11e8 <string_hex_dump+0x98>
jmp    16dd <string_hex_dump+0x58d>
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x90(%rbp)
mov    -0x90(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1216 <string_hex_dump+0xc6>
jmp    16dd <string_hex_dump+0x58d>
cmpq   $0x0,-0x20(%rbp)
je     1235 <string_hex_dump+0xe5>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xac(%rbp)
jmp    1242 <string_hex_dump+0xf2>
xor    %eax,%eax
mov    %eax,-0xac(%rbp)
jmp    1242 <string_hex_dump+0xf2>
mov    -0xac(%rbp),%eax
mov    %eax,-0x94(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     126d <string_hex_dump+0x11d>
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xb0(%rbp)
jmp    127a <string_hex_dump+0x12a>
xor    %eax,%eax
mov    %eax,-0xb0(%rbp)
jmp    127a <string_hex_dump+0x12a>
mov    -0xb0(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x94(%rbp),%eax
imul   $0x3,-0x18(%rbp),%ecx
add    %ecx,%eax
add    $0x2,%eax
add    -0x90(%rbp),%eax
add    -0x98(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x9c(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
jne    12cf <string_hex_dump+0x17f>
jmp    16dd <string_hex_dump+0x58d>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,%edi
add    $0x1,%edi
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
imul   %eax,%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1303 <string_hex_dump+0x1b3>
jmp    16dd <string_hex_dump+0x58d>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x80(%rbp),%rdi
mov    -0x8c(%rbp),%ecx
mov    -0x90(%rbp),%r8d
mov    $0x40,%esi
lea    0xcd9(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
movl   $0x0,-0xa0(%rbp)
movl   $0x0,-0xa4(%rbp)
movl   $0x0,-0xa8(%rbp)
mov    -0xa8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1598 <string_hex_dump+0x448>
mov    -0x38(%rbp),%rdi
movslq -0xa0(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq -0xa8(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
mov    $0x4,%esi
lea    0xc91(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0xa0(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0xa0(%rbp)
mov    -0x40(%rbp),%rax
movslq -0xa4(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0xb8(%rbp)
mov    -0x10(%rbp),%rax
movslq -0xa8(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     13df <string_hex_dump+0x28f>
mov    -0x10(%rbp),%rax
movslq -0xa8(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7f,%eax
jle    13ef <string_hex_dump+0x29f>
mov    $0x2e,%eax
mov    %eax,-0xbc(%rbp)
jmp    1404 <string_hex_dump+0x2b4>
mov    -0x10(%rbp),%rax
movslq -0xa8(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0xbc(%rbp)
mov    -0xb8(%rbp),%rdi
mov    -0xbc(%rbp),%ecx
mov    $0x3,%esi
lea    0xbfe(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0xa4(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jne    157f <string_hex_dump+0x42f>
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     1464 <string_hex_dump+0x314>
mov    -0x30(%rbp),%rdi
lea    0xbc0(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x40(%rbp),%rax
mov    -0xa4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x88(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcc(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0xc8(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     14bb <string_hex_dump+0x36b>
mov    -0x20(%rbp),%rax
mov    %rax,-0xe0(%rbp)
jmp    14ce <string_hex_dump+0x37e>
lea    0xb5e(%rip),%rax
mov    %rax,-0xe0(%rbp)
jmp    14ce <string_hex_dump+0x37e>
mov    -0xe0(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0xe8(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     150d <string_hex_dump+0x3bd>
mov    -0x28(%rbp),%rax
mov    %rax,-0x100(%rbp)
jmp    1520 <string_hex_dump+0x3d0>
lea    0xb0c(%rip),%rax
mov    %rax,-0x100(%rbp)
jmp    1520 <string_hex_dump+0x3d0>
mov    -0xe8(%rbp),%r9
mov    -0xf0(%rbp),%r8
mov    -0xf8(%rbp),%rcx
mov    -0xc8(%rbp),%rdx
mov    -0xcc(%rbp),%esi
mov    -0xd8(%rbp),%rdi
mov    -0x100(%rbp),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x88(%rbp),%rsi
call   1070 <strcat@plt>
movl   $0x0,-0xa0(%rbp)
movl   $0x0,-0xa4(%rbp)
jmp    1584 <string_hex_dump+0x434>
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    134c <string_hex_dump+0x1fc>
cmpl   $0x0,-0xa4(%rbp)
jle    16d8 <string_hex_dump+0x588>
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     15c2 <string_hex_dump+0x472>
mov    -0x30(%rbp),%rdi
lea    0xa62(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x40(%rbp),%rax
mov    -0xa4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x40(%rbp),%rax
movslq -0xa4(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x88(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10c(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x108(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1628 <string_hex_dump+0x4d8>
mov    -0x20(%rbp),%rax
mov    %rax,-0x120(%rbp)
jmp    163b <string_hex_dump+0x4eb>
lea    0x9f1(%rip),%rax
mov    %rax,-0x120(%rbp)
jmp    163b <string_hex_dump+0x4eb>
mov    -0x120(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     167a <string_hex_dump+0x52a>
mov    -0x28(%rbp),%rax
mov    %rax,-0x140(%rbp)
jmp    168d <string_hex_dump+0x53d>
lea    0x99f(%rip),%rax
mov    %rax,-0x140(%rbp)
jmp    168d <string_hex_dump+0x53d>
mov    -0x128(%rbp),%r9
mov    -0x130(%rbp),%r8
mov    -0x138(%rbp),%rcx
mov    -0x108(%rbp),%rdx
mov    -0x10c(%rbp),%esi
mov    -0x118(%rbp),%rdi
mov    -0x140(%rbp),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x88(%rbp),%rsi
call   1070 <strcat@plt>
jmp    16dd <string_hex_dump+0x58d>
cmpq   $0x0,-0x38(%rbp)
je     16f1 <string_hex_dump+0x5a1>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x40(%rbp)
je     1705 <string_hex_dump+0x5b5>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x88(%rbp)
je     171f <string_hex_dump+0x5cf>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_hex_dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
xor    %r13d,%r13d
test   %rdi,%rdi
je     1438 <string_hex_dump+0x2e8>
mov    %esi,%ebx
test   %esi,%esi
jle    1438 <string_hex_dump+0x2e8>
mov    %edx,%ebp
test   %edx,%edx
jle    1438 <string_hex_dump+0x2e8>
mov    %r8,%r12
mov    %rcx,%r14
mov    %rdi,%r15
lea    0x1(%rbp,%rbp,2),%edi
call   1060 <malloc@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     11e8 <string_hex_dump+0x98>
lea    0x1(%rbp,%rbp,1),%edi
call   1060 <malloc@plt>
xor    %r13d,%r13d
mov    %rax,0x28(%rsp)
test   %rax,%rax
je     11f0 <string_hex_dump+0xa0>
test   %r14,%r14
je     11c3 <string_hex_dump+0x73>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%r13d
lea    0x0(%rbp,%rbp,2),%eax
mov    %rax,0x20(%rsp)
lea    0x0(%rbp,%rbp,1),%eax
mov    %rax,0x30(%rsp)
test   %r12,%r12
mov    %ebx,0x3c(%rsp)
je     11fa <string_hex_dump+0xaa>
mov    %r12,%rdi
call   1040 <strlen@plt>
jmp    11fc <string_hex_dump+0xac>
xor    %r13d,%r13d
jmp    1438 <string_hex_dump+0x2e8>
mov    0x8(%rsp),%r14
jmp    1430 <string_hex_dump+0x2e0>
xor    %eax,%eax
mov    0x30(%rsp),%rcx
mov    0x20(%rsp),%rdx
add    %edx,%ecx
add    %ecx,%r13d
lea    (%rax,%r13,1),%ebx
add    $0x3,%ebx
mov    %ebx,%edi
call   1060 <malloc@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     138e <string_hex_dump+0x23e>
mov    0x3c(%rsp),%r13d
mov    %r13d,%eax
xor    %edx,%edx
div    %ebp
lea    0x1(%rax),%edi
mov    %ebx,0x14(%rsp)
imul   %ebx,%edi
add    $0x1,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     138e <string_hex_dump+0x23e>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0xda5(%rip),%rdx
lea    0x60(%rsp),%rdi
mov    $0x40,%esi
mov    0x20(%rsp),%rcx
mov    0x30(%rsp),%r8
xor    %eax,%eax
call   1050 <snprintf@plt>
test   %r14,%r14
lea    0xda0(%rip),%rax
mov    %r14,0x48(%rsp)
cmove  %rax,%r14
mov    %r14,0x58(%rsp)
test   %r12,%r12
mov    %r12,0x40(%rsp)
cmove  %rax,%r12
mov    %r12,0x50(%rsp)
mov    %r13d,%eax
mov    %rax,0x20(%rsp)
xor    %r13d,%r13d
xor    %ebp,%ebp
xor    %r14d,%r14d
jmp    12d3 <string_hex_dump+0x183>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x3,%r14d
add    $0x1,%r13
cmp    %r13,0x20(%rsp)
je     1398 <string_hex_dump+0x248>
movslq %r14d,%rdi
add    0x8(%rsp),%rdi
movzbl (%r15,%r13,1),%ecx
mov    $0x4,%esi
lea    0xd29(%rip),%rdx
xor    %eax,%eax
call   1050 <snprintf@plt>
movslq %ebp,%r12
mov    0x28(%rsp),%rax
lea    (%rax,%r12,1),%rdi
movzbl (%r15,%r13,1),%eax
cmp    $0x20,%al
mov    $0x2e,%ecx
cmovl  %ecx,%eax
movzbl %al,%ecx
mov    $0x3,%esi
lea    0xcfe(%rip),%rdx
xor    %eax,%eax
call   1050 <snprintf@plt>
lea    0x2(%r12),%ebp
cmp    0x30(%rsp),%ebp
jne    12c0 <string_hex_dump+0x170>
cmpb   $0x0,(%rbx)
je     1343 <string_hex_dump+0x1f3>
mov    %rbx,%rdi
lea    0xce1(%rip),%rsi
call   1070 <strcat@plt>
mov    0x28(%rsp),%r9
movb   $0x0,0x1(%r12,%r9,1)
mov    0x50(%rsp),%rax
mov    %rax,(%rsp)
xor    %r14d,%r14d
mov    0x18(%rsp),%rbp
mov    %rbp,%rdi
mov    0x14(%rsp),%esi
lea    0x60(%rsp),%rdx
mov    0x58(%rsp),%rcx
mov    0x8(%rsp),%r8
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
xor    %ebp,%ebp
jmp    12c4 <string_hex_dump+0x174>
xor    %r13d,%r13d
mov    0x18(%rsp),%r14
jmp    1417 <string_hex_dump+0x2c7>
test   %ebp,%ebp
mov    0x18(%rsp),%r14
jle    1414 <string_hex_dump+0x2c4>
cmpb   $0x0,(%rbx)
je     13b5 <string_hex_dump+0x265>
lea    0xc72(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    -0x1(%rbp),%eax
mov    0x48(%rsp),%rcx
test   %rcx,%rcx
lea    0xc59(%rip),%rsi
cmove  %rsi,%rcx
mov    0x40(%rsp),%rdx
test   %rdx,%rdx
mov    0x28(%rsp),%r9
movb   $0x0,(%r9,%rax,1)
mov    %ebp,%eax
movb   $0x0,(%r9,%rax,1)
cmove  %rsi,%rdx
mov    %rdx,(%rsp)
lea    0x60(%rsp),%rdx
mov    %r14,%rdi
mov    0x14(%rsp),%esi
mov    0x8(%rsp),%r8
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %rbx,%r13
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
jmp    1417 <string_hex_dump+0x2c7>
mov    %rbx,%r13
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x28(%rsp),%rdi
call   1030 <free@plt>
test   %r14,%r14
je     1438 <string_hex_dump+0x2e8>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r13,%rax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"%%s%%-%ds %%-%ds%%s\00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [4 x i8] c"%c \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [1 x i8] zeroinitializer
define i8* @string_hex_dump(i8* %0, i32 %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca [64 x i8]
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i8* %4, i8** %11
%25 = load i8*, i8** %7
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %33
27: ; preds = %5
%28 = load i32, i32* %8
%29 = icmp slt i32 %28, 1
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = load i32, i32* %9
%32 = icmp slt i32 %31, 1
br i1 %32, label %33, label %34
33: ; preds = %30, %27, %5
store i8* null, i8** %6
br label %266
34: ; preds = %30
store i8* null, i8** %13
store i8* null, i8** %14
store i8* null, i8** %16
store i8* null, i8** %12
%35 = load i32, i32* %9
%36 = mul nsw i32 %35, 3
store i32 %36, i32* %17
%37 = load i32, i32* %17
%38 = add nsw i32 %37, 1
%39 = call i8* @malloc(i32 %38)
store i8* %39, i8** %13
%40 = load i8*, i8** %13
%41 = icmp ne i8* %40, null
br i1 %41, label %43, label %42
42: ; preds = %34
br label %246
43: ; preds = %34
%44 = load i32, i32* %9
%45 = mul nsw i32 %44, 2
store i32 %45, i32* %18
%46 = load i32, i32* %18
%47 = add nsw i32 %46, 1
%48 = call i8* @malloc(i32 %47)
store i8* %48, i8** %14
%49 = load i8*, i8** %14
%50 = icmp ne i8* %49, null
br i1 %50, label %52, label %51
51: ; preds = %43
br label %246
52: ; preds = %43
%53 = load i8*, i8** %10
%54 = icmp ne i8* %53, null
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = load i8*, i8** %10
%57 = call i32 @strlen(i8* %56)
br label %59
58: ; preds = %52
br label %59
59: ; preds = %58, %55
%60 = phi i32 [ %57, %55 ], [ 0, %58 ]
store i32 %60, i32* %19
%61 = load i8*, i8** %11
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %66
63: ; preds = %59
%64 = load i8*, i8** %11
%65 = call i32 @strlen(i8* %64)
br label %67
66: ; preds = %59
br label %67
67: ; preds = %66, %63
%68 = phi i32 [ %65, %63 ], [ 0, %66 ]
store i32 %68, i32* %20
%69 = load i32, i32* %19
%70 = load i32, i32* %9
%71 = mul nsw i32 %70, 3
%72 = add nsw i32 %69, %71
%73 = add nsw i32 %72, 2
%74 = load i32, i32* %18
%75 = add nsw i32 %73, %74
%76 = load i32, i32* %20
%77 = add nsw i32 %75, %76
store i32 %77, i32* %21
%78 = load i32, i32* %21
%79 = add nsw i32 %78, 1
%80 = call i8* @malloc(i32 %79)
store i8* %80, i8** %16
%81 = load i8*, i8** %16
%82 = icmp ne i8* %81, null
br i1 %82, label %84, label %83
83: ; preds = %67
br label %246
84: ; preds = %67
%85 = load i32, i32* %8
%86 = load i32, i32* %9
%87 = sdiv i32 %85, %86
%88 = add nsw i32 %87, 1
%89 = load i32, i32* %21
%90 = add nsw i32 %89, 1
%91 = mul nsw i32 %88, %90
%92 = add nsw i32 %91, 1
%93 = call i8* @malloc(i32 %92)
store i8* %93, i8** %12
%94 = load i8*, i8** %12
%95 = icmp ne i8* %94, null
br i1 %95, label %97, label %96
96: ; preds = %84
br label %246
97: ; preds = %84
%98 = load i8*, i8** %12
%99 = getelementptr inbounds i8, i8* %98, i64 0
store i8 0, i8* %99
%100 = getelementptr inbounds [64 x i8], [64 x i8]* %15, i64 0, i64 0
%101 = load i32, i32* %17
%102 = load i32, i32* %18
%103 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %100, i32 64, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %101, i32 %102)
store i32 0, i32* %22
store i32 0, i32* %23
store i32 0, i32* %24
br label %104
104: ; preds = %197, %97
%105 = load i32, i32* %24
%106 = load i32, i32* %8
%107 = icmp slt i32 %105, %106
br i1 %107, label %108, label %200
108: ; preds = %104
%109 = load i8*, i8** %13
%110 = load i32, i32* %22
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8, i8* %109, i64 %111
%113 = load i8*, i8** %7
%114 = load i32, i32* %24
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8, i8* %113, i64 %115
%117 = load i8, i8* %116
%118 = zext i8 %117 to i32
%119 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %112, i32 4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %118)
%120 = load i32, i32* %22
%121 = add nsw i32 %120, 3
store i32 %121, i32* %22
%122 = load i8*, i8** %14
%123 = load i32, i32* %23
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8, i8* %122, i64 %124
%126 = load i8*, i8** %7
%127 = load i32, i32* %24
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds i8, i8* %126, i64 %128
%130 = load i8, i8* %129
%131 = zext i8 %130 to i32
%132 = icmp slt i32 %131, 32
br i1 %132, label %141, label %133
133: ; preds = %108
%134 = load i8*, i8** %7
%135 = load i32, i32* %24
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i8, i8* %134, i64 %136
%138 = load i8, i8* %137
%139 = zext i8 %138 to i32
%140 = icmp sgt i32 %139, 127
br i1 %140, label %141, label %142
141: ; preds = %133, %108
br label %149
142: ; preds = %133
%143 = load i8*, i8** %7
%144 = load i32, i32* %24
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i8, i8* %143, i64 %145
%147 = load i8, i8* %146
%148 = zext i8 %147 to i32
br label %149
149: ; preds = %142, %141
%150 = phi i32 [ 46, %141 ], [ %148, %142 ]
%151 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %125, i32 3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %150)
%152 = load i32, i32* %23
%153 = add nsw i32 %152, 2
store i32 %153, i32* %23
%154 = load i32, i32* %23
%155 = load i32, i32* %9
%156 = mul nsw i32 %155, 2
%157 = icmp eq i32 %154, %156
br i1 %157, label %158, label %196
158: ; preds = %149
%159 = load i8*, i8** %12
%160 = getelementptr inbounds i8, i8* %159, i64 0
%161 = load i8, i8* %160
%162 = icmp ne i8 %161, 0
br i1 %162, label %163, label %166
163: ; preds = %158
%164 = load i8*, i8** %12
%165 = call i32 @strcat(i8* %164, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %166
166: ; preds = %163, %158
%167 = load i8*, i8** %14
%168 = load i32, i32* %23
%169 = sub nsw i32 %168, 1
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds i8, i8* %167, i64 %170
store i8 0, i8* %171
%172 = load i8*, i8** %16
%173 = load i32, i32* %21
%174 = add nsw i32 %173, 1
%175 = getelementptr inbounds [64 x i8], [64 x i8]* %15, i64 0, i64 0
%176 = load i8*, i8** %10
%177 = icmp ne i8* %176, null
br i1 %177, label %178, label %180
178: ; preds = %166
%179 = load i8*, i8** %10
br label %181
180: ; preds = %166
br label %181
181: ; preds = %180, %178
%182 = phi i8* [ %179, %178 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), %180 ]
%183 = load i8*, i8** %13
%184 = load i8*, i8** %14
%185 = load i8*, i8** %11
%186 = icmp ne i8* %185, null
br i1 %186, label %187, label %189
187: ; preds = %181
%188 = load i8*, i8** %11
br label %190
189: ; preds = %181
br label %190
190: ; preds = %189, %187
%191 = phi i8* [ %188, %187 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), %189 ]
%192 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %172, i32 %174, i8* %175, i8* %182, i8* %183, i8* %184, i8* %191)
%193 = load i8*, i8** %12
%194 = load i8*, i8** %16
%195 = call i32 @strcat(i8* %193, i8* %194)
store i32 0, i32* %22
store i32 0, i32* %23
br label %196
196: ; preds = %190, %149
br label %197
197: ; preds = %196
%198 = load i32, i32* %24
%199 = add nsw i32 %198, 1
store i32 %199, i32* %24
br label %104
200: ; preds = %104
%201 = load i32, i32* %23
%202 = icmp sgt i32 %201, 0
br i1 %202, label %203, label %245
203: ; preds = %200
%204 = load i8*, i8** %12
%205 = getelementptr inbounds i8, i8* %204, i64 0
%206 = load i8, i8* %205
%207 = icmp ne i8 %206, 0
br i1 %207, label %208, label %211
208: ; preds = %203
%209 = load i8*, i8** %12
%210 = call i32 @strcat(i8* %209, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %211
211: ; preds = %208, %203
%212 = load i8*, i8** %14
%213 = load i32, i32* %23
%214 = sub nsw i32 %213, 1
%215 = sext i32 %214 to i64
%216 = getelementptr inbounds i8, i8* %212, i64 %215
store i8 0, i8* %216
%217 = load i8*, i8** %14
%218 = load i32, i32* %23
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds i8, i8* %217, i64 %219
store i8 0, i8* %220
%221 = load i8*, i8** %16
%222 = load i32, i32* %21
%223 = add nsw i32 %222, 1
%224 = getelementptr inbounds [64 x i8], [64 x i8]* %15, i64 0, i64 0
%225 = load i8*, i8** %10
%226 = icmp ne i8* %225, null
br i1 %226, label %227, label %229
227: ; preds = %211
%228 = load i8*, i8** %10
br label %230
229: ; preds = %211
br label %230
230: ; preds = %229, %227
%231 = phi i8* [ %228, %227 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), %229 ]
%232 = load i8*, i8** %13
%233 = load i8*, i8** %14
%234 = load i8*, i8** %11
%235 = icmp ne i8* %234, null
br i1 %235, label %236, label %238
236: ; preds = %230
%237 = load i8*, i8** %11
br label %239
238: ; preds = %230
br label %239
239: ; preds = %238, %236
%240 = phi i8* [ %237, %236 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), %238 ]
%241 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %221, i32 %223, i8* %224, i8* %231, i8* %232, i8* %233, i8* %240)
%242 = load i8*, i8** %12
%243 = load i8*, i8** %16
%244 = call i32 @strcat(i8* %242, i8* %243)
br label %245
245: ; preds = %239, %200
br label %246
246: ; preds = %245, %96, %83, %51, %42
%247 = load i8*, i8** %13
%248 = icmp ne i8* %247, null
br i1 %248, label %249, label %252
249: ; preds = %246
%250 = load i8*, i8** %13
%251 = call i32 @free(i8* %250)
br label %252
252: ; preds = %249, %246
%253 = load i8*, i8** %14
%254 = icmp ne i8* %253, null
br i1 %254, label %255, label %258
255: ; preds = %252
%256 = load i8*, i8** %14
%257 = call i32 @free(i8* %256)
br label %258
258: ; preds = %255, %252
%259 = load i8*, i8** %16
%260 = icmp ne i8* %259, null
br i1 %260, label %261, label %264
261: ; preds = %258
%262 = load i8*, i8** %16
%263 = call i32 @free(i8* %262)
br label %264
264: ; preds = %261, %258
%265 = load i8*, i8** %12
store i8* %265, i8** %6
br label %266
266: ; preds = %264, %33
%267 = load i8*, i8** %6
ret i8* %267
}

LLVM IR (-O2):
@.str = [21 x i8] c"%%s%%-%ds %%-%ds%%s\00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [4 x i8] c"%c \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [1 x i8] zeroinitializer
define i8* @string_hex_dump(i8* %0, i32 %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca [64 x i8]
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%8 = icmp eq i8* %0, null
%9 = icmp slt i32 %1, 1
%10 = or i1 %8, %9
%11 = icmp slt i32 %2, 1
%12 = or i1 %10, %11
br i1 %12, label %114, label %13
13: ; preds = %5
%14 = mul nsw i32 %2, 3
%15 = add nsw i32 %14, 1
%16 = tail call i8* @malloc(i32 %15)
%17 = icmp eq i8* %16, null
br i1 %17, label %114, label %18
18: ; preds = %13
%19 = shl nuw nsw i32 %2, 1
%20 = or i32 %19, 1
%21 = tail call i8* @malloc(i32 %20)
%22 = icmp eq i8* %21, null
br i1 %22, label %110, label %23
23: ; preds = %18
%24 = icmp eq i8* %3, null
br i1 %24, label %27, label %25
25: ; preds = %23
%26 = tail call i32 @strlen(i8* %3)
br label %27
27: ; preds = %23, %25
%28 = phi i32 [ %26, %25 ], [ 0, %23 ]
%29 = icmp eq i8* %4, null
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = tail call i32 @strlen(i8* %4)
br label %32
32: ; preds = %27, %30
%33 = phi i32 [ %31, %30 ], [ 0, %27 ]
%34 = add i32 %14, 3
%35 = add i32 %34, %19
%36 = add i32 %35, %28
%37 = add i32 %36, %33
%38 = tail call i8* @malloc(i32 %37)
%39 = icmp eq i8* %38, null
br i1 %39, label %105, label %40
40: ; preds = %32
%41 = udiv i32 %1, %2
%42 = add nuw nsw i32 %41, 1
%43 = mul nsw i32 %42, %37
%44 = add nsw i32 %43, 1
%45 = tail call i8* @malloc(i32 %44)
%46 = icmp eq i8* %45, null
br i1 %46, label %105, label %47
47: ; preds = %40
store i8 0, i8* %45
%48 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %7, i32 64, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %19)
%49 = select i1 %24, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* %3
%50 = select i1 %29, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* %4
%51 = zext i32 %1 to i64
br label %52
52: ; preds = %47, %83
%53 = phi i64 [ 0, %47 ], [ %86, %83 ]
%54 = phi i32 [ 0, %47 ], [ %85, %83 ]
%55 = phi i32 [ 0, %47 ], [ %84, %83 ]
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %16, i64 %56
%58 = getelementptr inbounds i8, i8* %0, i64 %53
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %57, i32 4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %60)
%62 = add nsw i32 %55, 3
%63 = sext i32 %54 to i64
%64 = getelementptr inbounds i8, i8* %21, i64 %63
%65 = load i8, i8* %58
%66 = icmp slt i8 %65, 32
%67 = select i1 %66, i8 46, i8 %65
%68 = zext i8 %67 to i32
%69 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %64, i32 3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %68)
%70 = add nsw i32 %54, 2
%71 = icmp eq i32 %70, %19
br i1 %71, label %72, label %83
72: ; preds = %52
%73 = load i8, i8* %45
%74 = icmp eq i8 %73, 0
br i1 %74, label %77, label %75
75: ; preds = %72
%76 = call i32 @strcat(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %77
77: ; preds = %75, %72
%78 = add nsw i32 %54, 1
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %21, i64 %79
store i8 0, i8* %80
%81 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %38, i32 %37, i8* %7, i8* %49, i8* %16, i8* %21, i8* %50)
%82 = call i32 @strcat(i8* %45, i8* %38)
br label %83
83: ; preds = %52, %77
%84 = phi i32 [ 0, %77 ], [ %62, %52 ]
%85 = phi i32 [ 0, %77 ], [ %70, %52 ]
%86 = add nuw nsw i64 %53, 1
%87 = icmp eq i64 %86, %51
br i1 %87, label %88, label %52
88: ; preds = %83
%89 = icmp sgt i32 %85, 0
br i1 %89, label %90, label %105
90: ; preds = %88
%91 = load i8, i8* %45
%92 = icmp eq i8 %91, 0
br i1 %92, label %95, label %93
93: ; preds = %90
%94 = call i32 @strcat(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %95
95: ; preds = %93, %90
%96 = add nsw i32 %85, -1
%97 = zext i32 %96 to i64
%98 = getelementptr inbounds i8, i8* %21, i64 %97
store i8 0, i8* %98
%99 = zext i32 %85 to i64
%100 = getelementptr inbounds i8, i8* %21, i64 %99
store i8 0, i8* %100
%101 = select i1 %24, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* %3
%102 = select i1 %29, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* %4
%103 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %38, i32 %37, i8* %7, i8* %101, i8* %16, i8* %21, i8* %102)
%104 = call i32 @strcat(i8* %45, i8* %38)
br label %105
105: ; preds = %88, %95, %32, %40
%106 = phi i8* [ %45, %95 ], [ null, %32 ], [ null, %40 ], [ %45, %88 ]
%107 = call i32 @free(i8* %16)
%108 = call i32 @free(i8* %21)
%109 = icmp eq i8* %38, null
br i1 %109, label %114, label %110
110: ; preds = %105, %18
%111 = phi i8* [ %16, %18 ], [ %38, %105 ]
%112 = phi i8* [ null, %18 ], [ %106, %105 ]
%113 = call i32 @free(i8* %111)
br label %114
114: ; preds = %110, %13, %105, %5
%115 = phi i8* [ null, %5 ], [ %106, %105 ], [ null, %13 ], [ %112, %110 ]
ret i8* %115
}