#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 */
char hexhightoasc11(char);
char hexlowtoasc11(char);
int bcdhex_to_aschex11(char bcdhex[], int len, char aschex[]) {
  int i;
  for (i = 0; i < len; i++) {
    aschex[2 * i] = hexhightoasc11(bcdhex[i]);
    aschex[2 * i + 1] = hexlowtoasc11(bcdhex[i]);
  }
  return (len * 2);
}


x86 assembly (clang, -O0):
<bcdhex_to_aschex11>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119d <bcdhex_to_aschex11+0x7d>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <hexhightoasc11@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <hexlowtoasc11@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <bcdhex_to_aschex11+0x1a>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bcdhex_to_aschex11>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
test   %esi,%esi
jle    1166 <bcdhex_to_aschex11+0x46>
mov    %rdx,%r12
mov    %rdi,%rbp
mov    %r14d,%r15d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl 0x0(%rbp,%rbx,1),%edi
call   1030 <hexhightoasc11@plt>
mov    %al,(%r12,%rbx,2)
movsbl 0x0(%rbp,%rbx,1),%edi
call   1040 <hexlowtoasc11@plt>
mov    %al,0x1(%r12,%rbx,2)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <bcdhex_to_aschex11+0x20>
add    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @bcdhex_to_aschex11(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 0, i32* %7
br label %8
8: ; preds = %36, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %39
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = call signext i8 @hexhightoasc11(i8 signext %17)
%19 = load i8*, i8** %6
%20 = load i32, i32* %7
%21 = mul nsw i32 2, %20
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
store i8 %18, i8* %23
%24 = load i8*, i8** %4
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = call signext i8 @hexlowtoasc11(i8 signext %28)
%30 = load i8*, i8** %6
%31 = load i32, i32* %7
%32 = mul nsw i32 2, %31
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %30, i64 %34
store i8 %29, i8* %35
br label %36
36: ; preds = %12
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %8
39: ; preds = %8
%40 = load i32, i32* %5
%41 = mul nsw i32 %40, 2
ret i32 %41
}

LLVM IR (-O2):
define i32 @bcdhex_to_aschex11(i8* nocapture %0, i32 %1, i8* nocapture writeonly %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %20
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %18, %7 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = tail call signext i8 @hexhightoasc11(i8 signext %10)
%12 = shl nuw nsw i64 %8, 1
%13 = getelementptr inbounds i8, i8* %2, i64 %12
store i8 %11, i8* %13
%14 = load i8, i8* %9
%15 = tail call signext i8 @hexlowtoasc11(i8 signext %14)
%16 = or i64 %12, 1
%17 = getelementptr inbounds i8, i8* %2, i64 %16
store i8 %15, i8* %17
%18 = add nuw nsw i64 %8, 1
%19 = icmp eq i64 %18, %6
br i1 %19, label %20, label %7
20: ; preds = %7, %3
%21 = shl nsw i32 %1, 1
ret i32 %21
}