#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 strlen(char *);
scalar_t__ strtol(char *, int /*<<< orphan*/, int);
void obd_hex_to_dec(char *hex_value, int *a, int *b) {
  char hex_byte[3] = {0};
  hex_byte[0] = hex_value[0];
  hex_byte[1] = hex_value[1];
  *a = (int)strtol(hex_byte, 0, 16);
  if (strlen(hex_value) == 4) {
    hex_byte[0] = hex_value[2];
    hex_byte[1] = hex_value[3];
    *b = (int)strtol(hex_byte, 0, 16);
    return;
  }
  *b = 0;
  return;
}


x86 assembly (clang, -O0):
<obd_hex_to_dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x1b(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x1b(%rbp)
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x1a(%rbp)
lea    -0x1b(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <strtol@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
jne    11c2 <obd_hex_to_dec+0x92>
mov    -0x8(%rbp),%rax
mov    0x2(%rax),%al
mov    %al,-0x1b(%rbp)
mov    -0x8(%rbp),%rax
mov    0x3(%rax),%al
mov    %al,-0x1a(%rbp)
lea    -0x1b(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <strtol@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    11cc <obd_hex_to_dec+0x9c>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<obd_hex_to_dec>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rbx
movb   $0x0,0x7(%rsp)
mov    (%rdi),%al
mov    %al,0x5(%rsp)
mov    0x1(%rdi),%al
mov    %al,0x6(%rsp)
lea    0x5(%rsp),%rdi
xor    %r15d,%r15d
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,(%r12)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
jne    118a <obd_hex_to_dec+0x6a>
mov    0x2(%rbx),%al
mov    %al,0x5(%rsp)
mov    0x3(%rbx),%al
mov    %al,0x6(%rsp)
lea    0x5(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %rax,%r15
mov    %r15d,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @obd_hex_to_dec(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca [3 x i8]
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = bitcast [3 x i8]* %7 to i8*
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
store i8 %11, i8* %12
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 1
store i8 %15, i8* %16
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%18 = call i64 @strtol(i8* %17, i32 0, i32 16)
%19 = trunc i64 %18 to i32
%20 = load i32*, i32** %5
store i32 %19, i32* %20
%21 = load i8*, i8** %4
%22 = call i32 @strlen(i8* %21)
%23 = icmp eq i32 %22, 4
br i1 %23, label %24, label %37
24: ; preds = %3
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 2
%27 = load i8, i8* %26
%28 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
store i8 %27, i8* %28
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 3
%31 = load i8, i8* %30
%32 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 1
store i8 %31, i8* %32
%33 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%34 = call i64 @strtol(i8* %33, i32 0, i32 16)
%35 = trunc i64 %34 to i32
%36 = load i32*, i32** %6
store i32 %35, i32* %36
br label %39
37: ; preds = %3
%38 = load i32*, i32** %6
store i32 0, i32* %38
br label %39
39: ; preds = %37, %24
ret void
}

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