#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 hexvalue(char);
int strlen(char *);
void make_decimal(char hex[7], int decimal[3]) {
  int counth, countd;
  for (counth = 1, countd = 0; counth < strlen(hex); countd++, counth += 2) {
    decimal[countd] = hexvalue(hex[counth]) * 16 + hexvalue(hex[counth + 1]);
  }
}


x86 assembly (clang, -O0):
<make_decimal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11ae <make_decimal+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <hexvalue@plt>
shl    $0x4,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <hexvalue@plt>
mov    -0x20(%rbp),%edx
add    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    113e <make_decimal+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_decimal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     1171 <make_decimal+0x51>
mov    $0x1,%ebx
nopl   0x0(%rax)
movsbl (%r15,%rbx,1),%edi
call   1030 <hexvalue@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl 0x1(%r15,%rbx,1),%edi
call   1030 <hexvalue@plt>
add    %ebp,%eax
mov    %eax,-0x2(%r14,%rbx,2)
add    $0x2,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    %ebx,%eax
jg     1140 <make_decimal+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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