#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 uint_fast64_t;
typedef int uint64_t;

/* Variables and functions */
int fgetc(int /*<<< orphan*/);
scalar_t__ isspace(int);
int /*<<< orphan*/ stdin;
bool readHex128(uint64_t *ptr) {
  int ch;
  uint_fast64_t out64, out0;
  int numDigits, digit;
  do {
    ch = fgetc(stdin);
  } while (isspace(ch));
  out64 = 0;
  out0 = 0;
  numDigits = 0;
  for (;;) {
    if (('0' <= ch) && (ch <= '9')) {
      digit = ch - '0';
    } else if (('A' <= ch) && (ch <= 'F')) {
      digit = ch - ('A' - 10);
    } else if (('a' <= ch) && (ch <= 'f')) {
      digit = ch - ('a' - 10);
    } else {
      break;
    }
    ++numDigits;
    if (32 < numDigits)
      return false;
    out64 = out64 << 4 | out0 >> 60;
    out0 = out0 << 4 | digit;
    ch = fgetc(stdin);
  }
  if (!numDigits)
    return false;
  ptr[1] = out64;
  ptr[0] = out0;
  return true;
}


x86 assembly (clang, -O0):
<readHex128>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
jne    112c <readHex128+0xc>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    $0x30,%eax
cmp    -0x14(%rbp),%eax
jg     118a <readHex128+0x6a>
cmpl   $0x39,-0x14(%rbp)
jg     118a <readHex128+0x6a>
mov    -0x14(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x24(%rbp)
jmp    11e5 <readHex128+0xc5>
mov    $0x41,%eax
cmp    -0x14(%rbp),%eax
jg     11b0 <readHex128+0x90>
cmpl   $0x46,-0x14(%rbp)
jg     11b0 <readHex128+0x90>
mov    -0x14(%rbp),%eax
sub    $0x37,%eax
mov    %eax,-0x24(%rbp)
jmp    11e0 <readHex128+0xc0>
mov    $0x61,%eax
cmp    -0x14(%rbp),%eax
jg     11d6 <readHex128+0xb6>
cmpl   $0x66,-0x14(%rbp)
jg     11d6 <readHex128+0xb6>
mov    -0x14(%rbp),%eax
sub    $0x57,%eax
mov    %eax,-0x24(%rbp)
jmp    11db <readHex128+0xbb>
jmp    1241 <readHex128+0x121>
jmp    11e0 <readHex128+0xc0>
jmp    11e5 <readHex128+0xc5>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    $0x20,%eax
cmp    -0x20(%rbp),%eax
jge    1208 <readHex128+0xe8>
movl   $0x0,-0x4(%rbp)
jmp    1271 <readHex128+0x151>
mov    -0x18(%rbp),%eax
shl    $0x4,%eax
mov    -0x1c(%rbp),%edx
mov    $0x3c,%ecx
sar    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x4,%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
jmp    1164 <readHex128+0x44>
cmpl   $0x0,-0x20(%rbp)
jne    1257 <readHex128+0x137>
movl   $0x0,-0x4(%rbp)
jmp    1271 <readHex128+0x151>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readHex128>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
mov    0x2eb6(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15),%edi
call   1030 <fgetc@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1140 <readHex128+0x20>
xor    %ebp,%ebp
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
lea    -0x30(%rbx),%eax
cmp    $0xa,%eax
jb     118d <readHex128+0x6d>
lea    -0x41(%rbx),%eax
cmp    $0x5,%eax
ja     1180 <readHex128+0x60>
add    $0xffffffc9,%ebx
jmp    118b <readHex128+0x6b>
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x61(%rbx),%eax
cmp    $0x5,%eax
ja     11a8 <readHex128+0x88>
add    $0xffffffa9,%ebx
mov    %ebx,%eax
cmp    $0x20,%r12d
je     11bf <readHex128+0x9f>
add    $0x1,%r12d
shl    $0x4,%ebp
or     %eax,%ebp
mov    (%r15),%edi
call   1030 <fgetc@plt>
mov    %eax,%ebx
jmp    1160 <readHex128+0x40>
test   %r12d,%r12d
je     11bf <readHex128+0x9f>
movl   $0x0,0x4(%r14)
mov    %ebp,(%r14)
mov    $0x1,%eax
jmp    11c1 <readHex128+0xa1>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @readHex128(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
br label %9
9: ; preds = %12, %1
%10 = load i32, i32* @stdin
%11 = call i32 @fgetc(i32 %10)
store i32 %11, i32* %4
br label %12
12: ; preds = %9
%13 = load i32, i32* %4
%14 = call i64 @isspace(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %9, label %16
16: ; preds = %12
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %17
17: ; preds = %53, %16
%18 = load i32, i32* %4
%19 = icmp sle i32 48, %18
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i32, i32* %4
%22 = icmp sle i32 %21, 57
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %4
%25 = sub nsw i32 %24, 48
store i32 %25, i32* %8
br label %47
26: ; preds = %20, %17
%27 = load i32, i32* %4
%28 = icmp sle i32 65, %27
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i32, i32* %4
%31 = icmp sle i32 %30, 70
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* %4
%34 = sub nsw i32 %33, 55
store i32 %34, i32* %8
br label %46
35: ; preds = %29, %26
%36 = load i32, i32* %4
%37 = icmp sle i32 97, %36
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = load i32, i32* %4
%40 = icmp sle i32 %39, 102
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* %4
%43 = sub nsw i32 %42, 87
store i32 %43, i32* %8
br label %45
44: ; preds = %38, %35
br label %65
45: ; preds = %41
br label %46
46: ; preds = %45, %32
br label %47
47: ; preds = %46, %23
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
%50 = load i32, i32* %7
%51 = icmp slt i32 32, %50
br i1 %51, label %52, label %53
52: ; preds = %47
store i32 0, i32* %2
br label %76
53: ; preds = %47
%54 = load i32, i32* %5
%55 = shl i32 %54, 4
%56 = load i32, i32* %6
%57 = ashr i32 %56, 60
%58 = or i32 %55, %57
store i32 %58, i32* %5
%59 = load i32, i32* %6
%60 = shl i32 %59, 4
%61 = load i32, i32* %8
%62 = or i32 %60, %61
store i32 %62, i32* %6
%63 = load i32, i32* @stdin
%64 = call i32 @fgetc(i32 %63)
store i32 %64, i32* %4
br label %17
65: ; preds = %44
%66 = load i32, i32* %7
%67 = icmp ne i32 %66, 0
br i1 %67, label %69, label %68
68: ; preds = %65
store i32 0, i32* %2
br label %76
69: ; preds = %65
%70 = load i32, i32* %5
%71 = load i32*, i32** %3
%72 = getelementptr inbounds i32, i32* %71, i64 1
store i32 %70, i32* %72
%73 = load i32, i32* %6
%74 = load i32*, i32** %3
%75 = getelementptr inbounds i32, i32* %74, i64 0
store i32 %73, i32* %75
store i32 1, i32* %2
br label %76
76: ; preds = %69, %68, %52
%77 = load i32, i32* %2
ret i32 %77
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @readHex128(i32* nocapture writeonly %0) {
br label %2
2: ; preds = %2, %1
%3 = load i32, i32* @stdin
%4 = tail call i32 @fgetc(i32 %3)
%5 = tail call i64 @isspace(i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %2
7: ; preds = %2, %26
%8 = phi i32 [ %31, %26 ], [ %4, %2 ]
%9 = phi i32 [ %29, %26 ], [ 0, %2 ]
%10 = phi i32 [ %27, %26 ], [ 0, %2 ]
%11 = add i32 %8, -48
%12 = icmp ult i32 %11, 10
br i1 %12, label %23, label %13
13: ; preds = %7
%14 = add i32 %8, -65
%15 = icmp ult i32 %14, 6
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = add nsw i32 %8, -55
br label %23
18: ; preds = %13
%19 = add i32 %8, -97
%20 = icmp ult i32 %19, 6
br i1 %20, label %21, label %32
21: ; preds = %18
%22 = add nsw i32 %8, -87
br label %23
23: ; preds = %7, %16, %21
%24 = phi i32 [ %17, %16 ], [ %22, %21 ], [ %11, %7 ]
%25 = icmp eq i32 %10, 32
br i1 %25, label %36, label %26
26: ; preds = %23
%27 = add nuw nsw i32 %10, 1
%28 = shl i32 %9, 4
%29 = or i32 %24, %28
%30 = load i32, i32* @stdin
%31 = tail call i32 @fgetc(i32 %30)
br label %7
32: ; preds = %18
%33 = icmp eq i32 %10, 0
br i1 %33, label %36, label %34
34: ; preds = %32
%35 = getelementptr inbounds i32, i32* %0, i64 1
store i32 0, i32* %35
store i32 %9, i32* %0
br label %36
36: ; preds = %23, %32, %34
%37 = phi i32 [ 1, %34 ], [ 0, %32 ], [ 0, %23 ]
ret i32 %37
}