#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 dhcpcd_wpa_hex2num(char const);
int dhcpcd_wpa_hex2byte(const char *src) {
  int h, l;
  if ((h = dhcpcd_wpa_hex2num(*src++)) == -1 ||
      (l = dhcpcd_wpa_hex2num(*src)) == -1)
    return -1;
  return (h << 4) | l;
}


x86 assembly (clang, -O0):
<dhcpcd_wpa_hex2byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <dhcpcd_wpa_hex2num@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1157 <dhcpcd_wpa_hex2byte+0x47>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <dhcpcd_wpa_hex2num@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    1163 <dhcpcd_wpa_hex2byte+0x53>
movl   $0xffffffff,-0x4(%rbp)
jmp    116f <dhcpcd_wpa_hex2byte+0x5f>
mov    -0x14(%rbp),%eax
shl    $0x4,%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dhcpcd_wpa_hex2byte>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <dhcpcd_wpa_hex2num@plt>
mov    $0xffffffff,%r14d
cmp    $0xffffffff,%eax
je     1142 <dhcpcd_wpa_hex2byte+0x32>
mov    %eax,%ebp
movsbl 0x1(%rbx),%edi
call   1030 <dhcpcd_wpa_hex2num@plt>
cmp    $0xffffffff,%eax
je     1142 <dhcpcd_wpa_hex2byte+0x32>
shl    $0x4,%ebp
or     %ebp,%eax
mov    %eax,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @dhcpcd_wpa_hex2byte(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i32 1
store i8* %7, i8** %3
%8 = load i8, i8* %6
%9 = call i32 @dhcpcd_wpa_hex2num(i8 signext %8)
store i32 %9, i32* %4
%10 = icmp eq i32 %9, -1
br i1 %10, label %16, label %11
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = call i32 @dhcpcd_wpa_hex2num(i8 signext %13)
store i32 %14, i32* %5
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %17
16: ; preds = %11, %1
store i32 -1, i32* %2
br label %22
17: ; preds = %11
%18 = load i32, i32* %4
%19 = shl i32 %18, 4
%20 = load i32, i32* %5
%21 = or i32 %19, %20
store i32 %21, i32* %2
br label %22
22: ; preds = %17, %16
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
define i32 @dhcpcd_wpa_hex2byte(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @dhcpcd_wpa_hex2num(i8 signext %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %13, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = tail call i32 @dhcpcd_wpa_hex2num(i8 signext %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = shl i32 %3, 4
%12 = or i32 %8, %11
br label %13
13: ; preds = %1, %5, %10
%14 = phi i32 [ %12, %10 ], [ -1, %5 ], [ -1, %1 ]
ret i32 %14
}