#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 *, int);
void blockToString(unsigned char block[16], char *str) {
  int i;
  for (i = 0; i < 16; i++) {
    sprintf(&str[2 * i], "%02X", (int)block[i]);
  }
  str[16 * 2] = 0;
}


x86 assembly (clang, -O0):
<blockToString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    1166 <blockToString+0x56>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xead(%rip),%rsi
call   1030 <sprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <blockToString+0x17>
mov    -0x10(%rbp),%rax
movb   $0x0,0x20(%rax)
add    $0x20,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
@.str = [5 x i8] c"%02X\00"
define void @blockToString(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = zext i8 %3 to i32
%5 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = getelementptr inbounds i8, i8* %1, i64 2
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = tail call i32 @sprintf(i8* dereferenceable(1) %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds i8, i8* %1, i64 4
%12 = getelementptr inbounds i8, i8* %0, i64 2
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds i8, i8* %1, i64 6
%17 = getelementptr inbounds i8, i8* %0, i64 3
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = tail call i32 @sprintf(i8* dereferenceable(1) %16, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds i8, i8* %1, i64 8
%22 = getelementptr inbounds i8, i8* %0, i64 4
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = tail call i32 @sprintf(i8* dereferenceable(1) %21, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds i8, i8* %1, i64 10
%27 = getelementptr inbounds i8, i8* %0, i64 5
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = tail call i32 @sprintf(i8* dereferenceable(1) %26, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds i8, i8* %1, i64 12
%32 = getelementptr inbounds i8, i8* %0, i64 6
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = tail call i32 @sprintf(i8* dereferenceable(1) %31, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds i8, i8* %1, i64 14
%37 = getelementptr inbounds i8, i8* %0, i64 7
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = tail call i32 @sprintf(i8* dereferenceable(1) %36, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds i8, i8* %1, i64 16
%42 = getelementptr inbounds i8, i8* %0, i64 8
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = tail call i32 @sprintf(i8* dereferenceable(1) %41, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds i8, i8* %1, i64 18
%47 = getelementptr inbounds i8, i8* %0, i64 9
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = tail call i32 @sprintf(i8* dereferenceable(1) %46, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %49)
%51 = getelementptr inbounds i8, i8* %1, i64 20
%52 = getelementptr inbounds i8, i8* %0, i64 10
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = tail call i32 @sprintf(i8* dereferenceable(1) %51, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %54)
%56 = getelementptr inbounds i8, i8* %1, i64 22
%57 = getelementptr inbounds i8, i8* %0, i64 11
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
%60 = tail call i32 @sprintf(i8* dereferenceable(1) %56, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %59)
%61 = getelementptr inbounds i8, i8* %1, i64 24
%62 = getelementptr inbounds i8, i8* %0, i64 12
%63 = load i8, i8* %62
%64 = zext i8 %63 to i32
%65 = tail call i32 @sprintf(i8* dereferenceable(1) %61, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %64)
%66 = getelementptr inbounds i8, i8* %1, i64 26
%67 = getelementptr inbounds i8, i8* %0, i64 13
%68 = load i8, i8* %67
%69 = zext i8 %68 to i32
%70 = tail call i32 @sprintf(i8* dereferenceable(1) %66, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %69)
%71 = getelementptr inbounds i8, i8* %1, i64 28
%72 = getelementptr inbounds i8, i8* %0, i64 14
%73 = load i8, i8* %72
%74 = zext i8 %73 to i32
%75 = tail call i32 @sprintf(i8* dereferenceable(1) %71, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %74)
%76 = getelementptr inbounds i8, i8* %1, i64 30
%77 = getelementptr inbounds i8, i8* %0, i64 15
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = tail call i32 @sprintf(i8* dereferenceable(1) %76, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %79)
%81 = getelementptr inbounds i8, i8* %1, i64 32
store i8 0, i8* %81
ret void
}