#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 */
scalar_t__ malloc(int);
scalar_t__ sprintf(char *, char *, int);
char *convert(unsigned char *hash) {
  char *fname = (char *)malloc(256);
  int i, count = 0;
  for (i = 0; i < 5; i++) {
    count += sprintf(fname + count, "%u", *(int *)(hash + i));
  }
  return fname;
}


x86 assembly (clang, -O0):
<convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x100,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    118f <convert+0x6f>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%edx
lea    0xe91(%rip),%rsi
call   1040 <sprintf@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1148 <convert+0x28>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
mov    $0x100,%edi
call   1030 <malloc@plt>
mov    %rax,%r13
mov    (%r14),%edx
lea    0xebd(%rip),%r15
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
mov    %rax,%r12
movslq %r12d,%rdi
add    %r13,%rdi
mov    0x1(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
mov    %rax,%rbx
add    %r12,%rbx
movslq %ebx,%rdi
add    %r13,%rdi
mov    0x2(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
add    %rbx,%rax
movslq %eax,%rbx
lea    (%rbx,%r13,1),%rdi
mov    0x3(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
add    %eax,%ebx
movslq %ebx,%rdi
add    %r13,%rdi
mov    0x4(%r14),%edx
mov    %r15,%rsi
call   1040 <sprintf@plt>
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
define i8* @convert(i8* nocapture %0) {
%2 = tail call i64 @malloc(i32 256)
%3 = inttoptr i64 %2 to i8*
%4 = bitcast i8* %0 to i32*
%5 = load i32, i32* %4
%6 = tail call i64 @sprintf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = shl i64 %6, 32
%8 = ashr exact i64 %7, 32
%9 = getelementptr inbounds i8, i8* %3, i64 %8
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = bitcast i8* %10 to i32*
%12 = load i32, i32* %11
%13 = tail call i64 @sprintf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = add i64 %13, %6
%15 = shl i64 %14, 32
%16 = ashr exact i64 %15, 32
%17 = getelementptr inbounds i8, i8* %3, i64 %16
%18 = getelementptr inbounds i8, i8* %0, i64 2
%19 = bitcast i8* %18 to i32*
%20 = load i32, i32* %19
%21 = tail call i64 @sprintf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = add i64 %21, %14
%23 = shl i64 %22, 32
%24 = ashr exact i64 %23, 32
%25 = getelementptr inbounds i8, i8* %3, i64 %24
%26 = getelementptr inbounds i8, i8* %0, i64 3
%27 = bitcast i8* %26 to i32*
%28 = load i32, i32* %27
%29 = tail call i64 @sprintf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = add i64 %29, %22
%31 = shl i64 %30, 32
%32 = ashr exact i64 %31, 32
%33 = getelementptr inbounds i8, i8* %3, i64 %32
%34 = getelementptr inbounds i8, i8* %0, i64 4
%35 = bitcast i8* %34 to i32*
%36 = load i32, i32* %35
%37 = tail call i64 @sprintf(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %36)
ret i8* %3
}