#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);
int /*<<< orphan*/ scanf(char *, char *);
void hex_to_dec(int dec[3]) {
  char allnumb[6];
  int deccount, hexcount1, hexcount2;
  scanf("%s", allnumb);
  for (deccount = 0, hexcount1 = 0, hexcount2 = 1;
       deccount < 3 || hexcount1 < 5 || hexcount2 < 6;
       deccount++, hexcount1 += 2, hexcount2 += 2) {
    dec[deccount] =
        dec_val(allnumb[hexcount1]) * 16 + dec_val(allnumb[hexcount2]);
  }
}


x86 assembly (clang, -O0):
<hex_to_dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xe(%rbp),%rsi
lea    0xec9(%rip),%rdi
call   1030 <scanf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    $0x1,%al
cmpl   $0x3,-0x14(%rbp)
mov    %al,-0x1d(%rbp)
jl     1179 <hex_to_dec+0x59>
mov    $0x1,%al
cmpl   $0x5,-0x18(%rbp)
mov    %al,-0x1d(%rbp)
jl     1179 <hex_to_dec+0x59>
cmpl   $0x6,-0x1c(%rbp)
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1189 <hex_to_dec+0x69>
jmp    11db <hex_to_dec+0xbb>
movslq -0x18(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%edi
call   1040 <dec_val@plt>
shl    $0x4,%eax
mov    %eax,-0x24(%rbp)
movslq -0x1c(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%edi
call   1040 <dec_val@plt>
mov    -0x24(%rbp),%edx
add    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    1151 <hex_to_dec+0x31>
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @hex_to_dec(i32* %0) {
%2 = alloca i32*
%3 = alloca [6 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %2
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
store i32 0, i32* %4
store i32 0, i32* %5
store i32 1, i32* %6
br label %9
9: ; preds = %37, %1
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 3
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 5
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 6
br label %18
18: ; preds = %15, %12, %9
%19 = phi i1 [ true, %12 ], [ true, %9 ], [ %17, %15 ]
br i1 %19, label %20, label %44
20: ; preds = %18
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = call i32 @dec_val(i8 signext %24)
%26 = mul nsw i32 %25, 16
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @dec_val(i8 signext %30)
%32 = add nsw i32 %26, %31
%33 = load i32*, i32** %2
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
store i32 %32, i32* %36
br label %37
37: ; preds = %20
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 2
store i32 %41, i32* %5
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 2
store i32 %43, i32* %6
br label %9
44: ; preds = %18
ret void
}

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