#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();
int zgeth1() {
  static 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,0x2f07(%rip)
cmp    $0x0,%eax
jge    113c <zgeth1+0x2c>
mov    0x2ef8(%rip),%eax
mov    %eax,-0x4(%rbp)
jmp    1210 <zgeth1+0x100>
mov    0x2eea(%rip),%eax
sub    $0x30,%eax
mov    %eax,0x2ee5(%rip)
cmpl   $0x9,0x2ede(%rip)
jle    1167 <zgeth1+0x57>
mov    0x2ed2(%rip),%eax
sub    $0x27,%eax
mov    %eax,0x2ec9(%rip)
mov    0x2ec3(%rip),%eax
and    $0xfffffff0,%eax
cmp    $0x0,%eax
je     1185 <zgeth1+0x75>
movl   $0xffffffff,-0x4(%rbp)
jmp    1210 <zgeth1+0x100>
mov    $0x0,%al
call   1030 <noxrd7@plt>
mov    %eax,0x2e9a(%rip)
cmp    $0x0,%eax
jge    11a9 <zgeth1+0x99>
mov    0x2e8b(%rip),%eax
mov    %eax,-0x4(%rbp)
jmp    1210 <zgeth1+0x100>
mov    0x2e7d(%rip),%eax
sub    $0x30,%eax
mov    %eax,0x2e74(%rip)
cmpl   $0x9,0x2e6d(%rip)
jle    11d4 <zgeth1+0xc4>
mov    0x2e61(%rip),%eax
sub    $0x27,%eax
mov    %eax,0x2e58(%rip)
mov    0x2e52(%rip),%eax
and    $0xfffffff0,%eax
cmp    $0x0,%eax
je     11f2 <zgeth1+0xe2>
movl   $0xffffffff,-0x4(%rbp)
jmp    1210 <zgeth1+0x100>
mov    0x2e38(%rip),%eax
shl    $0x4,%eax
add    0x2e2b(%rip),%eax
mov    %eax,0x2e25(%rip)
mov    0x2e1f(%rip),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zgeth1>:
push   %rbx
xor    %eax,%eax
call   1030 <noxrd7@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1165 <zgeth1+0x55>
lea    -0x30(%rbx),%eax
lea    -0x57(%rbx),%ecx
cmp    $0x3a,%ebx
cmovb  %eax,%ecx
mov    %ecx,0x2efc(%rip)
mov    $0xffffffff,%ebx
cmp    $0xf,%ecx
ja     1165 <zgeth1+0x55>
xor    %eax,%eax
call   1030 <noxrd7@plt>
test   %eax,%eax
js     1163 <zgeth1+0x53>
lea    -0x30(%rax),%edx
lea    -0x57(%rax),%ecx
cmp    $0x3a,%eax
cmovb  %edx,%ecx
cmp    $0xf,%ecx
ja     1165 <zgeth1+0x55>
mov    0x2ed0(%rip),%ebx
shl    $0x4,%ebx
add    %ecx,%ebx
jmp    1165 <zgeth1+0x55>
mov    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@zgeth1.n = internal unnamed_addr global i32 0
define i32 @zgeth1() {
%1 = tail call i32 (...) @noxrd7()
%2 = icmp slt i32 %1, 0
br i1 %2, label %20, 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
store i32 %6, i32* @zgeth1.n
%7 = icmp ult i32 %6, 16
br i1 %7, label %8, label %20
8: ; preds = %3
%9 = tail call i32 (...) @noxrd7()
%10 = icmp slt i32 %9, 0
br i1 %10, label %20, 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 %20
16: ; preds = %11
%17 = load i32, i32* @zgeth1.n
%18 = shl i32 %17, 4
%19 = add nuw nsw i32 %18, %14
br label %20
20: ; preds = %11, %8, %3, %0, %16
%21 = phi i32 [ %19, %16 ], [ %1, %0 ], [ -1, %3 ], [ %9, %8 ], [ -1, %11 ]
ret i32 %21
}