#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 noxrd7();
zgeth1() {
  register int c, n;
  if ((c = noxrd7()) < 0)
    return c;
  n = c - '0';
  if (n > 9)
    n -= ('a' - ':');
  if (n & ~0xF)
    return (-1);
  if ((c = noxrd7()) < 0)
    return c;
  c -= '0';
  if (c > 9)
    c -= ('a' - ':');
  if (c & ~0xF)
    return (-1);
  c += (n << 4);
  return c;
}


x86 assembly (clang, -O0):
<zgeth1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <noxrd7@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    1136 <zgeth1+0x26>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d4 <zgeth1+0xc4>
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
jle    1152 <zgeth1+0x42>
mov    -0xc(%rbp),%eax
sub    $0x27,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfffffff0,%eax
cmp    $0x0,%eax
je     116d <zgeth1+0x5d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d4 <zgeth1+0xc4>
mov    $0x0,%al
call   1030 <noxrd7@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    118b <zgeth1+0x7b>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d4 <zgeth1+0xc4>
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x9,-0x8(%rbp)
jle    11a7 <zgeth1+0x97>
mov    -0x8(%rbp),%eax
sub    $0x27,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xfffffff0,%eax
cmp    $0x0,%eax
je     11c2 <zgeth1+0xb2>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d4 <zgeth1+0xc4>
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zgeth1>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <noxrd7@plt>
mov    %eax,%ebx
test   %eax,%eax
js     115d <zgeth1+0x4d>
lea    -0x30(%rbx),%eax
lea    -0x57(%rbx),%ebp
cmp    $0x3a,%ebx
cmovb  %eax,%ebp
mov    $0xffffffff,%ebx
cmp    $0xf,%ebp
ja     115d <zgeth1+0x4d>
xor    %eax,%eax
call   1030 <noxrd7@plt>
test   %eax,%eax
js     115b <zgeth1+0x4b>
lea    -0x30(%rax),%edx
lea    -0x57(%rax),%ecx
cmp    $0x3a,%eax
cmovb  %edx,%ecx
cmp    $0xf,%ecx
ja     115d <zgeth1+0x4d>
shl    $0x4,%ebp
add    %ebp,%ecx
mov    %ecx,%ebx
jmp    115d <zgeth1+0x4d>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @zgeth1() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (...) @noxrd7()
store i32 %4, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = load i32, i32* %2
store i32 %7, i32* %1
br label %45
8: ; preds = %0
%9 = load i32, i32* %2
%10 = sub nsw i32 %9, 48
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 9
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* %3
%15 = sub nsw i32 %14, 39
store i32 %15, i32* %3
br label %16
16: ; preds = %13, %8
%17 = load i32, i32* %3
%18 = and i32 %17, -16
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 -1, i32* %1
br label %45
21: ; preds = %16
%22 = call i32 (...) @noxrd7()
store i32 %22, i32* %2
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = load i32, i32* %2
store i32 %25, i32* %1
br label %45
26: ; preds = %21
%27 = load i32, i32* %2
%28 = sub nsw i32 %27, 48
store i32 %28, i32* %2
%29 = load i32, i32* %2
%30 = icmp sgt i32 %29, 9
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i32, i32* %2
%33 = sub nsw i32 %32, 39
store i32 %33, i32* %2
br label %34
34: ; preds = %31, %26
%35 = load i32, i32* %2
%36 = and i32 %35, -16
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
store i32 -1, i32* %1
br label %45
39: ; preds = %34
%40 = load i32, i32* %3
%41 = shl i32 %40, 4
%42 = load i32, i32* %2
%43 = add nsw i32 %42, %41
store i32 %43, i32* %2
%44 = load i32, i32* %2
store i32 %44, i32* %1
br label %45
45: ; preds = %39, %38, %24, %20, %6
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
define i32 @zgeth1() {
%1 = tail call i32 (...) @noxrd7()
%2 = icmp slt i32 %1, 0
br i1 %2, label %19, label %3
3: ; preds = %0
%4 = icmp ugt i32 %1, 57
%5 = select i1 %4, i32 -87, i32 -48
%6 = add nsw i32 %5, %1
%7 = icmp ult i32 %6, 16
br i1 %7, label %8, label %19
8: ; preds = %3
%9 = tail call i32 (...) @noxrd7()
%10 = icmp slt i32 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %8
%12 = icmp ugt i32 %9, 57
%13 = select i1 %12, i32 -87, i32 -48
%14 = add nsw i32 %13, %9
%15 = icmp ult i32 %14, 16
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = shl nuw nsw i32 %6, 4
%18 = add nuw nsw i32 %14, %17
br label %19
19: ; preds = %11, %8, %3, %0, %16
%20 = phi i32 [ %18, %16 ], [ %1, %0 ], [ -1, %3 ], [ %9, %8 ], [ -1, %11 ]
ret i32 %20
}