#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 char_hexvalue(char);
int char4_hexvalue(char *hn_4_p) {
  return (4096 * char_hexvalue(hn_4_p[0]) + 256 * char_hexvalue(hn_4_p[1]) +
          16 * char_hexvalue(hn_4_p[2]) + char_hexvalue(hn_4_p[3]));
}


x86 assembly (clang, -O0):
<char4_hexvalue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <char_hexvalue@plt>
shl    $0xc,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <char_hexvalue@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
shl    $0x8,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <char_hexvalue@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
shl    $0x4,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%edi
call   1030 <char_hexvalue@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
add    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @char4_hexvalue(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 0
%5 = load i8, i8* %4
%6 = call i32 @char_hexvalue(i8 signext %5)
%7 = mul nsw i32 4096, %6
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = call i32 @char_hexvalue(i8 signext %10)
%12 = mul nsw i32 256, %11
%13 = add nsw i32 %7, %12
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 2
%16 = load i8, i8* %15
%17 = call i32 @char_hexvalue(i8 signext %16)
%18 = mul nsw i32 16, %17
%19 = add nsw i32 %13, %18
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i64 3
%22 = load i8, i8* %21
%23 = call i32 @char_hexvalue(i8 signext %22)
%24 = add nsw i32 %19, %23
ret i32 %24
}

LLVM IR (-O2):
define i32 @char4_hexvalue(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @char_hexvalue(i8 signext %2)
%4 = shl nsw i32 %3, 12
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = tail call i32 @char_hexvalue(i8 signext %6)
%8 = shl nsw i32 %7, 8
%9 = add nsw i32 %8, %4
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = load i8, i8* %10
%12 = tail call i32 @char_hexvalue(i8 signext %11)
%13 = shl nsw i32 %12, 4
%14 = add nsw i32 %9, %13
%15 = getelementptr inbounds i8, i8* %0, i64 3
%16 = load i8, i8* %15
%17 = tail call i32 @char_hexvalue(i8 signext %16)
%18 = add nsw i32 %14, %17
ret i32 %18
}