#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*/ tor_raw_abort_();
int /*<<< orphan*/ tor_raw_assertion_failed_msg_(char *, int, char *,
                                                 int /*<<< orphan*/ *);
int digit_to_num(char d) {
  int num = ((int)d) - (int)'0';
  (void)({
    if (!(num <= 9 && num >= 0)) {
      tor_raw_assertion_failed_msg_(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/zcoinofficial/zcoin/refs/heads/master/src/"
          "tor/src/lib/string/scanf.c",
          26, "num <= 9 && num >= 0", NULL);
      tor_raw_abort_();
    }
  });
  return num;
}


x86 assembly (clang, -O0):
<digit_to_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x9,-0x8(%rbp)
jg     114c <digit_to_num+0x2c>
cmpl   $0x0,-0x8(%rbp)
jge    116f <digit_to_num+0x4f>
lea    0xead(%rip),%rdi
mov    $0x1a,%esi
lea    0xf40(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <tor_raw_assertion_failed_msg_@plt>
mov    $0x0,%al
call   1030 <tor_raw_abort_@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<digit_to_num>:
push   %rbx
mov    %edi,%ebx
lea    -0x30(%rbx),%eax
cmp    $0xa,%al
jb     114b <digit_to_num+0x2b>
lea    0xecf(%rip),%rdi
lea    0xf67(%rip),%rdx
mov    $0x1a,%esi
xor    %ecx,%ecx
call   1040 <tor_raw_assertion_failed_msg_@plt>
xor    %eax,%eax
call   1030 <tor_raw_abort_@plt>
movsbl %bl,%eax
add    $0xffffffd0,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [159 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zcoinofficial/zcoin/refs/heads/master/src/tor/src/lib/string/scanf.c\00"
@.str.1 = [21 x i8] c"num <= 9 && num >= 0\00"
define i32 @digit_to_num(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
%6 = sub nsw i32 %5, 48
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 9
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* %3
%11 = icmp sge i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9, %1
%13 = call i32 @tor_raw_assertion_failed_msg_(i8* getelementptr inbounds ([159 x i8], [159 x i8]* @.str, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32* null)
%14 = call i32 (...) @tor_raw_abort_()
br label %15
15: ; preds = %12, %9
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
@.str = [159 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zcoinofficial/zcoin/refs/heads/master/src/tor/src/lib/string/scanf.c\00"
@.str.1 = [21 x i8] c"num <= 9 && num >= 0\00"
define i32 @digit_to_num(i8 signext %0) {
%2 = add i8 %0, -48
%3 = icmp ult i8 %2, 10
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @tor_raw_assertion_failed_msg_(i8* getelementptr inbounds ([159 x i8], [159 x i8]* @.str, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32* null)
%6 = tail call i32 (...) @tor_raw_abort_()
br label %7
7: ; preds = %1, %4
%8 = sext i8 %0 to i32
%9 = add nsw i32 %8, -48
ret i32 %9
}