#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int gethexnibble(int /*<<< orphan*/ *);
int gethexbyte(FILE *fp) {
  int nib;
  unsigned char n;
  if ((nib = gethexnibble(fp)) < 0)
    return -1;
  n = nib << 4;
  if ((nib = gethexnibble(fp)) < 0)
    return -1;
  n |= nib;
  return n;
}


x86 assembly (clang, -O0):
<gethexbyte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <gethexnibble@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    113d <gethexbyte+0x2d>
movl   $0xffffffff,-0x4(%rbp)
jmp    117a <gethexbyte+0x6a>
mov    -0x14(%rbp),%eax
shl    $0x4,%eax
mov    %al,-0x15(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <gethexnibble@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1167 <gethexbyte+0x57>
movl   $0xffffffff,-0x4(%rbp)
jmp    117a <gethexbyte+0x6a>
mov    -0x14(%rbp),%ecx
movzbl -0x15(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x15(%rbp)
movzbl -0x15(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gethexbyte>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <gethexnibble@plt>
mov    $0xffffffff,%r14d
test   %eax,%eax
js     113d <gethexbyte+0x2d>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <gethexnibble@plt>
test   %eax,%eax
js     113d <gethexbyte+0x2d>
shl    $0x4,%ebp
or     %ebp,%eax
movzbl %al,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @gethexbyte(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 @gethexnibble(i32* %6)
store i32 %7, i32* %4
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 -1, i32* %2
br label %26
10: ; preds = %1
%11 = load i32, i32* %4
%12 = shl i32 %11, 4
%13 = trunc i32 %12 to i8
store i8 %13, i8* %5
%14 = load i32*, i32** %3
%15 = call i32 @gethexnibble(i32* %14)
store i32 %15, i32* %4
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %10
store i32 -1, i32* %2
br label %26
18: ; preds = %10
%19 = load i32, i32* %4
%20 = load i8, i8* %5
%21 = zext i8 %20 to i32
%22 = or i32 %21, %19
%23 = trunc i32 %22 to i8
store i8 %23, i8* %5
%24 = load i8, i8* %5
%25 = zext i8 %24 to i32
store i32 %25, i32* %2
br label %26
26: ; preds = %18, %17, %9
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
define i32 @gethexbyte(i32* %0) {
%2 = tail call i32 @gethexnibble(i32* %0)
%3 = icmp slt i32 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = tail call i32 @gethexnibble(i32* %0)
%6 = icmp slt i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = shl i32 %2, 4
%9 = or i32 %5, %8
%10 = and i32 %9, 255
br label %11
11: ; preds = %4, %1, %7
%12 = phi i32 [ %10, %7 ], [ -1, %1 ], [ -1, %4 ]
ret i32 %12
}