#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 char uint8_t;

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char);
int /*<<< orphan*/ strcat(char *, char *);
void vthconvert(int size, char *crrz01, const uint8_t *xbuf) {
  uint8_t buf[400];
  bzero(buf, 400);
  for (int cz = 0; cz < size; cz++) {
    buf[cz] = xbuf[cz];
  }
  if (crrz01 != NULL) {
    char *crrz1 = NULL;
    crrz1 = crrz01;
    char conv_proc[800] = "\0";
    int i;
    for (i = 0; i < (size * 2); i++) {
      if (buf[i] != '\0') {
        sprintf(conv_proc, "%02X", buf[i]);
        strcat(crrz1, conv_proc);
      }
    }
    crrz1 = NULL;
  }
}


x86 assembly (clang, -O0):
<vthconvert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4f0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x1b0(%rbp),%rdi
mov    $0x190,%esi
call   1040 <bzero@plt>
movl   $0x0,-0x1b4(%rbp)
mov    -0x1b4(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b0 <vthconvert+0x70>
mov    -0x18(%rbp),%rax
movslq -0x1b4(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x1b4(%rbp),%rax
mov    %cl,-0x1b0(%rbp,%rax,1)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
jmp    1171 <vthconvert+0x31>
cmpq   $0x0,-0x10(%rbp)
je     1273 <vthconvert+0x133>
movq   $0x0,-0x1c0(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x1c0(%rbp)
lea    -0x4e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x320,%edx
call   1030 <memset@plt>
movl   $0x0,-0x4e4(%rbp)
mov    -0x4e4(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1268 <vthconvert+0x128>
movslq -0x4e4(%rbp),%rax
movsbl -0x1b0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     124f <vthconvert+0x10f>
lea    -0x4e0(%rbp),%rdi
movslq -0x4e4(%rbp),%rax
lea    0xdd1(%rip),%rsi
movsbl -0x1b0(%rbp,%rax,1),%edx
ff
call   1060 <sprintf@plt>
mov    -0x1c0(%rbp),%rdi
lea    -0x4e0(%rbp),%rsi
call   1050 <strcat@plt>
jmp    1254 <vthconvert+0x114>
mov    -0x4e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4e4(%rbp)
jmp    11ee <vthconvert+0xae>
movq   $0x0,-0x1c0(%rbp)
add    $0x4f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vthconvert>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x4b0,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%r15d
mov    %rsp,%rdi
mov    $0x190,%esi
call   1050 <bzero@plt>
test   %r15d,%r15d
jle    11ec <vthconvert+0x9c>
mov    %r15d,%edx
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1040 <memcpy@plt>
test   %r14,%r14
je     1205 <vthconvert+0xb5>
lea    0x190(%rsp),%r12
xor    %ebp,%ebp
mov    $0x320,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
add    %r15d,%r15d
cmp    $0x2,%r15d
mov    $0x1,%ebx
cmovge %r15d,%ebx
lea    0xe43(%rip),%r15
jmp    11c9 <vthconvert+0x79>
nop
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1205 <vthconvert+0xb5>
movzbl (%rsp,%rbp,1),%eax
test   %al,%al
je     11c0 <vthconvert+0x70>
movsbl %al,%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
jmp    11c0 <vthconvert+0x70>
test   %r14,%r14
je     1205 <vthconvert+0xb5>
lea    0x190(%rsp),%rdi
mov    $0x320,%edx
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x4b0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%02X\00"
define void @vthconvert(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [400 x i8]
%8 = alloca i32
%9 = alloca i8*
%10 = alloca [800 x i8]
%11 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%12 = getelementptr inbounds [400 x i8], [400 x i8]* %7, i64 0, i64 0
%13 = call i32 @bzero(i8* %12, i32 400)
store i32 0, i32* %8
br label %14
14: ; preds = %27, %3
%15 = load i32, i32* %8
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %30
18: ; preds = %14
%19 = load i8*, i8** %6
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [400 x i8], [400 x i8]* %7, i64 0, i64 %25
store i8 %23, i8* %26
br label %27
27: ; preds = %18
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %14
30: ; preds = %14
%31 = load i8*, i8** %5
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %63
33: ; preds = %30
store i8* null, i8** %9
%34 = load i8*, i8** %5
store i8* %34, i8** %9
%35 = bitcast [800 x i8]* %10 to i8*
store i32 0, i32* %11
br label %36
36: ; preds = %59, %33
%37 = load i32, i32* %11
%38 = load i32, i32* %4
%39 = mul nsw i32 %38, 2
%40 = icmp slt i32 %37, %39
br i1 %40, label %41, label %62
41: ; preds = %36
%42 = load i32, i32* %11
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [400 x i8], [400 x i8]* %7, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %58
48: ; preds = %41
%49 = getelementptr inbounds [800 x i8], [800 x i8]* %10, i64 0, i64 0
%50 = load i32, i32* %11
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [400 x i8], [400 x i8]* %7, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = call i32 @sprintf(i8* %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %53)
%55 = load i8*, i8** %9
%56 = getelementptr inbounds [800 x i8], [800 x i8]* %10, i64 0, i64 0
%57 = call i32 @strcat(i8* %55, i8* %56)
br label %58
58: ; preds = %48, %41
br label %59
59: ; preds = %58
%60 = load i32, i32* %11
%61 = add nsw i32 %60, 1
store i32 %61, i32* %11
br label %36
62: ; preds = %36
store i8* null, i8** %9
br label %63
63: ; preds = %62, %30
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02X\00"
define void @vthconvert(i32 %0, i8* %1, i8* nocapture %2) {
%4 = alloca [400 x i8]
%5 = alloca [800 x i8]
%6 = getelementptr inbounds [400 x i8], [400 x i8]* %4, i64 0, i64 0
%7 = call i32 @bzero(i8* %6, i32 400)
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = getelementptr inbounds [400 x i8], [400 x i8]* %4, i64 0, i64 0
%11 = zext i32 %0 to i64
%12 = icmp eq i8* %1, null
br i1 %12, label %35, label %17
13: ; preds = %3
%14 = icmp eq i8* %1, null
br i1 %14, label %35, label %15
15: ; preds = %13
%16 = getelementptr inbounds [800 x i8], [800 x i8]* %5, i64 0, i64 0
br label %33
17: ; preds = %9
%18 = getelementptr inbounds [800 x i8], [800 x i8]* %5, i64 0, i64 0
%19 = shl i32 %0, 1
%20 = call i32 @llvm.smax.i32(i32 %19, i32 1)
%21 = zext i32 %20 to i64
br label %22
22: ; preds = %17, %30
%23 = phi i64 [ 0, %17 ], [ %31, %30 ]
%24 = getelementptr inbounds [400 x i8], [400 x i8]* %4, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %22
%28 = call i32 @sprintf(i8* %18, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %25)
%29 = call i32 @strcat(i8* %1, i8* %18)
br label %30
30: ; preds = %22, %27
%31 = add nuw nsw i64 %23, 1
%32 = icmp eq i64 %31, %21
br i1 %32, label %33, label %22
33: ; preds = %30, %15
%34 = getelementptr inbounds [800 x i8], [800 x i8]* %5, i64 0, i64 0
br label %35
35: ; preds = %13, %33, %9
ret void
}