#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*/ free(char *);
char *igbc_char_hex(char);
scalar_t__ malloc(int);
char *__hexify(void *data, int size) {
  char *out = (char *)malloc(size * 3);
  int i = 0;
  for (i = 0; i < size; i++) {
    char *next = igbc_char_hex(((char *)data)[i]);
    out[i * 3] = next[0];
    out[(i * 3) + 1] = next[1];
    out[(i * 3) + 2] = ' ';
    free(next);
  }
  out[(size * 3) - 1] = '\0';
  return out;
}


x86 assembly (clang, -O0):
<__hexify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
imul   $0x3,-0xc(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d0 <__hexify+0xa0>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <igbc_char_hex@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%dl
mov    -0x18(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    0x1(%rax),%dl
mov    -0x18(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115a <__hexify+0x2a>
mov    -0x18(%rbp),%rax
imul   $0x3,-0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__hexify>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r12d
mov    %rdi,%rbx
movslq %esi,%rbp
lea    0x0(,%rbp,2),%r14
add    %rbp,%r14
mov    %r14d,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
test   %ebp,%ebp
jle    11a9 <__hexify+0x79>
mov    %r12d,%eax
lea    (%rax,%rax,2),%r12
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rbx),%edi
call   1050 <igbc_char_hex@plt>
movzbl (%rax),%ecx
mov    %ebp,%edx
mov    %cl,(%r15,%rdx,1)
movzbl 0x1(%rax),%ecx
lea    0x1(%rbp),%edx
mov    %cl,(%r15,%rdx,1)
lea    0x2(%rbp),%ecx
movb   $0x20,(%r15,%rcx,1)
mov    %rax,%rdi
call   1030 <free@plt>
add    $0x3,%rbp
add    $0x1,%rbx
cmp    %rbp,%r12
jne    1170 <__hexify+0x40>
movb   $0x0,-0x1(%r14,%r15,1)
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @__hexify(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = mul nsw i32 %8, 3
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %5
store i32 0, i32* %6
store i32 0, i32* %6
br label %12
12: ; preds = %48, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %51
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = call i8* @igbc_char_hex(i8 signext %21)
store i8* %22, i8** %7
%23 = load i8*, i8** %7
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = load i8*, i8** %5
%27 = load i32, i32* %6
%28 = mul nsw i32 %27, 3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
store i8 %25, i8* %30
%31 = load i8*, i8** %7
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8, i8* %32
%34 = load i8*, i8** %5
%35 = load i32, i32* %6
%36 = mul nsw i32 %35, 3
%37 = add nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %34, i64 %38
store i8 %33, i8* %39
%40 = load i8*, i8** %5
%41 = load i32, i32* %6
%42 = mul nsw i32 %41, 3
%43 = add nsw i32 %42, 2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %40, i64 %44
store i8 32, i8* %45
%46 = load i8*, i8** %7
%47 = call i32 @free(i8* %46)
br label %48
48: ; preds = %16
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %12
51: ; preds = %12
%52 = load i8*, i8** %5
%53 = load i32, i32* %4
%54 = mul nsw i32 %53, 3
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %52, i64 %56
store i8 0, i8* %57
%58 = load i8*, i8** %5
ret i8* %58
}

LLVM IR (-O2):
define i8* @__hexify(i8* nocapture %0, i32 %1) {
%3 = mul nsw i32 %1, 3
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to i8*
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %30
7: ; preds = %2
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %28, %9 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = tail call i8* @igbc_char_hex(i8 signext %12)
%14 = load i8, i8* %13
%15 = trunc i64 %10 to i32
%16 = mul nsw i32 %15, 3
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %5, i64 %17
store i8 %14, i8* %18
%19 = getelementptr inbounds i8, i8* %13, i64 1
%20 = load i8, i8* %19
%21 = add nuw nsw i32 %16, 1
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %5, i64 %22
store i8 %20, i8* %23
%24 = add nuw nsw i32 %16, 2
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %5, i64 %25
store i8 32, i8* %26
%27 = tail call i32 @free(i8* %13)
%28 = add nuw nsw i64 %10, 1
%29 = icmp eq i64 %28, %8
br i1 %29, label %30, label %9
30: ; preds = %9, %2
%31 = add nsw i32 %3, -1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %5, i64 %32
store i8 0, i8* %33
ret i8* %5
}