#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*/ sscanf(unsigned char *, char *, char *);
void Str2Hex(const char *sSrc, char *sDest, int nSrcLen) {
  int i;
  char szTmp[3];
  for (i = 0; i < nSrcLen; i++) {
    sscanf((unsigned char *)&sSrc[i * 2], "%02X", &sDest[i]);
  }
  return;
}


x86 assembly (clang, -O0):
<Str2Hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    116a <Str2Hex+0x5a>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
mov    -0x10(%rbp),%rdx
movslq -0x18(%rbp),%rax
add    %rax,%rdx
lea    0xea9(%rip),%rsi
call   1030 <sscanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <Str2Hex+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Str2Hex>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    114c <Str2Hex+0x3c>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%r12d
lea    0xed4(%rip),%r15
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <sscanf@plt>
add    $0x2,%rbx
add    $0x1,%r14
add    $0xffffffffffffffff,%r12
jne    1130 <Str2Hex+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%02X\00"
define void @Str2Hex(i8* nocapture %0, i8* %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %15
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %13, %7 ]
%9 = shl nuw nsw i64 %8, 1
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = getelementptr inbounds i8, i8* %1, i64 %8
%12 = tail call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, %6
br i1 %14, label %15, label %7
15: ; preds = %7, %3
ret void
}