#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 /*<<< orphan*/ die(char *, char *, int, char *);
int hexnibble(int x) {
  if (x >= '0' && x <= '9')
    return x - '0';
  if (x >= 'a' && x <= 'f')
    return x - 'a' + 10;
  if (x >= 'A' && x <= 'F')
    return x - 'A' + 10;
  do {
    if (!(0 == 1))
      die("%s:%d: ASSERT failed: %s\n",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/radii/undupfs/refs/heads/master/src/"
          "undup-debug.c",
          465, "0 == 1");
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<hexnibble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x30,-0x8(%rbp)
jl     113d <hexnibble+0x2d>
cmpl   $0x39,-0x8(%rbp)
jg     113d <hexnibble+0x2d>
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    11b2 <hexnibble+0xa2>
cmpl   $0x61,-0x8(%rbp)
jl     1162 <hexnibble+0x52>
cmpl   $0x66,-0x8(%rbp)
jg     1162 <hexnibble+0x52>
mov    -0x8(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    11b2 <hexnibble+0xa2>
cmpl   $0x41,-0x8(%rbp)
jl     1187 <hexnibble+0x77>
cmpl   $0x46,-0x8(%rbp)
jg     1187 <hexnibble+0x77>
mov    -0x8(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    11b2 <hexnibble+0xa2>
jmp    118c <hexnibble+0x7c>
lea    0xe6d(%rip),%rdi
lea    0xe80(%rip),%rsi
mov    $0x1d1,%edx
lea    0xf00(%rip),%rcx
call   1030 <die@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexnibble>:
lea    -0x30(%rdi),%eax
cmp    $0xa,%eax
jb     115a <hexnibble+0x4a>
lea    -0x61(%rdi),%eax
cmp    $0x5,%eax
ja     1126 <hexnibble+0x16>
add    $0xffffffa9,%edi
mov    %edi,%eax
ret
lea    -0x41(%rdi),%eax
cmp    $0x5,%eax
ja     1134 <hexnibble+0x24>
add    $0xffffffc9,%edi
mov    %edi,%eax
ret
push   %rax
lea    0xec4(%rip),%rdi
lea    0xed7(%rip),%rsi
lea    0xf5c(%rip),%rcx
mov    $0x1d1,%edx
call   1030 <die@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"%s:%d: ASSERT failed: %s\0A\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/radii/undupfs/refs/heads/master/src/undup-debug.c\00"
@.str.2 = [7 x i8] c"0 == 1\00"
define i32 @hexnibble(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sge i32 %4, 48
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 57
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sub nsw i32 %10, 48
store i32 %11, i32* %2
br label %36
12: ; preds = %6, %1
%13 = load i32, i32* %3
%14 = icmp sge i32 %13, 97
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %3
%17 = icmp sle i32 %16, 102
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, 97
%21 = add nsw i32 %20, 10
store i32 %21, i32* %2
br label %36
22: ; preds = %15, %12
%23 = load i32, i32* %3
%24 = icmp sge i32 %23, 65
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load i32, i32* %3
%27 = icmp sle i32 %26, 70
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* %3
%30 = sub nsw i32 %29, 65
%31 = add nsw i32 %30, 10
store i32 %31, i32* %2
br label %36
32: ; preds = %25, %22
br label %33
33: ; preds = %32
%34 = call i32 @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 465, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %33
store i32 0, i32* %2
br label %36
36: ; preds = %35, %28, %18, %9
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
@.str = [26 x i8] c"%s:%d: ASSERT failed: %s\0A\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/radii/undupfs/refs/heads/master/src/undup-debug.c\00"
@.str.2 = [7 x i8] c"0 == 1\00"
define i32 @hexnibble(i32 %0) {
%2 = add i32 %0, -48
%3 = icmp ult i32 %2, 10
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = add i32 %0, -97
%6 = icmp ult i32 %5, 6
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = add nsw i32 %0, -87
br label %16
9: ; preds = %4
%10 = add i32 %0, -65
%11 = icmp ult i32 %10, 6
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = add nsw i32 %0, -55
br label %16
14: ; preds = %9
%15 = tail call i32 @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 465, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %1, %14, %12, %7
%17 = phi i32 [ %8, %7 ], [ %13, %12 ], [ 0, %14 ], [ %2, %1 ]
ret i32 %17
}