#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 dec_val(char);
void hex_to_dec(char hex[7], int dec[3]) {
  int counter_1 = 1;
  int counter_2 = 0;
  for (; counter_1 < 7; counter_1 += 2, counter_2++) {
    dec[counter_2] = dec_val(hex[counter_1]) * 16 + dec_val(hex[counter_1 + 1]);
  }
}


x86 assembly (clang, -O0):
<hex_to_dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x7,-0x14(%rbp)
jge    118c <hex_to_dec+0x7c>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <dec_val@plt>
shl    $0x4,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <dec_val@plt>
mov    -0x1c(%rbp),%edx
add    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112e <hex_to_dec+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
define void @hex_to_dec(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 1
%4 = load i8, i8* %3
%5 = tail call i32 @dec_val(i8 signext %4)
%6 = shl nsw i32 %5, 4
%7 = getelementptr inbounds i8, i8* %0, i64 2
%8 = load i8, i8* %7
%9 = tail call i32 @dec_val(i8 signext %8)
%10 = add nsw i32 %9, %6
store i32 %10, i32* %1
%11 = getelementptr inbounds i8, i8* %0, i64 3
%12 = load i8, i8* %11
%13 = tail call i32 @dec_val(i8 signext %12)
%14 = shl nsw i32 %13, 4
%15 = getelementptr inbounds i8, i8* %0, i64 4
%16 = load i8, i8* %15
%17 = tail call i32 @dec_val(i8 signext %16)
%18 = add nsw i32 %17, %14
%19 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %18, i32* %19
%20 = getelementptr inbounds i8, i8* %0, i64 5
%21 = load i8, i8* %20
%22 = tail call i32 @dec_val(i8 signext %21)
%23 = shl nsw i32 %22, 4
%24 = getelementptr inbounds i8, i8* %0, i64 6
%25 = load i8, i8* %24
%26 = tail call i32 @dec_val(i8 signext %25)
%27 = add nsw i32 %26, %23
%28 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %27, i32* %28
ret void
}