#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 convert2(char *convert_result2, uint8_t *bufhx) {
  uint8_t *buf = NULL;
  buf = bufhx;
  char conv_proc[3] = "\0";
  conv_proc[3] = '\0';
  bzero(conv_proc, 3);
  int i;
  for (i = 0; i == 0; i++) {
    sprintf(conv_proc, "%02X", buf[i]);
    strcat(convert_result2, conv_proc);
  }
  buf = NULL;
}


x86 assembly (clang, -O0):
<convert2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x1b(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1030 <memset@plt>
movb   $0x0,-0x18(%rbp)
lea    -0x1b(%rbp),%rdi
mov    $0x3,%esi
call   1040 <bzero@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    11c9 <convert2+0x89>
lea    -0x1b(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe57(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1b(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1189 <convert2+0x49>
movq   $0x0,-0x18(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert2>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%r15
mov    %r15,%rdi
mov    $0x3,%esi
call   1030 <bzero@plt>
mov    (%rbx),%edx
lea    0xe9e(%rip),%rsi
mov    %r15,%rdi
call   1050 <sprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%02X\00"
define void @convert2(i8* %0, i32* nocapture %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = bitcast [3 x i8]* %3 to i32*
store i32 0, i32* %5
%6 = call i32 @bzero(i8* %4, i32 3)
%7 = load i32, i32* %1
%8 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @strcat(i8* %0, i8* %4)
ret void
}