#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 scalar_t__ int32_t;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, scalar_t__, char *, unsigned char,
                            unsigned char);
void fetch_readable_signatrue(unsigned char digest[20], char *buf,
                              int32_t len) {
  for (int i = 0; i < 20; i += 2) {
    snprintf(buf + i, len - i, "%02x%02x", digest[i], digest[i + 1]);
  }
}


x86 assembly (clang, -O0):
<fetch_readable_signatrue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jge    1185 <fetch_readable_signatrue+0x75>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
movslq -0x1c(%rbp),%rax
sub    %rax,%rsi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
movslq %edx,%r8
lea    0xe96(%rip),%rdx
movzbl %cl,%ecx
movzbl (%rax,%r8,1),%r8d
call   1030 <snprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <fetch_readable_signatrue+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fetch_readable_signatrue>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movzbl (%rdi),%ecx
movzbl 0x1(%rdi),%r8d
lea    0xed0(%rip),%r12
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %r12,%rdx
call   1030 <snprintf@plt>
lea    0x2(%r15),%rdi
lea    -0x2(%r14),%rsi
movzbl 0x2(%rbx),%ecx
movzbl 0x3(%rbx),%r8d
mov    %r12,%rdx
call   1030 <snprintf@plt>
lea    0x4(%r15),%rdi
lea    -0x4(%r14),%rsi
movzbl 0x4(%rbx),%ecx
movzbl 0x5(%rbx),%r8d
mov    %r12,%rdx
call   1030 <snprintf@plt>
lea    0x6(%r15),%rdi
lea    -0x6(%r14),%rsi
movzbl 0x6(%rbx),%ecx
movzbl 0x7(%rbx),%r8d
mov    %r12,%rdx
call   1030 <snprintf@plt>
lea    0x8(%r15),%rdi
lea    -0x8(%r14),%rsi
movzbl 0x8(%rbx),%ecx
movzbl 0x9(%rbx),%r8d
mov    %r12,%rdx
call   1030 <snprintf@plt>
lea    0xa(%r15),%rdi
lea    -0xa(%r14),%rsi
movzbl 0xa(%rbx),%ecx
movzbl 0xb(%rbx),%r8d
mov    %r12,%rdx
call   1030 <snprintf@plt>
lea    0xc(%r15),%rdi
lea    -0xc(%r14),%rsi
movzbl 0xc(%rbx),%ecx
movzbl 0xd(%rbx),%r8d
mov    %r12,%rdx
call   1030 <snprintf@plt>
lea    0xe(%r15),%rdi
lea    -0xe(%r14),%rsi
movzbl 0xe(%rbx),%ecx
movzbl 0xf(%rbx),%r8d
mov    %r12,%rdx
call   1030 <snprintf@plt>
lea    0x10(%r15),%rdi
lea    -0x10(%r14),%rsi
movzbl 0x10(%rbx),%ecx
movzbl 0x11(%rbx),%r8d
mov    %r12,%rdx
call   1030 <snprintf@plt>
add    $0x12,%r15
add    $0xffffffffffffffee,%r14
movzbl 0x12(%rbx),%ecx
movzbl 0x13(%rbx),%r8d
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <snprintf@plt>

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

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