#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 hexval(char);
int FixedHexStringToInteger(char *String) {
  int Value = 0;
  int i;
  for (i = 0; i < 8; i++) {
    Value = Value * 16;
    Value = Value + hexval(String[i]);
  }
  return Value;
}


x86 assembly (clang, -O0):
<FixedHexStringToInteger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    116c <FixedHexStringToInteger+0x5c>
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <hexval@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112a <FixedHexStringToInteger+0x1a>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FixedHexStringToInteger>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
movsbl (%rdi),%edi
call   1030 <hexval@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl 0x1(%r14),%edi
call   1030 <hexval@plt>
mov    %eax,%ebx
add    %ebp,%ebx
shl    $0x4,%ebx
movsbl 0x2(%r14),%edi
call   1030 <hexval@plt>
mov    %eax,%ebp
add    %ebx,%ebp
shl    $0x4,%ebp
movsbl 0x3(%r14),%edi
call   1030 <hexval@plt>
mov    %eax,%ebx
add    %ebp,%ebx
shl    $0x4,%ebx
movsbl 0x4(%r14),%edi
call   1030 <hexval@plt>
mov    %eax,%ebp
add    %ebx,%ebp
shl    $0x4,%ebp
movsbl 0x5(%r14),%edi
call   1030 <hexval@plt>
mov    %eax,%ebx
add    %ebp,%ebx
shl    $0x4,%ebx
movsbl 0x6(%r14),%edi
call   1030 <hexval@plt>
mov    %eax,%ebp
add    %ebx,%ebp
shl    $0x4,%ebp
movsbl 0x7(%r14),%edi
call   1030 <hexval@plt>
add    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @FixedHexStringToInteger(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %19, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 8
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load i32, i32* %3
%10 = mul nsw i32 %9, 16
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = load i8*, i8** %2
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = call i32 @hexval(i8 signext %16)
%18 = add nsw i32 %11, %17
store i32 %18, i32* %3
br label %19
19: ; preds = %8
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %5
22: ; preds = %5
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
define i32 @FixedHexStringToInteger(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @hexval(i8 signext %2)
%4 = shl nsw i32 %3, 4
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = tail call i32 @hexval(i8 signext %6)
%8 = add nsw i32 %7, %4
%9 = shl nsw i32 %8, 4
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = load i8, i8* %10
%12 = tail call i32 @hexval(i8 signext %11)
%13 = add nsw i32 %12, %9
%14 = shl nsw i32 %13, 4
%15 = getelementptr inbounds i8, i8* %0, i64 3
%16 = load i8, i8* %15
%17 = tail call i32 @hexval(i8 signext %16)
%18 = add nsw i32 %17, %14
%19 = shl nsw i32 %18, 4
%20 = getelementptr inbounds i8, i8* %0, i64 4
%21 = load i8, i8* %20
%22 = tail call i32 @hexval(i8 signext %21)
%23 = add nsw i32 %22, %19
%24 = shl nsw i32 %23, 4
%25 = getelementptr inbounds i8, i8* %0, i64 5
%26 = load i8, i8* %25
%27 = tail call i32 @hexval(i8 signext %26)
%28 = add nsw i32 %27, %24
%29 = shl nsw i32 %28, 4
%30 = getelementptr inbounds i8, i8* %0, i64 6
%31 = load i8, i8* %30
%32 = tail call i32 @hexval(i8 signext %31)
%33 = add nsw i32 %32, %29
%34 = shl nsw i32 %33, 4
%35 = getelementptr inbounds i8, i8* %0, i64 7
%36 = load i8, i8* %35
%37 = tail call i32 @hexval(i8 signext %36)
%38 = add nsw i32 %37, %34
ret i32 %38
}