#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*/ snprintf(char *, int, char *, int);
int strprintsha(char *dest, int *hashval) {
  int x;
  char *hashstr = dest;
  for (x = 0; x < 5; x++) {
    snprintf(hashstr, 9, "%08x", hashval[x]);
    hashstr += 8;
  }
  *hashstr = 0;
  return 0;
}


x86 assembly (clang, -O0):
<strprintsha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    1173 <strprintsha+0x63>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    $0x9,%esi
lea    0xeac(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112f <strprintsha+0x1f>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strprintsha>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rsi),%ecx
lea    0xedc(%rip),%r15
mov    $0x9,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
lea    0x8(%rbx),%rdi
mov    0x4(%r14),%ecx
mov    $0x9,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
lea    0x10(%rbx),%rdi
mov    0x8(%r14),%ecx
mov    $0x9,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
lea    0x18(%rbx),%rdi
mov    0xc(%r14),%ecx
mov    $0x9,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
lea    0x20(%rbx),%rdi
mov    0x10(%r14),%ecx
mov    $0x9,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
movb   $0x0,0x28(%rbx)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%08x\00"
define i32 @strprintsha(i8* %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = tail call i32 @snprintf(i8* %0, i32 9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = getelementptr inbounds i8, i8* %0, i64 8
%6 = getelementptr inbounds i32, i32* %1, i64 1
%7 = load i32, i32* %6
%8 = tail call i32 @snprintf(i8* %5, i32 9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds i8, i8* %0, i64 16
%10 = getelementptr inbounds i32, i32* %1, i64 2
%11 = load i32, i32* %10
%12 = tail call i32 @snprintf(i8* %9, i32 9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds i8, i8* %0, i64 24
%14 = getelementptr inbounds i32, i32* %1, i64 3
%15 = load i32, i32* %14
%16 = tail call i32 @snprintf(i8* %13, i32 9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i8, i8* %0, i64 32
%18 = getelementptr inbounds i32, i32* %1, i64 4
%19 = load i32, i32* %18
%20 = tail call i32 @snprintf(i8* %17, i32 9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds i8, i8* %0, i64 40
store i8 0, i8* %21
ret i32 0
}