#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 */
scalar_t__ c;
int n;
scalar_t__ noxrd7();
zgeth1() {
  register 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    %rax,%rbx
test   %ebx,%ebx
js     115e <zgeth1+0x4e>
lea    -0x30(%rbx),%eax
lea    -0x57(%rbx),%ebp
cmp    $0x3a,%ebx
cmovb  %eax,%ebp
mov    $0xffffffff,%ebx
cmp    $0xf,%ebp
ja     115e <zgeth1+0x4e>
xor    %eax,%eax
call   1030 <noxrd7@plt>
test   %eax,%eax
js     115c <zgeth1+0x4c>
lea    -0x30(%rax),%edx
lea    -0x57(%rax),%ecx
cmp    $0x3a,%eax
cmovb  %edx,%ecx
cmp    $0xf,%ecx
ja     115e <zgeth1+0x4e>
shl    $0x4,%ebp
add    %ebp,%ecx
mov    %ecx,%ebx
jmp    115e <zgeth1+0x4e>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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