#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 uint8_t;

/* Variables and functions */
char *strsign(const void *data, size_t len) {
  static char s[0x100];
  char *t = s;
  static const char *digits = "0123456789ABCDEF";
  const uint8_t *buf = data;
  while (len--) {
    *t++ = digits[*buf >> 4];
    *t++ = digits[*buf & 0x0F];
    buf++;
  }
  *t = '\0';
  return s;
}


x86 assembly (clang, -O0):
<strsign>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0x2f2d(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     1197 <strsign+0x97>
mov    0x2ee1(%rip),%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%ecx
sar    $0x4,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    0x2eba(%rip),%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%ecx
and    $0xf,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    111f <strsign+0x1f>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e9b(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strsign>:
test   %rsi,%rsi
je     1178 <strsign+0x78>
test   $0x1,%sil
jne    1181 <strsign+0x81>
lea    0x2f1e(%rip),%rcx
mov    %rsi,%r8
cmp    $0x1,%rsi
je     11c0 <strsign+0xc0>
xor    %edx,%edx
lea    0xed8(%rip),%rsi
nopl   0x0(%rax,%rax,1)
mov    (%rdi,%rdx,4),%eax
sar    $0x4,%eax
cltq
movzbl (%rax,%rsi,1),%eax
mov    %al,(%rcx)
mov    (%rdi,%rdx,4),%eax
and    $0xf,%eax
movzbl (%rax,%rsi,1),%eax
mov    %al,0x1(%rcx)
mov    0x4(%rdi,%rdx,4),%eax
sar    $0x4,%eax
cltq
movzbl (%rax,%rsi,1),%eax
mov    %al,0x2(%rcx)
mov    0x4(%rdi,%rdx,4),%eax
and    $0xf,%eax
movzbl (%rax,%rsi,1),%eax
mov    %al,0x3(%rcx)
add    $0x4,%rcx
add    $0x2,%rdx
cmp    %rdx,%r8
jne    1130 <strsign+0x30>
jmp    11c7 <strsign+0xc7>
lea    0x2eb1(%rip),%rcx
jmp    11c7 <strsign+0xc7>
lea    -0x1(%rsi),%r8
mov    (%rdi),%ecx
sar    $0x4,%ecx
movslq %ecx,%rcx
lea    0xe6c(%rip),%rdx
mov    (%rcx,%rdx,1),%cl
mov    %cl,0x2e93(%rip)
mov    (%rdi),%ecx
and    $0xf,%ecx
mov    (%rcx,%rdx,1),%cl
mov    %cl,0x2e86(%rip)
add    $0x4,%rdi
lea    0x2e7c(%rip),%rcx
cmp    $0x1,%rsi
jne    111f <strsign+0x1f>
lea    0x2e6b(%rip),%rcx
movb   $0x0,(%rcx)
lea    0x2e5f(%rip),%rax
ret

LLVM IR (-O0):
@strsign.s = internal global [256 x i8] zeroinitializer
@strsign.digits = internal global i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0)
@.str = [17 x i8] c"0123456789ABCDEF\00"
define i8* @strsign(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32*
store i8* %0, i8** %3
store i64 %1, i64* %4
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @strsign.s, i64 0, i64 0), i8** %5
%7 = load i8*, i8** %3
%8 = bitcast i8* %7 to i32*
store i32* %8, i32** %6
br label %9
9: ; preds = %13, %2
%10 = load i64, i64* %4
%11 = add i64 %10, -1
store i64 %11, i64* %4
%12 = icmp ne i64 %10, 0
br i1 %12, label %13, label %34
13: ; preds = %9
%14 = load i8*, i8** @strsign.digits
%15 = load i32*, i32** %6
%16 = load i32, i32* %15
%17 = ashr i32 %16, 4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %14, i64 %18
%20 = load i8, i8* %19
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %5
store i8 %20, i8* %21
%23 = load i8*, i8** @strsign.digits
%24 = load i32*, i32** %6
%25 = load i32, i32* %24
%26 = and i32 %25, 15
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %23, i64 %27
%29 = load i8, i8* %28
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %5
store i8 %29, i8* %30
%32 = load i32*, i32** %6
%33 = getelementptr inbounds i32, i32* %32, i32 1
store i32* %33, i32** %6
br label %9
34: ; preds = %9
%35 = load i8*, i8** %5
store i8 0, i8* %35
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @strsign.s, i64 0, i64 0)
}

LLVM IR (-O2):
@strsign.s = internal global [256 x i8] zeroinitializer
@.str = [17 x i8] c"0123456789ABCDEF\00"
define i8* @strsign(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %59, label %4
4: ; preds = %2
%5 = bitcast i8* %0 to i32*
%6 = and i64 %1, 1
%7 = icmp eq i64 %6, 0
br i1 %7, label %22, label %8
8: ; preds = %4
%9 = add i64 %1, -1
%10 = load i32, i32* %5
%11 = ashr i32 %10, 4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %12
%14 = load i8, i8* %13
store i8 %14, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @strsign.s, i64 0, i64 0)
%15 = load i32, i32* %5
%16 = and i32 %15, 15
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %17
%19 = load i8, i8* %18
store i8 %19, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @strsign.s, i64 0, i64 1)
%20 = getelementptr inbounds i8, i8* %0, i64 4
%21 = bitcast i8* %20 to i32*
br label %22
22: ; preds = %8, %4
%23 = phi i32* [ %5, %4 ], [ %21, %8 ]
%24 = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @strsign.s, i64 0, i64 0), %4 ], [ getelementptr inbounds ([256 x i8], [256 x i8]* @strsign.s, i64 0, i64 2), %8 ]
%25 = phi i64 [ %1, %4 ], [ %9, %8 ]
%26 = icmp eq i64 %1, 1
br i1 %26, label %59, label %27
27: ; preds = %22, %27
%28 = phi i32* [ %57, %27 ], [ %23, %22 ]
%29 = phi i8* [ %56, %27 ], [ %24, %22 ]
%30 = phi i64 [ %44, %27 ], [ %25, %22 ]
%31 = load i32, i32* %28
%32 = ashr i32 %31, 4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = getelementptr inbounds i8, i8* %29, i64 1
store i8 %35, i8* %29
%37 = load i32, i32* %28
%38 = and i32 %37, 15
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = getelementptr inbounds i8, i8* %29, i64 2
store i8 %41, i8* %36
%43 = getelementptr inbounds i32, i32* %28, i64 1
%44 = add i64 %30, -2
%45 = load i32, i32* %43
%46 = ashr i32 %45, 4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = getelementptr inbounds i8, i8* %29, i64 3
store i8 %49, i8* %42
%51 = load i32, i32* %43
%52 = and i32 %51, 15
%53 = zext i32 %52 to i64
%54 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = getelementptr inbounds i8, i8* %29, i64 4
store i8 %55, i8* %50
%57 = getelementptr inbounds i32, i32* %28, i64 2
%58 = icmp eq i64 %44, 0
br i1 %58, label %59, label %27
59: ; preds = %22, %27, %2
%60 = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @strsign.s, i64 0, i64 0), %2 ], [ getelementptr inbounds ([256 x i8], [256 x i8]* @strsign.s, i64 0, i64 2), %22 ], [ %56, %27 ]
store i8 0, i8* %60
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @strsign.s, i64 0, i64 0)
}