#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 sprintf(char *, char *, unsigned char const);
void get_xtra_hash_minor_hex(const unsigned char *a, char *szXtra) {
  unsigned char c;
  int i, j, start_byte = 4;
  c = a[start_byte] & 0xe0;
  j = sprintf(szXtra, "%02x", c);
  for (i = start_byte + 1; i < 32; i++)
    j += sprintf(szXtra + j, "%02x", a[i]);
}


x86 assembly (clang, -O0):
<get_xtra_hash_minor_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x4,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0xe0,%eax
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeba(%rip),%rsi
movzbl -0x11(%rbp),%edx
call   1030 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
jge    119c <get_xtra_hash_minor_hex+0x8c>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
lea    0xe81(%rip),%rsi
movzbl (%rax,%rcx,1),%edx
call   1030 <sprintf@plt>
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115b <get_xtra_hash_minor_hex+0x4b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_xtra_hash_minor_hex>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
movzbl 0x4(%rdi),%edx
and    $0xffffffe0,%edx
lea    0xed3(%rip),%r15
mov    %rsi,%rdi
mov    %r15,%rsi
call   1030 <sprintf@plt>
mov    %eax,%ebx
mov    $0x5,%r13d
movslq %ebx,%rbx
lea    (%r14,%rbx,1),%rdi
movzbl (%r12,%r13,1),%edx
mov    %r15,%rsi
call   1030 <sprintf@plt>
add    %eax,%ebx
add    $0x1,%r13
cmp    $0x20,%r13
jne    1140 <get_xtra_hash_minor_hex+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
define void @get_xtra_hash_minor_hex(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 4
%4 = load i8, i8* %3
%5 = and i8 %4, -32
%6 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %5)
br label %7
7: ; preds = %2, %7
%8 = phi i64 [ 5, %2 ], [ %16, %7 ]
%9 = phi i32 [ %6, %2 ], [ %15, %7 ]
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = getelementptr inbounds i8, i8* %0, i64 %8
%13 = load i8, i8* %12
%14 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %13)
%15 = add nsw i32 %14, %9
%16 = add nuw nsw i64 %8, 1
%17 = icmp eq i64 %16, 32
br i1 %17, label %18, label %7
18: ; preds = %7
ret void
}