#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 fromhex(int /*<<< orphan*/);
void convert_ascii_to_int(char *from, char *to, int n) {
  int nib1, nib2;
  while (n--) {
    nib1 = fromhex(*from++);
    nib2 = fromhex(*from++);
    *to++ = (((nib1 & 0x0f) << 4) & 0xf0) | (nib2 & 0x0f);
  }
}


x86 assembly (clang, -O0):
<convert_ascii_to_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     1199 <convert_ascii_to_int+0x89>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%edi
call   1030 <fromhex@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%edi
call   1030 <fromhex@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
and    $0xf,%eax
shl    $0x4,%eax
and    $0xf0,%eax
mov    -0x1c(%rbp),%ecx
and    $0xf,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1123 <convert_ascii_to_int+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_ascii_to_int>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
je     115c <convert_ascii_to_int+0x4c>
mov    %rsi,%r14
mov    %rdi,%r12
mov    %edx,%r15d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%r12,%rbx,2),%edi
call   1030 <fromhex@plt>
mov    %eax,%ebp
movsbl 0x1(%r12,%rbx,2),%edi
call   1030 <fromhex@plt>
shl    $0x4,%ebp
and    $0xf,%eax
or     %ebp,%eax
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %ebx,%r15d
jne    1130 <convert_ascii_to_int+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @convert_ascii_to_int(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
br label %9
9: ; preds = %13, %3
%10 = load i32, i32* %6
%11 = add nsw i32 %10, -1
store i32 %11, i32* %6
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %34
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %4
%16 = load i8, i8* %14
%17 = sext i8 %16 to i32
%18 = call i32 @fromhex(i32 %17)
store i32 %18, i32* %7
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %4
%21 = load i8, i8* %19
%22 = sext i8 %21 to i32
%23 = call i32 @fromhex(i32 %22)
store i32 %23, i32* %8
%24 = load i32, i32* %7
%25 = and i32 %24, 15
%26 = shl i32 %25, 4
%27 = and i32 %26, 240
%28 = load i32, i32* %8
%29 = and i32 %28, 15
%30 = or i32 %27, %29
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
store i8 %31, i8* %32
br label %9
34: ; preds = %9
ret void
}

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