#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*/ sprintf(char *, char *, char);
char *strdup(char *);
char *readable(char *data) {
  char r[33];
  int i;
  char *encoded = r;
  for (i = 0; i < 16; i++, encoded += 2, data++)
    sprintf(encoded, "%02hhx", *data);
  *encoded = '\0';
  return strdup(r);
}


x86 assembly (clang, -O0):
<readable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x10,-0x34(%rbp)
jge    1182 <readable+0x62>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rax
lea    0xeac(%rip),%rsi
movsbl (%rax),%edx
call   1030 <sprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x40(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113b <readable+0x1b>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x30(%rbp),%rdi
call   1040 <strdup@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readable>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
movsbl (%rdi),%edx
lea    0xeca(%rip),%r15
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x2(%rsp),%rdi
movsbl 0x1(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x4(%rsp),%rdi
movsbl 0x2(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x6(%rsp),%rdi
movsbl 0x3(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x8(%rsp),%rdi
movsbl 0x4(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0xa(%rsp),%rdi
movsbl 0x5(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0xc(%rsp),%rdi
movsbl 0x6(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0xe(%rsp),%rdi
movsbl 0x7(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x10(%rsp),%rdi
movsbl 0x8(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x12(%rsp),%rdi
movsbl 0x9(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x14(%rsp),%rdi
movsbl 0xa(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x16(%rsp),%rdi
movsbl 0xb(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x18(%rsp),%rdi
movsbl 0xc(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x1a(%rsp),%rdi
movsbl 0xd(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x1c(%rsp),%rdi
movsbl 0xe(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
lea    0x1e(%rsp),%rdi
movsbl 0xf(%rbx),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
movb   $0x0,0x20(%rsp)
mov    %r14,%rdi
call   1040 <strdup@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%02hhx\00"
define i8* @readable(i8* %0) {
%2 = alloca i8*
%3 = alloca [33 x i8]
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %2
%6 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
store i8* %6, i8** %5
store i32 0, i32* %4
br label %7
7: ; preds = %15, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 16
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = load i8*, i8** %5
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %13)
br label %15
15: ; preds = %10
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 2
store i8* %19, i8** %5
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %2
br label %7
22: ; preds = %7
%23 = load i8*, i8** %5
store i8 0, i8* %23
%24 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%25 = call i8* @strdup(i8* %24)
ret i8* %25
}

LLVM IR (-O2):
@.str = [7 x i8] c"%02hhx\00"
define noalias i8* @readable(i8* nocapture %0) {
%2 = alloca [33 x i8]
%3 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
%5 = call i32 @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %4)
%6 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 2
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = call i32 @sprintf(i8* dereferenceable(1) %6, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %8)
%10 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 4
%11 = getelementptr inbounds i8, i8* %0, i64 2
%12 = load i8, i8* %11
%13 = call i32 @sprintf(i8* dereferenceable(1) %10, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %12)
%14 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 6
%15 = getelementptr inbounds i8, i8* %0, i64 3
%16 = load i8, i8* %15
%17 = call i32 @sprintf(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %16)
%18 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 8
%19 = getelementptr inbounds i8, i8* %0, i64 4
%20 = load i8, i8* %19
%21 = call i32 @sprintf(i8* dereferenceable(1) %18, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %20)
%22 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 10
%23 = getelementptr inbounds i8, i8* %0, i64 5
%24 = load i8, i8* %23
%25 = call i32 @sprintf(i8* dereferenceable(1) %22, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %24)
%26 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 12
%27 = getelementptr inbounds i8, i8* %0, i64 6
%28 = load i8, i8* %27
%29 = call i32 @sprintf(i8* dereferenceable(1) %26, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %28)
%30 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 14
%31 = getelementptr inbounds i8, i8* %0, i64 7
%32 = load i8, i8* %31
%33 = call i32 @sprintf(i8* dereferenceable(1) %30, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %32)
%34 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 16
%35 = getelementptr inbounds i8, i8* %0, i64 8
%36 = load i8, i8* %35
%37 = call i32 @sprintf(i8* dereferenceable(1) %34, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %36)
%38 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 18
%39 = getelementptr inbounds i8, i8* %0, i64 9
%40 = load i8, i8* %39
%41 = call i32 @sprintf(i8* dereferenceable(1) %38, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %40)
%42 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 20
%43 = getelementptr inbounds i8, i8* %0, i64 10
%44 = load i8, i8* %43
%45 = call i32 @sprintf(i8* dereferenceable(1) %42, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %44)
%46 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 22
%47 = getelementptr inbounds i8, i8* %0, i64 11
%48 = load i8, i8* %47
%49 = call i32 @sprintf(i8* dereferenceable(1) %46, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %48)
%50 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 24
%51 = getelementptr inbounds i8, i8* %0, i64 12
%52 = load i8, i8* %51
%53 = call i32 @sprintf(i8* dereferenceable(1) %50, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %52)
%54 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 26
%55 = getelementptr inbounds i8, i8* %0, i64 13
%56 = load i8, i8* %55
%57 = call i32 @sprintf(i8* dereferenceable(1) %54, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %56)
%58 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 28
%59 = getelementptr inbounds i8, i8* %0, i64 14
%60 = load i8, i8* %59
%61 = call i32 @sprintf(i8* dereferenceable(1) %58, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %60)
%62 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 30
%63 = getelementptr inbounds i8, i8* %0, i64 15
%64 = load i8, i8* %63
%65 = call i32 @sprintf(i8* dereferenceable(1) %62, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %64)
%66 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 32
store i8 0, i8* %66
%67 = call i8* @strdup(i8* %3)
ret i8* %67
}