#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 */
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
void convert(char *convert_result, uint8_t *buf) {
  char conv_proc[800] = "\0";
  bzero(conv_proc, 800);
  int i;
  for (i = 0; i < 10; i++) {
    sprintf(conv_proc, "%02X", buf[i]);
    strcat(convert_result, conv_proc);
  }
}


x86 assembly (clang, -O0):
<convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x330(%rbp),%rdi
xor    %esi,%esi
mov    $0x320,%edx
call   1030 <memset@plt>
lea    -0x330(%rbp),%rdi
mov    $0x320,%esi
call   1040 <bzero@plt>
movl   $0x0,-0x334(%rbp)
cmpl   $0xa,-0x334(%rbp)
jge    11d3 <convert+0x93>
lea    -0x330(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x334(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe56(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x330(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x334(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x334(%rbp)
jmp    1181 <convert+0x41>
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x328,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsp,%rbx
mov    $0x320,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %rbx,%rdi
mov    $0x320,%esi
call   1040 <bzero@plt>
mov    (%r15),%edx
lea    0xe83(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    0x4(%r15),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    0x8(%r15),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    0xc(%r15),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    0x10(%r15),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    0x14(%r15),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    0x18(%r15),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    0x1c(%r15),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    0x20(%r15),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    0x24(%r15),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
add    $0x328,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%02X\00"
define void @convert(i8* %0, i32* nocapture %1) {
%3 = alloca [800 x i8]
%4 = getelementptr inbounds [800 x i8], [800 x i8]* %3, i64 0, i64 0
%5 = call i32 @bzero(i8* %4, i32 800)
%6 = load i32, i32* %1
%7 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @strcat(i8* %0, i8* %4)
%9 = getelementptr inbounds i32, i32* %1, i64 1
%10 = load i32, i32* %9
%11 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @strcat(i8* %0, i8* %4)
%13 = getelementptr inbounds i32, i32* %1, i64 2
%14 = load i32, i32* %13
%15 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = call i32 @strcat(i8* %0, i8* %4)
%17 = getelementptr inbounds i32, i32* %1, i64 3
%18 = load i32, i32* %17
%19 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = call i32 @strcat(i8* %0, i8* %4)
%21 = getelementptr inbounds i32, i32* %1, i64 4
%22 = load i32, i32* %21
%23 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = call i32 @strcat(i8* %0, i8* %4)
%25 = getelementptr inbounds i32, i32* %1, i64 5
%26 = load i32, i32* %25
%27 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = call i32 @strcat(i8* %0, i8* %4)
%29 = getelementptr inbounds i32, i32* %1, i64 6
%30 = load i32, i32* %29
%31 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = call i32 @strcat(i8* %0, i8* %4)
%33 = getelementptr inbounds i32, i32* %1, i64 7
%34 = load i32, i32* %33
%35 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = call i32 @strcat(i8* %0, i8* %4)
%37 = getelementptr inbounds i32, i32* %1, i64 8
%38 = load i32, i32* %37
%39 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = call i32 @strcat(i8* %0, i8* %4)
%41 = getelementptr inbounds i32, i32* %1, i64 9
%42 = load i32, i32* %41
%43 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = call i32 @strcat(i8* %0, i8* %4)
ret void
}